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)
 {
     $articlesList = Article::GetList($this->m_constraints, $this->m_order, $p_start, $p_limit, $p_count, false, false);
     $metaArticlesList = array();
     foreach ($articlesList as $article) {
         $metaArticlesList[] = new MetaArticle($article['language_id'], $article['number']);
     }
     return $metaArticlesList;
 }
 public function beforeRender()
 {
     $articlesParams = array();
     foreach ((array) \ArticleType::GetArticleTypes(true) as $one_art_type_name) {
         $one_art_type = new \ArticleType($one_art_type_name);
         if ($one_art_type->getFilterStatus()) {
             $articlesParams[] = new ComparisonOperation('type', new Operator('not', 'string'), $one_art_type->getTypeName());
         }
     }
     $articlesOrders = array(array('field' => 'bylastupdate', 'dir' => 'desc'));
     $this->items = Article::GetList($articlesParams, $articlesOrders, 0, self::LIMIT, $count = 0);
 }
 public function beforeRender()
 {
     $this->items = Article::GetList(array(
         new ComparisonOperation('published', new Operator('is'), 'true'),
         new ComparisonOperation('reads', new Operator('greater'), '0'),
         ), array(
             array(
                 'field' => 'bypopularity',
                 'dir' => 'desc',
             )
         ), 0, self::LIMIT, $count = 0);
 }
Example #4
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)
	{
	    $articlesList = Article::GetList($this->m_constraints, $this->m_order,
	    $p_start, $p_limit, $p_count);
	    $metaArticlesList = array();
	    foreach ($articlesList as $article) {
	        $metaArticlesList[] = new MetaArticle($article->getLanguageId(),
                                                  $article->getArticleNumber());
	    }
	    return $metaArticlesList;
	}
Example #5
0
            $articlesParams[] = new ComparisonOperation('type', new Operator('not', 'string'), $one_art_type->getTypeName());
        }
    }
}
// search
if (isset($_REQUEST['sSearch']) && strlen($_REQUEST['sSearch']) > 0) {
    $search_phrase = $_REQUEST['sSearch'];
    //$articlesParams[] = new ComparisonOperation('search_phrase', new Operator('is', 'integer'), $search_phrase);
    $articlesParams[] = new ComparisonOperation('search_phrase', new Operator('like', 'string'), "__match_all." . $search_phrase);
}
// sorting
$cols = $list->getColumnKeys();
$sortOptions = array('Number' => 'bynumber', 'Order' => 'bysectionorder', 'Name' => 'byname', 'Comments' => 'bycomments', 'Reads' => 'bypopularity', 'CreateDate' => 'bycreationdate', 'PublishDate' => 'bypublishdate');
$sortBy = 'bysectionorder';
$sortDir = 'asc';
$sortingCols = min(1, (int) $_REQUEST['iSortingCols']);
for ($i = 0; $i < $sortingCols; $i++) {
    $sortOptionsKey = (int) $_REQUEST['iSortCol_' . $i];
    if (!empty($sortOptions[$cols[$sortOptionsKey]])) {
        $sortBy = $sortOptions[$cols[$sortOptionsKey]];
        $sortDir = $_REQUEST['sSortDir_' . $i];
        break;
    }
}
// get articles
$articles = Article::GetList($articlesParams, array(array('field' => $sortBy, 'dir' => $sortDir)), $start, $limit, $articlesCount, true);
$return = array();
foreach ($articles as $article) {
    $return[] = $list->processItem($article);
}
return array('iTotalRecords' => Article::GetTotalCount(), 'iTotalDisplayRecords' => $articlesCount, 'sEcho' => (int) $_REQUEST['sEcho'], 'aaData' => $return);