Exemplo n.º 1
0
 private static function setChanged()
 {
     /* @var $changed Config */
     $changed = Config::getModelByKey(self::SITEMAP_CHANGED);
     if ($changed === null) {
         $changed = new Config(['key' => self::SITEMAP_CHANGED, 'value' => 'TRUE']);
     } elseif ($changed->value === 'FALSE') {
         $changed->value = 'TRUE';
     }
     return $changed->save();
 }
Exemplo n.º 2
0
 public function actionEcommerce()
 {
     $yaCounter = $gaCounter = ['id' => '', 'active' => 0];
     if (Yii::$app->request->isPost) {
         $gaCounter = array_merge($gaCounter, Yii::$app->request->post('GoogleCounter', []));
         $yaCounter = array_merge($yaCounter, Yii::$app->request->post('YandexCounter', []));
         $model = Config::getModelByKey('ecommerceCounters');
         if (empty($model)) {
             $model = new Config();
             $model->key = 'ecommerceCounters';
         }
         $model->value = Json::encode(['google' => $gaCounter, 'yandex' => $yaCounter]);
         $model->save();
     }
     $counters = Config::getModelByKey('ecommerceCounters');
     if (!empty($counters)) {
         $counters = Json::decode($counters->value);
         $gaCounter = !empty($counters['google']) ? $counters['google'] : $gaCounter;
         $yaCounter = !empty($counters['yandex']) ? $counters['yandex'] : $yaCounter;
     }
     return $this->render('ecommerce-counters', ['gaCounter' => $gaCounter, 'yaCounter' => $yaCounter]);
 }