Exemplo n.º 1
0
 public function init()
 {
     parent::init();
     $this->_texts = Data::cache(TextModel::CACHE_KEY, 3600, function () {
         return TextModel::find()->asArray()->all();
     });
 }
Exemplo n.º 2
0
 public function init()
 {
     parent::init();
     $texts = Data::cache(TextModel::CACHE_KEY, 3600, function () {
         return TextModel::find()->asArray()->all();
     });
     foreach ($texts as $text) {
         $this->_texts[$text['text_id']] = $this->parseText($text);
     }
 }
Exemplo n.º 3
0
 public function api_items()
 {
     return Data::cache(FaqModel::CACHE_KEY, 3600, function () {
         $items = [];
         foreach (FaqModel::find()->select(['faq_id', 'question', 'answer'])->status(FaqModel::STATUS_ON)->sort()->all() as $item) {
             $items[] = new FaqObject($item);
         }
         return $items;
     });
 }
Exemplo n.º 4
0
 public function init()
 {
     parent::init();
     $this->_items = Data::cache(CarouselModel::CACHE_KEY, 3600, function () {
         $items = [];
         foreach (CarouselModel::find()->status(CarouselModel::STATUS_ON)->sort()->all() as $item) {
             $items[] = new CarouselObject($item);
         }
         return $items;
     });
 }
Exemplo n.º 5
0
 public function api_all()
 {
     $data = Data::cache(FaqModel::CACHE_KEY, 3600, function () {
         return FaqModel::find()->select(['faq_id', 'question', 'answer'])->status(FaqModel::STATUS_ON)->sort()->asArray()->all();
     });
     $result = [];
     foreach ($data as $entry) {
         $result[] = $this->parseEntry($entry);
     }
     return $result;
 }
Exemplo n.º 6
0
 public static function findAllActive()
 {
     return Data::cache(self::CACHE_KEY, 3600, function () {
         $result = [];
         try {
             foreach (self::find()->where(['status' => self::STATUS_ON])->sort()->all() as $module) {
                 $module->trigger(self::EVENT_AFTER_FIND);
                 $result[$module->name] = (object) $module->attributes;
             }
         } catch (\yii\db\Exception $e) {
         }
         return $result;
     });
 }
Exemplo n.º 7
0
 public static function get($name)
 {
     if (!self::$_data) {
         self::$_data = Data::cache(self::CACHE_KEY, 3600, function () {
             $result = [];
             try {
                 foreach (parent::find()->all() as $setting) {
                     $result[$setting->name] = $setting->value;
                 }
             } catch (\yii\db\Exception $e) {
             }
             return $result;
         });
     }
     return isset(self::$_data[$name]) ? self::$_data[$name] : null;
 }
Exemplo n.º 8
0
 public function init()
 {
     parent::init();
     $data = Data::cache(CarouselModel::CACHE_KEY, 3600, function () {
         return CarouselModel::find()->status(CarouselModel::STATUS_ON)->sort()->asArray()->all();
     });
     foreach ($data as $item) {
         $temp = ['content' => '<img src="' . $item['image'] . '"/>', 'caption' => ''];
         if ($item['title']) {
             $temp['caption'] .= '<h3>' . $item['title'] . '</h3>';
         }
         if ($item['text']) {
             $temp['caption'] .= '<p>' . $item['text'] . '</p>';
         }
         $this->_items[] = $temp;
     }
 }