/** * Class constructor * * @param CRM_Core_Selector_API $object an object that implements the selector API * @param int $pageID default pageID * @param int $sortID default sortID * @param int $action the actions to potentially support * @param CRM_Core_Page|CRM_Core_Form $store place in session to store some values * @param int $output what do we so with the output, session/template//both * * @return Object * @access public */ function __construct($object, $pageID, $sortID, $action, $store = NULL, $output = self::TEMPLATE, $prefix = NULL, $case = NULL) { $this->_object = $object; $this->_pageID = $pageID ? $pageID : 1; $this->_sortID = $sortID ? $sortID : NULL; $this->_action = $action; $this->_store = $store; $this->_output = $output; $this->_prefix = $prefix; $this->_case = $case; // fix sortID if ($this->_sortID && strpos($this->_sortID, '_') === FALSE) { $this->_sortID .= '_u'; } $params = array('pageID' => $this->_pageID); // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); } $this->_sortOrder =& $this->_object->getSortOrder($action); $this->_sort = new CRM_Utils_Sort($this->_sortOrder, $this->_sortID); /* * if we are in transfer mode, do not goto database, use the * session values instead */ if ($output == self::TRANSFER) { $params['total'] = $this->_store->get($this->_prefix . 'rowCount'); } else { $params['total'] = $this->_object->getTotalCount($action, $this->_case); } $this->_total = $params['total']; $this->_object->getPagerParams($action, $params); /* * Set the default values of RowsPerPage */ $storeRowCount = $store->get($this->_prefix . CRM_Utils_Pager::PAGE_ROWCOUNT); if ($storeRowCount) { $params['rowCount'] = $storeRowCount; } elseif (!isset($params['rowCount'])) { $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT; } $this->_pager = new CRM_Utils_Pager($params); list($this->_pagerOffset, $this->_pagerRowCount) = $this->_pager->getOffsetAndRowCount(); }
/** * Class constructor * * @param CRM_Core_Selector_API $object an object that implements the selector API * @param int $pageID default pageID * @param int $sortID default sortID * @param int $action the actions to potentially support * @param CRM_Core_Page|CRM_Core_Form $store place in session to store some values * @param int $output what do we so with the output, session/template//both * * @return Object * @access public */ function CRM_Core_Selector_Controller($object, $pageID, $sortID, $action, $store = null, $output = CRM_CORE_SELECTOR_CONTROLLER_TEMPLATE) { $this->_object = $object; $this->_pageID = $pageID ? $pageID : 1; $this->_sortID = $sortID ? $sortID : null; $this->_action = $action; $this->_store = $store; $this->_output = $output; // fix sortID if ($this->_sortID && strpos($this->_sortID, '_') === false) { $this->_sortID .= '_u'; } $params = array('pageID' => $this->_pageID); // let the constructor initialize this, should happen only once if (!isset($GLOBALS['_CRM_CORE_SELECTOR_CONTROLLER']['_template'])) { $GLOBALS['_CRM_CORE_SELECTOR_CONTROLLER']['_template'] =& CRM_Core_Smarty::singleton(); } $this->_sortOrder =& $this->_object->getSortOrder($action); $this->_sort =& new CRM_Utils_Sort($this->_sortOrder, $this->_sortID); /* * if we are in transfer mode, do not goto database, use the * session values instead */ if ($output == CRM_CORE_SELECTOR_CONTROLLER_TRANSFER) { $params['total'] = $this->_store->get('rowCount'); } else { $params['total'] = $this->_object->getTotalCount($action); } $this->_total = $params['total']; $this->_object->getPagerParams($action, $params); /* * Set the default values of RowsPerPage */ $storeRowCount = $store->get(CRM_UTILS_PAGER_PAGE_ROWCOUNT); if ($storeRowCount) { $params['rowCount'] = $storeRowCount; } else { if (!isset($params['rowCount'])) { $params['rowCount'] = CRM_UTILS_PAGER_ROWCOUNT; } } $this->_pager =& new CRM_Utils_Pager($params); list($this->_pagerOffset, $this->_pagerRowCount) = $this->_pager->getOffsetAndRowCount(); }