/**
  * The class constructor.
  * The object will be created only if the specified $cid (Category ID)
  * is a correct value and such category exists in the DB.
  *
  * @param int $cid Category ID
  * @param int $localized The parameter defines, whether to return localized
  * values or to send as values the constants CATEGORYINFO_LOCALIZED_DATA or
  * CATEGORYINFO_NOT_LOCALIZED_DATA directly from the DB
  * @return CCategoryInfo object or null
  */
 function CCategoryInfo($cid, $localized = CATEGORYINFO_DEFAULT_LOCALIZED_MODE)
 {
     # If the product id is not correct, then the object will return the empty tag values
     if ($cid == null || !is_numeric($cid) || !modApiFunc('Catalog', 'isCorrectCategoryId', $cid)) {
         $this->_fCategoryIDIsIncorrect = true;
     }
     $this->_fCategoryID = $cid;
     if ($localized == CATEGORYINFO_LOCALIZED_DATA) {
         $this->localized = true;
     } else {
         $this->localized = false;
     }
     $this->debugmode = false;
     # Flip the keys of the array _fArtificialTagList, i.e.
     # the key values will equal the key itself.
     # It is necessary to make it easier to use the array
     $_tmp = $this->_fArtificialTagList;
     $this->_fArtificialTagList = array();
     foreach ($_tmp as $tag) {
         $this->_fArtificialTagList[$tag] = $tag;
     }
     # Load base category info.
     $this->_fBaseCategoryInfo = array(modapiFunc('Catalog', 'fetchBaseCategoryInfo', $this->_fCategoryID));
 }
Esempio n. 2
0
 function initShowTopic()
 {
     $this->_search_email = trim(modApiFunc('Request', 'getValueByKey', 'email'));
     $var = 'Subscription_Email_Search_' . $this->_topic_id;
     $this->_prev_search_email = modApifunc('Session', 'is_set', $var) ? modApifunc('Session', 'get', $var) : '';
     modApiFunc('Session', 'set', $var, $this->_search_email);
     $this->_topic = modApiFunc('Subscriptions', 'getTopic', $this->_topic_id);
     if (empty($this->_topic)) {
         return;
     }
     $this->_pager_name = 'Subscription_Topic_' . $this->_topic_id;
     modAPIFunc('Paginator', 'setCurrentPaginatorName', $this->_pager_name);
     $page = modApiFunc('Paginator', 'getPaginatorPage', $this->_pager_name);
     if ($page <= 0) {
         modapiFunc('Paginator', 'resetPaginator', $this->_pager_name);
     }
     if ($this->_search_email != $this->_prev_search_email) {
         modApiFunc('Paginator', 'resetPaginator', $this->_pager_name);
     }
     $this->emails =& $this->fetchEmails();
     $paginator_offset = modApiFunc('paginator', 'getCurrentPaginatorOffset');
     $this->emails_total = modAPIFunc('paginator', 'getCurrentPaginatorTotalRows');
     $emails_per_page = modAPIFunc('paginator', 'getPaginatorRowsPerPage', $this->_pager_name);
     if ($paginator_offset >= 0 && $this->emails_total > 0) {
         $this->emails_from = 1 + $paginator_offset;
         $this->emails_to = min($paginator_offset + $emails_per_page, $this->emails_total);
     } else {
         $this->emails_from = 0;
         $this->emails_to = 0;
     }
 }