Example #1
0
 /**
  * 有効なプラグインのロード. プラグインエンジンが有効になっていない場合は
  * プラグインエンジン自身のインストール処理を起動する
  *
  * @return void
  */
 public function load($plugin_activate_flg = true)
 {
     if (!defined('CONFIG_REALFILE') || !file_exists(CONFIG_REALFILE)) {
         return;
     }
     // インストール前
     if (GcUtils::isInstallFunction()) {
         return;
     }
     // インストール中
     if ($plugin_activate_flg === false) {
         return;
     }
     // 有効なプラグインを取得
     $arrPluginDataList = PluginUtil::getEnablePlugin();
     // pluginディレクトリを取得
     $arrPluginDirectory = PluginUtil::getPluginDirectory();
     foreach ($arrPluginDataList as $arrPluginData) {
         // プラグイン本体ファイル名が取得したプラグインディレクトリ一覧にある事を確認
         if (array_search($arrPluginData['plugin_code'], $arrPluginDirectory) !== false) {
             $plugin_file_path = PLUGIN_UPLOAD_REALDIR . $arrPluginData['plugin_code'] . '/' . $arrPluginData['class_name'] . '.php';
             // プラグイン本体ファイルが存在しない場合
             if (!file_exists($plugin_file_path)) {
                 // エラー出力
                 $msg = 'プラグイン本体ファイルが存在しない。当該プラグインを無視して続行する。';
                 $msg .= 'ファイル=' . var_export($plugin_file_path, true) . '; ';
                 trigger_error($msg, E_USER_WARNING);
                 // 次のプラグインへ続行
                 continue 1;
             }
             // プラグイン本体ファイルをrequire.
             require_once $plugin_file_path;
             // プラグインのインスタンス生成.
             $objPlugin = new $arrPluginData['class_name']($arrPluginData);
             // メンバ変数にプラグインのインスタンスを登録.
             $this->arrPluginInstances[$arrPluginData['plugin_id']] = $objPlugin;
             $this->arrPluginIds[] = $arrPluginData['plugin_id'];
             // ローカルフックポイントの登録.
             $this->registerLocalHookPoint($objPlugin, $arrPluginData['priority']);
             // スーパーフックポイントの登録.
             $this->registerSuperHookPoint($objPlugin, HOOK_POINT_PREPROCESS, 'preProcess', $arrPluginData['priority']);
             $this->registerSuperHookPoint($objPlugin, HOOK_POINT_PROCESS, 'process', $arrPluginData['priority']);
         }
     }
 }
 /**
  * Returns a callable given its string representation.
  *
  * @param string $name
  *
  * @return array A callable array
  *
  * @throws \InvalidArgumentException In case the method does not exist.
  */
 public function convertCallback($name)
 {
     if (preg_match(static::PAGE_PATTERN, $name)) {
         return function (Application $app, Request $request) use($name) {
             // setpath
             $path_info = $request->getPathInfo();
             if (substr($path_info, -1) == '/') {
                 $path_info .= 'index.php';
             }
             $_SERVER['SCRIPT_NAME'] = str_replace('/index.php', '', $request->server->get('SCRIPT_NAME')) . $path_info . (substr($path_info, -1) == '/' ? 'index.php' : '');
             $_SERVER['SCRIPT_FILENAME'] = dirname($request->server->get('SCRIPT_FILENAME')) . $path_info;
             // rtrim は PHP バージョン依存対策
             $GLOBALS['_realdir'] = rtrim(realpath(rtrim(realpath(dirname($request->server->get('SCRIPT_FILENAME'))), '/\\') . '/'), '/\\') . '/';
             $GLOBALS['_realdir'] = str_replace('\\', '/', $GLOBALS['_realdir']);
             $GLOBALS['_realdir'] = str_replace('//', '/', $GLOBALS['_realdir']);
             define('HTML_REALDIR', $GLOBALS['_realdir']);
             /** HTMLディレクトリからのDATAディレクトリの相対パス */
             define('HTML2DATA_DIR', '../app/');
             define('USE_FILENAME_DIR_INDEX', null);
             if (!defined('DATA_REALDIR')) {
                 define('DATA_REALDIR', HTML_REALDIR . HTML2DATA_DIR);
             }
             // アプリケーション初期化処理
             if (!defined('CACHE_REALDIR')) {
                 /** キャッシュ生成ディレクトリ */
                 define('CACHE_REALDIR', DATA_REALDIR . "cache/eccube/");
             }
             \Eccube\Framework\Helper\HandleErrorHelper::load();
             // アプリケーション初期化処理
             $objInit = new \Eccube\Framework\Initial();
             $objInit->init();
             // Page instance
             $objPage = new $name($app);
             if ($objPage instanceof \Eccube\Page\Admin\AbstractAdminPage) {
                 define('ADMIN_FUNCTION', true);
             } else {
                 define('FRONT_FUNCTION', true);
             }
             // 定数 SAFE が設定されている場合、DBアクセスを回避する。主に、エラー画面を意図する。
             if (!defined('SAFE') || !SAFE) {
                 // インストール中で無い場合、
                 if (!GcUtils::isInstallFunction()) {
                     // インストールチェック
                     Utils::sfInitInstall();
                     // セッション初期化・開始
                     $sessionFactory = SessionFactory::getInstance();
                     $sessionFactory->initSession();
                     /*
                      * 管理画面の場合は認証行う.
                      * 認証処理忘れ防止のため, \Eccube\Page\Admin::init() 等ではなく, ここでチェックする.
                      */
                     SessionHelper::adminAuthorization();
                 }
             }
             // bufferを初期化する
             if ($objPage instanceof \Eccube\Page\Admin\AbstractAdminPage) {
                 ob_start();
             } else {
                 // 絵文字変換 (除去) フィルターを組み込む。
                 ob_start(array('\\Eccube\\Framework\\MobileEmoji', 'handler'));
                 if (Application::alias('eccube.display')->detectDevice() == DEVICE_TYPE_MOBILE) {
                     // resize_image.phpは除外
                     if (!$objPage instanceof \Eccube\Page\ResizeImage) {
                         /* @var $objMobile MobileHelper */
                         $objMobile = Application::alias('eccube.helper.mobile');
                         $objMobile->sfMobileInit();
                     }
                 }
             }
             $objPage->init();
             $objPage->process();
             $response = ob_get_contents();
             ob_end_clean();
             return $response;
         };
     } else {
         return parent::convertCallback($name);
     }
 }
Example #3
0
 /**
  * 前方互換用
  *
  * @deprecated 2.12.0 GcUtils::isInstallFunction を使用すること
  */
 public function sfIsInstallFunction()
 {
     trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING);
     return GcUtils::isInstallFunction();
 }