if (($this->gEnv->canUseDb() && $this->gSystem->canInitSystem()) || // システム初期化モードのとき
!$this->gConfig->isConfigured()){ // 設定ファイルに設定がないとき(初回インストール)
- // インストーラファイルがない場合は回復
- $this->gInstance->getFileManager()->recoverInstaller();
+ // 旧システムがある場合はadminディレクトリまでアクセスしてインストーラを実行。
+ $isRedirect = false;
+ if ($this->_isExistsOldSystemDir()){
+ if ($this->gEnv->isAdminDirAccess()) $isRedirect = true;
+ } else {
+ $isRedirect = true;
+ }
+
+ if ($isRedirect){
+ // インストーラファイルがない場合は回復
+ $this->gInstance->getFileManager()->recoverInstaller();
- $this->gPage->redirectToInstall();
+ $this->gPage->redirectToInstall();
+ } else {
+ // サイト非公開(システムメンテナンス)表示
+ $this->gPage->showError(503);
+ }
return;
} else if ($this->gConfig->isConfigured() && !$this->gEnv->canUseDb()){ // DB接続失敗のとき
if ($this->gEnv->isAdminDirAccess()){ // 管理画面の場合のみインストーラ起動
$errMessage = ''; // エラーメッセージ
$messageDetail = ''; // 詳細メッセージ
- // ページID,ページサブIDからアクセス権をチェック
- $isPublicUrl = $this->gPage->canAccessUrl($isActivePage, $errCode);
- if (!$isPublicUrl && !$isSystemManageUser){// システム運用可能ユーザかどうか
+ // ページID,ページサブID以外のURLパラメータをチェック。ページマネージャーでの処理(startPage())の結果を反映。
+ $ret = $this->gPage->isSystemPage(); // システム制御ページへ遷移するかどうか
+ if ($ret){
+ // ページが見つかりません画面へ遷移
$canAccess = false;
- $isErrorAccess = true; // 不正アクセスかどうか
- $errMessage = 'ユーザに公開されていないページへのアクセス。';
+ $toAdminType = 4;
+ }
+
+ // ページID,ページサブIDからアクセス権をチェック
+ if ($canAccess){
+ $isPublicUrl = $this->gPage->canAccessUrl($isActivePage, $errCode);
+ if (!$isPublicUrl && !$isSystemManageUser){// システム運用可能ユーザかどうか
+ $canAccess = false;
+ $isErrorAccess = true; // 不正アクセスかどうか
+ $errMessage = 'ユーザに公開されていないページへのアクセス。';
- if (!$isActivePage){
- if ($errCode == 1){ // ページIDが不正な場合
- $toAdminType = 4;
- } else {
- $toAdminType = 3; // 有効なアクセスポイント、ページでない場合は存在しないページとする
+ if (!$isActivePage){
+ if ($errCode == 1){ // ページIDが不正な場合
+ $toAdminType = 4;
+ } else {
+ $toAdminType = 3; // 有効なアクセスポイント、ページでない場合は存在しないページとする
+ }
}
}
}
-
+
// ################### ユーザアクセス制御 ######################
// クッキーがないため権限を識別できない場合でも、管理者として処理する場合があるので、サブクラスの_checkAccess()メソッドは必ず通るようにする
if ($canAccess){ // アクセス可能な場合はユーザをチェック
$this->gCache->setPageCache($request, $pageData); // キャッシュデータを設定
echo $pageData;
} else {
+ // ***** WordPressテンプレートの場合は非共通のウィジェットが使用されていなくても表示可とする *****
+ if ($this->gEnv->getCurrentTemplateType() == 100) $nonSharedWidgetCount = 1;
+
if ($isSystemAdmin || $nonSharedWidgetCount > 0){
$this->gCache->setPageCache($request, $pageData); // キャッシュデータを設定
echo $pageData;
// ################# パラメータチェック ################
if (!$isSystemManageUser && !$this->gAccess->isValidAdminKey() && $this->gEnv->isServerConnector()){ // サーバ接続の場合
// クエリーパラメータはウィジェットIDのみ正常とする
- $params = $this->gRequest->getQueryArray();
+ $params = $request->getQueryArray();
$paramCount = count($params);
if (!($paramCount == 1 && !empty($params[M3_REQUEST_PARAM_WIDGET_ID]))){
// アクセスエラーのログを残す
$this->gPage->startWidgetXml($cmd);
// 指定のウィジェットを実行
- $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/index.php';
+ $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/' . M3_FILENAME_INDEX;
if (file_exists($widgetIndexFile)){
// 実行のログを残す
$this->gPage->startWidgetRss($cmd);
// 指定のウィジェットを実行
- $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/index.php';
+ $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/' . M3_FILENAME_INDEX;
if (file_exists($widgetIndexFile)){
// ウィジェット定義ID、ページ定義のシリアル番号を取得
// 指定のウィジェットを実行
if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定のとき
- $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/admin/index.php'; // 管理用画面
+ $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/admin/' . M3_FILENAME_INDEX; // 管理用画面
} else {
- $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/index.php';
+ $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/' . M3_FILENAME_INDEX;
}
if (file_exists($widgetIndexFile)){
// ウィジェット定義ID、ページ定義のシリアル番号を取得
*/
function _createPage($request, $curTemplate, $subTemplateId = '')
{
- $defaultIndexFile = 'index.php'; // テンプレートの起動ファイル
+ $defaultIndexFile = M3_FILENAME_INDEX; // テンプレートの起動ファイル
$cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND); // 実行コマンドを取得
// サブクラスの前処理を実行
if (method_exists($this, '_preBuffer')) $this->_preBuffer($request);
- if ($convType == 100){ // Wordpressテンプレートのとき
- // WordPress用定義値
+ if ($convType == 100){ // WordPressテンプレートのとき
+ // WordPress用ベース定義値
define('WPINC', 'wp-includes');
define('ABSPATH', $this->gEnv->getWordpressRootPath() . '/' );
define('TEMPLATEPATH', $this->gEnv->getTemplatesPath() . '/' . $curTemplate);
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/load.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/default-constants.php'); // デフォルト値取得
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/plugin.php');
-//wp_initial_constants();
-//wp_set_lang_dir();
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/functions.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/default-filters.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/l10n.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-locale.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-user.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-walker.php');
- require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-query.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-query.php'); // コンテンツデータ取得
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-comment-query.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-term.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-walker-page.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-theme.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-list-util.php');
// require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-walker-nav-menu.php');
// require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-dependency.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-post.php'); // コンテンツAPIマネージャーからWP_Post型でデータを取得
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/post.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/user.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/widgets.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/comment.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/http.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/kses.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/script-loader.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/theme.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/template.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/link-template.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/category.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/category-template.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/post-template.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/post-thumbnail-template.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/comment-template.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/author-template.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/nav-menu-template.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/nav-menu.php');
// require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/option.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/pomo/translations.php');
require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/pomo/mo.php');
-
- // テンプレート内のファイルを読み込む
- if ( file_exists(TEMPLATEPATH . '/functions.php')) include(TEMPLATEPATH . '/functions.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/capabilities.php');
+ require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/meta.php');
// Magic3用インターフェイス
- require_once($this->gEnv->getWordpressRootPath() . '/contentApi.php');// コンテンツ取得用API
- require_once($this->gEnv->getWordpressRootPath() . '/wpInit.php'); // 初期値設定
-
+ require_once($this->gEnv->getWordpressRootPath() . '/wpInit.php'); // 初期値取得
+ require_once($this->gEnv->getWordpressRootPath() . '/contentApi.php'); // コンテンツ取得API
+ require_once($this->gEnv->getWordpressRootPath() . '/menuApi.php'); // メニュー情報取得API
+ require_once($this->gEnv->getWordpressRootPath() . '/WPRender.php'); // ウィジェット描画クラス
// ##### データ初期化 #####
- wp_initial_constants(); // 定義値取得
- m3WpInit(); // Magic3用インターフェイス初期化。$GLOBALS['m3WpOptions']を初期化し、get_option()はここから使用可能にする。
-
+ wp_initial_constants(); // WordPressその他定義値設定
+
// プラグイン初期化
$GLOBALS['wp_plugin_paths'] = array(); // $wp_plugin_pathsは未使用?
foreach (wp_get_active_and_valid_plugins() as $plugin) {// プラグインロード
unset($plugin);
// WordPressメインオブジェクト作成
- $GLOBALS['locale'] = $this->gEnv->getCurrentLanguage();
- $GLOBALS['wp'] = new WP();
- $GLOBALS['wp_the_query'] = new WP_Query();
+ $GLOBALS['wp_version'] = '4.7.0'; // 下位互換性チェックで引っかかるのでv4.7.0に定める
+ $GLOBALS['locale'] = $this->gEnv->getCurrentLanguage(); // 表示言語を設定
+ $GLOBALS['wp_the_query'] = new WP_Query(); // $wp_the_queryは変更不可変数で$wp_queryは変更可変数
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
- $GLOBALS['gContentApi'] = new contentApi(); // Magic3コンテンツアクセスクラス
-
- // 初期処理
+ $GLOBALS['wp'] = new WP();
+ $GLOBALS['gContentApi'] = new contentApi(); // Magic3コンテンツAPIオブジェクト
+ $GLOBALS['gMenuApi'] = new menuApi(); // Magic3メニュー情報APIオブジェクト
+ // テンプレートから参照可能にする
+ global $wp_query;
+
+ // テンプレート初期処理
do_action('setup_theme');
- load_default_textdomain();
- do_action('after_setup_theme');
+ load_default_textdomain(); // 言語リソースを読み込む
+ m3WpInit(); // 言語リソース読み込み後にMagic3用インターフェイス初期化。$GLOBALS['m3WpOptions']を初期化し、get_option()はここから使用可能にする。
+ $GLOBALS['wp_locale'] = new WP_Locale(); // 言語リソース読み込み後に生成
+ if ( file_exists(TEMPLATEPATH . '/functions.php')) include(TEMPLATEPATH . '/functions.php');// テンプレート初期処理
+ do_action('after_setup_theme'); // wp-multibyte-patchプラグイン読み込み
+ do_action('init'); // テンプレート側からの初期処理(ウィジェットのCSSの初期化等)
do_action('wp_loaded');
- wp();
- // ##### 起動ページを設定 #####
+ // ##### 起動PHPファイル取得。データ取得用パラメータ設定。#####
// URLパラメータからコンテンツ形式を取得し、ページを選択
- $params = $this->gRequest->getQueryArray();
+ $params = $request->getQueryArray();
$paramCount = count($params);
reset($params);
$firstKey = key($params);
- $firstValue = $params[$firstKey];
+// $firstValue = $params[$firstKey];
+ // コンテンツタイプに合わせて起動PHPファイルを決める。デフォルトはindex.phpで一覧形式で表示。
$contentType = $GLOBALS['gContentApi']->getContentType();
switch ($contentType){
case M3_VIEW_TYPE_CONTENT: // 汎用コンテンツ
if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT){ // コンテンツIDのとき
- $defaultIndexFile = get_page_template(); // 固定ページテンプレート
+ // ページタイプを設定
+ $GLOBALS['gContentApi']->setPageType('page');
+
+ // フルパスで返るので相対パスに修正
+ $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, get_page_template()); // 固定ページテンプレート
+
+ // コンテンツID設定
+ $firstValue = $request->trimValueOf($firstKey);
+ $GLOBALS['gContentApi']->setContentId($firstValue);
}
break;
case M3_VIEW_TYPE_PRODUCT: // 製品
// if ($firstKey == M3_REQUEST_PARAM_BLOG_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ID_SHORT || // ブログIDのとき
// $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT){ // ブログ記事IDのとき
if ($firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT){ // ブログ記事IDのとき
- $defaultIndexFile = get_single_template(); // 記事詳細テンプレート
+ // ページタイプを設定
+ $GLOBALS['gContentApi']->setPageType('single');
+
+ // フルパスで返るので相対パスに修正
+ $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, get_single_template()); // 記事詳細テンプレート
+
+ // コンテンツID設定
+ $firstValue = $request->trimValueOf($firstKey);
+ $GLOBALS['gContentApi']->setContentId($firstValue);
+ } else {
+ // カテゴリーが設定されている場合はカテゴリー画面を表示
+ $pageTypeDefined = false; // ページタイプ確定したかどうか
+ $value = $request->trimValueOf(M3_REQUEST_PARAM_CATEGORY_ID);
+ if (!empty($value)){
+ // ページタイプを設定
+ $GLOBALS['gContentApi']->setPageType('category'); // カテゴリー表示
+
+ // カテゴリー用テンプレート取得
+ $template = get_category_template();
+ if (empty($template)) $template = get_archive_template(); // カテゴリー用のテンプレートが取得できない場合はアーカイブ用テンプレートを取得
+
+ // フルパスで返るので相対パスに修正
+ $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, $template); // カテゴリーテンプレート
+
+ $pageTypeDefined = true; // ページタイプ確定
+ }
+ if (!$pageTypeDefined){
+ $year = $request->trimValueOf(M3_REQUEST_PARAM_YEAR); // 年指定
+ $month = $request->trimValueOf(M3_REQUEST_PARAM_MONTH); // 月指定
+ $day = $request->trimValueOf(M3_REQUEST_PARAM_DAY); // 日指定
+
+ if (!empty($year)){ // 年月日指定のとき
+ // ページタイプを設定
+ $GLOBALS['gContentApi']->setPageType('date'); // 年月日表示
+
+ // 年月日用テンプレート取得
+ $template = get_date_template();
+ if (empty($template)) $template = get_archive_template(); // 年月日用のテンプレートが取得できない場合はアーカイブ用テンプレートを取得
+
+ // フルパスで返るので相対パスに修正
+ $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, $template);
+
+ $pageTypeDefined = true; // ページタイプ確定
+ }
+ }
+ // 検索条件が設定されている場合は検索画面を表示
+ if (!$pageTypeDefined){
+ $value = $request->trimValueOf('s');
+ if (!empty($value)){
+ // ページタイプを設定
+ $GLOBALS['gContentApi']->setPageType('search'); // 検索結果表示
+
+ // フルパスで返るので相対パスに修正
+ $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, get_search_template()); // 検索結果テンプレート
+ }
+ }
}
break;
case M3_VIEW_TYPE_WIKI: // Wiki
break;
case M3_VIEW_TYPE_PHOTO: // フォトギャラリー
break;
+ default:
+ // コンテンツタイプが設定されていないページ(お問合わせページ等)に場合は、固定ページ用のテンプレートを使用
+ // ページタイプを設定
+ $GLOBALS['gContentApi']->setPageType('page');
+
+ // フルパスで返るので相対パスに修正
+ $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, get_page_template()); // 固定ページテンプレート
+ break;
+ }
+
+ // 現在デフォルトページを表示している場合で「sub」パラメータがなくWordPressにフロントページ用のスクリプトがある場合はWordPressフロント画面を表示する
+ if ($defaultIndexFile == M3_FILENAME_INDEX){
+ $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_PAGE_SUB_ID);
+ if ($this->gEnv->getCurrentPageSubId() == $this->gEnv->getDefaultPageSubId() && empty($pageSubId)){
+ $frontPageTemplate = get_front_page_template();
+ if (!empty($frontPageTemplate)) $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, $frontPageTemplate); // フロントページテンプレート
+ }
}
+ // WordPressオブジェクト作成
+ wp();
} else if ($convType >= 1){ // Joomla!v1.5,v2.5テンプレートのとき
global $mainframe;
require_once($this->gEnv->getJoomlaRootPath() . '/mosDef.php');// Joomla定義読み込み
// ################### テンプレート読み込み ###################
// テンプレートのポジションタグからウィジェットが実行される
- //$templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/index.php';
+ //$templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/' . M3_FILENAME_INDEX;
$templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/' . $defaultIndexFile;
if (file_exists($templateIndexFile)){
require_once($templateIndexFile);
} else { // テンプレートが存在しないとき
if ($this->gEnv->isSystemManageUser()){ // システム管理ユーザのとき
- echo 'template not found error: ' . $curTemplate;
+ echo 'template not found error: ' . $curTemplate . ', path=' . $templateIndexFile;
} else {
// 一般向けにはメンテナンス画面を表示
$this->gPage->setSystemHandleMode(10/*サイト非公開中*/);
ob_clean();
// Joomla!タグの変換処理(ウィジェット実行)
- if ($convType >= 1){ // Joomla!v1.5,v2.5テンプレートのとき
+ if ($convType >= 1 && $convType < 100){ // Joomla!v1.5,v2.5テンプレートのとき
$srcContents = $this->gPage->launchWidgetByJoomlaTag($srcContents, $convType);
}
$curTemplateId = self::SYSTEM_TEMPLATE;// システム画面用テンプレート
} else {
// テンプレートの存在チェック
- $templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplateId . '/index.php';
+ $templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplateId . '/' . M3_FILENAME_INDEX;
if (!file_exists($templateIndexFile)) $curTemplateId = self::SYSTEM_TEMPLATE;// システム画面用テンプレート
}
}
$this->_script[strtolower($type)] .= chr(13).$content;
}
}
+ /**
+ * WordPressテンプレートの起動ファイルパスを相対パスに変換
+ *
+ * @param string $templateId テンプレートID
+ * @param string $path テンプレートの起動ファイル絶対パス
+ * @return string テンプレート内での相対パス。エラー発生の場合はデフォルト(index.php)を返す。
+ */
+ function _getRelativeTemplateIndexPath($templateId, $path)
+ {
+ $savedPath = $path;
+ $templatePath = $this->gEnv->getTemplatesPath() . '/' . $templateId . '/';
+
+ // テンプレートまでのパスを削除
+ $path = str_replace($templatePath, '', $path);
+ if ($path == $savedPath) $path = M3_FILENAME_INDEX;
+ return $path;
+ }
+ /**
+ * 旧システムディレクトリが存在するかどうかを取得
+ *
+ * @return bool true=存在する、false=存在しない
+ */
+ function _isExistsOldSystemDir()
+ {
+ // 旧システムディレクトリは同ディレクト階層に存在し、ディレクトリ名の先頭に「_」が付加されているディレクトリ
+ $currentDir = $this->gEnv->getSystemRootPath();
+ $parentDir = dirname($currentDir);
+ $dirName = basename($currentDir);
+ if (is_dir($parentDir . '/_' . $dirName)){
+ return true;
+ } else {
+ return false;
+ }
+ }
}
?>