7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
9 * @package Magic3 Framework
10 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11 * @copyright Copyright 2006-2017 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
14 * @link http://www.magic3.org
16 require_once(M3_SYSTEM_INCLUDE_PATH . '/db/systemDb.php'); // システムDBアクセスクラス
17 require_once(M3_SYSTEM_INCLUDE_PATH . '/common/core.php');
19 class BaseFrameContainer extends Core
21 protected $_db; // DB接続オブジェクト
22 private $joomlaBufArray = array(); // Joomla!データ受け渡し用
23 const SYSTEM_TEMPLATE = '_system'; // システム画面用テンプレート
24 const M_ADMIN_TEMPLATE = 'm/_admin'; // 携帯用管理画面テンプレート
25 const ERR_MESSAGE_ACCESS_DENY = 'Access denied.'; // ウィジェットアクセスエラーのメッセージ
26 const SITE_ACCESS_EXCEPTION_IP = 'site_access_exception_ip'; // アクセス制御、例外とするIP
27 const CONFIG_KEY_MSG_TEMPLATE = 'msg_template'; // メッセージ用テンプレート取得キー
28 // const CF_MOBILE_AUTO_REDIRECT = 'mobile_auto_redirect'; // 携帯の自動遷移
29 const TEMPLATE_GENERATOR_THEMLER = 'themler'; // テンプレート作成アプリケーション(Themler)
34 function __construct()
37 parent::__construct();
40 $this->_db = $this->gInstance->getSytemDbObject();
43 * 起動マネージャから呼ばれる唯一のメソッド
45 * @param RequestManager $request HTTPリクエスト処理クラス
47 function process($request)
50 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND); // 実行コマンドを取得
52 // インストール画面への制御は、install.phpファイルの作成、削除で制御する
53 // 最小限の設定が行われていない場合,DBに接続できない場合は、インストール画面へ
54 if (!defined('M3_STATE_IN_INSTALL')){
55 if (($this->gEnv->canUseDb() && $this->gSystem->canInitSystem()) || // システム初期化モードのとき
56 !$this->gConfig->isConfigured()){ // 設定ファイルに設定がないとき(初回インストール)
59 $this->gInstance->getFileManager()->recoverInstaller();
61 $this->gPage->redirectToInstall();
63 } else if ($this->gConfig->isConfigured() && !$this->gEnv->canUseDb()){ // DB接続失敗のとき
64 if ($this->gEnv->isAdminDirAccess()){ // 管理画面の場合のみインストーラ起動
66 $this->gInstance->getFileManager()->recoverInstaller();
68 $this->gPage->redirectToInstall();
71 $this->gPage->showError(500);
78 //$this->gLog->info(__METHOD__, 'フレーム作成開始');
81 // セッション変数読み込み。サブページIDの設定。
82 $this->gPage->startPage($request);
85 $isSystemAdmin = $this->gEnv->isSystemAdmin(); // 管理者権限があるかどうか
86 $isSystemManageUser = $this->gEnv->isSystemManageUser(); // システム運用可能かどうか
88 if (!defined('M3_STATE_IN_INSTALL')){ // インストールモード以外のとき
89 // ############## ユーザごとの設定の読み込み ###################
90 // 引数での言語設定取得、言語変更可能な場合は変更
91 // 言語の優先順は、URLの言語設定、クッキーの言語設定の順
92 if (!$this->gEnv->isAdminDirAccess()){ // 管理画面以外の場合
93 if ($this->gEnv->getCanChangeLang() && $this->gEnv->isMultiLanguageSite()){ // 言語変更可能で多言語対応サイトのとき
94 $lang = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_LANG);
97 $lang = $request->getCookieValue(M3_COOKIE_LANG);
101 if (in_array($lang, $this->gSystem->getAcceptLanguage())){
102 $this->gEnv->setCurrentLanguage($lang);
105 $request->setCookieValue(M3_COOKIE_LANG, $lang);
106 } else { // アクセス不可の場合はクッキーを削除
108 $request->setCookieValue(M3_COOKIE_LANG, '', -1);
112 $request->setCookieValue(M3_COOKIE_LANG, '', -1);
115 $this->gPage->loadLang();
117 // ################### URLアクセス制御 ######################
118 // 非公開URLへは管理権限がないとアクセスできない
119 $canAccess = true; // アクセス可能かどうか
120 $isErrorAccess = false; // 不正アクセスかどうか
121 $toAdminType = 0; // 管理画面の遷移タイプ(0=アクセス不可、1=ログイン画面、2=サイト非公開画面, 3=存在しないページ)
122 $errMessage = ''; // エラーメッセージ
123 $messageDetail = ''; // 詳細メッセージ
125 // ページID,ページサブIDからアクセス権をチェック
126 $isPublicUrl = $this->gPage->canAccessUrl($isActivePage, $errCode);
127 if (!$isPublicUrl && !$isSystemManageUser){// システム運用可能ユーザかどうか
129 $isErrorAccess = true; // 不正アクセスかどうか
130 $errMessage = 'ユーザに公開されていないページへのアクセス。';
133 if ($errCode == 1){ // ページIDが不正な場合
136 $toAdminType = 3; // 有効なアクセスポイント、ページでない場合は存在しないページとする
141 // ################### ユーザアクセス制御 ######################
142 // クッキーがないため権限を識別できない場合でも、管理者として処理する場合があるので、サブクラスの_checkAccess()メソッドは必ず通るようにする
143 if ($canAccess){ // アクセス可能な場合はユーザをチェック
144 if (method_exists($this, '_checkAccess')){
146 $canAccess = $this->_checkAccess($request); // サブクラスメソッドの呼び出し
148 // フロント画面から直接管理画面が呼ばれた場合は一旦ログインへ遷移
150 ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェットの設定
151 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET)){ // 表示位置を表示するとき(ウィジェット付き)
153 $toAdminType = 1; // ログイン画面へ
155 } else { // _checkAccess()がないときは、標準のアクセス制御
157 $canAccess = $this->_accessSite($request); // サイト公開制御
159 if ($cmd == M3_REQUEST_CMD_LOGIN || // ログイン画面を表示のとき
160 $cmd == M3_REQUEST_CMD_LOGOUT){ // ログアウトのとき
164 $toAdminType = 1; // ログイン画面へ
165 } else if ($cmd != '' && // コマンドなし
166 $cmd != M3_REQUEST_CMD_CHANGE_TEMPLATE && // テンプレート変更
167 $cmd != M3_REQUEST_CMD_SHOW_POSITION && // 表示位置を表示するとき
168 $cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET && // 表示位置を表示するとき(ウィジェット付き)
169 $cmd != M3_REQUEST_CMD_FIND_WIDGET && // ウィジェットを検索
170 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行
171 $cmd != M3_REQUEST_CMD_PREVIEW && // サイトのプレビューを表示
172 $cmd != M3_REQUEST_CMD_RSS && // RSS配信
173 $cmd != M3_REQUEST_CMD_CSS){ // CSS生成
175 // 標準のアクセスでは、上記コマンド以外は受け付けない
177 $isErrorAccess = true; // 不正アクセス
178 $errMessage = '不正なコマンドの実行。';
179 $messageDetail = 'アクセスポイント状態=公開';
181 } else { // サイトアクセスできない場合は、管理画面でメッセージを表示
182 if ($cmd == M3_REQUEST_CMD_LOGIN || // ログイン画面を表示のとき
183 $cmd == M3_REQUEST_CMD_LOGOUT || // ログアウトのとき
184 $cmd == M3_REQUEST_CMD_PREVIEW){ // サイトのプレビューを表示
185 $toAdminType = 1; // ログイン画面へ
187 $toAdminType = 2; // サイト非公開画面へ
191 if ($cmd != '' && // コマンドなし
192 $cmd != M3_REQUEST_CMD_LOGIN && // ログイン画面を表示のとき
193 $cmd != M3_REQUEST_CMD_LOGOUT && // ログアウトのとき
194 $cmd != M3_REQUEST_CMD_CHANGE_TEMPLATE && // テンプレート変更
195 $cmd != M3_REQUEST_CMD_SHOW_POSITION && // 表示位置を表示するとき
196 $cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET && // 表示位置を表示するとき(ウィジェット付き)
197 $cmd != M3_REQUEST_CMD_FIND_WIDGET && // ウィジェットを検索
198 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行
199 $cmd != M3_REQUEST_CMD_PREVIEW && // サイトのプレビューを表示
200 $cmd != M3_REQUEST_CMD_RSS && // RSS配信
201 $cmd != M3_REQUEST_CMD_CSS){ // CSS生成
203 $isErrorAccess = true; // 不正アクセス
204 $errMessage = '不正なコマンドの実行。';
205 $messageDetail = 'アクセスポイント状態=非公開';
209 // システム運用可能ユーザはアクセス可。
210 // ログアウトのときはすでに管理ユーザの可能性があるので、ログアウト時は変更しない
211 //if ($isSystemManageUser && $cmd != M3_REQUEST_CMD_LOGOUT) $canAccess = true;
212 if ($isSystemAdmin && $cmd != M3_REQUEST_CMD_LOGOUT) $canAccess = true; // 2011/8/31 システム管理者のみに変更
214 // #################### アクセスログ記録 #######################
215 // DBが使用可能であれば、ログイン処理終了後、アクセスログを残す
216 if ($this->gEnv->canUseDb()) $this->gAccess->accessLog();
220 switch ($toAdminType){
223 $this->gPage->setSystemHandleMode(1/*管理画面*/);
226 $this->gPage->setSystemHandleMode(10/*サイト非公開中*/);
228 case 3: // 存在しないページ画面へ(システム運用可能ユーザ以外)
229 // サイトが非公開の場合は、メンテナンス中画面のみ表示
230 if ($this->_accessSite($request)){ // サイト公開中の場合
231 $messageDetail = 'アクセスポイント状態=公開';
232 $this->gPage->setSystemHandleMode(12/*存在しないページ*/);
234 $messageDetail = 'アクセスポイント状態=非公開';
235 $this->gPage->setSystemHandleMode(10/*サイト非公開中*/);
238 case 4: // 不正なページIDの指定
239 $messageDetail = '不正なページIDの指定';
240 $this->gPage->setSystemHandleMode(12/*存在しないページ*/);
242 default: // アクセス不可画面へ
244 $this->gPage->setSystemHandleMode(11/*アクセス不可*/);
248 $this->_showSystemPage($request, $toAdminType);
250 // 不正アクセスの場合は、アクセスエラーログを残す
251 if ($isErrorAccess) $this->gOpeLog->writeUserAccess(__METHOD__, '不正なアクセスを検出しました。' . $errMessage, 2201, 'アクセスをブロックしました。URL: ' . $this->gEnv->getCurrentRequestUri() . ', ' . $messageDetail);
254 // #################### URLの遷移 #######################
255 //if ($this->gSystem->getSystemConfig(self::CF_MOBILE_AUTO_REDIRECT)){ // 携帯自動遷移を行う場合
256 if ($this->gSystem->mobileAutoRedirect()){ // 携帯自動遷移を行う場合
258 if ($this->gEnv->isMobile() && !$this->gEnv->getIsMobileSite()){
259 $this->gPage->redirect($this->gEnv->getDefaultMobileUrl(true/*携帯用パラメータ付加*/), true/*遷移時のダイアログ表示を抑止*/);
263 if ($this->gSystem->smartphoneAutoRedirect()){ // スマートフォン自動遷移を行う場合
264 // スマートフォンのときはスマートフォンURLへ遷移
265 if ($this->gEnv->isSmartphone() && !$this->gEnv->getIsSmartphoneSite()){
266 $this->gPage->redirect($this->gEnv->getDefaultSmartphoneUrl());
272 // ################## 実行コマンドから処理を確定 ##################
273 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
275 // 画面作成モードか、ウィジェット単体処理モードかを決定
276 $createPage = true; // 画面作成モード
277 if ($cmd == M3_REQUEST_CMD_INIT_DB){ // DB初期化オペレーションのとき
278 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION){ // 表示位置を表示するとき
280 //if ($this->gEnv->isSystemAdmin()){
282 // ポジションの表示画面のアクセスは、すべて管理機能URLで受け付ける
284 /* $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
285 if (empty($pageId)) $pageId = $this->gEnv->getDefaultPageId(); // 値がないときはデフォルトのページIDを設定
286 $this->gEnv->setCurrentPageId($pageId);
287 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
288 if (!empty($pageSubId)) $this->gEnv->setCurrentPageSubId($pageSubId);
290 $this->gPage->showPosition(1); // ポジションを表示
294 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
296 //if ($this->gEnv->isSystemAdmin()){
298 // ポジションの表示画面のアクセスは、すべて管理機能URLで受け付ける
300 /* $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
301 if (empty($pageId)) $pageId = $this->gEnv->getDefaultPageId(); // 値がないときはデフォルトのページIDを設定
302 $this->gEnv->setCurrentPageId($pageId);
303 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
304 if (!empty($pageSubId)) $this->gEnv->setCurrentPageSubId($pageSubId);
306 $this->gPage->showPosition(2); // ウィジェット付きポジションを表示
310 } else if ($cmd == M3_REQUEST_CMD_GET_WIDGET_INFO){ // ウィジェット各種情報取得(AJAX用)
312 $this->gPage->getWidgetInfoByAjax($request);
314 } else if ($cmd == M3_REQUEST_CMD_SHOW_PHPINFO){ // phpinfoの表示
316 $this->_showPhpinfoPage($request);
318 } else if ($cmd == M3_REQUEST_CMD_FIND_WIDGET){ // ウィジェットを検索し、前面表示
319 // 目的のウィジェットのあるページサブIDへ遷移
320 $this->gPage->redirectToUpdatedPageSubId($request);
322 } else if ($cmd == M3_REQUEST_CMD_SHOW_WIDGET){ // ウィジェットの単体表示
323 $createPage = false; // ウィジェット単体処理モードに設定
324 $this->gPage->showWidget(); // ウィジェット表示
325 } else if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェットの設定管理
326 $createPage = false; // ウィジェット単体処理モードに設定
327 $this->gPage->showWidget(); // ウィジェット表示
328 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体オペレーション
329 $createPage = false; // ウィジェット単体処理モードに設定
331 // ウィンドウオープンタイプ指定のときは、テンプレートを表示する
332 if (!empty($openBy)) $this->gPage->showWidget(); // ウィジェット表示
333 } else if ($cmd == M3_REQUEST_CMD_RSS){ // RSS配信
334 $createPage = false; // ウィジェット単体処理モードに設定
335 } else if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成
337 } else if ($this->gEnv->isServerConnector()){ // サーバ接続の場合
338 $createPage = false; // ウィジェット単体処理モードに設定
341 // ################### クライアントへの出力方法の制御 ######################
343 $widgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
344 if ($createPage){ // 通常の画面作成の場合
346 $this->gCache->initCache($request); // キャッシュ機能初期化
347 $cacheData = $this->gCache->getPageCache($request);
349 if (empty($cacheData)){ // キャッシュデータがないときは画面を作成
351 $curTemplateId = $this->_defineTemplate($request, $subTemplateId);
354 $pageData = $this->_createPage($request, $curTemplateId, $subTemplateId);
356 // 使用した非共通ウィジェットの数をチェック
357 $nonSharedWidgetCount = $this->gPage->getNonSharedWidgetCount();
358 if ($nonSharedWidgetCount == -1){ // カウントなしの場合
359 $this->gCache->setPageCache($request, $pageData); // キャッシュデータを設定
362 if ($isSystemAdmin || $nonSharedWidgetCount > 0){
363 $this->gCache->setPageCache($request, $pageData); // キャッシュデータを設定
365 } else { // 管理者以外で、非共通のウィジェットが使用されていないページはアクセス不可とする
366 $errMessage = 'ユーザに公開されていないページへのアクセス。';
367 $messageDetail = 'アクセスポイント状態=公開, 要因: グローバルウィジェットのみのページへのアクセスはできません。ページには1つ以上のローカルウィジェットが必要です。';
368 $this->gOpeLog->writeUserAccess(__METHOD__, '不正なアクセスを検出しました。' . $errMessage, 2202, 'アクセスをブロックしました。URL: ' . $this->gEnv->getCurrentRequestUri() . ', ' . $messageDetail);
371 $this->gPage->redirect('?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=_accessdeny');
373 //$this->gPage->setSystemHandleMode(11/*アクセス不可*/);
376 //$this->_showSystemPage($request, 0/*アクセス不可画面*/);
383 if ($cmd != M3_REQUEST_CMD_CSS){ // 画面出力(CSS生成以外)のとき
385 echo $this->gPage->getOptionContents($request);
387 } else { // ウィジェット単体実行モードのとき
388 // ###################ウィジェット指定で出力の場合####################
389 // ウィジェット単体を直接実行するインターフェイスで、HTTPヘッダは送信しない。
391 // ・Ajaxを使って、データをやり取りしたい場合
392 // ・ウィジェット単体での実行(ウィジェットが生成したタグのみ)
393 // ・ウィジェット単体での実行(HTMLやJavascriptの追加あり)
394 // ・ウィジェット個別の設定(セキュリティの必要あり)
396 // ################# アクセスチェック ################
397 // ウィジェット単体オペレーションのときは、ウィジェット情報の単体実行許可があるかどうか判断(管理権限にかかわらず同じ動作)
398 if ($cmd == M3_REQUEST_CMD_DO_WIDGET || // ウィジェット単体実行
399 $cmd == M3_REQUEST_CMD_RSS){ // RSS配信
400 if (empty($widgetId)){
401 $this->gOpeLog->writeUserAccess(__METHOD__, 'ウィジェットIDが設定されていません。', 2200,
404 } else if ($this->_db->getWidgetInfo($widgetId, $row)){ // ウィジェット情報取得
405 if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !$row['wd_enable_operation']){ // ウィジェット単体実行
407 $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd, self::ERR_MESSAGE_ACCESS_DENY);
409 $this->gOpeLog->writeUserAccess(__METHOD__, 'このウィジェットは単体起動できません。(ウィジェットID: ' . $widgetId . ')', 2200,
410 '実行処理はキャンセルされました。このウィジェットは単体起動できないウィジェットです。単体起動を許可するにはウィジェット情報(_widgets)の単体起動フラグ(wd_enable_operation)がtrueになっている必要があります。');
412 } else if ($cmd == M3_REQUEST_CMD_RSS && !$row['wd_has_rss']){ // RSS配信
414 $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd, self::ERR_MESSAGE_ACCESS_DENY);
416 $this->gOpeLog->writeUserAccess(__METHOD__, 'このウィジェットはRSS配信できません。(ウィジェットID: ' . $widgetId . ')', 2200,
417 '実行処理はキャンセルされました。このウィジェットはRSS配信できないウィジェットです。RSS配信を許可するにはウィジェット情報(_widgets)のRSS配信フラグ(wd_has_rss)がtrueになっている必要があります。');
421 $this->gOpeLog->writeUserAccess(__METHOD__, 'このウィジェットは実行許可がありません。(ウィジェットID: ' . $widgetId . ')', 2200,
422 '実行処理はキャンセルされました。ウィジェット情報(_widgets)が見つかりません。');
427 // 管理権限がない場合は、ウィジェットのページへの配置状況からアクセス権限をチェックする
428 if (!$isSystemManageUser && !$this->gAccess->isValidAdminKey() && !$this->_db->canAccessWidget($widgetId)){
430 $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd, self::ERR_MESSAGE_ACCESS_DENY);
432 $this->gOpeLog->writeUserAccess(__METHOD__, 'ウィジェットへの不正なアクセスを検出しました。(ウィジェットID: ' . $widgetId . ')', 2200,
433 '実行処理はキャンセルされました。このウィジェットは一般ユーザに公開されているページ上に存在しないため単体実行できません。');
437 // ################# パラメータチェック ################
438 if (!$isSystemManageUser && !$this->gAccess->isValidAdminKey() && $this->gEnv->isServerConnector()){ // サーバ接続の場合
439 // クエリーパラメータはウィジェットIDのみ正常とする
440 $params = $this->gRequest->getQueryArray();
441 $paramCount = count($params);
442 if (!($paramCount == 1 && !empty($params[M3_REQUEST_PARAM_WIDGET_ID]))){
444 $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd, self::ERR_MESSAGE_ACCESS_DENY);
446 $this->gOpeLog->writeUserAccess(__METHOD__, 'サーバ接続アクセスポイントへの不正なアクセスを検出しました。', 2200,
447 '実行処理はキャンセルされました。URLのクエリー部が不正です。URL=' . $this->gEnv->getCurrentRequestUri());
452 // 画面表示する場合はテンプレートを設定。画面に表示しない場合はテンプレートが必要ない。
453 if ($this->gPage->getShowWidget()){
455 //$curTemplate = $this->_defineTemplate($request);
456 $curTemplate = $this->gSystem->defaultAdminTemplateId();
459 $this->gEnv->setCurrentTemplateId($curTemplate);
462 // ################### バッファリング開始 ######################
463 // ob_end_flush()までの出力をバッファリングする
467 if (method_exists($this, '_preBuffer')) $this->_preBuffer($request);
470 $this->gEnv->setCurrentWidgetId($widgetId);
472 if ($this->gEnv->isServerConnector()){ // サーバ接続の場合
473 // ウィジェット用のHTMLヘッダを出力
474 $this->gPage->startWidgetXml($cmd);
477 $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/index.php';
479 if (file_exists($widgetIndexFile)){
481 $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd);
483 require_once($widgetIndexFile);
485 echo 'file not found: ' . $widgetIndexFile;
489 $this->gPage->endWidgetXml($cmd);
490 } else if ($cmd == M3_REQUEST_CMD_RSS){ // RSS配信のとき
493 // ウィジェット用のHTMLヘッダを出力
494 $this->gPage->startWidgetRss($cmd);
497 $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/index.php';
499 if (file_exists($widgetIndexFile)){
500 // ウィジェット定義ID、ページ定義のシリアル番号を取得
501 $configId = 0; // 定義ID
502 $serial = 0; // シリアル番号
503 if ($this->_db->getPageDefOnPageByWidgetId($this->gEnv->getCurrentPageId(), $this->gEnv->getCurrentPageSubId(), $widgetId, $row)){
504 $configId = $row['pd_config_id']; // 定義ID
505 $serial = $row['pd_serial']; // シリアル番号
509 $this->gEnv->setCurrentWidgetConfigId($configId);
512 $this->gEnv->setCurrentPageDefSerial($serial);
515 $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd);
517 require_once($widgetIndexFile);
520 $this->gEnv->setCurrentWidgetConfigId('');
523 $this->gEnv->setCurrentPageDefSerial(0);
525 echo 'file not found: ' . $widgetIndexFile;
528 // 現在のバッファ内容を取得し、バッファを破棄
529 $content = ob_get_contents();
533 $this->gPage->endWidgetRss($cmd, $content);
534 } else { // RSS配信以外のとき
537 // ウィジェット用のHTMLヘッダを出力
538 $this->gPage->startWidget($cmd);
541 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定のとき
542 $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/admin/index.php'; // 管理用画面
544 $widgetIndexFile = $this->gEnv->getWidgetsPath() . '/' . $widgetId . '/index.php';
546 if (file_exists($widgetIndexFile)){
547 // ウィジェット定義ID、ページ定義のシリアル番号を取得
548 $configId = 0; // 定義ID
549 $serial = 0; // シリアル番号
550 if ($this->_db->getPageDefOnPageByWidgetId($this->gEnv->getCurrentPageId(), $this->gEnv->getCurrentPageSubId(), $widgetId, $row)){
551 $configId = $row['pd_config_id']; // 定義ID
552 $serial = $row['pd_serial']; // シリアル番号
556 $this->gEnv->setCurrentWidgetConfigId($configId);
559 $this->gEnv->setCurrentPageDefSerial($serial);
562 $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd);
564 require_once($widgetIndexFile);
567 $this->gEnv->setCurrentWidgetConfigId('');
570 $this->gEnv->setCurrentPageDefSerial(0);
572 echo 'file not found: ' . $widgetIndexFile;
575 // 現在のバッファ内容を取得し、バッファを破棄
576 $content = ob_get_contents();
580 $this->gPage->endWidget($cmd, $content);
584 $this->gEnv->setCurrentWidgetId('');
587 if (method_exists($this, '_postBuffer')) $this->_postBuffer($request);
589 if ($cmd == M3_REQUEST_CMD_SHOW_WIDGET || // ウィジェットの単体表示
590 $cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット設定のとき
591 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy))){ // ウィンドウオープンタイプ指定でウィジェット単体実行のとき
593 // 現在の出力内容を取得し、一旦内容をクリア
594 $srcContents = ob_get_contents();
597 // 追加変換処理。HTMLヘッダ出力する。
598 $destContents = $this->gPage->lateLaunchWidget($request, $srcContents);
603 // ページ作成終了処理(HTTPヘッダ出力)
604 $this->gPage->endPage($request);
606 if ($cmd != M3_REQUEST_CMD_RSS){ // 画面出力(RSS配信以外)のとき
608 echo $this->gPage->getOptionContents($request);
611 // バッファ内容を送信(クライアントへの送信完了)
614 if (!defined('M3_STATE_IN_INSTALL')){ // インストールモード以外のとき
615 // #################### アクセスログ記録 #######################
616 // DBが使用可能であれば、アクセスログのユーザを登録
617 if ($this->gEnv->canUseDb()) $this->gAccess->accessLogUser();
621 //$this->gLog->info(__METHOD__, 'フレーム作成終了');
626 * @param RequestManager $request HTTPリクエスト処理クラス
627 * @param string $curTemplate テンプレートID
628 * @param string $subTemplateId サブページID
629 * @return string 画面出力
631 function _createPage($request, $curTemplate, $subTemplateId = '')
633 $defaultIndexFile = 'index.php'; // テンプレートの起動ファイル
635 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND); // 実行コマンドを取得
638 $this->gEnv->setCurrentTemplateId($curTemplate, $subTemplateId);
641 $convType = 0; // 変換処理タイプ(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
642 if ($this->gEnv->getIsMobileSite()){
643 $convType = -1; // 携帯サイト用変換
645 // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
646 $convType = $this->gEnv->getCurrentTemplateType();
650 if (method_exists($this, '_prepareBuffer')) $this->_prepareBuffer($request);
652 // ################### バッファリング開始 ######################
653 // ob_end_flush()までの出力をバッファリングする
654 if ($convType == -1){// 携帯用サイトの場合は出力エンコーディングを変更
655 $mobileEncoding = $this->gEnv->getMobileEncoding(); // 携帯用エンコーディングを取得
656 mb_http_output($mobileEncoding);
657 ob_start("mb_output_handler"); // 出力のバッファリング開始
663 if (method_exists($this, '_preBuffer')) $this->_preBuffer($request);
665 if ($convType == 100){ // Wordpressテンプレートのとき
667 define('WPINC', 'wp-includes');
668 define('ABSPATH', $this->gEnv->getWordpressRootPath() . '/' );
669 define('TEMPLATEPATH', $this->gEnv->getTemplatesPath() . '/' . $curTemplate);
670 define('STYLESHEETPATH', $this->gEnv->getTemplatesPath() . '/' . $curTemplate); // 子テンプレートを使用している場合は子テンプレートを示す。デフォルトはテンプレートを示す。
671 define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
672 define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages');
673 define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
674 define('WP_CONTENT_URL', '/wp-content'); // 定義自体は必要であるが使用しないのでダミー値で定義
675 define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins'); // 定義自体は必要であるが使用しないのでダミー値で定義
677 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/load.php');
678 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/default-constants.php'); // デフォルト値取得
679 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/plugin.php');
680 //wp_initial_constants();
683 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/functions.php');
684 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/default-filters.php');
685 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/l10n.php');
686 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp.php');
687 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-walker.php');
688 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-query.php');
689 // require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-walker-nav-menu.php');
690 // require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-dependency.php');
691 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/class-wp-post.php'); // コンテンツAPIマネージャーからWP_Post型でデータを取得
693 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/query.php');
694 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/pluggable.php');
695 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/post.php');
696 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/user.php');
697 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/widgets.php');
698 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/http.php');
699 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/kses.php');
700 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/script-loader.php');
701 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/theme.php');
702 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/template.php');
703 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/link-template.php');
704 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/category-template.php');
705 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/post-template.php');
706 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/post-thumbnail-template.php');
707 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/comment-template.php');
708 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/author-template.php');
709 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/nav-menu-template.php');
710 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/nav-menu.php');
711 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/general-template.php');
712 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/cache.php');
713 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/shortcodes.php');
714 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/formatting.php');
715 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/post-formats.php');
716 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/taxonomy.php');
717 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/media.php');
718 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/embed.php');
719 // require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/option.php');
720 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/pomo/translations.php');
721 require_once($this->gEnv->getWordpressRootPath() . '/wp-includes/pomo/mo.php');
724 if ( file_exists(TEMPLATEPATH . '/functions.php')) include(TEMPLATEPATH . '/functions.php');
727 require_once($this->gEnv->getWordpressRootPath() . '/contentApi.php');// コンテンツ取得用API
728 require_once($this->gEnv->getWordpressRootPath() . '/wpInit.php'); // 初期値設定
731 // ##### データ初期化 #####
732 wp_initial_constants(); // 定義値取得
733 m3WpInit(); // Magic3用インターフェイス初期化。$GLOBALS['m3WpOptions']を初期化し、get_option()はここから使用可能にする。
736 $GLOBALS['wp_plugin_paths'] = array(); // $wp_plugin_pathsは未使用?
737 foreach (wp_get_active_and_valid_plugins() as $plugin) {// プラグインロード
738 wp_register_plugin_realpath($plugin);
739 include_once($plugin);
743 // WordPressメインオブジェクト作成
744 $GLOBALS['locale'] = $this->gEnv->getCurrentLanguage();
745 $GLOBALS['wp'] = new WP();
746 $GLOBALS['wp_the_query'] = new WP_Query();
747 $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
748 $GLOBALS['gContentApi'] = new contentApi(); // Magic3コンテンツアクセスクラス
751 do_action('setup_theme');
752 load_default_textdomain();
753 do_action('after_setup_theme');
754 do_action('wp_loaded');
757 // ##### 起動ページを設定 #####
758 // URLパラメータからコンテンツ形式を取得し、ページを選択
759 $params = $this->gRequest->getQueryArray();
760 $paramCount = count($params);
762 $firstKey = key($params);
763 $firstValue = $params[$firstKey];
765 $contentType = $GLOBALS['gContentApi']->getContentType();
766 switch ($contentType){
767 case M3_VIEW_TYPE_CONTENT: // 汎用コンテンツ
768 if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT){ // コンテンツIDのとき
769 $defaultIndexFile = get_page_template(); // 固定ページテンプレート
772 case M3_VIEW_TYPE_PRODUCT: // 製品
774 case M3_VIEW_TYPE_BBS: // BBS
776 case M3_VIEW_TYPE_BLOG: // ブログ
777 // if ($firstKey == M3_REQUEST_PARAM_BLOG_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ID_SHORT || // ブログIDのとき
778 // $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT){ // ブログ記事IDのとき
779 if ($firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT){ // ブログ記事IDのとき
780 $defaultIndexFile = get_single_template(); // 記事詳細テンプレート
783 case M3_VIEW_TYPE_WIKI: // Wiki
785 case M3_VIEW_TYPE_USER: // ユーザ作成コンテンツ
787 case M3_VIEW_TYPE_EVENT: // イベント
789 case M3_VIEW_TYPE_PHOTO: // フォトギャラリー
792 } else if ($convType >= 1){ // Joomla!v1.5,v2.5テンプレートのとき
794 require_once($this->gEnv->getJoomlaRootPath() . '/mosDef.php');// Joomla定義読み込み
795 require_once($this->gEnv->getJoomlaRootPath() . '/JParameter.php');
796 require_once($this->gEnv->getJoomlaRootPath() . '/JRender.php');
800 $paramFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/params.ini';
801 if (is_readable($paramFile)){
802 $content = file_get_contents($paramFile);
803 $params = new JParameter($content);
805 $params = new JParameter();
807 // テンプレートヘッダ画像上のテキスト設定(Joomla!テンプレート2.5以降)
808 $params->set('siteTitle', $this->gEnv->getSiteName()); // サイト名
809 $params->set('siteSlogan', $this->gSystem->getSiteDef(M3_TB_FIELD_SITE_SLOGAN)); // サイトスローガン
811 // Joomla!テンプレート共通の設定
815 define('JPATH_BASE', dirname(__FILE__));
816 define('JPATH_SITE', $this->gEnv->getSystemRootPath());
817 define('JPATH_PLUGINS', $this->gEnv->getJoomlaRootPath() . '/class/plugins'); // プラグインパス
818 // define('JPATH_THEMES', $this->gEnv->getTemplatesPath()); // テンプレートパス ## テンプレート内でエラーが発生するのでここでは定義しない(2015/10/13)
819 define('DS', DIRECTORY_SEPARATOR);
820 $this->language = $this->gEnv->getCurrentLanguage();
821 $this->template = $curTemplate;
822 //$this->baseurl = $this->gEnv->getRootUrl();
823 $this->baseurl = $this->gEnv->getRootUrlByCurrentPage();
824 $this->direction = 'ltr';
825 $this->params = $params;
828 if ($this->gEnv->getCurrentTemplateGenerator() == self::TEMPLATE_GENERATOR_THEMLER){ // Themlerテンプレートの場合はサブテンプレート用のパラメータを設定
829 // JRequest経由でレンダー側にサブテンプレートIDを渡す
830 if (!empty($subTemplateId)) JRequest::injectSetVar('file_template_name', $subTemplateId);
832 // サブテンプレートIDの渡し方は以下の方法もある(Themlerテンプレート1.39以降はこちらが有効)
834 if (!empty($subTemplateId)) $this->setBuffer('<!--TEMPLATE ' . $subTemplateId . ' /-->', 'component');
837 // 現在のJoomla!ドキュメントを設定
838 $this->gEnv->setJoomlaDocument($this);
839 } else { // デフォルト(Joomla!v1.0テンプレート)テンプレートのとき(PC用および携帯用)
840 // Joomla!テンプレート共通の設定
844 global $mosConfig_absolute_path;
845 global $mosConfig_live_site;
846 global $mosConfig_sitename;
847 global $mosConfig_favicon;
848 global $mosConfig_sef;
849 global $cur_template;
851 require_once($this->gEnv->getJoomlaRootPath() . '/mosDef.php');// Joomla定義読み込み
852 require_once($this->gEnv->getJoomlaRootPath() . '/mosFunc.php');
853 require_once($this->gEnv->getJoomlaRootPath() . '/includes/sef.php');
856 // ################### テンプレート読み込み ###################
857 // テンプレートのポジションタグからウィジェットが実行される
858 //$templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/index.php';
859 $templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplate . '/' . $defaultIndexFile;
860 if (file_exists($templateIndexFile)){
861 require_once($templateIndexFile);
862 } else { // テンプレートが存在しないとき
863 if ($this->gEnv->isSystemManageUser()){ // システム管理ユーザのとき
864 echo 'template not found error: ' . $curTemplate;
867 $this->gPage->setSystemHandleMode(10/*サイト非公開中*/);
868 $this->_showSystemPage($request, 2/*サイト非公開画面*/);// システム制御画面を表示
870 // 運用ログに記録(一度だけ出力したい)
871 //$this->gOpeLog->writeFatal(__METHOD__, 'テンプレートが存在しません。メンテナンス画面を表示します。(テンプレートID=' . $curTemplate . ')', 1100);
877 if (method_exists($this, '_postBuffer')) $this->_postBuffer($request);
879 // 現在の出力内容を取得し、一旦内容をクリア
880 $srcContents = ob_get_contents();
883 // Joomla!タグの変換処理(ウィジェット実行)
884 if ($convType >= 1){ // Joomla!v1.5,v2.5テンプレートのとき
885 $srcContents = $this->gPage->launchWidgetByJoomlaTag($srcContents, $convType);
888 // 遅延実行ウィジェットの出力を埋め込む。HTMLヘッダ出力する。
889 $destContents = $this->gPage->lateLaunchWidget($request, $srcContents);
891 // 携帯インターフェイスのときのときは、手動変換後、バイナリコード(絵文字等)を埋め込む
892 if ($convType == -1){ // 携帯アクセスポイントの場合
894 $destContents = mb_convert_encoding($destContents, $mobileEncoding, M3_ENCODING);
896 // コンテンツ変換メソッドがある場合は実行
897 if (method_exists($this, '_convContents')){
898 $destContents = $this->_convContents($destContents);// 絵文字埋め込み処理等
902 // ##### CSS生成の場合は、すべてのウィジェット実行後出力を削除する #####
903 if ($cmd == M3_REQUEST_CMD_CSS) $destContents = ''; // CSS生成のとき
905 // ページ作成終了処理(HTTPヘッダ出力)
906 $destContents .= $this->gPage->endPage($request, true/*出力を取得*/); // 最終HTMLを追加
907 if ($this->gPage->isRedirect()) return '';// リダイレクトの場合ob_end_clean()を実行すると、ログインできないことがあるのでここで終了(2011/11/11)
914 return $destContents;
919 * @param RequestManager $request HTTPリクエスト処理クラス
920 * @param string $subTemplateId テンプレートIDが取得できるときはサブページIDが返る
921 * @return string テンプレート名
923 function _defineTemplate($request, &$subTemplateId)
925 // ########### テンプレートID(ディレクトリ名)を設定 ############
926 // テンプレートIDの指定の方法は2パターン
931 // 1.サブクラスの_setTemplate()で固定設定にしている場合の固定値
936 $isSystemManageUser = $this->gEnv->isSystemManageUser(); // システム運用可能かどうか
937 $useSubClassDefine = true; // サブクラスでの定義を使用するかどうか
939 // テンプレート変更のときは、セッションのテンプレートIDを変更
940 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND); // 実行コマンドを取得
941 if ($cmd == M3_REQUEST_CMD_CHANGE_TEMPLATE){
942 // テンプレートIDをセッションに残す場合
943 if ($this->gSystem->useTemplateIdInSession()){ // セッションに保存する場合
944 $request->setSessionValue(M3_SESSION_CURRENT_TEMPLATE, $request->trimValueOf(M3_SYSTEM_TAG_CHANGE_TEMPLATE));
948 // サブクラスでテンプレートIDを指定している場合はそちらを使用
949 $templateDefined = false; // テンプレート固定かどうか
950 if ($useSubClassDefine){
951 $tmplStr = trim($this->_setTemplate($request));
952 if (strlen($tmplStr) > 0){
953 $curTemplate = $tmplStr;
954 $templateDefined = true; // テンプレート固定かどうか
958 // セッションにあるときは、セッションの値を使用(携帯でないとき)
959 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
960 if (empty($curTemplate)){
961 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 表示位置を表示するとき
962 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
963 // URLの引数として、ページIDとページサブIDが指定されてくる
964 // URLの引数のテンプレートを優先し、引数で指定されていなければ、ページ用個別のテンプレートを取得する
966 // URLの引数でテンプレートIDが指定されている場合は設定
967 $templateId = $request->trimValueOf(M3_REQUEST_PARAM_TEMPLATE_ID); // テンプレートIDを取得
968 if (!empty($templateId)) $curTemplate = $templateId;
970 // ページ用個別に設定されたテンプレートがある場合は取得
971 if (empty($curTemplate)){
972 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
973 $line = $this->gPage->getPageInfo($pageId, $pageSubId);
975 $pageTemplateId = $line['pn_template_id'];
976 $subTemplateId = $line['pn_sub_template_id']; // サブテンプレートID
978 if (!empty($pageTemplateId)) $curTemplate = $pageTemplateId;
982 if (empty($curTemplate)){
983 if ($pageId == $this->gEnv->getDefaultPageId()){ // 通常サイトのとき
984 $curTemplate = $this->gSystem->defaultTemplateId();
985 $subTemplateId = $this->gSystem->defaultSubTemplateId();
986 } else if ($pageId == $this->gEnv->getDefaultMobilePageId()){ // 携帯サイトのとき
987 $curTemplate = $this->gSystem->defaultMobileTemplateId(); // 携帯用デフォルトテンプレート
988 } else if ($pageId == $this->gEnv->getDefaultSmartphonePageId()){ // スマートフォン用サイトのとき
989 $curTemplate = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
990 } else if ($pageId == $this->gEnv->getDefaultAdminPageId() || // 管理サイトのとき
991 $pageId == $this->gEnv->getDefaultRegistPageId()){ // 登録サイトのとき
992 $curTemplate = $this->gSystem->defaultAdminTemplateId();
993 } else if (empty($pageId)){ // ページIDが指定されていないときは、ウィジェットを表示しないテンプレートのみの表示
994 // URLの引数でテンプレートIDが指定されている場合は設定
995 // $templateId = $request->trimValueOf(M3_REQUEST_PARAM_TEMPLATE_ID); // テンプレートIDを取得
996 // if (!empty($templateId)) $curTemplate = $templateId;
1000 // ページ用のテンプレートがあるときは優先
1001 $pageTemplateId = $this->gPage->getTemplateIdFromCurrentPageInfo($subTemplateId);
1002 if (!empty($pageTemplateId)) $curTemplate = $pageTemplateId;
1004 // テンプレートIDをセッションから取得
1005 if (empty($curTemplate) && !$isSystemManageUser){ // システム運用者はセッション値を使用できない
1006 if ($this->gSystem->useTemplateIdInSession()){ // セッションに保存する場合
1007 if (!$this->gEnv->getIsMobileSite() && !$this->gEnv->getIsSmartphoneSite()){
1008 $curTemplate = $request->getSessionValue(M3_SESSION_CURRENT_TEMPLATE);// 携帯サイト、スマートフォンサイトでないときはセッション値を取得
1013 // オプションのテンプレートがある場合はオプションを優先
1014 $optionTemplate = $this->gPage->getOptionTemplateId();
1015 if (!empty($optionTemplate)){
1016 $curTemplate = $optionTemplate;
1017 $templateDefined = true; // テンプレート固定かどうか
1020 // セッションにないときはデフォルトを取得
1021 if (empty($curTemplate)){
1022 if ($this->gEnv->getIsMobileSite()){// 携帯用サイトの場合
1023 $curTemplate = $this->gSystem->defaultMobileTemplateId(); // 携帯用デフォルトテンプレート
1024 } else if ($this->gEnv->getIsSmartphoneSite()){// スマートフォン用サイトの場合
1025 $curTemplate = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
1027 $curTemplate = $this->gSystem->defaultTemplateId();
1028 $subTemplateId = $this->gSystem->defaultSubTemplateId();
1034 if (empty($curTemplate)){
1035 // テンプレートが1つもみつからないときは、管理用テンプレートを使用
1036 $curTemplate = $this->gSystem->defaultAdminTemplateId();
1037 echo 'template not found. viewing by administration template. [' . $curTemplate . ']';
1038 } else { // セッションにテンプレートIDを保存
1039 // テンプレートIDをセッションに残す場合
1040 /* if ($this->gSystem->useTemplateIdInSession()){ // セッションに保存する場合
1041 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 表示位置を表示するとき
1042 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
1044 if (!$this->gEnv->getIsMobileSite() && !$this->gEnv->getIsSmartphoneSite() && !$templateDefined){ // PC用画面でサブクラス固定でないとき場合は保存
1045 $request->setSessionValue(M3_SESSION_CURRENT_TEMPLATE, $curTemplate);
1050 return $curTemplate;
1055 * @param RequestManager $request HTTPリクエスト処理クラス
1056 * @return bool サイトにアクセスできるかどうか
1058 function _accessSite($request)
1061 $isOpen = $this->gSystem->siteInPublic();
1063 // PC用サイト、携帯用サイト、スマートフォン用サイトの公開状況をチェック
1064 if ($this->gEnv->getIsPcSite()){
1065 if ($this->gSystem->sitePcInPublic()) return true;
1066 } else if ($this->gEnv->getIsMobileSite()){
1067 if ($this->gSystem->siteMobileInPublic()) return true;
1068 } else if ($this->gEnv->getIsSmartphoneSite()){
1069 if ($this->gSystem->siteSmartphoneInPublic()) return true;
1074 $ip = $this->gSystem->getSystemConfig(self::SITE_ACCESS_EXCEPTION_IP);
1075 if (!empty($ip) && $ip = $request->trimServerValueOf('REMOTE_ADDR')){
1085 * @param RequestManager $request HTTPリクエスト処理クラス
1086 * @param int $type 画面タイプ(0=アクセス不可、1=ログイン画面、2=サイト非公開画面)
1089 function _showSystemPage($request, $type)
1092 $pageId = 'admin_index'; // 管理画面を表示
1093 $this->gEnv->setCurrentPageId($pageId); // ここでデフォルトページサブIDが再設定される
1094 $this->gEnv->setCurrentPageSubId($this->gEnv->getDefaultPageSubId());// デフォルトページサブIDをカレントにする
1097 // DBで設定されている値を取得し、なければ管理用デフォルトテンプレートを使用
1098 if ($this->gEnv->getIsMobileSite()){ // 携帯用サイトのアクセスの場合
1099 $curTemplateId = self::M_ADMIN_TEMPLATE; // 携帯管理画面用テンプレート
1100 } else { // 携帯以外のサイトへのアクセスの場合
1101 if ($type == 1){ // ログインはデフォルトの管理画面テンプレートに固定
1102 $curTemplateId = $this->gSystem->defaultAdminTemplateId();
1104 $curTemplateId = $this->gSystem->getSystemConfig(self::CONFIG_KEY_MSG_TEMPLATE);
1105 if (empty($curTemplateId)){
1106 $curTemplateId = self::SYSTEM_TEMPLATE;// システム画面用テンプレート
1109 $templateIndexFile = $this->gEnv->getTemplatesPath() . '/' . $curTemplateId . '/index.php';
1110 if (!file_exists($templateIndexFile)) $curTemplateId = self::SYSTEM_TEMPLATE;// システム画面用テンプレート
1116 $pageData = $this->_createPage($request, $curTemplateId);
1122 * @param RequestManager $request HTTPリクエスト処理クラス
1125 function _showPhpinfoPage($request)
1127 // ################### バッファリング開始 ######################
1128 // ob_end_flush()までの出力をバッファリングする
1133 // バッファ内容を送信(クライアントへの送信完了)
1137 * 以下、Joomla!v1.5テンプレート専用
1142 * @param string $pos ポジション
1143 * @return int ウィジェット数
1145 function countModules($pos)
1147 $count = $this->gPage->getWidgetsCount($pos);
1150 function getBuffer($type = null, $name = null, $attribs = array())
1152 if (isset($this->joomlaBufArray[$type])){
1153 return $this->joomlaBufArray[$type];
1158 function setBuffer($contents, $type, $name = null)
1160 $this->joomlaBufArray[$type] = $contents;
1166 * @return string 出力タイプ
1175 * @return array ヘッダ情報
1177 function getHeadData()
1180 /*$data['title'] = $this->title;
1181 $data['description']= $this->description;
1182 $data['link'] = $this->link;
1183 $data['metaTags'] = $this->_metaTags;
1184 $data['links'] = $this->_links;
1185 $data['styleSheets']= $this->_styleSheets;
1186 $data['style'] = $this->_style;
1187 $data['scripts'] = $this->_scripts;
1188 $data['script'] = $this->_script;
1189 $data['custom'] = $this->_custom;*/
1195 * @return string ベースパス
1202 * Adds a linked script to the page
1204 * @param string $url URL to the linked script
1205 * @param string $type Type of script. Defaults to 'text/javascript'
1208 function addScript($url, $type="text/javascript") {
1209 $this->_scripts[$url] = $type;
1212 * Adds a script to the page
1215 * @param string $content Script
1216 * @param string $type Scripting mime (defaults to 'text/javascript')
1219 function addScriptDeclaration($content, $type = 'text/javascript')
1221 if (!isset($this->_script[strtolower($type)])) {
1222 $this->_script[strtolower($type)] = $content;
1224 $this->_script[strtolower($type)] .= chr(13).$content;