BcUtil::getDefaultDataPath PHP Method

getDefaultDataPath() public static method

初期データのフォルダは アンダースコア区切り推奨
public static getDefaultDataPath ( string $plugin = null, string $theme = null, string $pattern = null ) : string
$plugin string プラグイン名
$theme string テーマ名
$pattern string 初期データの類型
return string Or false
    public static function getDefaultDataPath($plugin = null, $theme = null, $pattern = null)
    {
        if (!$plugin) {
            $plugin = 'Core';
        } else {
            $plugin = Inflector::camelize($plugin);
        }
        if (!$theme) {
            $theme = 'core';
        }
        if (!$pattern) {
            $pattern = 'default';
        }
        if ($plugin == 'Core') {
            $paths = array(BASER_CONFIGS . 'data' . DS . $pattern);
            if ($theme != 'core') {
                $paths = array_merge(array(BASER_THEMES . $theme . DS . 'Config' . DS . 'data' . DS . $pattern, BASER_THEMES . $theme . DS . 'Config' . DS . 'Data' . DS . $pattern, BASER_THEMES . $theme . DS . 'Config' . DS . 'Data' . DS . Inflector::camelize($pattern), BASER_CONFIGS . 'theme' . DS . $theme . DS . 'Config' . DS . 'data' . DS . $pattern, BASER_THEMES . $theme . DS . 'Config' . DS . 'data' . DS . 'default', BASER_THEMES . $theme . DS . 'Config' . DS . 'Data' . DS . 'default'), $paths);
            }
        } else {
            $pluginPaths = App::path('Plugin');
            foreach ($pluginPaths as $pluginPath) {
                $pluginPath .= $plugin;
                if (is_dir($pluginPath)) {
                    break;
                }
                $pluginPath = null;
            }
            if (!$pluginPath) {
                return false;
            }
            $paths = array($pluginPath . DS . 'Config' . DS . 'data' . DS . $pattern, $pluginPath . DS . 'Config' . DS . 'Data' . DS . $pattern, $pluginPath . DS . 'Config' . DS . 'Data' . DS . Inflector::camelize($pattern), $pluginPath . DS . 'sql', $pluginPath . DS . 'Config' . DS . 'data' . DS . 'default', $pluginPath . DS . 'Config' . DS . 'Data' . DS . 'default');
            if ($theme != 'core') {
                $paths = array_merge(array(BASER_THEMES . $theme . DS . 'Config' . DS . 'data' . DS . $pattern . DS . $plugin, BASER_THEMES . $theme . DS . 'Config' . DS . 'Data' . DS . $pattern . DS . $plugin, BASER_THEMES . $theme . DS . 'Config' . DS . 'Data' . DS . Inflector::camelize($pattern) . DS . $plugin, BASER_CONFIGS . 'theme' . DS . $theme . DS . 'config' . DS . 'data' . DS . $pattern . DS . $plugin, BASER_THEMES . $theme . DS . 'Config' . DS . 'data' . DS . 'default' . DS . $plugin, BASER_THEMES . $theme . DS . 'Config' . DS . 'Data' . DS . 'default' . DS . $plugin), $paths);
            }
        }
        foreach ($paths as $path) {
            if (is_dir($path)) {
                return $path;
            }
        }
        return false;
    }

Usage Example

コード例 #1
0
ファイル: ThemesController.php プロジェクト: hanhunhun/hanlog
 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;
 }
All Usage Examples Of BcUtil::getDefaultDataPath