ContextBoxArticle::GetList PHP Метод

GetList() публичный статический Метод

Gets an issues list based on the given parameters.
public static GetList ( array $params, string $p_order = null, integer $p_start, integer $p_limit, integer &$p_count, $p_skipCache = false ) : array
$params array
$p_order string An array of columns and directions to order by
$p_start integer The record number to start the list
$p_limit integer The offset. How many records from $p_start will be retrieved.
$p_count integer The total count of the elements; this count is computed without applying the start ($p_start) and limit parameters ($p_limit)
Результат array $issuesList An array of Issue objects
    public static function GetList(array $params, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false)
    {
        global $g_ado_db;
        if (!$p_skipCache && CampCache::IsEnabled()) {
            $paramsArray['parameters'] = serialize($params);
            $paramsArray['order'] = is_null($p_order) ? 'id' : $p_order;
            $paramsArray['start'] = $p_start;
            $paramsArray['limit'] = $p_limit;
            $cacheListObj = new CampCacheList($paramsArray, __METHOD__);
            $issuesList = $cacheListObj->fetchFromCache();
            if ($issuesList !== false && is_array($issuesList)) {
                return $issuesList;
            }
        }
        if (isset($params['role']) && $params['role'] == 'child') {
            $sql = 'SELECT DISTINCT b.fk_article_no FROM context_boxes b, Articles a0' . ' WHERE a0.Number = b.fk_article_no AND ' . ' a0.Type = "dossier" AND ' . ' b.id IN (SELECT c.fk_context_id ' . '     FROM Articles a, context_articles c ' . '     WHERE c.fk_article_no = ' . $params['article'] . '     AND a.Number = c.fk_article_no)';
            if (isset($params['published']) && $params['published'] == 'true') {
                $sql .= ' AND a0.Published = "Y"';
            }
            $sql .= ' ORDER BY a0.PublishDate DESC';
        } else {
            if (isset($params['published']) && $params['published'] == 'true') {
                $sql = 'SELECT DISTINCT b.fk_article_no FROM context_articles b, Articles a0' . ' WHERE b.fk_context_id = ' . $params['context_box'] . ' AND ' . ' b.fk_article_no = a0.Number AND ' . ' a0.Published = "Y"' . ' ORDER BY b.id';
            } else {
                $sql = 'SELECT fk_article_no FROM context_articles' . ' WHERE fk_context_id = ' . $params['context_box'] . ' ORDER BY id';
            }
        }
        if ($p_limit > 0) {
            $sql .= ' LIMIT ' . $p_limit;
        }
        $returnArray = array();
        $rows = $g_ado_db->GetAll($sql);
        if (is_array($rows)) {
            foreach ($rows as $row) {
                $returnArray[] = $row['fk_article_no'];
            }
        }
        $p_count = count($returnArray);
        return $returnArray;
    }

Usage Example

Пример #1
0
 /**
  * Creates the list of objects. Sets the parameter $p_hasNextElements to
  * true if this list is limited and elements still exist in the original
  * list (from which this was truncated) after the last element of this
  * list.
  *
  * @param int $p_start
  * @param int $p_limit
  * @param array $p_parameters
  * @param int &$p_count
  * @return array
  */
 protected function CreateList($p_start = 0, $p_limit = 0, array $p_parameters, &$p_count)
 {
     $context = CampTemplate::singleton()->context();
     if (!$context->article->defined()) {
         return array();
     }
     if (!$context->language->defined()) {
         $languageId = $context->publication->default_language->number;
     } else {
         $languageId = $context->language->number;
     }
     $contextBox = new ContextBox(null, $context->article->number);
     $p_parameters['context_box'] = $contextBox->getId();
     $p_parameters['article'] = $context->article->number;
     $BoxArticlesList = ContextBoxArticle::GetList($p_parameters, $this->m_order, $p_start, $p_limit, $p_count);
     $preview = $context->preview;
     $metaBoxArticlesList = array();
     foreach ($BoxArticlesList as $articleNo) {
         $article = new MetaArticle($languageId, $articleNo);
         if ($article->defined() && ($preview || $article->is_published)) {
             $metaBoxArticlesList[] = $article;
         }
     }
     return $metaBoxArticlesList;
 }
All Usage Examples Of ContextBoxArticle::GetList