public function run() { $cacheName = "ContentBlock{$this->code}" . Yii::app()->language; $output = Yii::app()->cache->get($cacheName); if ($output === false) { $block = ContentBlock::model()->published()->findByCode($this->code); if (null === $block) { if ($this->silent === false) { throw new CException(Yii::t('ContentBlockModule.contentblock', 'Content block "{code}" was not found !', array('{code}' => $this->code))); } $output = ''; } else { switch ($block->type) { case ContentBlock::PHP_CODE: $output = eval($block->content); break; case ContentBlock::SIMPLE_TEXT: $output = CHtml::encode($block->content); break; case ContentBlock::HTML_TEXT: $output = $block->content; break; } } Yii::app()->cache->set($cacheName, $output); } $this->render($this->view, array('output' => $output)); }
public function loadModel($id) { if (($model = ContentBlock::model()->findByPk($id)) === null) { throw new CHttpException(404, Yii::t('ContentBlockModule.contentblock', 'Page was not found!')); } return $model; }
public function loadModel($id) { if (($model = ContentBlock::model()->findByPk($id)) === null) { throw new CHttpException(404, 'Страница не найдена'); } return $model; }
public function run() { $cacheName = "{$this->cacheName}{$this->code}"; $output = Yii::app()->cache->get($cacheName); if ($output === false) { $block = ContentBlock::model()->find('code = :code', array(':code' => $this->code)); if (is_null($block)) { if ((bool) $this->silent === false) { throw new CException(Yii::t('contentblock', 'Контент блок "{code}" не найден !', array('{code}' => $this->code))); } } else { switch ($block->type) { case ContentBlock::PHP_CODE: $output = eval($block->content); break; case ContentBlock::SIMPLE_TEXT: $output = CHtml::encode($block->content); break; case ContentBlock::HTML_TEXT: $output = $block->content; break; } } Yii::app()->cache->set($cacheName, $output); } $this->render('contentblock', array('output' => $output)); }
/** * @throws CException */ public function run() { $cacheName = "ContentBlock{$this->code}"; $output = Yii::app()->getCache()->get($cacheName); if (false === $output) { $block = ContentBlock::model()->findByAttributes(['code' => $this->code]); if (null === $block) { if (false === $this->silent) { throw new CException(Yii::t('ContentBlockModule.contentblock', 'Content block "{code}" was not found !', ['{code}' => $this->code])); } $output = ''; } else { $output = $block->status == ContentBlock::STATUS_ACTIVE ? $block->getContent() : ''; } Yii::app()->getCache()->set($cacheName, $output); } $this->render($this->view, ['output' => $output]); }
public function run() { $cacheName = "ContentBlock{$this->category}" . Yii::app()->language; $blocks = Yii::app()->cache->get($cacheName); if ($blocks === false) { $category = Category::model()->findByAttributes(['slug' => $this->category]); $criteria = new CDbCriteria(['scopes' => ['active']]); $criteria->addCondition('category_id = :category_id'); $criteria->params[':category_id'] = $category->id; if ($this->rand) { $criteria->order = 'RAND()'; } if ($this->limit) { $criteria->limit = (int) $this->limit; } $blocks = ContentBlock::model()->findAll($criteria); if (empty($blocks) && $this->silent === false) { throw new CException(Yii::t('ContentBlockModule.contentblock', 'Group content block "{category_id}" was not found !', ['{category_id}' => $this->category])); } Yii::app()->cache->set($cacheName, $blocks, $this->cacheTime); } $this->render($this->view, ['blocks' => $blocks]); }
public function run() { $cacheName = "ContentBlock{$this->code}" . Yii::app()->language; $output = Yii::app()->cache->get($cacheName); if ($output === false) { $block = ContentBlock::model()->active()->findByAttributes(['code' => $this->code]); if (null === $block) { if ($this->silent === false) { throw new CException(Yii::t('ContentBlockModule.contentblock', 'Content block "{code}" was not found !', ['{code}' => $this->code])); } $blockContent = ''; } else { if ($block->status == ContentBlock::STATUS_ACTIVE) { $blockContent = $block->getContent(); } else { $blockContent = ''; } } $output = $this->render($this->view, ['output' => $blockContent, 'block' => $block], true); Yii::app()->cache->set($cacheName, $output); } echo $output; }
public static function adminSign() { $adminSign = ''; if (Yii::app()->controller) { Yii::app()->controller->widget("application.modules.contentblock.widgets.ContentBlockWidget", array("code" => "admin-sign"), true); } else { Yii::import("application.modules.contentblock.models.*"); $block = ContentBlock::model()->find('code = :code', array(':code' => "admin-sign")); if ($block !== null) { $adminSign = $block->content; } } return $adminSign; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * * @param integer $id the ID of the model to be loaded * * @return ContentBlock $model * * @throws CHttpException */ public function loadModel($id) { $model = ContentBlock::model()->with('category')->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, Yii::t('ContentBlockModule.contentblock', 'Page was not found!')); } return $model; }
public function match_content_old() { /* problem with Phalanx service? - use previous version of Phalanx extension - tested */ return ContentBlock::onEditFilter($this->getText(), '', $this->block); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = ContentBlock::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }