示例#1
0
 public function init()
 {
     parent::init();
     if ($this->categoryId) {
         $language_id = FrontEndHelper::getLanguageIdFromAcronym();
         $web_id = FrontEndHelper::getWebIdFromTextId(\Yii::$app->request->get('web', \Yii::$app->params['defaultWeb']));
         $this->viewName = 'calendarium';
         $this->orderBy = 'DATE_FORMAT(content.content_date, "%m%d") ASC';
         $this->withImage = true;
         $this->withDate = true;
         $sql = "( SELECT DISTINCT `content`.*\n\t\t\t\t\tFROM `content`\n\t\t\t\t\tINNER JOIN `article_category` ON article_category.article_id=content.id\n\t\t\t\t\tINNER JOIN `category` ON (category.id=article_category.category_id AND category.id=:category_id)\n\t\t\t\t\tINNER JOIN `menu_item_content` ON menu_item_content.category_id=category.id\n\t\t\t\t\tINNER JOIN `menu_item` ON menu_item.id=menu_item_content.menu_item_id\n\t\t\t\t\tINNER JOIN `menu` ON menu.id=menu_item.menu_id\n\t\t\t\t\tWHERE ((((((`content`.`content_type`=:content_type))\n\t\t\t\t\t\tAND (NOT (`content`.`id`" . ($this->articleId ? "=" . $this->articleId : " IS NULL") . ")))\n                        AND (`content`.`active`=TRUE)) " . (Yii::$app->user->isGuest ? " AND (`content`.`public`=TRUE))" : '') . "\n\t\t\t\t\t\tAND (`content`.`language_id`=:language_id))\n\t\t\t\t\t\tAND (`menu`.`web_id`=:web_id))\n\t\t\t\t\tORDER BY " . $this->orderBy . ($this->itemsCount ? " LIMIT " . $this->itemsCount : "");
         $query = ContentRecord::findBySql($sql, [':category_id' => $this->categoryId ?: $this->categoryId, ':content_type' => ContentRecord::TYPE_ARTICLE, ':language_id' => $language_id, ':web_id' => $web_id]);
         $this->_items = $query->all();
         $this->setMenuUrlParts();
     } else {
         throw new InvalidParamException(\Yii::t('front', 'No required parameter given') . ' - categoryId');
     }
 }