Пример #1
0
 public function init()
 {
     parent::init();
     $this->_texts = Data::cache(TextModel::CACHE_KEY, 3600, function () {
         return TextModel::find()->asArray()->all();
     });
 }
Пример #2
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;
     });
 }
Пример #3
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);
     }
 }
Пример #4
0
 public function registerRegional()
 {
     $lang = Data::getLocale();
     if ($lang != 'en') {
         $langAsset = 'lang/' . $lang . '.js';
         if (file_exists(Yii::getAlias($this->assetBundle->sourcePath . '/' . $langAsset))) {
             $this->assetBundle->js[] = $langAsset;
             $this->options['lang'] = $lang;
         }
     }
 }
Пример #5
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;
     });
 }
Пример #6
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;
 }
Пример #7
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;
     });
 }
Пример #8
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;
 }
Пример #9
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;
     }
 }
Пример #10
0
 public function actionClearModuleSettings()
 {
     $activedModules = \yii\easyii\models\Module::findAllActive();
     $language = Data::getLocale();
     foreach (glob(Yii::getAlias('@easyii') . DIRECTORY_SEPARATOR . 'modules/*') as $module) {
         $moduleName = basename($module);
         $moduleClass = 'yii\\easyii\\modules\\' . $moduleName . '\\' . ucfirst($moduleName) . 'Module';
         $moduleConfig = $moduleClass::$installConfig;
         $installedModule = $activedModules[$moduleName];
         $module = Module::findOne($installedModule->module_id);
         $module->title = !empty($moduleConfig['title'][$language]) ? $moduleConfig['title'][$language] : $moduleConfig['title']['en'];
         $module->settings = Yii::createObject($moduleClass, [$moduleName])->settings;
         $module->order_num = $moduleConfig['order_num'];
         $module->icon = $moduleConfig['icon'];
         $module->status = Module::STATUS_ON;
         $module->save();
     }
     return $this->back();
 }
Пример #11
0
    public function registerScript()
    {
        if (empty($this->options['locale'])) {
            $this->options['locale'] = Data::getLocale();
        }
        $clientOptions = count($this->options) ? Json::encode($this->options) : '';
        $time = $this->model->{$this->attribute} ? $this->model->{$this->attribute} : time();
        $this->getView()->registerJs('
            var dtpContainer = $("#' . $this->widgetId . '");

            dtpContainer.datetimepicker(' . $clientOptions . ')
            .on("dp.change", function (e) {
                $("#' . Html::getInputId($this->model, $this->attribute) . '").val(e.date.unix());
            })
            .data("DateTimePicker")
            .date(moment(' . $time * 1000 . '));

            $("[type=text]", dtpContainer).focus(function(e){
                dtpContainer.data("DateTimePicker").show();
            });
        ');
    }
Пример #12
0
 private function installModules()
 {
     $language = Data::getLocale();
     foreach (glob(Yii::getAlias('@easyii') . DIRECTORY_SEPARATOR . 'modules/*') as $module) {
         $moduleName = basename($module);
         $moduleClass = 'yii\\easyii\\modules\\' . $moduleName . '\\' . ucfirst($moduleName) . 'Module';
         $moduleConfig = $moduleClass::$installConfig;
         $module = new Module(['name' => $moduleName, 'class' => $moduleClass, 'title' => !empty($moduleConfig['title'][$language]) ? $moduleConfig['title'][$language] : $moduleConfig['title']['en'], 'icon' => $moduleConfig['icon'], 'settings' => Yii::createObject($moduleClass, [$moduleName])->settings, 'order_num' => $moduleConfig['order_num'], 'status' => Module::STATUS_ON]);
         $module->save();
     }
 }