/** * Builds the where statement * * @since 5.0 * @access public * @return array * @internal param $string */ public function _buildDataQueryWhere() { $db = JFactory::getDBO(); // JSNPagebuilder custom $filter_category = isset($this->attributes['articlelist_filter_easy_categories']) ? explode(",", $this->attributes['articlelist_filter_easy_categories']) : ''; $filter_blogger = isset($this->attributes['articlelist_filter_easy_authors']) ? explode(",", $this->attributes['articlelist_filter_easy_authors']) : ''; $dateFiltering = isset($this->attributes['articlelist_filter_date']) ? $this->attributes['articlelist_filter_date'] : 'off'; $dateField = isset($this->attributes['articlelist_date_field']) ? $this->attributes['articlelist_date_field'] : 'a.created'; $where = array(); // Published posts only $where[] = 'a.`published` = ' . $db->quote(1); $categoryAlias = 'c.`id`'; if (!$this->attributes['is_old_version']) { $where[] = 'a.' . $db->qn('state') . '=' . $db->quote(0); $categoryAlias = 'cat.`category_id`'; } if ($filter_category != '') { $categories = $filter_category; $jsnEasyCategoriesModel = new JSNPbEasyblogCategoriesModel(); foreach ($filter_category as $_category_id) { $children = $jsnEasyCategoriesModel->getChildCategories($_category_id, true); foreach ($children as $_child) { $categories[] = $_child->id; } } $where[] = ' ' . $categoryAlias . ' IN (' . implode(',', $categories) . ')'; } else { $where[] = ' ' . $categoryAlias . ' = ""'; } if ($filter_blogger != '') { $where[] = ' a.`created_by` IN (' . implode(',', $filter_blogger) . ')'; } $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote(JFactory::getDate()->toSql()); switch ($dateFiltering) { case 'range': $startDateRange = isset($this->attributes['articlelist_range_date_start']) ? $db->quote(JFactory::getDate($this->attributes['articlelist_range_date_start'])->toSql()) : $nullDate; $endDateRange = isset($this->attributes['articlelist_range_date_end']) ? $db->quote(JFactory::getDate($this->attributes['articlelist_range_date_end'])->toSql()) : $nowDate; $where[] = ' (' . $dateField . ' >= DATE(' . $startDateRange . ') AND DATE(' . $dateField . ') <= DATE(' . $endDateRange . ')) '; break; case 'relative': $relativeDate = isset($this->attributes['articlelist_relative_date']) ? (int) $this->attributes['articlelist_relative_date'] : '30'; $where[] = ' ' . $dateField . ' >= DATE(DATE_SUB(' . $nowDate . ', INTERVAL ' . $relativeDate . ' DAY)) '; break; case 'off': default: break; } $where = count($where) ? ' WHERE ' . implode(' AND ', $where) : ''; return $where; }
/** * @return array */ public static function getArticleListEasyCategories() { if (!JSNPagebuilderHelpersPagebuilder::checkComponentEnabled("com_easyblog")) { return array(); } self::loadEasyblogLibraries(); $easyCategoryModel = new JSNPbEasyblogCategoriesModel(); $easyCategoies = $easyCategoryModel->getData(false); $options = array(); foreach ($easyCategoies as $_key => $_value) { $options[$_value->id] = $_value->title; } return $options; }