+ $this->layout = CRM_Utils_Request::retrieve('layout', 'String');
+ }
+
+ /**
+ * Override to set limit
+ * @param int $rowCount
+ */
+ public function limit($rowCount = self::ROW_COUNT_LIMIT) {
+ parent::limit($rowCount);
+ }
+
+ /**
+ * Override to set pager with limit
+ * @param int $rowCount
+ */
+ public function setPager($rowCount = self::ROW_COUNT_LIMIT) {
+ // We should not be rendering the pager in overlay mode
+ if (!isset($this->layout)) {
+ $this->_dashBoardRowCount = $rowCount;
+ $this->_limit = TRUE;
+ parent::setPager($rowCount);
+ }
+ }
+
+ /**
+ * This is a function similar to limit, in fact we copied it as-is and removed
+ * some `set` statements
+ *
+ */
+ public function getLimit($rowCount = self::ROW_COUNT_LIMIT) {
+ if ($this->addPaging) {
+
+ $pageId = CRM_Utils_Request::retrieve('crmPID', 'Integer');
+
+ // @todo all http vars should be extracted in the preProcess
+ // - not randomly in the class
+ if (!$pageId && !empty($_POST)) {
+ if (isset($_POST['PagerBottomButton']) && isset($_POST['crmPID_B'])) {
+ $pageId = max((int) $_POST['crmPID_B'], 1);
+ }
+ elseif (isset($_POST['PagerTopButton']) && isset($_POST['crmPID'])) {
+ $pageId = max((int) $_POST['crmPID'], 1);
+ }
+ unset($_POST['crmPID_B'], $_POST['crmPID']);
+ }
+
+ $pageId = $pageId ? $pageId : 1;
+ $offset = ($pageId - 1) * $rowCount;
+
+ $offset = CRM_Utils_Type::escape($offset, 'Int');
+ $rowCount = CRM_Utils_Type::escape($rowCount, 'Int');
+ $this->_limit = " LIMIT $offset, $rowCount";
+ $this->dblimit = $rowCount;
+ $this->dboffset = $offset;
+ }
+ }
+
+ /**
+ * Given a key value that we know is a foreign key to another table, return
+ * what the DAO thinks is the "label" for the foreign entity. For example
+ * if it's referencing a contact then return the contact name, or if it's an
+ * activity then return the activity subject.
+ * If it's the type of DAO that doesn't have such a thing, just echo back
+ * what we were given.
+ *
+ * @param string $fkClassName
+ * @param string $field
+ * @param int $keyval
+ * @return string
+ */
+ private function convertForeignKeyValuesToLabels(string $fkClassName, string $field, int $keyval): string {
+ if ($fkClassName::$_labelField) {
+ $labelValue = CRM_Core_DAO::getFieldValue($fkClassName, $keyval, $fkClassName::$_labelField);
+ // Not sure if this should use ts - there's not a lot of context (`%1 (id: %2)`) - and also the similar field labels above don't use ts.
+ return "{$labelValue} (id: {$keyval})";
+ }
+ return (string) $keyval;