Beispiel #1
0
 /**
  * Install selected theme.
  *
  * @param string $theme
  *
  * @return \yii\web\Response
  */
 public function actionInstall($theme)
 {
     $fileConfig = $this->_themeDir . $theme . '/config/main.php';
     if (is_file($fileConfig)) {
         $config = (require_once $fileConfig);
         if (!is_array($config)) {
             Yii::$app->getSession()->setFlash('danger', Yii::t('writesdown', "File config must return an array."));
         } else {
             if (Option::set('theme', $theme)) {
                 Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', "Theme successfully installed."));
             }
         }
     } else {
         Yii::$app->getSession()->setFlash('danger', Yii::t('writesdown', "Theme not successfully installed. Error: invalid config file"));
     }
     // Redirect to index when the theme successfully installed
     return $this->redirect(['index']);
 }
Beispiel #2
0
 /**
  * Install selected theme and run install and uninstall action based on config.
  *
  * @param string $theme
  *
  * @return \yii\web\Response
  */
 public function actionInstall($theme)
 {
     if (is_file($fileConfigInstalled = $this->_themeDir . Option::get('theme') . '/config/main.php')) {
         $configOld = (require $fileConfigInstalled);
         if (isset($configOld['uninstall'])) {
             try {
                 Yii::createObject($configOld['uninstall']);
             } catch (Exception $e) {
             }
         }
     }
     if (is_file($fileConfigInstall = $this->_themeDir . $theme . '/config/main.php')) {
         $configNew = (require $fileConfigInstall);
         if (isset($configNew['install'])) {
             try {
                 Yii::createObject($configNew['install']);
             } catch (Exception $e) {
             }
         }
     }
     if (Option::set('theme', $theme)) {
         Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', "Theme successfully installed."));
     } else {
         Yii::$app->getSession()->setFlash('danger', Yii::t('writesdown', "File config must return an array."));
     }
     return $this->redirect(['index']);
 }
 /**
  * Install sitemap by default option.
  */
 public function actionInstall()
 {
     if (Option::set('sitemap', $this->_defaultOption)) {
         $this->redirect(['index']);
     }
 }
Beispiel #4
0
 /**
  * Install selected theme and run install and uninstall action based on config.
  *
  * @param string $theme
  *
  * @return \yii\web\Response
  */
 public function actionInstall($theme)
 {
     foreach (ArrayHelper::getValue($this->getConfig(Option::get('theme')), 'uninstall', []) as $type) {
         try {
             Yii::createObject($type);
         } catch (Exception $e) {
         }
     }
     foreach (ArrayHelper::getValue($this->getConfig($theme), 'install', []) as $type) {
         try {
             Yii::createObject($type);
         } catch (Exception $e) {
         }
     }
     if (Option::set('theme', $theme)) {
         Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', "Theme successfully installed."));
     }
     return $this->redirect(['index']);
 }