getCurrentThemesPlugins() public static method

テーマ梱包プラグインのリストを取得する
public static getCurrentThemesPlugins ( ) : array
return array
Example #1
0
 protected function _applyTheme($theme)
 {
     $plugins = BcUtil::getCurrentThemesPlugins();
     // テーマ梱包のプラグインをアンインストール
     foreach ($plugins as $plugin) {
         $this->BcManager->uninstallPlugin($plugin);
     }
     $siteConfig['SiteConfig']['theme'] = $theme;
     $this->SiteConfig->saveKeyValue($siteConfig);
     clearViewCache();
     $info = array();
     $themePath = BASER_THEMES . $theme . DS;
     $Folder = new Folder($themePath . 'Plugin');
     $files = $Folder->read(true, true, false);
     if (!empty($files[0])) {
         $info = array_merge($info, array('このテーマは下記のプラグインを同梱しています。'));
         foreach ($files[0] as $file) {
             $info[] = '	・' . $file;
         }
     }
     Configure::write('BcSite.theme', $theme);
     $plugins = BcUtil::getCurrentThemesPlugins();
     App::build(array('Plugin' => array_merge(array(BASER_THEMES . $theme . DS . 'Plugin' . DS), App::path('Plugin'))));
     // テーマ梱包のプラグインをインストール
     foreach ($plugins as $plugin) {
         $this->BcManager->installPlugin($plugin);
     }
     $path = BcUtil::getDefaultDataPath('Core', $theme);
     if (strpos($path, '/theme/' . $theme . '/') !== false) {
         if ($info) {
             $info = array_merge($info, array(''));
         }
         $info = array_merge($info, array('このテーマは初期データを保有しています。', 'Webサイトにテーマに合ったデータを適用するには、初期データ読込を実行してください。'));
     }
     if (!$this->Page->createAllPageTemplate()) {
         $message = array('テーマ変更中にページテンプレートの生成に失敗しました。', '「Pages」フォルダに書き込み権限が付与されていない可能性があります。', '権限設定後、テーマの適用をやり直すか、表示できないページについて固定ページ管理より更新処理を行ってください。');
         if ($info) {
             $message = array_merge($message, array(''), $info);
         }
         $this->setMessage(implode('<br />', $message), true);
     } else {
         $message = array('テーマ「' . $theme . '」を適用しました。');
         if ($info) {
             $message = array_merge($message, array(''), $info);
         }
         $this->setMessage(implode('<br />', $message));
     }
     return true;
 }
 /**
  * Step 5: 設定ファイルの生成
  * データベース設定ファイル[database.php]
  * インストールファイル[install.php]
  * 
  * @return void
  * @access public
  */
 public function step5()
 {
     $this->pageTitle = 'baserCMSのインストール完了!';
     Cache::config('default', array('engine' => 'File'));
     if (!BC_INSTALLED) {
         $installationData = $this->Session->read('Installation');
         $installationData['lastStep'] = true;
         checkTmpFolders();
         Configure::write('Cache.disable', false);
         // インストールファイルでセッションの保存方法を切り替える為、インストール情報をキャッシュに保存
         Cache::write('Installation', $installationData, 'default');
         // データベース設定を書き込む
         $this->BcManager->createDatabaseConfig($this->_readDbSetting());
         // インストールファイルを生成する
         $secritySalt = $this->Session->read('Installation.salt');
         $secrityCipherSeed = $this->Session->read('Installation.cipherSeed');
         $this->BcManager->createInstallFile($secritySalt, $secrityCipherSeed);
         //==================================================================
         // BcManagerComponent::createPageTemplates() を実行する際、
         // 固定ページでプラグインを利用している場合あり、プラグインがロードされていないとエラーになる為、
         // リダイレクト前にコアプラグインの有効化とテーマ保有のプラグインのインストールを完了させておく
         // =================================================================
         // データベースのデータを初期設定に更新
         $this->BcManager->executeDefaultUpdates($this->_readDbSetting(Cache::read('Installation', 'default')));
         // テーマを配置する
         $this->BcManager->deployTheme();
         $dbDataPattern = $this->Session->read('Installation.dbDataPattern');
         list($theme, $pattern) = explode('.', $dbDataPattern);
         loadSiteConfig();
         App::build(array('Plugin' => array_merge(array(BASER_THEMES . Configure::read('BcSite.theme') . DS . 'Plugin' . DS), App::path('Plugin'))));
         $themesPlugins = BcUtil::getCurrentThemesPlugins();
         if ($themesPlugins) {
             foreach ($themesPlugins as $plugin) {
                 $this->BcManager->installPlugin($plugin);
                 CakePlugin::load($plugin);
                 $this->BcManager->resetTables('plugin', $dbConfig = null, $plugin);
                 $this->BcManager->loadDefaultDataPattern('plugin', null, $pattern, $theme, $plugin);
             }
         }
         clearAllCache();
         if (function_exists('opcache_reset')) {
             opcache_reset();
         }
         $this->redirect('step5');
     } else {
         $installationData = Cache::read('Installation', 'default');
         if (empty($installationData['lastStep'])) {
             return;
         }
     }
     // ログイン
     $this->_login();
     // テーマに管理画面のアセットへのシンボリックリンクを作成する
     $this->BcManager->deployAdminAssets();
     // アップロード用初期フォルダを作成する
     $this->BcManager->createDefaultFiles();
     // エディタテンプレート用の画像を配置
     $this->BcManager->deployEditorTemplateImage();
     // Pagesファイルを生成する
     $this->BcManager->createPageTemplates();
     $this->Session->delete('InstallLastStep');
 }
Example #3
0
 /**
  * テーマ梱包プラグインのリストを取得する
  */
 public function testGetCurrentThemesPlugins()
 {
     // プラグインが存在しない場合(デフォルトのbccolumn)
     $result = BcUtil::getCurrentThemesPlugins();
     $expect = array();
     $this->assertEquals($expect, $result, 'テーマ梱包プラグインのリストを正しく取得できません');
     // プラグインが存在する場合
     // ダミーのプラグインディレクトリを作成
     $theme = Configure::read('BcSite.theme');
     $path = BASER_THEMES . $theme . DS . 'Plugin';
     $Folder = new Folder();
     $Folder->create($path . DS . 'dummy1');
     $Folder->create($path . DS . 'dummy2');
     $result = BcUtil::getCurrentThemesPlugins();
     // ダミーのプラグインディレクトリを削除
     $Folder->delete($path);
     $expect = array('dummy1', 'dummy2');
     $this->assertEquals($expect, $result, 'テーマ梱包プラグインのリストを正しく取得できません');
 }