/**
  * 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();
 }