9 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
11 * @package Magic3 Framework
12 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
13 * @copyright Copyright 2006-2018 Magic3 Project.
14 * @license http://www.gnu.org/copyleft/gpl.html GPL License
16 * @link http://www.magic3.org
18 require_once(M3_SYSTEM_INCLUDE_PATH . '/common/core.php');
19 require_once(M3_SYSTEM_INCLUDE_PATH . '/common/scriptLibInfo.php');
21 class PageManager extends Core
23 private $popupMsg; // ポップアップダイアログメッセージ
24 private $showPositionMode; // ポジション表示モード
25 private $showWidget; // ウィジェットの単体表示
26 private $systemHandleMode; // システム制御遷移モード(1=サイト非公開時)
27 private $isPageEditable; // フロント画面ページ編集可能モード
28 private $isTransparentMode; // 画面透過モード
29 private $isPersonalMode; // 機能アクセスパーソナルモード
30 private $isEditMode; // フロント画面編集モード
31 private $isLayout; // 画面レイアウト中かどうか
32 private $isPageTopUrl; // ページトップ(サブページ内のトップ位置)のURLかどうか
33 private $isContentDetailPage; // コンテンツ詳細画面のページかどうか
34 private $tmpData; // データ作成用
35 private $db; // DBオブジェクト
36 private $defaultScriptFiles; // デフォルトで読み込むスクリプトファイル
37 private $defaultCssFiles; // デフォルトで読み込むCSSファイル
38 private $defaultAdminScriptFiles; // デフォルトで読み込むスクリプトファイル(管理用)
39 private $defaultAdminCssFiles; // デフォルトで読み込むCSSファイル(管理用)
40 private $defaultAdminDirScriptFiles; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
41 private $defaultAdminDirCssFiles; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
42 private $headScriptFiles = array(); // ウィジェットからの追加で読み込むスクリプトファイル
43 private $headPreMobileScriptFiles = array();// ウィジェットからの追加で読み込むスクリプトファイル(jQueryMobile用挿入ファイル)
44 private $headCssFiles = array(); // ウィジェットからの追加で読み込むCSSファイル
45 private $headRssFiles = array(); // HTMLヘッダに出力するRSS配信情報
46 private $currentWidgetPosition; // 現在のウィジェットのポジション
47 private $currentWidgetIndex; // 現在のウィジェットのポジション番号
48 private $pageDefPosition; // 現在取得しているページ定義のポジション
49 private $pageDefRows; // ページ定義レコード
50 private $nonSharedWidgetCount = -1; // 非共通ウィジェットの数(-1=ページ作成でないとき)
51 private $replaceHeadDone; // ヘッダマクロ変換処理が完了したかどうか
52 private $useHelp = false; // 標準ヘルプ機能を使用するかどうか
53 private $hasScriptCache = false; // JavaScriptファイルをブラウザにキャッシュさせるかどうか
54 private $isAccessPointWithAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
55 private $lateLaunchWidgetList; // 遅延実行ウィジェットのリスト
56 private $latelaunchWidgetParam; // 遅延実行ウィジェットのパラメータ
57 private $defPositions = array(); // テンプレート上のポジション(画面定義データすべて)
58 private $viewPositions = array(); // テンプレート上のポジション(ウィジェット表示ありのみ)
59 private $viewPosId = array(); // テンプレート上のポジションのタグID
60 private $updateParentWindow; // 親ウィンドウを再描画するかどうか
61 private $updateDefSerial; // 更新する項目のページ定義シリアル番号
62 private $headDescription; // HTMLヘッダ「description」に出力する文字列
63 private $headKeywords; // HTMLヘッダ「keywords」に出力する文字列
64 private $headOthers; // HTMLヘッダに出力するタグ文字列
65 private $adminHeadOthers; // HTMLヘッダに出力するタグ文字列(管理画面用)
66 private $lastHeadTitle; // 最後にヘッダ部titleにセットした文字列
67 private $lastHeadDescription; // 最後にヘッダ部descriptionにセットした文字列
68 private $lastHeadKeywords; // 最後にヘッダ部keywordsにセットした文字列
69 private $headFirstTag; // HTMLヘッダに最初に出力するタグ文字列
70 private $headCss = array(); // HTMLヘッダにCSS出力する文字列
71 private $headScript = array(); // HTMLヘッダにJavascript出力する文字列
72 private $headPreMobileScript = array(); // HTMLヘッダにJavascript出力する文字列(jQueryMobile用挿入スクリプト)
73 private $headString = array(); // HTMLヘッダに出力する任意文字列
74 private $exportCss = array(); // 外部出力でCSS出力する文字列
75 private $lastHeadCss; // 最後に設定したHTMLヘッダにCSS出力する文字列
76 private $lastHeadScript; // 最後に設定したHTMLヘッダにJavascript出力する文字列
77 private $lastHeadString; // 最後に設定したHTMLヘッダに出力する任意文字列
78 private $headSubTitle = array(); // ヘッダタグサブタイトル
79 private $headSubTitleUrl = array(); // ヘッダサブタイトルのリンク先
80 private $headCanonicalUrl; // カノニカル属性URL
81 private $initScript = ''; // ウィンドウ初期化時に実行されるスクリプト
82 private $outputByHtml = true; // HTMLフォーマットで出力するかどうか
83 private $outputByStandardHead; // HTML文書の標準のヘッダタグを出力するかどうか
84 private $outputHead; // HTMLヘッダ出力を行ったかどうか
85 private $outputTheme; // jQueryUIテーマ出力を行ったかどうか
86 private $outputAjaxResponseBody; // AJAX用のレスポンスボディデータかどうか
87 private $isAbort; // ページ作成処理を中断するかどうか
88 private $isWidgetAbort; // 各ウィジェット処理を中断するかどうか
89 private $isRedirect; // リダイレクトするかどうか
90 private $isSystemPage; // システム制御ページを表示するかどうか
91 private $libFiles; // javascript追加用ライブラリ
92 private $pageDefRev = 234; // 画面定義のリビジョン番号
93 private $pageInfo; // すべてのページ情報
94 private $currentPageInfo; // 現在のページのページ情報
95 private $configWidgetInfo; // ウィジェット設定画面のウィジェットの情報
96 private $contentType = ''; // ページのコンテンツタイプ
97 private $mainContentTypeInfo; // フロント画面で使用する主要コンテンツタイプ
98 private $subContentTypeInfo; // フロント画面で使用する補助コンテンツタイプ
99 private $mainFeatureTypeInfo; // フロント画面で使用する主要機能タイプ
100 private $adminFeatureTypeInfo; // 管理画面専用で使用する主要機能タイプ
101 private $rssVersion; // RSSバージョン
102 private $rssChannel; // RSSチャンネルデータ
103 private $selectedJQueryFilename; // 使用対象のjQueryファイル
104 private $selectedJQueryUiFilename; // 使用対象のjQuery UIファイル
105 private $selectedJQueryMobileFilename; // 使用対象のjQueryMobileファイル
106 private $urlParamOrder; // URLパラメータの並び順
107 private $wysiwygEditor; // 管理画面用WYSIWYGエディター
108 private $optionTemplateId; // 追加設定するテンプレートID
109 private $optionSubTemplateId; // 追加設定するサブテンプレートID
110 private $isContentGooglemaps; // コンテンツにGoogleマップが含むかどうか
111 private $useGooglemaps; // Googleマップを使用するかどうか
112 private $useBootstrap; // Bootstrapを使用するかどうか
113 private $isHtml5; // HTML5で出力するかどうか
114 private $ckeditorCssFiles = array(); // CKEditor用のCSSファイル
115 private $ckeditorTemplateType; // CKEditor用のテンプレートタイプ
116 private $adminSubNavbarDef = array(); // 管理画面用のサブメニューバーの定義
117 private $adminBreadcrumbDef = array(); // 管理画面用パンくずリスト定義
118 private $adminBreadcrumbDefHelp = array(); // 管理画面用パンくずリストヘルプ定義
119 const CONFIG_KEY_HEAD_TITLE_FORMAT = 'head_title_format'; // ヘッダ作成用フォーマット
120 const ADMIN_WIDGET_ID = 'admin_main'; // 管理用ウィジェットのウィジェットID
121 //const CONTENT_TYPE_WIKI = 'wiki'; // ページのコンテンツタイプ(Wiki)
122 const WIDGET_ID_TAG_START = '{{WIDGETID:'; // 遅延実行用タグ
123 const WIDGET_ID_TAG_END = '}}'; // 遅延実行用タグ
124 const WIDGET_ID_TITLE_TAG_START = '{{WIDGETID_TITLE:'; // 遅延実行用タグ(タイトル埋め込み用)
125 const WIDGET_ID_TITLE_TAG_END = '}}'; // 遅延実行用タグ(タイトル埋め込み用)
126 const WIDGET_ID_SEPARATOR = ',';
127 const HEAD_TAGS = '{{HEAD_TAGS}}'; // HTMLヘッダ出力用タグ
128 const MENUBAR_TAGS = '{{MENUBAR_TAGS}}'; // メニューバー出力用タグ
129 const MENUBAR_SCRIPT_TAGS = '{{MENUBAR_SCRIPT_TAGS}}'; // メニューバー出力用スクリプトタグ
130 const WIDGET_ICON_IMG_SIZE = 32; // ウィジェットアイコンサイズ
131 const WIDGET_INVISIBLE_CLASS = 'm3invisible'; // 非表示ウィジェットクラス
132 const WIDGET_LOGIN_STATUS_CLASS = 'm3loginstatus'; // ログイン状態連動クラス
133 const WIDGET_OUTER_CLASS = 'm3_widget_outer'; // ウィジェット外枠クラス
134 const WIDGET_OUTER_CLASS_HEAD_POSITION = 'm3_pos_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
135 const WIDGET_OUTER_CLASS_WIDGET_TAG = 'm3_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
136 // const WIDGET_INNER_CLASS = 'm3_widget_inner'; // ウィジェットの内側クラス
137 const POSITION_TAG_HEAD = 'm3pos_'; // ポジションの識別用タグIDヘッダ
138 const WIDGET_TAG_HEAD = 'm3widget_'; // ウィジェットの識別用タグIDヘッダ
139 // const WIDGET_TAG_HEAD_SHORT = 'm3_'; // ウィジェットの識別用タグIDヘッダ
140 const WIDGET_TYPE_TAG_HEAD = 'm3widgettype_'; // ウィジェット種別の識別用タグIDヘッダ
141 const WIDTET_CLASS_NAME = 'm3widget'; // ウィジェットオブジェクトのタグクラス名
142 const WIDTET_CLASS_TYPE_0 = 'm3widget_type0'; // ウィジェットオブジェクトのタグクラス(グローバル属性でない)
143 const WIDTET_CLASS_TYPE_1 = 'm3widget_type1'; // ウィジェットオブジェクトのタグクラス(グローバル属性)
144 const POSITION_CLASS_NAME = 'm3position'; // ポジションオブジェクトのタグクラス名
145 const JOOMLA10_DEFAULT_WIDGET_MENU_PARAM = 'class="moduletable"'; // Joomla!1.0用デフォルトメニューパラメータ値
146 const ADMIN_TEMPLATE = '_admin'; // PC管理用テンプレートID
147 const M_ADMIN_TEMPLATE = 'm/_admin'; // 携帯用管理画面テンプレートID
148 const SCRIPT_LIB_SEPARATOR = ';'; // JavaScriptライブラリ読み込み設定のライブラリの区切り
149 const PAGE_ID_SEPARATOR = ','; // ページIDとページサブID連結用
150 const DEFAULT_ADMIN_FAVICON_FILE = '/images/system/favicon.ico'; // デフォルトの管理画面用faviconファイル
151 const DEFAULT_FAVICON_FILE = '/favicon.ico'; // デフォルトのfaviconファイル
152 // const DEFAULT_SITE_NAME = 'サイト名未設定'; // 管理画面用のデフォルトサイト名
153 const DEFAULT_ADMIN_TITLE = '管理画面'; // デフォルトの管理画面名
154 const WIDGET_TITLE_START = '['; // ウィジェットのタイトルの括弧
155 const WIDGET_TITLE_END = ']'; // ウィジェットのタイトルの括弧
156 const DEFAULT_RSS_VERSION = '1.0'; // デフォルトのRSSのバージョン
157 const CF_ACCESS_IN_INTRANET = 'access_in_intranet'; // イントラネット運用かどうか
158 const CF_USE_LATEST_SCRIPT_LIB = 'dev_use_latest_script_lib'; // 最新のJavaScriptライブラリを使用するかどうか
159 const CF_GOOGLE_MAPS_KEY = 'google_maps_key'; // Googleマップ利用キー
160 const CF_CONFIG_WINDOW_OPEN_TYPE = 'config_window_open_type'; // ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
161 const CF_JQUERY_VERSION = 'jquery_version'; // jQueryバージョン
162 const CF_EXTERNAL_JQUERY = 'external_jquery'; // システム外部のjQueryを使用するかどうか
163 const CF_WYSIWYG_EDITOR = 'wysiwyg_editor'; // 管理画面用WYSIWYGエディター
164 const CF_ADMIN_JQUERY_VERSION = 'admin_jquery_version'; // 管理画面用jQueryバージョン
165 const CF_USE_JQUERY = 'use_jquery'; // jQueryを常に使用するかどうか
166 const CF_SMARTPHONE_USE_JQUERY_MOBILE = 'smartphone_use_jquery_mobile'; // スマートフォン画面でjQuery Mobileを使用
167 const SD_HEAD_OTHERS = 'head_others'; // ヘッダその他タグ
168 const DEFAULT_THEME_DIR = '/ui/themes/'; // jQueryUIテーマ格納ディレクトリ
169 const THEME_CSS_FILE = 'jquery-ui.custom.css'; // テーマファイル
170 const CONFIG_ICON_FILE = '/images/system/config.png'; // ウィジェット定義画面アイコン
171 const ADJUST_ICON_FILE = '/images/system/adjust_widget.png'; // 位置調整アイコン
172 const SHARED_ICON_FILE = '/images/system/shared.png'; // グローバル属性
173 const DELETE_ICON_FILE = '/images/system/delete.png'; // ウィジェット削除
174 const CONFIG_ICON32_FILE = '/images/system/config32.png'; // ウィジェット定義画面アイコン(ツールチップ用)
175 const ADJUST_ICON32_FILE = '/images/system/adjust_widget32.png'; // 位置調整アイコン(ツールチップ用)
176 const CLOSE_BOX_ICON32_FILE = '/images/system/close_box.png'; // ウィンドウ閉じるアイコン(ツールチップ用)
177 const NOTICE_ICON_FILE = '/images/system/notice16.png'; // ウィジェット配置注意アイコン
178 const ALERT_ICON_FILE = '/images/system/alert16.png'; // ウィジェット配置警告アイコン
179 // const ADMIN_ICON_FILE = '/images/system/admin64.png'; // パネルメニュー管理画面遷移用アイコン
180 // const LOGOUT_ICON_FILE = '/images/system/logout64.png'; // パネルメニューログアウト用アイコン
181 // const EDIT_PAGE_ICON_FILE = '/images/system/create_page64.png'; // パネルメニュー編集用アイコン
182 const ADMIN_ICON_FILE = '/images/system/home32.png'; // パネルメニュー管理画面遷移用アイコン
183 const LOGOUT_ICON_FILE = '/images/system/logout32.png'; // パネルメニューログアウト用アイコン
184 const EDIT_PAGE_ICON_FILE = '/images/system/create_page32.png'; // パネルメニュー編集用アイコン
185 // const EDIT_END_ICON_FILE = '/images/system/close32.png'; // パネルメニュー編集終了用アイコン
186 const EDIT_END_ICON_FILE = '/images/system/back32.png'; // パネルメニュー編集終了用アイコン
187 const CLOSE_ICON_FILE = '/images/system/close32.png'; // ウィンドウ閉じるアイコン
188 const PREV_ICON_FILE = '/images/system/prev48.png'; // ウィンドウ「前へ」アイコン
189 const NEXT_ICON_FILE = '/images/system/next48.png'; // ウィンドウ「次へ」アイコン
190 const DEFAULT_READMORE_TITLE = 'もっと読む'; // もっと読むボタンのデフォルトタイトル
191 const POS_HEAD_NAV_MENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // 特殊ポジションブロック(ナビゲーションメニュー型)
192 const POS_HEAD_MAIN = '<i class="glyphicon glyphicon-stop" rel="m3help" title="メイン型" data-placement="auto"></i> '; // 特殊ポジションブロック(メイン型)
193 const WIDGET_MARK_MAIN = '<i class="glyphicon glyphicon-stop" rel="m3help" title="メイン型" data-placement="auto"></i> '; // ウィジェットの機能マーク(メイン型ウィジェット)
194 const WIDGET_MARK_NAVMENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // ウィジェットの機能マーク(ナビゲーションメニュー)
195 const WIDGET_FUNCTION_MARK_BOOTSTRAP = ' <span class="label label-warning" rel="m3help" title="Bootstrap型テンプレート対応" data-placement="auto">B</span>'; // ウィジェット機能マーク(Boostrap型テンプレート
196 const WIDGET_FUNCTION_MARK_WORDPRESS = ' <span class="label label-warning" rel="m3help" title="WordPress型テンプレート対応" data-placement="auto">W</span>'; // ウィジェット機能マーク(WordPress型テンプレート
197 const WIDGET_STYLE_NAVMENU = '_navmenu'; // ウィジェットの表示スタイル(ナビゲーションメニュー)
198 const WIDGET_STYLE_WORDPRESS = '_wordpress'; // ウィジェットの表示スタイル(WordPressテンプレート用出力)
199 const WIDGET_STYLE_WORDPRESS_NOTITLE = '_wordpress_notitle'; // ウィジェットの表示スタイル(WordPressテンプレート(タイトルなし)用出力)
202 const CONTENT_OBJ_ID = 'contentlib'; // 汎用コンテンツオブジェクトID
203 const BLOG_OBJ_ID = 'bloglib'; // ブログオブジェクトID
204 const LINKINFO_OBJ_ID = 'linkinfo'; // リンク情報オブジェクトID
207 const IWIDTET_CMD_CONTENT = 'content'; // コンテンツ取得
208 const IWIDTET_CMD_INIT = 'init'; // 初期化
209 const IWIDTET_CMD_UPDATE = 'update'; // 更新
210 const IWIDTET_CMD_CALC = 'calc'; // 計算
213 const M3_ADMIN_SCRIPT_FILENAME = 'm3admin2.0.2.js'; // 管理機能用スクリプト(FCKEditor2.6.6、CKEditor4.0.1対応)
214 const M3_ADMIN_WIDGET_SCRIPT_FILENAME = 'm3admin_widget2.0.10.js'; // 管理機能(ウィジェット操作)用スクリプト(Magic3 v1.15.0以降)
215 const M3_ADMIN_WIDGET_CSS_FILE = '/m3/widget.css'; // 管理機能(ウィジェット操作)用CSSファイル
216 const M3_STD_SCRIPT_FILENAME = 'm3std1.5.2.js'; // 一般、管理機能共通スクリプト
217 const M3_OPTION_SCRIPT_FILENAME = 'm3opt1.2.1.js'; // AJAXを含んだオプションライブラリファイル(jQuery必須)
218 const M3_ADMIN_CSS_FILE = 'm3/admin.css'; // 管理機能用のCSS
219 const M3_EDIT_CSS_FILE = 'm3/edit.css'; // フロント画面編集用のCSS
220 const M3_DEFAULT_CSS_FILE = 'm3/default.css'; // フロント画面共通のデフォルトCSS
221 const M3_CKEDITOR_CSS_FILE = 'm3/ckeditor.css'; // CKEditorの編集エリア用CSS
224 const USE_BOOTSTRAP_ADMIN = false; // 管理画面でBootstrapを使用するかどうか(デフォルト値)
225 const BOOTSTRAP_BUTTON_CLASS = 'btn btn-default';
228 const FILEBROWSER_WIDTH_RATIO = '0.8'; // ファイルブラウザ幅比率
229 const FILEBROWSER_HEIGHT_RATIO = '0.8'; // ファイルブラウザ高さ比率
234 function __construct()
236 global $gInstanceManager;
238 global $gSystemManager;
239 global $gRequestManager;
242 parent::__construct();
244 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
245 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
248 $this->db = $gInstanceManager->getSytemDbObject();
251 $value = $gSystemManager->getSystemConfig(self::CF_ACCESS_IN_INTRANET); // イントラネット運用かどうか
252 if (empty($value)){ // インターネット運用
253 $this->useGooglemaps = true; // Googleマップを使用するかどうか
255 $this->useHelp = true; // ヘルプ機能
257 // デフォルトのWYSIWYGエディターを取得
258 $this->wysiwygEditor = $gSystemManager->getSystemConfig(self::CF_WYSIWYG_EDITOR); // 管理画面用WYSIWYGエディター
260 // ##### Javascriptライブラリのバージョン設定 #####
262 // アクセスする画面に応じてjQueryのバージョンを設定
263 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
264 $value = $gSystemManager->getSystemConfig(self::CF_ADMIN_JQUERY_VERSION);// 管理画面用jQueryバージョン
266 // 管理画面にBOOTSTRAPを使用するかどうか(初期値)
267 $this->useBootstrap = self::USE_BOOTSTRAP_ADMIN;
270 // 小画面デバイス最適化の場合は最新バージョンを使用
271 if ($gEnvManager->isSmallDeviceAdmin()) ScriptLibInfo::setCkeditorVer(1/*最新*/);
273 $value = $gSystemManager->getSystemConfig(self::CF_JQUERY_VERSION);// jQueryバージョン
275 ScriptLibInfo::setJQueryVer($value);
277 // WYSISIGエディターのタイプを設定。ScriptLibInfo::getLib()を実行する前に設定。
278 ScriptLibInfo::setWysiwygEditorType($this->wysiwygEditor);
281 $this->libFiles = ScriptLibInfo::getLib(); // ライブラリ取得
284 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(0); // 使用対象のjQueryファイル
285 $this->selectedJQueryUiFilename = ScriptLibInfo::getJQueryFilename(1); // 使用対象のjQuery UIファイル
287 // ##### フロント画面用のデフォルトのJavascript、CSSを取得 #####
288 $this->defaultScriptFiles = array(
289 $this->selectedJQueryFilename, // jQuery
290 self::M3_STD_SCRIPT_FILENAME
292 $this->defaultCssFiles = array(
293 self::M3_DEFAULT_CSS_FILE // フロント画面共通のデフォルトCSS
296 // ##### 管理機能用のデフォルトのJavascript、CSSを取得 #####
297 if (defined('M3_STATE_IN_INSTALL')){ // インストーラの場合のスクリプト
298 $this->defaultAdminScriptFiles = array(
299 $this->selectedJQueryFilename, // jQuery
300 // self::M3_STD_SCRIPT_FILENAME,
301 self::M3_ADMIN_SCRIPT_FILENAME
303 $this->defaultAdminCssFiles = array(); // 管理機能用のCSS
305 $this->defaultAdminScriptFiles = array(
306 $this->selectedJQueryFilename, // jQuery
307 $this->selectedJQueryUiFilename, // jQuery UI Core
308 ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME, // jQuery Contextmenu Lib
309 self::M3_STD_SCRIPT_FILENAME,
310 self::M3_ADMIN_SCRIPT_FILENAME,
311 self::M3_OPTION_SCRIPT_FILENAME
313 $this->defaultAdminCssFiles = array(
314 self::M3_ADMIN_CSS_FILE // 管理機能用のCSS
318 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用
319 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用
320 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_NUMERIC); // 入力制限プラグイン
321 // $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
324 // 管理権限なしで管理ディレクトリアクセスで読み込むスクリプトファイル
325 $this->defaultAdminDirScriptFiles = array($this->selectedJQueryFilename); // jQuery
328 $this->lateLaunchWidgetList = array();
329 $this->latelaunchWidgetParam = array();
332 if ($gEnvManager->canUseDb()){
333 $value = $this->gSystem->getSystemConfig('script_cache_in_browser'); // ブラウザにJavaScriptファイルのキャッシュを保持するかどうか
334 if ($value != '') $this->hasScriptCache = $value;
337 $this->rssVersion = self::DEFAULT_RSS_VERSION; // RSSバージョン
339 // フロント画面で使用する主要コンテンツタイプ
340 $this->mainContentTypeInfo = array(
341 array( 'name' => '会員情報', 'value' => M3_VIEW_TYPE_MEMBER),
342 array( 'name' => '汎用コンテンツ', 'value' => M3_VIEW_TYPE_CONTENT),
343 array( 'name' => '製品', 'value' => M3_VIEW_TYPE_PRODUCT),
344 array( 'name' => 'BBS', 'value' => M3_VIEW_TYPE_BBS),
345 array( 'name' => 'ブログ', 'value' => M3_VIEW_TYPE_BLOG),
346 array( 'name' => 'Wiki', 'value' => M3_VIEW_TYPE_WIKI),
347 array( 'name' => 'ユーザ作成コンテンツ', 'value' => M3_VIEW_TYPE_USER),
348 array( 'name' => 'イベント情報', 'value' => M3_VIEW_TYPE_EVENT),
349 array( 'name' => 'フォトギャラリー', 'value' => M3_VIEW_TYPE_PHOTO)
351 // フロント画面で使用する補助コンテンツタイプ(ページ属性に対応しない)
352 $this->subContentTypeInfo = array( array( 'name' => '新着情報', 'value' => M3_VIEW_TYPE_NEWS),
353 array( 'name' => 'コメント', 'value' => M3_VIEW_TYPE_COMMENT),
354 array( 'name' => 'イベント予約', 'value' => M3_VIEW_TYPE_EVENTENTRY),
355 array( 'name' => 'バナー', 'value' => M3_VIEW_TYPE_BANNER)
357 // フロント画面で使用する主要機能タイプ(「ダッシュボード」は含まない)
358 $this->mainFeatureTypeInfo = array( array( 'name' => '検索', 'value' => M3_VIEW_TYPE_SEARCH),
359 array( 'name' => 'Eコマース', 'value' => M3_VIEW_TYPE_COMMERCE),
360 array( 'name' => 'カレンダー', 'value' => M3_VIEW_TYPE_CALENDAR)
363 $this->adminFeatureTypeInfo = array( array( 'name' => 'ダッシュボード', 'value' => M3_VIEW_TYPE_DASHBOARD)
367 $this->urlParamOrder = array(
369 M3_REQUEST_PARAM_CONTENT_ID => -20, // 汎用コンテンツID
370 M3_REQUEST_PARAM_CONTENT_ID_SHORT => -19, // 汎用コンテンツID(略式)
371 M3_REQUEST_PARAM_PRODUCT_ID => -18, // 製品ID
372 M3_REQUEST_PARAM_PRODUCT_ID_SHORT => -17, // 製品ID(略式)
373 M3_REQUEST_PARAM_BLOG_ID => -16, // ブログID
374 M3_REQUEST_PARAM_BLOG_ID_SHORT => -15, // ブログID(略式)
375 M3_REQUEST_PARAM_BLOG_ENTRY_ID => -14, // ブログ記事ID
376 M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT => -13, // ブログ記事ID(略式)
377 M3_REQUEST_PARAM_BBS_ID => -12, // 掲示板投稿記事ID
378 M3_REQUEST_PARAM_BBS_ID_SHORT => -11, // 掲示板投稿記事ID(略式)
379 M3_REQUEST_PARAM_BBS_THREAD_ID => -10, // 掲示板投稿スレッドID
380 M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT => -9, // 掲示板投稿スレッドID(略式)
381 M3_REQUEST_PARAM_USER_ID => -8, // ユーザ作成コンテンツID
382 M3_REQUEST_PARAM_USER_ID_SHORT => -7, // ユーザ作成コンテンツID(略式)
383 M3_REQUEST_PARAM_ROOM_ID => -6, // ユーザ作成コンテンツ区画ID
384 M3_REQUEST_PARAM_ROOM_ID_SHORT => -5, // ユーザ作成コンテンツ区画ID(略式)
385 M3_REQUEST_PARAM_EVENT_ID => -4, // イベントID
386 M3_REQUEST_PARAM_EVENT_ID_SHORT => -3, // イベントID(略式)
387 M3_REQUEST_PARAM_PHOTO_ID => -2, // 画像ID
388 M3_REQUEST_PARAM_PHOTO_ID_SHORT => -1, // 画像ID(略式)
390 M3_REQUEST_PARAM_PAGE_SUB_ID => 1, // ページサブID
391 M3_REQUEST_PARAM_PAGE_CONTENT_ID => 2, // ページコンテンツID
392 M3_REQUEST_PARAM_WIDGET_ID => 3, // ウィジェットID
393 M3_REQUEST_PARAM_TEMPLATE_ID => 4, // テンプレートID
394 M3_REQUEST_PARAM_URL => 5, // リンク先等のURL
395 M3_REQUEST_PARAM_STAMP => 6, // 公開発行ID
396 M3_REQUEST_PARAM_OPTION => 7, // 通信オプション
397 M3_REQUEST_PARAM_OPERATION_COMMAND => 8, // 実行処理
398 M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND => 9, // Wikiコマンド実行
399 M3_REQUEST_PARAM_OPERATION_TASK => 10, // ウィジェット間共通処理
400 M3_REQUEST_PARAM_OPERATION_ACT => 11, // クライアントからの実行処理
401 M3_REQUEST_PARAM_OPERATION_LANG => 12, // 言語指定表示
402 M3_REQUEST_PARAM_SERIAL_NO => 13, // シリアル番号
403 M3_REQUEST_PARAM_PAGE_NO => 14, // ページ番号
404 M3_REQUEST_PARAM_LIST_NO => 15, // 一覧番号
405 M3_REQUEST_PARAM_ITEM_NO => 16, // 項目番号
406 M3_REQUEST_PARAM_OPERATION_TODO => 17, // 指定ウィジェットに実行させる処理
407 M3_REQUEST_PARAM_FROM => 18, // メッセージの送信元ウィジェットID
408 M3_REQUEST_PARAM_VIEW_STYLE => 19, // 表示スタイル
409 M3_REQUEST_PARAM_FORWARD => 20, // 画面遷移用パラメータ
410 M3_REQUEST_PARAM_OPEN_BY => 22, // ウィンドウの開き方
411 M3_REQUEST_PARAM_SHOW_HEADER => 23, // ヘッダ部表示制御
412 M3_REQUEST_PARAM_SHOW_FOOTER => 24, // フッタ部表示制御
413 M3_REQUEST_PARAM_SHOW_MENU => 25, // メニュー部表示制御
414 M3_REQUEST_PARAM_KEYWORD => 26, // 検索キーワード
415 M3_REQUEST_PARAM_HISTORY => 27, // 履歴インデックスNo
416 M3_REQUEST_PARAM_DEF_PAGE_ID => 28, // ページID(画面編集用)
417 M3_REQUEST_PARAM_DEF_PAGE_SUB_ID => 29, // ページサブID(画面編集用)
418 M3_REQUEST_PARAM_PAGE_DEF_SERIAL => 30, // ページ定義のレコードシリアル番号(設定画面起動時)
419 M3_REQUEST_PARAM_PAGE_DEF_CONFIG_ID => 31, // ページ定義のウィジェット定義ID(設定画面起動時)
420 M3_REQUEST_PARAM_BACK_URL => 32, // 戻り先URL
421 M3_REQUEST_PARAM_BACKUP_URL => 33, // URL退避用(画面編集時)
422 M3_REQUEST_PARAM_SERVER => 34, // サーバ指定
423 M3_REQUEST_PARAM_CATEGORY_ID => 35, // カテゴリID(共通)
424 M3_REQUEST_PARAM_WIDTH => 36, // 幅
425 M3_REQUEST_PARAM_HEIGHT => 37); // 高さ
430 * @return array コンテンツタイプ
432 public function _getAllContentType()
434 global $M3_ALL_CONTENT_TYPE;
436 /* $contentType = array( M3_VIEW_TYPE_CONTENT, // 汎用コンテンツ
437 M3_VIEW_TYPE_PRODUCT, // 製品
438 M3_VIEW_TYPE_BBS, // BBS
439 M3_VIEW_TYPE_BLOG, // ブログ
440 M3_VIEW_TYPE_WIKI, // wiki
441 M3_VIEW_TYPE_USER, // ユーザ作成コンテンツ
442 M3_VIEW_TYPE_EVENT, // イベント
443 M3_VIEW_TYPE_PHOTO); // フォトギャラリー
444 return $contentType;*/
445 return $M3_ALL_CONTENT_TYPE;
450 * @return array 機能タイプ
452 public function _getAllFeatureType()
454 global $M3_ALL_FEATURE_TYPE;
456 /* $featureType = array( M3_VIEW_TYPE_DASHBOARD, // ダッシュボード
457 M3_VIEW_TYPE_SEARCH, // 検索結果
458 M3_VIEW_TYPE_COMMERCE); // Eコマース
459 return $featureType;*/
460 return $M3_ALL_FEATURE_TYPE;
467 function setNoTimeout()
469 if (ini_get('safe_mode') == '0') set_time_limit(0);
474 * @param string $msg メッセージ
476 function setPopupMsg($msg)
478 $this->popupMsg = $msg;
481 * HTMLヘッダ「description」に出力する文字列を設定
483 * @param string $str 出力文字列
485 function setHeadDescription($str)
487 if (is_string($str) && !empty($str)){
488 $this->headDescription = $str;
489 $this->lastHeadDescription = $str; // 最後に設定した値を退避
493 * HTMLヘッダ「description」に出力する文字列を取得
495 * @return string $str 出力文字列
497 function getHeadDescription()
499 return $this->headDescription;
502 * HTMLヘッダ「keywords」に出力する文字列を設定
504 * @param string $str 出力文字列
506 function setHeadKeywords($str)
508 if (is_string($str) && !empty($str)){
509 $this->headKeywords = $str;
510 $this->lastHeadKeywords = $str; // 最後に設定した値を退避
514 * HTMLヘッダ「keywords」に出力する文字列を取得
516 * @return string $str 出力文字列
518 function getHeadKeywords()
520 return $this->headKeywords;
523 * HTMLヘッダに出力するタグ文字列を設定
525 * @param string $str 出力文字列
528 function setHeadOthers($str)
530 if (is_string($str) && !empty($str)){
531 $this->headOthers = $str;
535 * HTMLヘッダに出力するタグ文字列を追加
537 * @param string $str 出力文字列
540 function addHeadOthers($str)
542 if (is_string($str) && !empty($str)){
544 $pos = strpos($this->headOthers, $str);
545 if ($pos === false) $this->headOthers .= $str;
549 * HTMLヘッダに出力するタグ文字列を追加(管理画面用)
551 * @param string $str 出力文字列
554 function addAdminHeadOthers($str)
556 if (is_string($str) && !empty($str)){
558 $pos = strpos($this->adminHeadOthers, $str);
559 if ($pos === false) $this->adminHeadOthers .= $str;
563 * HTMLヘッダ「title」のサブタイトル出力する文字列を設定
565 * @param string $str 出力文字列
566 * @param string $url リンク先
567 * @param bool $isDefault デフォルト値かどうか
570 function setHeadSubTitle($str = '', $url = '', $isDefault = false)
572 // ##### ページのサブタイトルはデフォルトでページのMETAタイトルを使用し、メインウィジェット側で上書きする #####
574 static $isUpdated = false; // デフォルト値が更新されているかどうか
576 if (!is_string($str) || empty($str)) return;
580 $this->headSubTitle = array();
581 $this->headSubTitleUrl = array();
582 $this->lastHeadTitle = '';
584 } else { // デフォルトでない場合はデータを追加
585 if (!$isUpdated){ // デフォルト値が更新されていない場合は以前のデータを削除
586 $this->headSubTitle = array();
587 $this->headSubTitleUrl = array();
588 $this->lastHeadTitle = '';
589 $isUpdated = true; // デフォルト値は更新された
593 $this->headSubTitle[] = $str;
594 $this->headSubTitleUrl[] = $url;
595 $this->lastHeadTitle = $str; // 最後に設定した値を退避
598 * HTMLヘッダ「title」のサブタイトル出力する文字列を取得
600 * @return $array サブタイトルに設定されている文字列を連想配列(title=タイトル、url=リンク先URL)の配列で返す
602 function getHeadSubTitle()
604 $titleArray = array();
605 $titleCount = count($this->headSubTitle);
606 for ($i = 0; $i < $titleCount; $i++){
607 $line = array('title' => $this->headSubTitle[$i], 'url' => $this->headSubTitleUrl[$i]);
608 $titleArray[] = $line;
613 * HTMLヘッダに出力するCSSの文字列を設定
615 * @param string $css 追加するCSS内容
618 function addHeadCss($css)
620 $destCss = trim($css);
621 if (!empty($destCss)){
622 //if (!in_array($css, $this->headCss)) $this->headCss[] = $css;
623 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css; // CSS動的外部出力
625 $this->lastHeadCss = $css; // 最後に設定したHTMLヘッダにCSS出力する文字列
629 * 外部出力で出力するCSSの文字列を設定(ウィジェット共通設定からの設定値)
631 * @param string $css 追加するCSS内容
634 function addExportCss($css)
636 $destCss = trim($css);
637 if (!empty($destCss)){
638 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css;
642 * HTMLヘッダに出力するJavascriptの文字列を設定
644 * @param string $script 追加するJavascript内容
647 function addHeadScript($script)
649 $destScript = trim($script);
650 if (!empty($destScript)){
651 if (!in_array($script, $this->headScript)) $this->headScript[] = $script;
653 $this->lastHeadScript = $script; // 最後に設定したHTMLヘッダにJavascript出力する文字列
657 * HTMLヘッダに出力するJavascriptの文字列(jQueryMobile用挿入スクリプト)を設定
659 * @param string $script 追加するJavascript内容
662 function addHeadPreMobileScript($script)
664 $destScript = trim($script);
665 if (!empty($destScript)){
666 if (!in_array($script, $this->headPreMobileScript)) $this->headPreMobileScript[] = $script;
670 * HTMLヘッダに出力する任意文字列を設定
672 * @param string $str 追加する任意文字列
675 function addHeadString($str)
677 $destScript = trim($str);
678 if (!empty($destScript)){
679 if (!in_array($str, $this->headString)) $this->headString[] = $str;
681 $this->lastHeadString = $str; // 最後に設定したHTMLヘッダに出力する任意文字列
685 * HTMLヘッダに出力するCSSファイルを追加
687 * @param string,array $cssFile CSSファイルURLパス
690 function addHeadCssFile($cssFile)
692 if (is_array($cssFile)){ // 配列の場合
693 for ($i = 0; $i < count($cssFile); $i++){
694 $destCss = trim($cssFile[$i]);
695 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
698 $destCss = trim($cssFile);
699 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
703 * HTMLヘッダに出力するJavascriptライブラリを追加
705 * @param string,array $scriptLib JavascriptライブラリID
708 function addHeadAdminScriptLib($scriptLib)
710 if (is_array($scriptLib)){ // 配列の場合
711 for ($i = 0; $i < count($scriptLib); $i++){
712 $destScript = trim($scriptLib[$i]);
713 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
716 $destScript = trim($scriptLib);
717 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
721 * HTMLヘッダに出力するJavascriptライブラリを追加
723 * @param string,array $scriptLib JavascriptライブラリID
726 function addHeadScriptLib($scriptLib)
728 if (is_array($scriptLib)){ // 配列の場合
729 for ($i = 0; $i < count($scriptLib); $i++){
730 $destScript = trim($scriptLib[$i]);
731 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
734 $destScript = trim($scriptLib);
735 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
739 * HTMLヘッダに出力するJavascriptファイルを追加
741 * @param string,array $scriptFile JavascriptファイルURLパス
744 function addHeadScriptFile($scriptFile)
746 if (is_array($scriptFile)){ // 配列の場合
747 for ($i = 0; $i < count($scriptFile); $i++){
748 $destScript = trim($scriptFile[$i]);
749 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
752 $destScript = trim($scriptFile);
753 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
757 * HTMLヘッダに出力するJavascriptファイル(jQueryMobile用挿入ファイル)を追加
759 * @param string,array $scriptFile JavascriptファイルURLパス
762 function addHeadPreMobileScriptFile($scriptFile)
764 if (is_array($scriptFile)){ // 配列の場合
765 for ($i = 0; $i < count($scriptFile); $i++){
766 $destScript = trim($scriptFile[$i]);
767 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
770 $destScript = trim($scriptFile);
771 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
775 * HTMLヘッダに出力するRSSファイルを追加
777 * @param array $rssFile タイトル(title)、配信用URL(href)の連想配列。複数の場合は連想配列の配列。
780 function addHeadRssFile($rssFile)
783 if (!is_array($rssFile)) return;
786 if (is_array($line)){ // 複数追加の場合
787 for ($i = 0; $i < count($line); $i++){
789 $url = trim($line[$i]['href']);
791 for ($j = 0; $j < count($this->headRssFiles); $j++){
792 $storedUrl = $this->headRssFiles[$j]['href'];
793 if ($url == $storedUrl) break;
795 if ($j == count($this->headRssFiles)){ // 見つからないときは追加
796 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
797 'title' => $line[$i]['title']); // タイトル
803 $url = trim($rssFile['href']);
805 for ($i = 0; $i < count($this->headRssFiles); $i++){
806 $storedUrl = $this->headRssFiles[$i]['href'];
807 if ($url == $storedUrl) break;
809 if ($i == count($this->headRssFiles)){ // 見つからないときは追加
810 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
811 'title' => $rssFile['title']); // タイトル
817 * HTMLヘッダに最初に出力するタグ文字列を設定
819 * @param string $str 追加するタグ文字列
822 function setHeadFirstTag($str)
824 if (!empty($str)) $this->headFirstTag = $str;
827 * ヘッダ部に出力するカノニカル属性URLを設定
829 * @param string $url URL
832 function setCanonicalUrl($url)
834 if (!empty($url)) $this->headCanonicalUrl = $url; // カノニカル属性URL
837 * RSSチャンネル部に出力するデータを設定
839 * @param array $rssData RSSチャンネル部データ
842 function setRssChannel($rssData)
844 if (!empty($rssData)) $this->rssChannel = $rssData; // RSSチャンネルデータ
849 * @param int $mode 0=ポジション表示しない(通常画面)、1=ポジション表示、2=ウィジェット込みポジション表示
851 function showPosition($mode)
853 $this->showPositionMode = $mode;
858 * @return bool true=レイアウト中、false=レイアウト中でない
862 return $this->isLayout; // 画面レイアウト中かどうか
867 function showWidget()
869 $this->showWidget = true;
874 * @param bool true=単体表示、false=単体表示でない
876 function getShowWidget()
878 return $this->showWidget;
883 * @param int $mode 0=設定なし、1=ログイン画面、10=サイト非公開、11=アクセス不可、12=存在しないページ
885 function setSystemHandleMode($mode)
887 $this->systemHandleMode = $mode;
892 function getSystemHandleMode()
894 return $this->systemHandleMode;
901 function setEditMode()
903 $this->isEditMode = true;
908 * @return bool true=編集モードオン、false=編集モードオフ
910 function isEditMode()
912 return $this->isEditMode;
919 function setPersonalMode()
921 $this->isPersonalMode = true;
926 * @return bool true=パーソナルモードオン、false=パーソナルモードオフ
928 function isPersonalMode()
930 return $this->isPersonalMode;
933 * 出力フォーマットがHTMLであるかを設定
935 * @param bool $isHtml HTMLフォーマットかどうか
938 function setOutputByHtml($isHtml)
940 $this->outputByHtml = $isHtml;
944 * AJAX用のレスポンスボディデータかどうかを設定
946 * @param bool $isResponseBody レスポンスボディデータかどうか
949 function setOutputAjaxResponseBody($isResponseBody)
951 $this->outputAjaxResponseBody = $isResponseBody;
956 * @param bool $status ヘルプ機能を使用するかどうか
959 function setUseHelp($status)
961 $this->useHelp = $status;
966 * @return bool ヘルプ機能を使用するかどうか
968 function getUseHelp()
970 return $this->useHelp;
973 * 表示するコンテンツにGoogleマップが含まれているかを設定
975 * @param bool $status Googleマップを含むかどうか
978 function setIsContentGooglemaps($status)
980 $this->isContentGooglemaps = $status; // コンテンツにGoogleマップが含むかどうか
983 * 表示するコンテンツにGoogleマップが含まれているかを取得
985 * @return bool ヘルプ機能を使用するかどうか
987 function isContentGooglemaps()
989 return $this->isContentGooglemaps;
992 * JavaScriptのブラウザキャッシュの使用可否を設定
994 * @param bool $status ブラウザキャッシュを使用するかどうか
997 function setHasScriptCache($status)
999 $this->hasScriptCache = $status;
1006 function useBootstrap()
1008 $this->useBootstrap = true; // Bootstrapを使用するかどうか
1011 * Bootstrapを強制的に未使用に設定
1015 function cancelBootstrap()
1017 $this->useBootstrap = false; // Bootstrapを使用するかどうか
1022 * @return bool true=使用、false=使用しない
1024 function getUseBootstrap()
1026 return $this->useBootstrap; // Bootstrapを使用するかどうか
1035 $this->isHtml5 = true; // HTML5で出力するかどうか
1038 * ページ作成処理を中断するかどうかを取得
1040 * @return bool true=中断、false=継続
1042 function isPageAbort()
1044 return $this->isAbort;
1047 * 現在のウィジェットのポジションを取得
1049 * @param string $pos ポジション
1050 * @param int $index インデックス番号
1053 function getCurrentWidgetPosition(&$pos, &$index)
1055 $pos = $this->currentWidgetPosition; // 現在のウィジェットのポジション
1056 $index = $this->currentWidgetIndex; // 現在のウィジェットのポジション番号
1061 * @param int $defSerial ページ定義シリアル番号
1064 function updateParentWindow($defSerial = 0)
1066 $this->updateParentWindow = true;
1067 $this->updateDefSerial = $defSerial; // 更新する項目のページ定義シリアル番号
1072 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1075 function addCssFile($path)
1077 $destPath = trim($path, '/');
1078 if (!in_array($destPath, $this->defaultCssFiles)) $this->defaultCssFiles[] = $destPath;
1083 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1086 function addAdminCssFile($path)
1088 $destPath = trim($path, '/');
1089 if (!in_array($destPath, $this->defaultAdminCssFiles)) $this->defaultAdminCssFiles[] = $destPath;
1094 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1097 function addCkeditorCssFile($path)
1099 $destPath = trim($path, '/');
1100 if (!in_array($destPath, $this->ckeditorCssFiles)) $this->ckeditorCssFiles[] = $destPath;
1105 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1108 function addScriptFile($path)
1110 $destPath = trim($path, '/');
1111 if (!empty($destPath) && !in_array($destPath, $this->defaultScriptFiles)) $this->defaultScriptFiles[] = $destPath;
1116 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1119 function addAdminScriptFile($path)
1121 $destPath = trim($path, '/');
1122 if (!in_array($destPath, $this->defaultAdminScriptFiles)) $this->defaultAdminScriptFiles[] = $destPath;
1127 * @return array テンプレートID,サブテンプレートIDの配列
1129 function getOptionTemplateId()
1131 global $gEnvManager;
1134 $pageId = $gEnvManager->getCurrentPageId();
1136 switch ($this->contentType){
1137 case M3_VIEW_TYPE_CONTENT: // ページのコンテンツタイプ
1139 $contentLibObj = $this->gInstance->getObject(self::CONTENT_OBJ_ID);
1140 if (isset($contentLibObj)) list($this->optionTemplateId, $this->optionSubTemplateId) = $contentLibObj->getOptionTemplate();
1142 case M3_VIEW_TYPE_BLOG: // ページがブログタイプのとき
1143 if ($pageId == $this->gEnv->getDefaultPageId()){ // PCサイトのとき
1144 // ブログライブラリオブジェクトからテンプレートを取得
1145 $blogLibObj = $this->gInstance->getObject(self::BLOG_OBJ_ID);
1146 if (isset($blogLibObj)) list($this->optionTemplateId, $this->optionSubTemplateId) = $blogLibObj->getOptionTemplate();
1150 return array($this->optionTemplateId, $this->optionSubTemplateId);
1153 * 使用した非共通ウィジェットの数を取得
1155 * @return int ウィジェット数
1157 function getNonSharedWidgetCount()
1159 return $this->nonSharedWidgetCount;
1164 * @return string コンテンツタイプ
1166 function getContentType()
1168 return $this->contentType;
1171 * フロント画面で使用する主要コンテンツタイプの情報取得
1173 * @return array コンテンツタイプの情報の連想配列
1175 function getMainContentTypeInfo()
1177 return $this->mainContentTypeInfo; // 主要コンテンツタイプ
1180 * フロント画面で使用する補助コンテンツタイプの情報取得
1182 * @return array コンテンツタイプの情報の連想配列
1184 function getSubContentTypeInfo()
1186 return $this->subContentTypeInfo; // 補助コンテンツタイプ
1189 * フロント画面で使用する主要コンテンツタイプを取得
1191 * @return array コンテンツタイプの配列
1193 function getMainContentTypes()
1196 //return array_map(create_function('$a', 'return $a["value"];'), $this->mainContentTypeInfo);
1197 $types = array_map(function($a){ return $a["value"]; }, $this->mainContentTypeInfo);
1201 * フロント画面で使用するサブコンテンツタイプを取得
1203 * @return array コンテンツタイプの配列
1205 function getSubContentTypes()
1208 // return array_map(create_function('$a', 'return $a["value"];'), $this->subContentTypeInfo);
1209 $types = array_map(function($a){ return $a["value"]; }, $this->subContentTypeInfo);
1213 * フロント画面で使用する主要機能タイプ情報を取得
1215 * @return array 機能タイプの情報の連想配列
1217 function getMainFeatureTypeInfo()
1219 return $this->mainFeatureTypeInfo; // 主要機能タイプ
1222 * フロント画面で使用する主要機能タイプを取得
1224 * @return array 機能タイプの配列
1226 function getMainFeatureTypes()
1229 // return array_map(create_function('$a', 'return $a["value"];'), $this->mainFeatureTypeInfo);
1230 $types = array_map(function($a){ return $a["value"]; }, $this->mainFeatureTypeInfo);
1237 * @return array ページ属性情報の連想配列
1239 function getAllPageAttributeTypeInfo()
1241 return array_merge($this->mainContentTypeInfo, $this->subContentTypeInfo, $this->mainFeatureTypeInfo, $this->adminFeatureTypeInfo);
1244 * 管理画面用のサブメニューバーの定義を設定
1246 * @param array $def メニューバー定義
1249 function setAdminSubNavbarDef($def)
1251 $this->adminSubNavbarDef = $def;
1254 * 管理画面用のサブメニューバーの定義を取得
1256 * @return array メニューバーの定義
1258 function getAdminSubNavbarDef()
1260 return $this->adminSubNavbarDef;
1265 * @param array $def パンくずリスト定義
1266 * @param array $help ヘルプ(title,bodyの連想配列)
1269 function setAdminBreadcrumbDef($def, $help = array())
1271 $this->adminBreadcrumbDef = $def;
1272 if (!empty($help)) $this->adminBreadcrumbDefHelp = $help; // 管理画面用パンくずリストヘルプ定義
1277 * @param array $help ヘルプ(title,bodyの連想配列)
1278 * @return array パンくずリスト定義
1280 function getAdminBreadcrumbDef(&$help)
1283 $argNum = func_num_args();
1285 // ヘルプ取得用パラメータが存在する場合は定義を設定
1286 if ($argNum > 0) $help = $this->adminBreadcrumbDefHelp;
1288 return $this->adminBreadcrumbDef;
1293 * HTTPヘッダを設定する。セッションを取得する。サブページIDを設定する。
1295 * @param RequestManager $request HTTPリクエスト処理クラス
1298 function startPage($request)
1300 global $gEnvManager;
1301 global $gRequestManager;
1302 global $gInstanceManager;
1303 global $gAccessManager;
1304 global $gSystemManager;
1305 global $gDispManager;
1306 global $gOpeLogManager;
1309 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
1310 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
1311 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
1312 $pageId = $gEnvManager->getCurrentPageId();
1314 // ###### クライアントIDの読み込み、再設定 ######
1315 // この後、クライアントIDがアクセスログに記録される
1316 $clientId = $request->getCookieValue(M3_COOKIE_CLIENT_ID);
1317 if (empty($clientId)){ // クライアントIDが設定されていないとき(初回アクセス)
1319 $clientId = $this->gAccess->createClientId();
1321 $this->gAccess->setClientId($clientId); // クライアントIDを設定
1324 $this->gEnv->setCanUseCookie(true);
1326 $request->setCookieValue(M3_COOKIE_CLIENT_ID, $clientId, M3_COOKIE_EXPIRE_CLIENT_ID);
1328 // インストール時の管理画面用ライブラリを追加(フレームコンテナでの設定を反映)
1329 if (defined('M3_STATE_IN_INSTALL')){
1331 if ($this->useBootstrap){
1332 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
1333 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
1336 // 管理者キーがあればGETまたはPOST値のセッションIDを使用する
1337 // if ($gEnvManager->isAdminDirAccess()){
1338 // if ($gAccessManager->isValidAdminKey()) session_id($gRequestManager->trimValueOf(session_name()));
1342 // 最終HTML(ページ全体で使用するHTML)の出力
1343 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
1344 $gRequestManager->stopSessionUpdate(); // セッションの更新を停止
1350 // ##### インストール時はここで終了 #####
1351 if (defined('M3_STATE_IN_INSTALL')) return; // インストール時は実行しない
1353 // セッションを再生成する(セキュリティ対策)
1354 if ($gSystemManager->regenerateSessionId()){
1355 $gAccessManager->setOldSessionId(session_id()); // 古いセッションIDを保存
1356 session_regenerate_id(true);
1360 $userInfo = $gRequestManager->getSessionValueWithSerialize(M3_SESSION_USER_INFO);
1361 if (!$gAccessManager->checkSessionSecurity($userInfo)) return; // セキュリティ問題ありの場合はここで終了
1362 // ##### ここで終了した場合はページサブIDが未設定のためページ不正のエラーが発生しアクセスエラー画面が表示される #####
1364 // ##### POST時のリファラーチェック #####
1365 // WooCommerceのAJAX処理が通らないのでチェックしない?
1366 /* if ($gRequestManager->isPostMethod() && !$this->_checkReferer()){
1367 $errMsg = '不正なPOSTデータ(リファラー異常)を検出しました。アクセス元IP: ' . $gAccessManager->getClientIp();
1368 $msgDetail = 'アクセスをブロックしました。account=' . $userInfo->account . ', userid=' . $userInfo->userId;
1369 $gOpeLogManager->writeUserError(__METHOD__, $errMsg, 2210, $msgDetail);
1374 $gRequestManager->_doSessionOpenEventCallback();
1377 $gInstanceManager->setUserInfo($userInfo);
1379 // ##### 自動ログイン #####
1380 // ログイン中でない場合は自動ログインでユーザ情報を取得
1381 $gAccessManager->startAutoLogin();
1384 if (M3_SYSTEM_DEBUG) echo 'Debug mode<br />';
1386 // ##### ユーザアクセスモードの設定 #####
1387 if (!empty($userInfo) && $userInfo->isPersonal()) $this->setPersonalMode(); // パーソナルモードをオン
1388 /* if (($userInfo->userType == UserInfo::USER_TYPE_MANAGER && $userInfo->userOptType == UserInfo::USER_OPT_TYPE_PAGE_MANAGER)|| // ページ運用者の場合
1389 $userInfo->userType < UserInfo::USER_TYPE_MANAGER){ // システム運用者よりも権限が低い場合
1392 $this->setPersonalMode();
1395 // ##### ページIDの修正 #####
1396 // ポジション表示の場合はページID、ページサブIDを再設定。再設定はシステム管理者のみ可能。
1397 if (($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 管理画面(ウィジェットなしポジション表示)のとき
1398 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) && // 管理画面(ウィジェット付きポジション表示)のとき
1399 // $gEnvManager->isSystemAdmin()){
1400 $gEnvManager->isSystemManageUser()){ // システム運用可能の場合(2018/8/5変更)
1402 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1403 if (empty($pageId)) $pageId = $this->gEnv->getDefaultPageId(); // 値がないときはデフォルトのページIDを設定
1404 $this->gEnv->setCurrentPageId($pageId);
1405 $subId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1406 if (!empty($subId)) $this->gEnv->setCurrentPageSubId($subId);
1409 // ##### サブページIDの設定 #####
1410 if ($gEnvManager->isAdminDirAccess() && // 管理画面へのアクセスのとき
1411 ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT)){ // ログイン、ログアウト場合は管理画面のページサブIDを指定
1412 $subId = $gEnvManager->getAdminDefaultPageSubId(); // 管理画面用のデフォルトページサブID
1414 if (empty($subId)) $subId = $request->trimValueOf(M3_REQUEST_PARAM_PAGE_SUB_ID);// ページサブIDを取得
1416 if (empty($subId)){ // サブページIDが設定されていないとき
1417 // URLパラメータからコンテンツ形式を取得し、ページを選択
1418 $params = $gRequestManager->getQueryArray();
1419 $paramCount = count($params);
1421 // コマンド以外のパラメータ数が1つだけのときはパラメータからページ属性を判断する
1422 // 値が空でもキーがあれば属性を持つとする
1423 if ($paramCount == 0){
1424 $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1426 //if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemAdmin() && empty($task)){
1427 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser() && empty($task)){
1428 // ダッシュボード機能は、パラメータなし、管理者ディレクトリ、システム運用者の条件で使用可能(2018/8/5変更)
1429 // POST値にタスクがある場合はダッシュボードとしない
1430 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_DASHBOARD, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1432 } else if ($paramCount > 0 && !$gEnvManager->isAdminDirAccess()){ // パラメータ付きの場合(2013/3/23)
1433 // ##### ページ属性から画面を選択(管理画面は対応しない) ###
1434 // 最初のURLパラメータでコンテンツを判断
1435 // プレビュー(cmd=preview)等のパターンで複数パラメータがある
1437 $firstKey = key($params);
1438 $firstValue = $params[$firstKey];
1440 if (!empty($firstValue)){ // 「key=value」の形式であること
1442 case M3_REQUEST_PARAM_CONTENT_ID: // コンテンツIDのとき
1443 case M3_REQUEST_PARAM_CONTENT_ID_SHORT:
1444 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1445 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1446 if (!$checkStatus) return; // エラーの場合は終了
1448 // ローカルメニューのURLからページを特定。ページが特定できないときはページ属性で取得。
1449 $url = $gEnvManager->getMacroPath($gEnvManager->getCurrentRequestUri());
1450 $ret = $this->db->getSubPageIdByMenuItemUrl($url, $gEnvManager->getCurrentPageId(), M3_VIEW_TYPE_CONTENT, $rows);
1452 $rowCount = count($rows);
1453 for ($i = 0; $i < $rowCount; $i++){
1454 // コンテンツを表示するウィジェットがあるときはページサブIDを確定
1455 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);
1456 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);// コンテンツタイプでの取得に変更(2012/6/20)
1457 if (!empty($widgetId)){
1458 $subId = $rows[$i]['pd_sub_id'];
1463 if (empty($subId)) $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_CONTENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1464 $this->contentType = M3_VIEW_TYPE_CONTENT; // ページのコンテンツタイプ
1466 // コンテンツ詳細ページかどうかを設定
1467 if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT) $this->isContentDetailPage = true;
1469 case M3_REQUEST_PARAM_PRODUCT_ID: // 製品IDのとき
1470 case M3_REQUEST_PARAM_PRODUCT_ID_SHORT:
1471 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1472 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1473 if (!$checkStatus) return; // エラーの場合は終了
1475 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PRODUCT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1476 $this->contentType = M3_VIEW_TYPE_PRODUCT; // ページのコンテンツタイプ
1478 // コンテンツ詳細ページかどうかを設定
1479 $this->isContentDetailPage = true;
1481 case M3_REQUEST_PARAM_BBS_ID: // 掲示板投稿記事のとき
1482 case M3_REQUEST_PARAM_BBS_ID_SHORT:
1483 case M3_REQUEST_PARAM_BBS_THREAD_ID:
1484 case M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT:
1485 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1486 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1487 if (!$checkStatus) return; // エラーの場合は終了
1489 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BBS, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1490 $this->contentType = M3_VIEW_TYPE_BBS; // ページのコンテンツタイプ
1492 // コンテンツ詳細ページかどうかを設定
1493 if ($firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID || $firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT) $this->isContentDetailPage = true;
1495 case M3_REQUEST_PARAM_EVENT_ID: // イベント記事のとき
1496 case M3_REQUEST_PARAM_EVENT_ID_SHORT:
1497 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1498 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1499 if (!$checkStatus) return; // エラーの場合は終了
1501 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_EVENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1502 $this->contentType = M3_VIEW_TYPE_EVENT; // ページのコンテンツタイプ
1504 // コンテンツ詳細ページかどうかを設定
1505 $this->isContentDetailPage = true;
1507 case M3_REQUEST_PARAM_PHOTO_ID: // フォトギャラリー写真のとき
1508 case M3_REQUEST_PARAM_PHOTO_ID_SHORT:
1509 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1510 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1511 if (!$checkStatus) return; // エラーの場合は終了
1513 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PHOTO, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1514 $this->contentType = M3_VIEW_TYPE_PHOTO; // ページのコンテンツタイプ
1516 // コンテンツ詳細ページかどうかを設定
1517 $this->isContentDetailPage = true;
1519 case M3_REQUEST_PARAM_BLOG_ID: // ブログIDのとき
1520 case M3_REQUEST_PARAM_BLOG_ID_SHORT:
1521 case M3_REQUEST_PARAM_BLOG_ENTRY_ID:
1522 case M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT:
1523 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1524 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1525 if (!$checkStatus) return; // エラーの場合は終了
1527 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BLOG, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1528 $this->contentType = M3_VIEW_TYPE_BLOG; // ページのコンテンツタイプ
1530 // コンテンツ詳細ページかどうかを設定
1531 if ($firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT) $this->isContentDetailPage = true;
1533 case M3_REQUEST_PARAM_ROOM_ID: // ユーザ作成コンテンツのとき
1534 case M3_REQUEST_PARAM_ROOM_ID_SHORT:
1535 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1536 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1537 if (!$checkStatus) return; // エラーの場合は終了
1539 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_USER, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1540 $this->contentType = M3_VIEW_TYPE_USER; // ページのコンテンツタイプ
1542 // コンテンツ詳細ページかどうかを設定
1543 $this->isContentDetailPage = true;
1545 // コンテンツを表示するウィジェットを取得
1546 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);
1547 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);// コンテンツタイプでの取得に変更(2012/6/20)
1548 if (!empty($widgetId)){
1549 // ルーム用の定義ID(所属グループID)を取得
1550 $roomId = isset($params[M3_REQUEST_PARAM_ROOM_ID]) ? $params[M3_REQUEST_PARAM_ROOM_ID] : $params[M3_REQUEST_PARAM_ROOM_ID_SHORT];
1551 $configId = $this->db->getWidgetConfigIdForRoom($roomId);
1553 // グループIDを定義IDとするページのページサブIDを取得
1554 $subPageId = $this->getPageSubIdByWidget($gEnvManager->getCurrentPageId(), $widgetId, $configId);
1555 if (!empty($subPageId)) $subId = $subPageId;
1558 default: // オプションのURLコンテンツパラメータからサブページIDを取得
1559 $ret = $this->db->getSubPageIdByUrlContentParam($gEnvManager->getCurrentPageId(), $firstKey, $row);
1560 if ($ret) $subId = $row['pd_sub_id'];
1568 // 「http://www.example.com?ページ名」「wcmd」の場合はwikiコンテンツページを選択
1569 $wikiCmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND);
1570 $pageName = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
1572 if (!empty($wikiCmd) || !empty($pageName)){ // Wikiコンテンツページを指定のとき
1574 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_WIKI, $gEnvManager->getCurrentPageId());
1575 $this->contentType = M3_VIEW_TYPE_WIKI; // ページのコンテンツタイプ
1577 // コンテンツ詳細ページかどうかを設定
1578 $this->isContentDetailPage = true;
1581 // その他のGET,POSTパラメータからページサブID取得
1583 // 検索用パラメータなどでリダイレクト先のURLが取得できた場合は遷移
1584 $subId = $this->getPageSubIdByParam($request, $redirectUrl);
1585 if (!empty($subId) && !empty($redirectUrl)) $this->redirect($redirectUrl);
1588 // ページサブIDが取得できない場合はデフォルトを使用
1589 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
1590 } else { // ページサブIDが設定されているとき
1591 // URLパラメータからコンテンツ形式を取得し、ページを選択
1592 $params = $gRequestManager->getQueryArray();
1593 $paramCount = count($params);
1594 if ($paramCount == 1) $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1597 $gEnvManager->setCurrentPageSubId($subId);// サブページIDを設定
1599 // SSL通信機能がオンの場合は、アクセスされたURLのSSLをチェックし不正の場合は正しいURLにリダイレクト
1600 // 設定に間違いがある場合、管理画面にアクセスできなくなるので、フロント画面のみ制御
1601 // if ($gEnvManager->getUseSsl() || $gEnvManager->getUseSslAdmin()){
1602 if ($gEnvManager->getUseSsl()){ // フロント画面のSSL設定のみチェック(2016/7/30)
1603 if (!$gEnvManager->isAdminDirAccess()){ // 管理画面以外へのアクセスのとき
1604 // ルートURLがSSLの場合はSSLに固定
1605 if ($gEnvManager->isRootUrlSsl()){ // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
1608 $isSsl = $gEnvManager->isSslByCurrentPage();
1610 $currentUrl = $gEnvManager->getCurrentRequestUri();
1612 $correctUrl = str_replace('http://', 'https://', $currentUrl);
1614 $correctUrl = str_replace('https://', 'http://', $currentUrl);
1616 if ($currentUrl != $correctUrl) $this->redirect($correctUrl);
1620 $gEnvManager->initMultiDomain();
1623 $gDispManager->load();
1625 // ##### 画面に必要なスクリプトを追加 #####
1626 // スマートフォン用URLのときはスマートフォン用のjQueryを使用
1627 if ($gEnvManager->getIsSmartphoneSite()){
1628 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(10); // スマートフォン用jQueryファイル
1630 if (isset($this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'])){
1631 $scriptFiles = $this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'];
1632 if (count($scriptFiles) > 0) $this->selectedJQueryMobileFilename = $scriptFiles[0]; // 使用対象のjQueryMobileファイル
1636 // Magic3管理用のスクリプトを追加
1637 if (!$gEnvManager->getIsMobileSite()){ // 携帯用URL以外のとき
1638 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
1639 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
1640 // $this->isEditMode = true; // フロント画面編集モード
1641 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定(コンテキストメニュー表示)
1644 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1645 //if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE){ // ウィジェット設定画面またはテンプレート設定画面のとき
1646 $this->addAdminScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1648 // Googleマップライブラリの読み込み
1649 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1650 $this->defaultAdminScriptFiles[] = ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS);
1652 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1653 $this->isLayout = true; // 画面レイアウト中かどうか
1654 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_IDTABS); // 管理パネル用スクリプト追加(ポジション表示追加分)
1655 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_DROPDOWN); // 管理パネル用スクリプト追加(ドロップダウンメニュー)
1656 //$this->useBootstrap = true; // Bootstrapを使用
1657 //$this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1659 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1660 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1662 // スクリプトが必要なウィジェットをすべて取得
1663 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1664 for ($i = 0; $i < count($rows); $i++){
1665 $this->addAdminScript($task, trim($rows[$i]['wd_add_script_lib']));
1667 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1669 $widgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
1670 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
1671 if ($ret) $this->addAdminScript($task, trim($this->configWidgetInfo['wd_add_script_lib_a'])); // 管理機能用スクリプト
1674 } else { // フロント画面へのアクセスのとき
1675 // フロント画面用スクリプトファイル追加
1676 $value = $gSystemManager->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
1677 if ($value) $this->addScriptFile($this->selectedJQueryFilename);
1679 if ($cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
1680 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
1681 if ($gEnvManager->isSystemManageUser()){
1682 $this->isEditMode = true; // フロント画面編集モード
1683 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定
1685 // システム運用権限がある場合は管理用スクリプトを追加
1686 // フロント画面と管理画面の切り替え用のスライドメニューバーには管理用スクリプト,CSSが必要
1687 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1688 $this->addScriptFile(ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME); // jQuery Contextmenu Lib
1689 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1690 //$this->addScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1691 $this->addScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用スクリプト追加
1692 $this->addScript('', ScriptLibInfo::LIB_JQUERY_COOKIE); // 管理パネル用スクリプト追加
1693 $this->addScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用スクリプト追加
1694 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1695 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1697 $this->addCssFile(self::M3_ADMIN_CSS_FILE); // 管理機能用CSS
1698 } else if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1699 $this->isEditMode = true; // フロント画面編集モード
1701 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
1702 if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1703 $this->isEditMode = true; // フロント画面編集モード
1705 // $this->addScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
1706 $this->addScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1707 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1708 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
1709 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1710 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1712 // Googleマップライブラリの読み込み
1713 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1714 $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS));
1722 $row = $this->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
1724 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1725 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1728 $this->currentPageInfo = $row; // 現在のページのページ情報
1731 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1732 /* $defPageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1733 $defPageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1736 $row = $this->getPageInfo($defPageId, $defPageSubId);
1738 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1739 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1742 $this->currentPageInfo = $row; // 現在のページのページ情報
1746 // $ret = $this->db->getPageDefOnPage($defPageId, $defPageSubId, $rows);
1747 $ret = $this->db->getPageDefOnPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1749 for ($i = 0; $i < count($rows); $i++){
1750 $position = $rows[$i]['pd_position_id'];
1751 if (!in_array($position, $this->defPositions)) $this->defPositions[] = $position; // 画面定義データのポジション(すべて)
1757 if ($openBy == 'tabs') $this->isTransparentMode = true; // 画面透過モード
1760 * URLの最初のパラメータが不正文字の場合はエラー画面へリダイレクト
1762 * @param string $value URLの最初のパラメータ値
1763 * @return bool true=正常、false=異常
1765 function _checkFirstValueRedirect($value)
1767 global $gEnvManager;
1768 global $gOpeLogManager;
1770 // 半角英小文字大文字、数字、アンダーバー、ハイフン、カンマのみ使用可能。
1771 if (preg_match("/[^0-9a-zA-Z-_,]/", $value)){
1772 $errMessage = 'URLパラメータの不正。';
1773 $gOpeLogManager->writeUserAccess(__METHOD__, '不正なアクセスを検出しました。' . $errMessage, 2200, 'アクセスをブロックしました。URL: ' . $gEnvManager->getCurrentRequestUri());
1775 // $this->redirect('?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=_accessdeny');
1777 $this->isSystemPage = true;
1790 global $gEnvManager;
1791 global $gSystemManager;
1793 $lang = $gEnvManager->getCurrentLanguage();
1795 // デフォルト言語とカレント言語が異なる場合のみ実行
1796 if ($lang != $gEnvManager->getDefaultLanguage()){
1798 $gSystemManager->roadSiteDefByLang($lang);
1802 $this->headDescription = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_DESCRIPTION); // HTMLヘッダ「description」に出力する文字列
1803 $this->headKeywords = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_KEYWORDS); // HTMLヘッダ「keywords」に出力する文字列
1804 $this->headOthers = $gSystemManager->getSiteDef(self::SD_HEAD_OTHERS); // HTMLヘッダに出力するタグ文字列
1806 // デフォルトのページ情報でヘッダを更新
1807 if (!empty($this->currentPageInfo)){
1808 $title = $this->currentPageInfo['pn_meta_title']; // 画面タイトル
1809 $desc = $this->currentPageInfo['pn_meta_description']; // ページ要約
1810 $keyword = $this->currentPageInfo['pn_meta_keywords']; // ページキーワード
1811 $headOthers = $this->currentPageInfo['pn_head_others']; // ヘッダその他タグ
1813 if (!empty($title)) $this->setHeadSubTitle($title, '', true); // デフォルト値として設定
1814 if (!empty($desc)) $this->setHeadDescription($desc);
1815 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1816 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1819 // 現在の言語のページ情報でヘッダを更新
1820 $ret = $this->db->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $lang, $row);
1822 $title = $row['pn_meta_title']; // 画面タイトル
1823 $desc = $row['pn_meta_description']; // ページ要約
1824 $keyword = $row['pn_meta_keywords']; // ページキーワード
1825 $headOthers = $row['pn_head_others']; // ヘッダその他タグ
1827 if (!empty($title)) $this->setHeadSubTitle($title, '', true); // デフォルト値として設定
1828 if (!empty($desc)) $this->setHeadDescription($desc);
1829 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1830 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1833 // $this->currentPageInfo = $row; // 現在のページのページ情報
1837 * スクリプト追加情報から、管理機能用のJavascriptファイル、CSSを追加する
1839 * @param string $task 指定タスク
1840 * @param string $scriptInfo スクリプト追加情報
1843 function addAdminScript($task, $scriptInfo)
1845 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1846 for ($i = 0; $i < count($itemArray); $i++){
1847 $pos = strpos($itemArray[$i], '=');
1848 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1849 $libs = trim($itemArray[$i]);
1850 } else { // タスク指定のとき
1851 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1852 $libTask = trim($libTask);
1853 $libs = trim($libs);
1855 if (strEndsWith($libTask, '_')){ // 「task_subtask」形式のタスクのとき
1856 if (!strStartsWith($task, $libTask)) $libs = ''; // タスクIDの先頭部が異なるときは追加しない
1858 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1861 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1862 $libsArray = explode(',', $libs);
1863 for ($j = 0; $j < count($libsArray); $j++){
1864 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1867 $setLibArray = ScriptLibInfo::getLibSet($lib);
1868 $setLibCount = count($setLibArray);
1869 if ($setLibCount > 0){ // ライブラリセットの場合
1870 for ($k = 0; $k < $setLibCount; $k++){
1871 $this->_addAdminScript($setLibArray[$k]);
1874 $this->_addAdminScript($lib);
1881 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1883 * @param string $lib ライブラリID
1886 function _addAdminScript($lib)
1889 if (!isset($this->libFiles[$lib])) return;
1892 // if (strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1893 // jQuery UIライブラリを追加
1894 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1895 if (isset($dependentLib)){
1896 for ($i = 0; $i < count($dependentLib); $i++){
1897 $addLib = $dependentLib[$i];
1900 if (isset($this->libFiles[$addLib]['script'])){
1901 $scriptFiles = $this->libFiles[$addLib]['script'];
1902 for ($m = 0; $m < count($scriptFiles); $m++){
1903 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1907 if (isset($this->libFiles[$addLib]['script_lang'])){
1908 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1909 for ($m = 0; $m < count($scriptFiles); $m++){
1910 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1914 if (isset($this->libFiles[$addLib]['css'])){
1915 $cssFiles = $this->libFiles[$addLib]['css'];
1916 for ($m = 0; $m < count($cssFiles); $m++){
1917 $this->addAdminCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1922 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1923 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1924 $this->outputTheme = true;
1929 if (isset($this->libFiles[$lib]['script'])){
1930 $scriptFiles = $this->libFiles[$lib]['script'];
1932 // ##### ライブラリ情報を作成する場合 #####
1933 if (empty($scriptFiles)){
1934 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
1935 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
1938 for ($i = 0; $i < count($scriptFiles); $i++){
1939 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1943 if (isset($this->libFiles[$lib]['script_lang'])){
1944 $scriptFiles = ScriptLibInfo::getLangScript($lib);
1945 for ($i = 0; $i < count($scriptFiles); $i++){
1946 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1950 if (isset($this->libFiles[$lib]['css'])){
1951 $cssFiles = $this->libFiles[$lib]['css'];
1952 for ($i = 0; $i < count($cssFiles); $i++){
1953 $this->addAdminCssFile($cssFiles[$i]); // 管理機能用のCSS追加
1957 if (strncmp($lib, 'jquery-ui.', 10) == 0){ // jQuery UIのwidgetsまたはeffectsのとき。jQuery UI Coreはデフォルトで読み込まれている。
1959 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1960 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1961 $this->outputTheme = true;
1966 * スクリプト追加情報から、通常機能用のJavascriptファイル、CSSを追加する
1968 * @param string $task 指定タスク
1969 * @param string $scriptInfo スクリプト追加情報
1972 function addScript($task, $scriptInfo)
1974 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1975 for ($i = 0; $i < count($itemArray); $i++){
1976 $pos = strpos($itemArray[$i], '=');
1977 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1978 $libs = trim($itemArray[$i]);
1979 } else { // タスク指定のとき
1980 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1981 $libTask = trim($libTask);
1982 $libs = trim($libs);
1983 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1985 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1986 $libsArray = explode(',', $libs);
1987 for ($j = 0; $j < count($libsArray); $j++){
1988 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1990 // jQueryライブラリ等、デフォルトでは追加されないライブラリを追加
1991 $setLibArray = ScriptLibInfo::getLibSet($lib);// ライブラリセットを展開
1992 $setLibCount = count($setLibArray);
1993 if ($setLibCount > 0){ // ライブラリセットの場合
1994 for ($k = 0; $k < $setLibCount; $k++){
1995 $this->_addScript($setLibArray[$k]);
1998 $this->_addScript($lib);
2005 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
2007 * @param string $lib ライブラリID
2010 function _addScript($lib)
2013 if (!isset($this->libFiles[$lib])) return;
2015 // ライブラリの依存ライブラリファイルを追加
2016 if (strcmp($lib, 'jquery') == 0){// jQuery本体のとき
2017 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
2018 } else if (strncmp($lib, 'jquery.', 7) == 0){ // jQueryプラグインのとき
2019 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
2020 if (strcmp($lib, 'jquery.mobile') == 0){ // jQueryMobileファイルのとき
2021 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
2022 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
2023 for ($i = 0; $i < count($this->headPreMobileScriptFiles); $i++){
2024 $this->addScriptFile($this->headPreMobileScriptFiles[$i]); // 通常機能用のスクリプト追加
2029 $dependentLib = ScriptLibInfo::getDependentLib($lib);
2030 if (isset($dependentLib)){
2031 for ($i = 0; $i < count($dependentLib); $i++){
2032 $addLib = $dependentLib[$i];
2035 if (isset($this->libFiles[$addLib]['script'])){
2036 $scriptFiles = $this->libFiles[$addLib]['script'];
2037 for ($m = 0; $m < count($scriptFiles); $m++){
2038 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
2042 if (isset($this->libFiles[$addLib]['script_lang'])){
2043 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
2044 for ($m = 0; $m < count($scriptFiles); $m++){
2045 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
2049 if (isset($this->libFiles[$addLib]['css'])){
2050 $cssFiles = $this->libFiles[$addLib]['css'];
2051 for ($m = 0; $m < count($cssFiles); $m++){
2052 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
2058 } else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI) == 0){ // jQuery UI
2059 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
2060 //} else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI_PLUS) == 0){ // jQuery UI plus
2061 // $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
2062 // $this->addScriptFile($this->selectedJQueryUiFilename); // jQuery Coreスクリプト追加
2063 } else if (strncmp($lib, 'jquery-ui.', 10) == 0 || // jQuery UIのwidgetsまたはeffectsのとき
2064 strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
2067 if (strncmp($lib, 'jquery-ui.', 10) == 0){
2068 $jQueryUiInfo = ScriptLibInfo::getJQueryUiInfo();// ライブラリ情報取得
2069 $dependentLib = $jQueryUiInfo[$lib]; // 依存ライブラリ取得
2071 $dependentLib = ScriptLibInfo::getDependentLib($lib);
2073 for ($i = 0; $i < count($dependentLib); $i++){
2074 $addLib = $dependentLib[$i];
2077 if (isset($this->libFiles[$addLib]['script'])){
2078 $scriptFiles = $this->libFiles[$addLib]['script'];
2079 for ($m = 0; $m < count($scriptFiles); $m++){
2080 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
2084 if (isset($this->libFiles[$addLib]['script_lang'])){
2085 $scriptFiles = ScriptLibInfo::getLangScript($addLib);;
2086 for ($m = 0; $m < count($scriptFiles); $m++){
2087 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
2091 if (isset($this->libFiles[$addLib]['css'])){
2092 $cssFiles = $this->libFiles[$addLib]['css'];
2093 for ($m = 0; $m < count($cssFiles); $m++){
2094 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
2099 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
2100 $this->addCssFile($this->getDefaultThemeUrl()); // 通常機能用のCSS追加
2101 $this->outputTheme = true;
2106 if (isset($this->libFiles[$lib]['script'])){
2107 $scriptFiles = $this->libFiles[$lib]['script'];
2109 // ##### ライブラリ情報を作成する場合 #####
2110 if (empty($scriptFiles)){
2111 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
2112 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2115 for ($i = 0; $i < count($scriptFiles); $i++){
2116 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
2120 if (isset($this->libFiles[$lib]['script_lang'])){
2121 $scriptFiles = ScriptLibInfo::getLangScript($lib);
2122 for ($i = 0; $i < count($scriptFiles); $i++){
2123 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
2127 if (isset($this->libFiles[$lib]['css'])){
2128 $cssFiles = $this->libFiles[$lib]['css'];
2129 for ($i = 0; $i < count($cssFiles); $i++){
2130 $this->addCssFile($cssFiles[$i]); // 通常機能用のCSS追加
2135 * 非ログイン時の管理機能用のJavascriptファイル、CSSを追加する
2137 * @param array, string $lib 追加ライブラリID
2140 function addPermittedAdminScript($lib)
2142 if (is_array($lib)){
2143 for ($j = 0; $j < count($lib); $j++){
2147 if (isset($this->libFiles[$libId]['script'])){
2148 $scriptFiles = $this->libFiles[$libId]['script'];
2150 // ##### ライブラリ情報を作成する場合 #####
2151 if (empty($scriptFiles)){
2152 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
2153 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2156 for ($i = 0; $i < count($scriptFiles); $i++){
2157 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2161 if (isset($this->libFiles[$libId]['script_lang'])){
2162 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2163 for ($i = 0; $i < count($scriptFiles); $i++){
2164 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2168 if (isset($this->libFiles[$libId]['css'])){
2169 $cssFiles = $this->libFiles[$libId]['css'];
2170 for ($i = 0; $i < count($cssFiles); $i++){
2171 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2179 if (isset($this->libFiles[$libId]['script'])){
2180 $scriptFiles = $this->libFiles[$libId]['script'];
2182 // ##### ライブラリ情報を作成する場合 #####
2183 if (empty($scriptFiles)){
2184 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
2185 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2188 for ($i = 0; $i < count($scriptFiles); $i++){
2189 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2193 if (isset($this->libFiles[$libId]['script_lang'])){
2194 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2195 for ($i = 0; $i < count($scriptFiles); $i++){
2196 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2200 if (isset($this->libFiles[$libId]['css'])){
2201 $cssFiles = $this->libFiles[$libId]['css'];
2202 for ($i = 0; $i < count($cssFiles); $i++){
2203 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2213 * ・ウィジェットで生成されたHTTPヘッダを設定する
2215 * @param RequestManager $request HTTPリクエスト処理クラス
2216 * @param bool $getOutput 出力を取得するかどうか
2217 * @return string 最終出力HTML
2219 function endPage($request, $getOutput = false)
2221 global $gRequestManager;
2222 global $gInstanceManager;
2223 global $gEnvManager;
2224 global $gDispManager;
2225 global $gAccessManager;
2228 if ($this->isAbort) return '';
2233 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2235 // 最終HTML(ページ全体で使用するHTML)の出力
2236 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
2238 if (count($this->exportCss) > 0){
2239 for ($i = 0; $i < count($this->exportCss); $i++){
2240 $contents .= $this->exportCss[$i] . M3_NL;
2245 header('Content-type: text/css');
2247 // 画面情報、ユーザ情報の保存は行わない
2249 } else if ($cmd != M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体オペレーションのときは出力しない
2251 $contents = $this->getLastContents($request);
2253 echo $this->getLastContents($request);
2258 $userInfo = $gInstanceManager->getUserInfo();
2259 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2262 $gRequestManager->_doSessionCloseEventCallback();
2265 $gDispManager->save();
2267 // キャッシュリミッタは、各リクエスト毎に(アウトプットバッファー が無効な場合は、
2268 // session_start()がコールされる 前に) session_cache_limiter()をコールする必要がある。
2270 // session_cache_limiter('private');
2271 // session_cache_expire(5);
2272 if ($this->isRedirect) return ''; // リダイレクトの場合は終了
2274 // ########## HTTPヘッダ出力処理 ########
2275 if (headers_sent($filename, $linenum)){ // HTTPヘッダが既に送信されているとき
2276 echo "$filename の $linenum 行目でヘッダがすでに送信されています。";
2278 if ($gEnvManager->isMobile()){ // 携帯の場合
2279 // ドコモ端末の場合はリクエストヘッダにXHTMLを指定しないとXHTMLを処理しない
2280 $agent = $gInstanceManager->getMobileAgent();
2281 if ($agent->isDoCoMo()){ // ドコモ端末のとき
2282 header('Content-Type: application/xhtml+xml;');
2286 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// 過去の日付
2287 header('Cache-Control: no-store, no-cache, must-revalidate');// HTTP/1.1
2288 header('Cache-Control: post-check=0, pre-check=0', false);
2289 header('Pragma: no-cache');
2292 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
2295 header('Content-Type: text/html; charset=UTF-8'); // 2018/4/19 Firefoxで文字化けが起きる場合があるので追加
2297 // Ajax用JSON型データをHTTPヘッダに格納
2298 $gInstanceManager->getAjaxManager()->header();
2300 // システム制御画面が設定されている場合はステータスコードを変更
2301 //if ($this->gEnv->getIsMaintenance()){
2302 if (!$this->isRedirect){ // リダイレクトがセットされていない場合
2303 switch ($this->systemHandleMode){
2304 case 10: // サイト非公開(システムメンテナンス)
2305 header('HTTP/1.1 503 Service Temporarily Unavailable');
2306 header('Status: 503 Service Temporarily Unavailable');
2308 case 11: // アクセス禁止のとき
2309 header('HTTP/1.1 403 Forbidden');
2310 header('Status: 403 Forbidden');
2312 case 12: // 存在しないページのとき
2313 header("HTTP/1.1 404 Not Found");
2314 header("Status: 404 Not Found");
2319 // ##### 自動ログイン #####
2320 $gAccessManager->endAutoLogin();
2327 * 注意)exitSystem()でシステムを終了させる必要あり
2331 function abortPage()
2333 global $gInstanceManager;
2334 global $gRequestManager;
2336 // HTTPヘッダを削除(PHP 5.3以上で有効)
2337 if (version_compare(PHP_VERSION, '5.3.0') >= 0) header_remove();
2339 // exit()等でabortPage()が最後の処理になってしまう可能性があるのでなるべく必要な処理を行う
2340 //if (ob_get_level() > 0) ob_end_clean();// バッファ内容が残っているときは破棄
2341 while (ob_get_level()) ob_end_clean(); // バッファ削除方法変更(2009/12/2)
2344 $userInfo = $gInstanceManager->getUserInfo();
2345 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2348 $gRequestManager->_doSessionCloseEventCallback();
2350 $this->isAbort = true; // ページ作成処理を中断するかどうか
2357 function abortWidget()
2359 $this->isWidgetAbort = true; // 各ウィジェット処理を中断するかどうか
2366 function exitSystem()
2368 global $gEnvManager;
2369 global $gAccessManager;
2371 // DBが使用可能であれば、アクセスログのユーザを登録
2372 if ($gEnvManager->canUseDb()) $gAccessManager->accessLogUser();
2377 * Joomla!v1.5タグを読み込んでウィジェット実行
2379 * @param string $srcBuf バッファデータ
2380 * @param int $templateVer テンプレートバージョン(99=レイアウト用テンプレート、0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
2381 * @return string 変換後文字列
2383 function launchWidgetByJoomlaTag($srcBuf, $templateVer)
2389 if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\s*\/>#iU', $srcBuf, $matches)){
2390 $count = count($matches[1]);
2391 for ($i = 0; $i < $count; $i++)
2394 $type = $matches[1][$i];
2396 if (strcasecmp($type, 'head') == 0){ // ヘッダ埋め込みタグの場合
2399 $contents = ob_get_contents();
2400 } else if (strcasecmp($type, 'modules') == 0 || strcasecmp($type, 'module') == 0 || // 一般ウィジェット用配置ブロックの場合
2401 strcasecmp($type, 'navmenu') == 0){ // ナビゲーションメニューウィジェット用配置ブロックの場合
2402 $name = ''; // ポジション名
2403 $posType = ''; // ポジションのタイプ
2404 $style = ''; // 表示スタイル
2405 $params = explode(' ', $matches[2][$i]);
2406 $paramArray = array();
2407 for ($j = 0; $j < count($params); $j++){
2408 list($key, $value) = explode('=', $params[$j]);
2410 $value = trim($value, "\"'");
2411 if (!empty($key)) $paramArray[$key] = $value;
2413 $value = $paramArray['name'];
2416 $attr['name'] = $value;
2418 $value = $paramArray['type']; // 配置ブロックのタイプを属性に格納。テンプレート内での参照用。
2421 $attr['type'] = $value;
2423 $value = $paramArray['id'];
2424 if (isset($value)) $attr['id'] = $value;
2426 // スタイルが設定されている場合はオプションスタイルを取得
2427 $value = $paramArray['style'];
2430 $attr['style'] = $value;
2432 $optionStyle = $paramArray[$value]; // オプションのスタイル
2433 if (isset($optionStyle)) $attr[$value] = $optionStyle;
2435 /* for ($j = 0; $j < count($params); $j++){
2436 list($key, $value) = explode('=', $params[$j]);
2437 if (strcasecmp($key, 'name') == 0){
2438 $name = strtolower(trim($value, "\"'"));
2439 $attr['name'] = $name;
2440 } else if (strcasecmp($key, 'style') == 0){
2442 $style = trim($value, "\"'");
2443 } else if (strcasecmp($key, 'artstyle') == 0){ // テンプレート側指定の表示スタイル(Artisteer用)
2444 $attr['artstyle'] = trim($value, "\"'");
2445 } else if (strcasecmp($key, 'bootstyle') == 0){ // テンプレート側指定の表示スタイル(Bootstrap用)
2446 $attr['bootstyle'] = trim($value, "\"'");
2447 } else if (strcasecmp($key, 'drstyle') == 0){ // テンプレート側指定の表示スタイル(Themer用)
2448 $attr['drstyle'] = trim($value, "\"'");
2452 if (!empty($name)){ // ポジション名が取得できたとき
2453 // Joomla!では、テンプレートの「jdoc:include」タグの属性styleが空のときは「none」で処理される
2454 // Joomla!デフォルトで設定可能なのは「none,table,horz,xhtml,rounded,outline」
2455 // 配置ブロックがナビゲーション型に固定されていない場合はテンプレートの種類によってナビゲーションかどうかを判断
2456 if (strcasecmp($type, 'navmenu') == 0){ // メニューウィジェット用配置ブロックの場合
2457 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2458 $attr['type'] = $type; // テンプレート内での参照用
2460 switch ($templateVer){
2461 case 0: // デフォルトテンプレート(Joomla!v1.0)
2462 case 1: // Joomla!v1.5
2463 case 2: // Joomla!v2.5
2464 case 10: // Bootstrap v3.0
2466 if (strcasecmp($name, 'user3') == 0 || // ナビゲーションメニュー位置の場合
2467 strcasecmp($name, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
2468 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
2469 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2472 case 99: // レイアウト用テンプレート
2473 global $gRequestManager;
2474 static $templateType; // レイアウト用テンプレートタイプを一度だけ取得
2475 static $templateGenerator;
2477 if (!isset($templateType)){
2480 // レイアウト用テンプレートの場合は対象とするテンプレートの情報を取得して判断する
2481 $pageId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
2482 $pageSubId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
2484 // ページ用個別に設定されたテンプレートがある場合は取得
2486 $line = $this->getPageInfo($pageId, $pageSubId);
2487 if (!empty($line)) $curTemplate = $line['pn_template_id'];
2490 if (empty($curTemplate)){
2491 if ($pageId == $this->gEnv->getDefaultPageId()){ // 通常サイトのとき
2492 $curTemplate = $this->gSystem->defaultTemplateId();
2493 } else if ($pageId == $this->gEnv->getDefaultSmartphonePageId()){ // スマートフォン用サイトのとき
2494 $curTemplate = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
2499 $ret = $this->db->getTemplate($curTemplate, $row);
2501 $templateType = $row['tm_type'];
2502 $templateGenerator = $row['tm_generator'];
2506 if ($templateType != 99){
2507 // Themlerテンプレート場合は配置ポジション名が「hmenu」をナビゲーション型とする
2508 if ($templateGenerator == 'themler'){
2509 if (strcasecmp($name, 'hmenu') == 0){ // Joomla!v3テンプレート対応
2510 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2513 if (strcasecmp($name, 'user3') == 0 || // ナビゲーションメニュー位置の場合
2514 strcasecmp($name, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
2515 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2522 if (empty($style)) $style = 'none';
2525 $contents = $this->getContents($name, $style, $templateVer, $attr);
2527 } else if (strcasecmp($type, 'component') == 0){ // メインポジションタグの場合
2529 $style = ''; // 表示スタイル
2530 $params = explode(' ', $matches[2][$i]);
2531 for ($j = 0; $j < count($params); $j++){
2532 list($key, $value) = explode('=', $params[$j]);
2533 if (strcasecmp($key, 'style') == 0){
2535 $style = trim($value, "\"'");
2539 if ($style != 'none') $style = 'xhtml';
2540 $contents = $this->getContents('main', $style, $templateVer, $attr);
2541 } else if (strcasecmp($type, 'message') == 0){ // メッセージタグの場合
2543 $replace[$i] = $contents;
2546 $destBuf = str_replace($matches[0], $replace, $srcBuf);
2553 * 遅延実行インデックスのついているウィジェットをインデックス順に実行し、出力バッファデータ内のタグの位置に出力を埋め込む
2555 * @param RequestManager $request HTTPリクエスト処理クラス
2556 * @param string $srcBuf バッファデータ
2557 * @return string 変換後文字列
2559 function lateLaunchWidget($request, $srcBuf)
2561 static $render; // HTML生成オブジェクト
2562 global $gEnvManager;
2563 global $gErrorManager;
2564 global $gDesignManager;
2566 // ページ作成中断またはウィジェット処理中断のときは終了
2567 if ($this->isAbort || $this->isWidgetAbort) return '';
2569 // ウィジェットヘッダ(Joomla!1.0用)を出力のタイプを取得
2570 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
2573 $templateVer = $gEnvManager->getCurrentTemplateType();
2575 // 遅延実行ウィジェットをインデックス順にソート
2576 asort($this->lateLaunchWidgetList, SORT_NUMERIC);
2580 foreach ($this->lateLaunchWidgetList as $widgetId => $value){
2582 $count = count($this->latelaunchWidgetParam);
2583 for ($i = 0; $i < $count; $i++){
2584 list($wId, $maxNo, $confId, $preId, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $pageDefRec) = $this->latelaunchWidgetParam[$i];
2585 if ($wId == $widgetId){
2587 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
2588 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
2589 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
2592 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
2593 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
2599 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
2602 $configId = $confId; // ウィジェット定義ID
2603 if ($configId == 0) $configId = '';
2604 $prefix = $preId; // サフィックス文字列
2606 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
2607 $joomlaTitleVisble = false;
2608 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
2609 if (!empty($title)){
2610 if ($widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2611 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
2612 echo '<tr><th>' . $title . '</th></tr>' . M3_NL;
2613 echo '<tr><td>' . M3_NL;
2614 $joomlaTitleVisble = true;
2615 } else if ($widgetHeaderType == 2){ // 携帯用ウィジェットヘッダ出力
2616 echo '<div>' . $title . '</div>' . M3_NL;
2617 $joomlaTitleVisble = true;
2622 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
2623 // ウィジェット親のCSS定義があるときは、タグを追加
2624 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
2627 echo $gDesignManager->getAdditionalWidgetOutput(true);
2630 $gEnvManager->setCurrentWidgetId($widgetId);
2633 $gEnvManager->setCurrentWidgetConfigId($configId);
2636 $gEnvManager->setCurrentPageDefSerial($serial);
2639 $gEnvManager->setCurrentPageDefRec($pageDefRec);
2642 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
2645 $gEnvManager->setCurrentWidgetTitle('');
2648 $gEnvManager->setCurrentWidgetStyle($style);
2650 // ウィジェットのグローバル属性状況を設定
2651 $gEnvManager->setIsCurrentWidgetShared($shared);
2654 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
2657 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
2658 $msg = 'widget-start(' . $widgetId . ')';
2659 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2660 require($widgetIndexFile);
2661 $msg = 'widget-end(' . $widgetId . ')';
2662 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2665 $gEnvManager->setCurrentWidgetId('');
2668 $gEnvManager->setCurrentWidgetConfigId('');
2671 $gEnvManager->setCurrentPageDefSerial(0);
2674 $gEnvManager->setCurrentPageDefRec();
2677 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
2680 $gEnvManager->setCurrentWidgetStyle('');
2682 // ウィジェットのグローバル属性状況を解除
2683 $gEnvManager->setIsCurrentWidgetShared(false);
2686 $newTitle = $gEnvManager->getCurrentWidgetTitle();
2689 echo $gDesignManager->getAdditionalWidgetOutput(false);
2691 // ウィジェット親のCSS定義があるときは、タグを追加
2692 if (!empty($cssStyle)) echo '</div>' . M3_NL;
2694 //echo '</div>' . M3_NL;
2696 // Joomla!1.0テンプレートのときはタイトルを出力
2697 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2698 echo '</td></tr>' . M3_NL;
2699 echo '</table>' . M3_NL;
2702 // 現在のバッファ内容を取得し、バッファを破棄
2703 $srcContents = ob_get_contents();
2706 // ### テンプレート側のウィジェット生成処理使える場合はウィジェットの出力と入れ替える ###
2707 // ### 先のrequire($widgetIndexFile)で必要なデータは作成されている ###
2708 if ($templateVer >= 1 && $templateVer < 100){ // Joomla!v1.5,v2.5テンプレートのとき
2709 $widgetType = $pageDefRec['wd_type']; // ウィジェットタイプ
2710 if ($widgetType == 'breadcrumb'){ // パンくずリスト
2712 if (!isset($render)) $render = new JRender();
2714 $templateContents = $render->getBreadcrumbContents('', '', '', array(), array(), $pageDefRec, $templateVer); // テンプレートバージョンのみ必要
2715 if (!empty($templateContents)) $srcContents = $templateContents;
2720 $tag = self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
2721 $destBuf = str_replace($tag, $srcContents, $destBuf);
2724 if (!empty($newTitle)) $title = $newTitle;
2725 $tag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
2726 $destBuf = str_replace($tag, $title, $destBuf);
2728 // ##### 外部出力用のCSSがある場合は追加 #####
2729 if (!empty($exportCss)){
2731 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $index; // ウィジェット識別用ユニークタグ
2732 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
2733 $this->addExportCss($exportCss);
2739 // ##### HTMLヘッダ出力処理 #####
2740 $destBuf = $this->replaceHead($destBuf);
2747 * @param string $jobType ジョブタイプ
2750 function launchJob($jobType)
2752 global $gEnvManager;
2754 // ジョブタイプから実行するウィジェットIDを取得
2755 $widgetId = $this->getWidgetIdByJobType($jobType);
2756 if (empty($widgetId)) return;
2759 $gEnvManager->setCurrentWidgetId($widgetId);
2762 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/admin/job.php';
2764 if (file_exists($widgetIndexFile)){
2766 // $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd);
2768 require_once($widgetIndexFile);
2770 echo 'file not found: ' . $widgetIndexFile;
2774 $gEnvManager->setCurrentWidgetId();
2779 * @param string $srcBuf 変換元
2780 * @return string 変換後文字列
2782 function replaceHead($srcBuf)
2786 // ##### ヘッダ部分の置換 #####
2787 if ($this->outputHead){ // HTMLヘッダ出力を行っているとき
2790 // HTMLヘッダに最初に出力するタグ文字列がある場合は追加
2791 if (!empty($this->headFirstTag)) $replaceStr .= $this->headFirstTag;
2793 // METAタグcharset等のHTML文書の標準のヘッダタグを出力
2794 if ($this->outputByStandardHead) $replaceStr .= $this->getStandardHead();
2797 $replaceStr .= $this->getHeaderOutput();
2800 $destBuf = str_replace(self::HEAD_TAGS, $replaceStr, $destBuf);
2802 $this->replaceHeadDone = true; // ヘッダマクロ変換処理が完了したかどうか
2810 function enableReplaceHead()
2812 $this->outputHead = true;
2815 * ウィジェット検索モードの場合のページサブIDの設定
2817 * @param RequestManager $request HTTPリクエスト処理クラス
2819 function redirectToUpdatedPageSubId($request)
2821 global $gEnvManager;
2823 // 現在設定されているページIDを取得
2824 $pageId = $gEnvManager->getCurrentPageId();
2825 $pageSubId = $gEnvManager->getCurrentPageSubId();
2828 $fromWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_FROM);
2831 $targetWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
2833 // 対象のウィジェットのページサブIDを取得
2834 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2835 if ($ret){// データが存在する
2836 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2837 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2838 if ($ret){// データが存在する
2839 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2841 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2846 for ($i = 0; $i < count($rows); $i++){
2847 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2852 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2853 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2855 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2858 } else { // 対象のウィジェットが見つからない場合は、互換ウィジェットを探す
2859 $widgetId = $this->db->getCompatibleWidgetId($targetWidgetId);
2860 if (!empty($widgetId)){
2861 $targetWidgetId = $widgetId;
2863 // 対象のウィジェットのページサブIDを取得
2864 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2865 if ($ret){// データが存在する
2866 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2867 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2868 if ($ret){// データが存在する
2869 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2871 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2876 for ($i = 0; $i < count($rows); $i++){
2877 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2882 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2883 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2885 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2891 // ページサブIDが見つからないときは、既に設定されている値を使用
2892 // 既に設定されている値は、URL「sub」パラメータで指定されている値か
2893 // 設定されていない場合はデフォルトのサブページID
2894 // ********** 指定ページへリダイレクト ***********
2896 $todo = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TODO);
2897 $todo = str_replace(M3_TODO_SEPARATOR, '&', $todo); // セパレータを変換
2898 // $redirectUrl = '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2899 $redirectUrl = $gEnvManager->createPageUrl() . '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2900 if (!empty($todo)) $redirectUrl .= '&' . $todo;
2901 if ($gEnvManager->getIsMobileSite()){ // 携帯用アクセスポイントの場合
2902 $this->redirect($redirectUrl, true/*遷移時のダイアログ表示を抑止*/);
2904 $this->redirect($redirectUrl);
2910 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2911 * 追加するHTMLは主にウィンドウ制御用のスクリプト
2913 * @return string 最終HTML
2915 function getLastContents()
2917 global $gEnvManager;
2918 global $gRequestManager;
2921 $initScript = ''; // 初期化用スクリプト
2922 $pageId = $gEnvManager->getCurrentPageId();
2923 $pageSubId = $gEnvManager->getCurrentPageSubId();
2924 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2926 if (!$gEnvManager->isSystemManageUser()) return ''; // システム運用権限がない場合は終了
2929 if ($cmd == M3_REQUEST_CMD_RSS || // RSS配信のときは終了
2930 $cmd == M3_REQUEST_CMD_DO_WIDGET) return ''; // ウィジェット単体オペレーションのときは出力しない
2932 if ($gEnvManager->getIsMobileSite()) return ''; // 携帯用URLのときは終了
2934 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2936 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
2937 /* // テンプレート上のポジション名
2938 if (count($this->viewPosId) > 0){
2940 for ($i = 0; $i < count($this->viewPosId); $i++){
2941 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
2942 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
2944 $posArrayStr .= ']';
2945 $contents .= 'var M3_POSITIONS=' . $posArrayStr . ';' . M3_NL;
2948 $contents .= 'var M3_REVISION=' . $this->pageDefRev . ';' . M3_NL;*/
2951 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2952 $contents .= M3_INDENT_SPACE . 'window.m3.m3UpdateByConfig(serial);' . M3_NL;
2953 $contents .= '}' . M3_NL;
2954 } else if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定画面
2955 } else { // ダッシュボード画面、メイン管理画面
2957 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2958 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2959 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2960 $contents .= '}' . M3_NL;
2963 // ウィジェット単体実行以外のときの処理
2964 if (!$this->showWidget){
2965 if ($this->updateParentWindow){ // 管理画面からの親画面の更新
2966 $initScript .= M3_INDENT_SPACE . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
2971 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2972 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2973 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2974 $contents .= '}' . M3_NL;
2978 if (!empty($contents) || !empty($initScript)){
2979 // $destContents .= '<script type="text/javascript">' . M3_NL;
2980 // $destContents .= '//<![CDATA[' . M3_NL;
2981 $destContents .= $contents;
2982 if (!empty($initScript)){ // 初期化用スクリプト
2983 $destContents .= '$(function(){' . M3_NL;
2984 $destContents .= $initScript;
2985 $destContents .= '});' . M3_NL;
2987 // $destContents .= '//]]>' . M3_NL;
2988 // $destContents .= '</script>' . M3_NL;
2990 return $destContents;
2995 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2997 * @param RequestManager $request HTTPリクエスト処理クラス
2998 * @return string 最終HTML
3000 function getOptionContents($request)
3002 global $gEnvManager;
3007 if ($this->isAbort) return '';
3009 // AJAX用のレスポンスボディデータのときは終了
3010 if ($this->outputAjaxResponseBody) return '';
3013 // AJAXを送信する場合は空文字列では送信できないので、ダミーデータを返す
3014 if ($this->isWidgetAbort) $contents .= 'NO DATA' . M3_NL;
3017 if (!$gEnvManager->isMobile() && $this->outputByHtml){ // 携帯以外で、HTML出力のとき
3018 $contents .= '<!-- created by ' . M3_SYSTEM_NAME . ' v' . M3_SYSTEM_VERSION . ' - http://www.magic3.org -->' . M3_NL;
3019 $contents .= '<!-- convert time: ' . sprintf('%01.03f', microtime(true) - M3_MTIME) . ' -->' . M3_NL;
3024 * Widget単体起動用のHTMLのヘッダ部(headタグ)出力
3026 * startWidget(),endWidget()は、以下のコマンドを処理する
3027 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
3028 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
3029 * ・M3_REQUEST_CMD_CONFIG_TEMPLATE(テンプレート設定画面)
3030 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
3031 * Widgetの出力方法は、以下のパターンがある
3032 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
3033 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
3035 * @param string $cmd 起動コマンド
3037 function startWidget($cmd)
3039 global $gEnvManager;
3040 global $gRequestManager;
3042 // ウィジェット単体表示のときのみ出力
3043 if (!$this->showWidget) return;
3046 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
3047 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
3049 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
3050 if (intval($tempVer) >= 2) $this->isHtml5 = true; // HTML5で出力するかどうか
3053 if ($this->isHtml5){
3054 echo '<!DOCTYPE html>' . M3_NL;
3055 echo '<html dir="ltr" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
3056 echo '<head>' . M3_NL;
3058 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . M3_NL;
3059 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $gEnvManager->getCurrentLanguage() . '" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
3060 echo '<head>' . M3_NL;
3061 // echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' . M3_NL;
3064 // HTMLのヘッダ部(headタグ内)出力
3067 // ##### 作成対象がウィジェットの場合とテンプレートの場合に分ける #####
3068 if ($cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE){ // テンプレート設定画面の場合
3069 $templateId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_TEMPLATE_ID);// テンプレートID
3072 $widgetId = $gEnvManager->getCurrentWidgetId(); // カレントのウィジェットID
3076 if ($gEnvManager->getUseSslAdmin()){
3077 $rootUrl = $gEnvManager->getSslRootUrl();
3078 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
3079 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
3081 $rootUrl = $gEnvManager->getRootUrl();
3082 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
3083 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
3086 // ##### テンプレートのCSSの読み込み #####
3087 // テンプレートは管理用テンプレートに固定されている
3088 //if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット設定のとき
3089 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3090 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
3091 $curTemplateUrl = $templatesUrl . '/' . $gEnvManager->getCurrentTemplateId();
3092 if ($this->isHtml5){
3093 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/style.css" media="screen">' . M3_NL;
3094 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/widget.css" media="screen">' . M3_NL; // ウィジェット設定画面用CSS
3095 echo '<!--[if IE]><link rel="stylesheet" href="' . $curTemplateUrl . '/css/iestyles.css" media="screen"><![endif]-->' . M3_NL;
3096 echo '<!--[if lt IE 9]><script src="' . $curTemplateUrl . '/html5shiv.js"></script><![endif]-->' . M3_NL;
3098 echo '<link href="' . $curTemplateUrl . '/css/style.css" rel="stylesheet" type="text/css" />' . M3_NL;
3099 echo '<!--[if IE]><link rel="stylesheet" type="text/css" media="screen" href="' . $curTemplateUrl . '/css/iestyles.css" /><![endif]-->' . M3_NL;
3103 $ret = $this->db->getWidgetInfo($widgetId, $row);
3105 // ##### 共通ライブラリ読み込み設定 #####
3106 if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
3107 $scritLib = trim($row['wd_add_script_lib']);
3108 if (!empty($scritLib)) $this->addScript($task, $scritLib);
3111 // CSS読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
3112 if ($row['wd_read_css']){
3113 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_CSS;
3114 if (is_dir($searchPath)){
3115 $dir = dir($searchPath);
3116 while (($file = $dir->read()) !== false){
3117 $filePath = $searchPath . '/' . $file;
3118 if ($file != '.' && $file != '..' && is_file($filePath)
3119 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3122 $cssURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_CSS . '/' . $file;
3123 echo '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3130 // スクリプト読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
3131 if ($row['wd_read_scripts']){
3132 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS;
3133 if (is_dir($searchPath)){
3134 $dir = dir($searchPath);
3135 while (($file = $dir->read()) !== false){
3136 $filePath = $searchPath . '/' . $file;
3137 if ($file != '.' && $file != '..' && is_file($filePath)
3138 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3141 $scriptURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
3143 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3144 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3145 echo '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3151 // ##### スクリプト用出力用タグを埋め込む #####
3152 // ウィジェット設定画面用メニューバーの作成
3153 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3154 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3155 echo self::MENUBAR_SCRIPT_TAGS; // メニューバー出力用タグ
3158 // ##### 作成対象がウィジェットの場合とテンプレートの場合に分ける #####
3160 if ($cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE){ // テンプレート設定画面の場合
3161 $title = self::WIDGET_TITLE_START . 'テンプレート' . self::WIDGET_TITLE_END . ' ' . $templateId;
3162 $gEnvManager->setCurrentWidgetTitle($title);
3163 echo '<title>' . htmlspecialchars($title) . '</title>' . M3_NL;
3165 $title = $row['wd_name'];
3166 if (empty($title)) $title = $row['wd_id'];
3167 $gEnvManager->setCurrentWidgetTitle($title);
3168 echo '<title>' . self::WIDGET_TITLE_START . htmlspecialchars($title) . self::WIDGET_TITLE_END . '</title>' . M3_NL;
3170 echo '</head>' . M3_NL;
3172 // タブでウィンドウを開く場合は背景を透過モードにする
3173 if ($this->isTransparentMode){
3174 echo '<body style="background-color:transparent;">' . M3_NL;
3176 echo '<body>' . M3_NL;
3178 // ウィジェット設定画面用メニューバーの作成
3179 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3180 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3182 $desc = $row['wd_description']; // 説明
3183 $gEnvManager->setCurrentWidgetParams('desc', $desc);
3185 echo self::MENUBAR_TAGS; // メニューバー出力用タグ
3188 if ($this->useBootstrap) echo '<div class="container">' . M3_NL;
3190 // 別ウィンドウで表示のときは、「閉じる」ボタンを表示
3191 if ($cmd == M3_REQUEST_CMD_SHOW_WIDGET || // ウィジェットの単体表示のとき
3192 $cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3193 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット単体実行でフロント画面編集モードのとき
3195 // if ($this->isEditMode){// フロント画面編集モードのとき
3196 if (!empty($openBy)){
3197 // サーバ指定されている場合はサーバ情報を取得
3199 $server = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_SERVER);
3200 if (!empty($server)){
3202 $ret = $this->db->getServerById($server, $row);
3204 $serverName = 'サーバ名:' . $row['ts_name'];// サーバ名
3205 echo '<div align="left" style="float:left;padding-left:30px;"><label>' . convertToHtmlEntity($serverName) . '</label></div>';
3208 // タブ、インナーフレーム、ダイアログ表示以外のときは「閉じる」ボタンを表示
3209 if ($openBy != 'tabs' && $openBy != 'iframe' && $openBy != 'dialog'){ // 以外
3210 if ($openBy == 'logout'){
3211 $titleStr = 'ログアウト';
3212 echo '<div class="m3configclose"><a href="#" onclick="location.href=\'?cmd=logout\';" data-placement="left" data-container="body" title="' . $titleStr . '" rel="m3help"><img src="' . $rootUrl . self::CLOSE_ICON_FILE .
3213 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
3216 echo '<div class="m3configclose"><a href="#" onclick="window.close();" data-placement="left" data-container="body" title="' . $titleStr . '" rel="m3help"><img src="' . $rootUrl . self::CLOSE_ICON_FILE .
3217 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
3223 echo '<div class="m3configprev" style="display:none;"><a id="m3configprev" href="#"><img src="' . $rootUrl . self::PREV_ICON_FILE .
3224 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
3226 echo '<div class="m3confignext" style="display:none;"><a id="m3confignext" href="#"><img src="' . $rootUrl . self::NEXT_ICON_FILE .
3227 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
3230 echo '<!-- Widget Start -->' . M3_NL;
3235 * startWidget(),endWidget()は、以下のコマンドを処理する
3236 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
3237 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
3238 * ・M3_REQUEST_CMD_CONFIG_TEMPLATE(テンプレート設定画面)
3239 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
3241 * @param string $cmd 起動コマンド
3242 * @param string $srcContent HTML出力ソース
3244 function endWidget($cmd, $srcContent)
3246 global $gDesignManager;
3248 // ウィジェット単体表示のときのみ出力
3249 if (!$this->showWidget) return;
3253 $breadcrumbHtml = '';
3254 if (!empty($this->adminSubNavbarDef)) $breadcrumbHtml .= $gDesignManager->createSubMenubar($this->adminSubNavbarDef);
3255 if (!empty($this->adminBreadcrumbDef)) $breadcrumbHtml .= $gDesignManager->createAdminBreadcrumb($this->adminBreadcrumbDef);
3256 $destContent = str_replace(self::MENUBAR_TAGS, $breadcrumbHtml, $srcContent);
3259 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3260 $replaceStr .= '//<![CDATA[' . M3_NL;
3264 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェットの設定管理
3266 $replaceStr .= 'function m3UpdateByConfig(serial){' . M3_NL;
3267 $replaceStr .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
3268 $replaceStr .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
3269 $replaceStr .= M3_INDENT_SPACE . 'm3UpdateParentWindow();' . M3_NL; // 親ウィンドウ更新
3270 $replaceStr .= '}' . M3_NL;
3273 $replaceStr .= 'function hideIEErrors(){' . M3_NL;
3274 $replaceStr .= M3_INDENT_SPACE . 'return true;' . M3_NL;
3275 $replaceStr .= '}' . M3_NL;
3276 $replaceStr .= 'window.onerror = hideIEErrors;' . M3_NL;
3280 $replaceStr .= '$(function(){' . M3_NL;
3282 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3283 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // フロント画面編集モードのとき
3284 if (!empty($this->adminSubNavbarDef) || !empty($this->adminBreadcrumbDef)){
3285 $menubarHeight = $gDesignManager->getSubMenubarHeight();
3286 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("nav.secondlevel").css("margin-top", "0");' . M3_NL;
3287 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("body").css("padding-top", "' . $menubarHeight . 'px");' . M3_NL;
3290 // ##### ウィジェットからの指定による処理 #####
3291 if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
3292 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
3293 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
3294 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
3295 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
3298 $replaceStr .= '});' . M3_NL;
3299 $replaceStr .= '//]]>' . M3_NL;
3300 $replaceStr .= '</script>' . M3_NL;
3301 $destContent = str_replace(self::MENUBAR_SCRIPT_TAGS, $replaceStr, $destContent);
3302 echo $destContent;// 変換したコンテンツを出力
3304 echo '<!-- Widget End -->' . M3_NL;
3307 if ($this->useBootstrap) echo '</div>' . M3_NL;
3309 echo '</body>' . M3_NL;
3310 echo '</html>' . M3_NL;
3313 * Widget単体RSS出力用のHTMLのヘッダ部(headタグ)出力
3315 * Widgetの出力方法は、以下のパターンがある
3316 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
3317 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
3319 * @param string $cmd 起動コマンド
3321 function startWidgetRss($cmd)
3325 * Widget単体RSS出力用のタグを閉じる
3327 * @param string $cmd 起動コマンド
3328 * @param string $rssContent RSS配信内容
3330 function endWidgetRss($cmd, $rssContent)
3332 global $gEnvManager;
3335 if ($this->isAbort) return;
3337 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3340 $lang = $gEnvManager->getCurrentLanguage();
3341 $date = getW3CDate(); // RSS1.0用日付
3342 $copyright = $gEnvManager->getSiteCopyRight(); // 著作権
3343 $title = $this->rssChannel['title']; // タイトル
3344 $link = $this->rssChannel['link']; // RSS取得用URL
3345 $desc = $this->rssChannel['description']; // 説明
3346 $seq = $this->rssChannel['seq']; // 項目の並び順(URL)
3348 switch ($this->rssVersion){ // RSSバージョン
3351 echo '<rdf:RDF xmlns="http://purl.org/rss/1.0/" ';
3352 echo 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
3353 echo 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
3354 echo 'xml:lang="' . $lang . '">' . M3_NL;
3355 echo '<channel rdf:about="' . convertUrlToHtmlEntity($link) . '">' . M3_NL;
3356 echo '<title>' . convertToHtmlEntity($title) . '</title>' . M3_NL;
3357 echo '<link>' . convertUrlToHtmlEntity($link) . '</link>' . M3_NL; // 「convertUrlToHtmlEntity」が必要
3358 echo '<description>' . convertToHtmlEntity($desc) . '</description>' . M3_NL;
3359 echo '<dc:language>' . $lang . '</dc:language>' . M3_NL;
3360 if (!empty($copyright)) echo '<dc:rights>' . convertToHtmlEntity($copyright) . '</dc:rights>' . M3_NL;
3361 echo '<dc:date>' . $date . '</dc:date>' . M3_NL;
3362 echo '<items>' . M3_NL;
3363 if (count($seq) > 0){
3364 echo str_repeat(M3_INDENT_SPACE, 1) . '<rdf:Seq>' . M3_NL;
3365 for ($i = 0; $i < count($seq); $i++){
3366 echo str_repeat(M3_INDENT_SPACE, 2) . '<rdf:li rdf:resource="' . convertUrlToHtmlEntity($seq[$i]) . '" />' . M3_NL;
3368 echo str_repeat(M3_INDENT_SPACE, 1) . '</rdf:Seq>' . M3_NL;
3370 echo '</items>' . M3_NL;
3371 echo '</channel>' . M3_NL;
3373 echo '</rdf:RDF>' . M3_NL;
3380 header("Content-type: text/xml; charset=utf-8");
3383 * 直サーバ接続時のXML出力用のHTMLのヘッダ部(headタグ)出力
3385 * @param string $cmd 起動コマンド
3388 function startWidgetXml($cmd)
3391 //header("Content-type: text/xml; charset=utf-8");
3396 * @param string $cmd 起動コマンド
3399 function endWidgetXml()
3405 * @return string ドキュメントタイプ出力
3407 function getMobileDocType()
3409 global $gEnvManager;
3410 global $gInstanceManager;
3411 global $gRequestManager;
3413 $docTypeStr = ''; // 出力するDocType
3414 $agent = $gInstanceManager->getMobileAgent();
3415 if ($agent->isDoCoMo()){ // ドコモ端末のとき
3416 $htmlVer = $agent->getHTMLVersion();
3419 $docTypeStr = '<!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/1.0) 1.0//EN" "i-xhtml_4ja_10.dtd">';
3422 $docTypeStr = '<!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/1.1) 1.0//EN" "i-xhtml_4ja_10.dtd">';
3425 $docTypeStr = '<!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/2.0) 1.0//EN" "i-xhtml_4ja_10.dtd">';
3428 $docTypeStr = '<!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/2.1) 1.0//EN" "i-xhtml_4ja_10.dtd">';
3431 $docTypeStr = '<!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/2.2) 1.0//EN" "i-xhtml_4ja_10.dtd">';
3434 $docTypeStr = '<!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/2.3) 1.0//EN" "i-xhtml_4ja_10.dtd">';
3437 if (preg_match("/^DoCoMo\/1\.0/i", $gRequestManager->trimServerValueOf('HTTP_USER_AGENT'))){ // mova端末のとき
3438 // mova端末のときはドキュメントタイプなしにすると画面表示可能
3443 } else if ($agent->isEZweb()){ // au端末のとき
3444 if ($agent->isWAP2()){
3445 $docTypeStr = '<!DOCTYPE html PUBLIC "-//OPENWAVE//DTD XHTML 1.0//EN" "http://www.openwave.com/DTD/xhtml-basic.dtd">';
3447 } else if ($agent->isSoftBank()){ // ソフトバンク端末のとき
3448 if ($agent->isTypeW() || $agent->isType3GC()){
3449 $docTypeStr = '<!DOCTYPE html PUBLIC "-//J-PHONE//DTD XHTML Basic 1.0 Plus//EN" "xhtml-basic10-plus.dtd">';
3452 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3453 if (empty($docTypeStr)) $docTypeStr = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
3454 echo $docTypeStr . M3_NL;
3459 * @return string XML宣言
3461 function getDefaultXmlDeclaration()
3463 return '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>';
3466 * HTMLのヘッダ部(headタグ内)出力
3468 * システムに共通な定義をHTMLのheadタグ内に出力する
3469 * mosFunc.phpからも実行されるので、このメソッドは引数なしに固定。
3470 * この関数は、以下の「形式1」または「形式2」でheadタグ内に記述する
3472 * 形式1: <!-- m3:HTMLHeader -->
3473 * 形式2(old style): <?php mosShowHead(); ?>
3475 function getHeader()
3478 $this->outputHead = true; // HTMLヘッダ出力を行ったかどうか
3479 $this->outputByStandardHead = true; // HTML文書の標準のヘッダタグを出力するか
3481 // ##### Magic3システムで必要なヘッダ出力用のタグを埋め込む #####
3482 echo self::HEAD_TAGS; // HTMLヘッダの埋め込みデータ
3485 * HTML文書の標準のヘッダタグを出力
3487 * @return string 標準ヘッダ文字列
3489 function getStandardHead()
3491 global $gEnvManager;
3492 global $gRequestManager;
3494 $headStr = ''; // ヘッダ文字列;
3497 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3499 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
3500 $this->isHtml5 = true;
3502 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
3503 if (intval($tempVer) >= 2) $this->isHtml5 = true;
3507 if ($this->isHtml5){
3508 $headStr .= '<meta charset="' . M3_HTML_CHARSET . '">' . M3_NL;
3510 $headStr .= '<meta http-equiv="content-script-type" content="text/javascript" />' . M3_NL;
3511 $headStr .= '<meta http-equiv="content-style-type" content="text/css" />' . M3_NL;
3512 $headStr .= '<meta http-equiv="content-type" content="application/xhtml+xml; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
3514 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3515 // Bootstrapで必要なMETAタグを追加
3516 $headStr .= '<meta name="viewport" content="width=device-width, initial-scale=1">' . M3_NL;
3520 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 表示位置を表示するとき
3521 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
3523 if ($gEnvManager->getUseSslAdmin()){
3524 $rootUrl = $gEnvManager->getSslRootUrl();
3526 $rootUrl = $gEnvManager->getRootUrl();
3528 $headStr .= '<base href="' . $rootUrl . '/" />' . M3_NL;
3535 * @return string HTMLヘッダ出力文字列
3537 function getHeaderOutput()
3539 global $gEnvManager;
3540 global $gRequestManager;
3541 global $gInstanceManager;
3542 global $gSystemManager;
3544 $replaceStr = ''; // 変換文字列
3547 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3548 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
3549 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
3550 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
3552 // ********************************************************
3554 // ********************************************************
3555 // ##### テンプレートの設定、フレームの設定から必要なライブラリを取得 #####
3557 // if (!$this->useBootstrap) $this->useBootstrap = $gEnvManager->getCurrentTemplateUseBootstrap();
3558 if ($this->useBootstrap){
3559 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3560 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3561 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
3562 if ($cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)以外のとき
3563 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3565 // テンプレートタイプが管理画面のBootstrapバージョン(v3.0)と異なる場合はBootstrapを使用しない場合の管理機能用スクリプトを読み込む
3566 $templateType = $gEnvManager->getCurrentTemplateType();
3567 if ($templateType != 10) $this->addAdminScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3569 } else { // ログインしていない場合(ログイン画面等)
3570 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP);
3571 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP_ADMIN);// Bootstrap管理画面オプション
3573 } else { // フロント画面へのアクセスの場合
3574 // ### Bootstrapのjsとcssはテンプレート側で読み込む ###
3575 // ### フロントからプレビューコマンドでログイン画面を表示させるパターンがあるので注意 ###
3576 // if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW || // ログイン、ログアウト場合
3577 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || ($cmd == M3_REQUEST_CMD_PREVIEW && !$gEnvManager->isCurrentUserLogined()) || // ログイン、ログアウト場合
3578 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
3580 $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3582 if ($gEnvManager->isSystemManageUser() || // システム運用権限がある場合
3583 $gEnvManager->isContentEditableUser()){ // 投稿ユーザの場合
3584 // テンプレートタイプが管理画面のBootstrapバージョン(v3.0)と異なる場合はBootstrapを使用しない場合の管理機能用スクリプトを読み込む
3585 $templateType = $gEnvManager->getCurrentTemplateType();
3586 if ($templateType != 10) $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3591 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3592 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3593 $this->addAdminScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3595 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3597 } else if ($gEnvManager->isContentEditableUser()){ // 投稿ユーザの場合
3598 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3602 // ********************************************************
3604 // ********************************************************
3605 // ##### インストール時のヘッダ出力 #####
3606 if (defined('M3_STATE_IN_INSTALL')){
3609 if (count($this->headSubTitle) > 0) $title = htmlspecialchars(trim($this->headSubTitle[0]));
3611 // ********** メタタグの設定 **********
3612 $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3614 // ##### インストーラ用のファイルの読み込み #####
3615 $scriptsUrl = '../scripts';
3617 // 管理機能用共通ライブラリのCSSの読み込み
3618 $count = count($this->defaultAdminCssFiles);
3619 for ($i = 0; $i < $count; $i++){
3621 $cssFilename = $this->defaultAdminCssFiles[$i];
3622 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3623 $cssURL = $cssFilename;
3625 $cssURL = $scriptsUrl . '/' . $cssFilename;
3627 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3630 // 管理画面用の共通スクリプトを読み込む
3631 $count = count($this->defaultAdminScriptFiles);
3632 for ($i = 0; $i < $count; $i++){
3633 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3636 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3637 $scriptURL = $scriptFilename;
3641 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3643 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3646 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3649 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3650 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3651 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3654 // ##### ページへJavascriptの埋め込む #####
3655 // JavaScriptグローバル変数の設定
3656 $rootUrl = $gEnvManager->getRootUrl();
3657 if (empty($rootUrl)) $rootUrl = $gEnvManager->calcSystemRootUrl();
3658 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3659 $replaceStr .= '//<![CDATA[' . M3_NL;
3660 $replaceStr .= '// Magic3 Global values' . M3_NL;
3661 if (!empty($rootUrl)) $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3662 $replaceStr .= '//]]>' . M3_NL;
3663 $replaceStr .= '</script>' . M3_NL;
3668 $cleanType = $gEnvManager->getCurrentTemplateCleanType(); // テンプレートクリーンタイプ
3669 /* if ($this->db->getTemplate($gEnvManager->getCurrentTemplateId(), $templateRow)){
3670 $cleanType = $templateRow['tm_clean_type'];
3675 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3677 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
3679 $isSslPage = $this->isSslPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
3682 $rootUrl = $gEnvManager->getSslRootUrl();
3683 $scriptsUrl = $gEnvManager->getSslScriptsUrl(); // スクリプト読み込み用パス
3684 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
3685 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
3687 $rootUrl = $gEnvManager->getRootUrl();
3688 $scriptsUrl = $gEnvManager->getScriptsUrl(); // スクリプト読み込み用パス
3689 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
3690 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
3694 if (!$this->showWidget){// 単体実行以外のとき
3695 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスの場合
3697 // メイン画面は「サイト名 - 管理画面」、サブ画面は個別画面名
3698 $siteName = $gEnvManager->getSiteName();
3699 // if (empty($siteName)) $siteName = self::DEFAULT_SITE_NAME;
3700 $title = $siteName . ' - ' . self::DEFAULT_ADMIN_TITLE;
3701 $titleCount = count($this->headSubTitle);
3702 if ($titleCount > 0) $title = $this->headSubTitle[$titleCount -1]; // サブタイトルが設定されている場合は変更
3703 $replaceStr .= '<title>' . htmlspecialchars($title) . '</title>' . M3_NL;
3705 // その他HTMLヘッダに出力するタグ文字列
3706 if (!empty($this->adminHeadOthers)){
3708 $this->adminHeadOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->adminHeadOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3709 $replaceStr .= $this->adminHeadOthers . M3_NL;
3711 } else { // 管理画面以外の画面へのアクセスの場合
3713 $titleItemCount = 0; // タイトル項目数
3714 $defaultTitle = trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_TITLE));
3715 if (!empty($defaultTitle)) $titleItemCount++;
3716 if (!empty($this->headSubTitle)){ // サブタイトルが設定されているとき
3717 $titleItemCount += count($this->headSubTitle);
3721 if ($titleItemCount > 0){
3722 $format = $this->gSystem->getSystemConfig(self::CONFIG_KEY_HEAD_TITLE_FORMAT);
3723 if (empty($format)){
3724 $title = htmlspecialchars($defaultTitle);
3726 $formats = explode(';', $format);
3727 $titleItemCount = ($titleItemCount > count($formats)) ? count($formats) : $titleItemCount;
3728 $title = $formats[$titleItemCount -1];
3730 if (!empty($defaultTitle)){
3731 $title = str_replace('$1', htmlspecialchars($defaultTitle), $title);
3734 for ($i = 0; $i < count($this->headSubTitle); $i++){
3735 $key = '$' . $number;
3736 $value = htmlspecialchars(trim($this->headSubTitle[$i]));
3737 $title = str_replace($key, $value, $title);
3742 if (!empty($title)) $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3745 if (!empty($this->headDescription)) $replaceStr .= '<meta name="description" content="' . htmlspecialchars($this->headDescription) . '" />' . M3_NL;
3748 if (!empty($this->headKeywords)) $replaceStr .= '<meta name="keywords" content="' . htmlspecialchars($this->headKeywords) . '" />' . M3_NL;
3750 // その他HTMLヘッダに出力するタグ文字列
3751 if (!empty($this->headOthers)){
3753 $this->headOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->headOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3754 $replaceStr .= $this->headOthers . M3_NL;
3759 // ##### PC用URLと携帯用URLのアクセス別に処理 #####
3760 if ($gEnvManager->getIsMobileSite()){ // 携帯用URLのとき
3761 } else { // PC用URLまたはスマートフォン用URLのとき
3762 // ##### テンプレート情報に応じた処理 #####
3763 // テンプレートクリーンが必要な場合はJQueryを追加
3764 if ($cleanType != 0) $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
3767 $robots = htmlspecialchars(trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_ROBOTS)));
3768 if (!empty($robots)){
3769 $replaceStr .= '<meta name="robots" content="' . $robots . '" />' . M3_NL;
3773 $replaceStr .= '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
3775 // カノニカル属性、Faviconの読み込み
3776 $templateId = $gEnvManager->getCurrentTemplateId();
3777 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3778 // テンプレートのFaviconがない場合はシステムのデフォルトのFaviconを使用
3779 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3780 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3781 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3782 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3785 $faviconPath = $gEnvManager->getSystemRootPath() . self::DEFAULT_ADMIN_FAVICON_FILE;
3786 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3787 $faviconFile = $rootUrl . self::DEFAULT_ADMIN_FAVICON_FILE;
3788 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3793 if (!empty($this->headCanonicalUrl)) $replaceStr .= '<link rel="canonical" href="' . convertUrlToHtmlEntity($this->headCanonicalUrl) .'" />' . M3_NL; // カノニカル属性URL
3796 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3797 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3798 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3799 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3802 // ##### 追加ライブラリの読み込み #####
3803 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用URLのとき
3804 $value = $gSystemManager->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面で常にjQuery Mobileを使用
3806 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
3807 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
3808 for ($l = 0; $l < count($this->headPreMobileScriptFiles); $l++){
3809 $this->addScriptFile($this->headPreMobileScriptFiles[$l]); // 通常機能用のスクリプト追加
3812 $this->addScriptFile($this->selectedJQueryMobileFilename);
3816 // ##### Ajaxライブラリの読み込み #####
3817 if (!$gEnvManager->isAdminDirAccess()){ // 通常画面へのアクセスのとき
3818 if ($this->db->isExistsWidgetWithAjax($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId())){// Ajaxライブラリを使用しているウィジェットがあるときは追加
3819 $this->addScriptFile($this->selectedJQueryFilename); // デフォルトAjaxライブラリ追加
3820 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
3824 // ##### 共通ライブラリの読み込み #####
3825 if (!$this->showWidget){// 単体実行以外のとき
3826 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3827 for ($i = 0; $i < count($rows); $i++){
3828 $this->addScript($task, trim($rows[$i]['wd_add_script_lib']));
3832 // ##### 共通CSS読み込み #####
3833 if (($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()) || $this->isEditMode){ // フロント画面編集モード
3834 $cssURL = $scriptsUrl . '/' . self::M3_EDIT_CSS_FILE;
3835 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3837 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3838 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
3839 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3840 // 管理機能用共通ライブラリのCSSの読み込み
3841 $count = count($this->defaultAdminCssFiles);
3842 for ($i = 0; $i < $count; $i++){
3844 //$cssURL = $scriptsUrl . '/' . $this->defaultAdminCssFiles[$i];
3845 $cssFilename = $this->defaultAdminCssFiles[$i];
3846 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3847 $cssURL = $cssFilename;
3849 $cssURL = $scriptsUrl . '/' . $cssFilename;
3851 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3854 // 管理権限なしで管理ディレクトリアクセスで必要なCSSファイルを読み込む
3855 $count = count($this->defaultAdminDirCssFiles);
3856 for ($i = 0; $i < $count; $i++){
3858 $cssURL = $scriptsUrl . '/' . $this->defaultAdminDirCssFiles[$i];
3859 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3864 $count = count($this->defaultCssFiles);
3865 for ($i = 0; $i < $count; $i++){
3867 $cssFilename = $this->defaultCssFiles[$i];
3868 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3869 $cssURL = $cssFilename;
3871 $cssURL = $scriptsUrl . '/' . $cssFilename;
3873 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3877 // ##### 表示モードによるCSS読み込み #####
3878 // ウィジェット付きポジション画面は管理画面のアクセスではない
3879 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3881 $cssURL = $scriptsUrl . self::M3_ADMIN_WIDGET_CSS_FILE;
3882 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3885 // ##### ウィジェットごとのCSS読み込み #####
3887 $this->db->getWidgetsIdWithCss($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3888 for ($i = 0; $i < count($rows); $i++){
3889 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS;
3890 // ディレクトリがあるときはディレクトリ内読み込み
3891 if (is_dir($searchPath)){
3892 $dir = dir($searchPath);
3893 while (($file = $dir->read()) !== false){
3894 $filePath = $searchPath . '/' . $file;
3895 if ($file != '.' && $file != '..' && is_file($filePath)
3896 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3899 $cssURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS . '/' . $file;
3900 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3906 // ##### 外部出力用CSS読み込み #####
3907 // ウィジェットからの追加のCSS読み込み
3908 $count = count($this->headCssFiles);
3909 for ($i = 0; $i < $count; $i++){
3910 $cssUrl = $this->headCssFiles[$i];
3911 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3912 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3915 // 外部出力用CSSデータがある場合はURLを追加
3916 if (!empty($this->exportCss)){
3917 $cssUrl = $this->createCssCmdUrl($isSslPage, date('YmdHis'));
3918 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3919 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3922 // ##### RSS配信情報の読み込み #####
3923 $count = count($this->headRssFiles);
3924 for ($i = 0; $i < $count; $i++){
3925 $rssUrl = $this->headRssFiles[$i]['href'];// リンク先URL
3926 $rssTitle = $this->headRssFiles[$i]['title'];// タイトル
3927 $replaceStr .= '<link rel="alternate" type="application/rss+xml" title="' . $rssTitle . '" href="' . convertUrlToHtmlEntity($rssUrl) . '" />' . M3_NL;
3930 // ##### 共通Javascriptの読み込み #####
3931 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3932 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3933 // 管理画面用の共通スクリプトを読み込む
3934 $count = count($this->defaultAdminScriptFiles);
3935 for ($i = 0; $i < $count; $i++){
3936 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3939 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3940 $scriptURL = $scriptFilename;
3944 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3946 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3949 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3952 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3953 //$scriptURL = $scriptsUrl . '/' . $scriptFilename;
3954 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3955 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3957 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示のときは、ウィジェット操作ライブラリを読み込む
3959 $scriptURL = $scriptsUrl . '/' . self::M3_ADMIN_WIDGET_SCRIPT_FILENAME;
3960 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();// スクリプトをキャッシュ保存しない場合は、パラメータを付加
3961 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3963 } else { // システム運用権限がない場合
3964 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3965 $count = count($this->defaultAdminDirScriptFiles);
3966 for ($i = 0; $i < $count; $i++){
3967 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3969 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3970 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3971 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3972 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3976 // Googleマップライブラリの読み込み
3977 if ($this->useGooglemaps && $this->isContentGooglemaps) $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS)); // コンテンツにGoogleマップが含むかどうか
3979 $useExternalJquery = $gSystemManager->getSystemConfig(self::CF_EXTERNAL_JQUERY); // システム外部のjQueryを使用するかどうか
3981 $count = count($this->defaultScriptFiles);
3982 for ($i = 0; $i < $count; $i++){
3983 $defaultScriptFile = $this->defaultScriptFiles[$i];
3985 // 外部のjQueryを使用する場合はSCRIPTタグを出力しない
3986 if ($defaultScriptFile == $this->selectedJQueryFilename && $useExternalJquery) continue;
3988 // ##### jQueryMobileスクリプトを追加する場合は直前に初期化スクリプトを追加 #####
3989 if ($defaultScriptFile == $this->selectedJQueryMobileFilename){
3990 if (count($this->headPreMobileScript) > 0){
3991 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3992 $replaceStr .= '//<![CDATA[' . M3_NL;
3993 for ($j = 0; $j < count($this->headPreMobileScript); $j++){
3994 $replaceStr .= $this->headPreMobileScript[$j];
3996 $replaceStr .= M3_NL;
3997 $replaceStr .= '//]]>' . M3_NL;
3998 $replaceStr .= '</script>' . M3_NL;
4003 if (strncasecmp($defaultScriptFile, 'http://', 7) == 0 || strncasecmp($defaultScriptFile, 'https://', 8) == 0){
4004 $scriptURL = $defaultScriptFile;
4008 $scriptURL = str_replace('http://', 'https://', $scriptURL);
4010 $scriptURL = str_replace('https://', 'http://', $scriptURL);
4013 $scriptURL = $scriptsUrl . '/' . $defaultScriptFile;
4016 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
4017 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
4018 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
4021 // ### フロントからプレビューコマンドでログイン画面を表示させるパターンがあるので注意 ###
4022 // if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW){ // ログイン、ログアウト場合
4023 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || ($cmd == M3_REQUEST_CMD_PREVIEW && !$gEnvManager->isCurrentUserLogined())){ // ログイン、ログアウト場合
4024 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
4025 $count = count($this->defaultAdminDirScriptFiles);
4026 for ($i = 0; $i < $count; $i++){
4027 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
4028 if (!in_array($scriptFilename, $this->defaultScriptFiles)){ // 既に追加されていない場合のみ追加
4029 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
4030 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
4031 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
4032 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
4037 // ***** [WordPressテンプレート] jQueryの読み込み後、ヘッダ部に出力するテンプレート用のJavascriptがあれば読み込む *****
4038 $headData = $this->gEnv->getWpHeadScriptsData();
4039 if (!empty($headData)) $replaceStr .= $headData;
4041 // ##### ウィジェットごとのJavaScript読み込み #####
4042 // スクリプトがあるウィジェットを取得
4043 $this->db->getWidgetsIdWithScript($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
4044 for ($i = 0; $i < count($rows); $i++){
4045 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS;
4047 // ディレクトリがあるときはディレクトリ内読み込み
4048 if (is_dir($searchPath)){
4049 $dir = dir($searchPath);
4050 while (($file = $dir->read()) !== false){
4051 $filePath = $searchPath . '/' . $file;
4052 if ($file != '.' && $file != '..' && is_file($filePath)
4053 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
4056 $scriptURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
4057 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
4058 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
4059 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
4065 // ウィジェットからの追加のCSS読み込み
4066 $count = count($this->headScriptFiles);
4067 for ($i = 0; $i < $count; $i++){
4068 $scriptUrl = $this->headScriptFiles[$i];
4069 if ($isSslPage) $scriptUrl = str_replace('http://', 'https://', $scriptUrl); // SSL化が必要なときは変換
4071 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
4072 if (!$this->hasScriptCache) $scriptUrl .= $this->getCacheParam();
4073 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptUrl) . '"></script>' . M3_NL;
4077 $openType = $this->gSystem->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE);// ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
4079 // ##### ページへJavascriptの埋め込む #####
4080 // JavaScriptグローバル変数の設定
4081 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
4082 //$replaceStr .= '<!--' . M3_NL;
4083 $replaceStr .= '<script type="text/javascript">' . M3_NL;
4084 $replaceStr .= '//<![CDATA[' . M3_NL;
4085 $replaceStr .= '// Magic3 Global values' . M3_NL;
4086 $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
4088 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()){ // 管理画面へのアクセス、システム運用権限があり
4089 $pageId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID); // ページID
4090 $pageSubId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);// ページサブID
4093 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
4094 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
4097 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
4098 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
4100 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4103 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4104 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4105 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4107 // Googleマップライブラリの読み込み
4108 if ($this->useGooglemaps){
4109 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
4111 // CKEditor拡張プラグイン用の定義
4112 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
4113 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
4115 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
4119 if ($this->isPersonalMode){
4120 $replaceStr .= 'var M3_PERSONAL_MODE = true;' . M3_NL;
4122 $replaceStr .= 'var M3_PERSONAL_MODE = false;' . M3_NL;
4124 // 管理画面の小画面デバイス最適化を行うかどうか
4125 if ($gEnvManager->isSmallDeviceAdmin()){
4126 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = true;' . M3_NL;
4128 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = false;' . M3_NL;
4131 // ウィジェット詳細設定画面専用のJavaScriptグローバル変数
4132 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){
4133 //if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE){ // ウィジェット設定画面またはテンプレート設定画面のとき
4134 // ##### CKEditor用の設定 #####
4135 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
4137 // CKEditor用のCSSファイル
4138 if (!empty($this->ckeditorCssFiles)){
4139 // 編集エリア用のCSSファイルを追加
4140 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4141 //array_unshift($this->ckeditorCssFiles, $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE);
4143 //$fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
4144 $fileList = implode(', ', array_map(function($a){ return "'" . $a . "'"; }, $this->ckeditorCssFiles));
4145 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4147 // CKEditor用(レイアウト)のCSSファイル
4148 $cssFiles = array();
4149 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_ADMIN_CSS; // BootstrapのCSSを追加
4150 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4151 // $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
4152 $fileList = implode(', ', array_map(function($a){ return "'" . $a . "'"; }, $cssFiles));
4153 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4155 // CKEditor用のテンプレートタイプ
4156 if (isset($this->ckeditorTemplateType)){
4157 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
4159 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION){ // ポジション表示
4160 $replaceStr .= 'var M3_POSITION_DATA = "' . implode(',', $this->defPositions) . '";' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
4161 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = 0;' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
4162 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
4164 $positionData = $this->getRestPositionData();
4167 if (count($this->viewPosId) > 0){
4169 for ($i = 0; $i < count($this->viewPosId); $i++){
4170 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
4171 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
4173 $posArrayStr .= ']';
4174 $replaceStr .= 'var M3_POSITIONS = ' . $posArrayStr . ';' . M3_NL;
4177 $replaceStr .= 'var M3_REVISION = ' . $this->pageDefRev . ';' . M3_NL;
4180 $replaceStr .= 'var M3_REST_POSITION_DATA = \'' . $positionData . '\';' . M3_NL;
4181 } else if (!empty($pageId)){
4182 $accessPoint = $this->gEnv->getAllDefaultPageId();
4183 for ($i = 0; $i < count($accessPoint); $i++){
4184 if ($pageId == $accessPoint[$i]){
4185 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $i . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
4189 } else { // メインの管理画面の場合
4190 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = 0;' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
4193 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
4194 if (!empty($task)){ // 戻りタスクが設定されているときのみ最大化可能
4195 $replaceStr .= 'function gobackPagedef(){' . M3_NL;
4196 $replaceStr .= ' window.location.href = "' . $gEnvManager->getDefaultAdminUrl() . '?pageid=' . $pageId . '&pagesubid=' . $pageSubId . '&task=' . $task . '";' . M3_NL;
4197 $replaceStr .= '}' . M3_NL;
4198 $replaceStr .= '$(function(){' . M3_NL;
4199 $replaceStr .= ' $(document).keyup(function(e){' . M3_NL;
4200 $replaceStr .= ' if (e.which == 36) gobackPagedef();' . M3_NL;
4201 $replaceStr .= ' });' . M3_NL;
4202 $replaceStr .= '});' . M3_NL;
4205 // ##### 管理用テンプレートを使用している場合の処理 #####
4206 // Bootstrap用のスクリプト処理
4207 if ($this->useBootstrap){
4208 $replaceStr .= '$(function(){' . M3_NL;
4209 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
4210 $replaceStr .= '});' . M3_NL;
4213 } else if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4214 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
4215 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
4218 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
4219 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
4221 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4224 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4225 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4226 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4228 // Googleマップライブラリの読み込み
4229 if ($this->useGooglemaps){
4230 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
4232 // CKEditor拡張プラグイン用の定義
4233 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
4234 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
4236 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
4240 if ($this->isPersonalMode){
4241 $replaceStr .= 'var M3_PERSONAL_MODE = true;' . M3_NL;
4243 $replaceStr .= 'var M3_PERSONAL_MODE = false;' . M3_NL;
4247 $templateType = $gEnvManager->getCurrentTemplateType();
4248 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4249 } else if ($this->isEditMode){ // フロント画面編集モード(コンテンツ編集可能ユーザ)
4250 if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
4252 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4255 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4256 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4257 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4259 // Googleマップライブラリの読み込み
4260 if ($this->useGooglemaps){
4261 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
4263 // CKEditor拡張プラグイン用の定義
4264 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
4265 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
4267 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
4270 // 起動がパーソナルモードかどうか(常にパーソナルモード)
4271 $replaceStr .= 'var M3_PERSONAL_MODE = true;' . M3_NL;
4273 // 管理画面の小画面デバイス最適化を行うかどうか
4274 if ($gEnvManager->isSmallDeviceAdmin()){
4275 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = true;' . M3_NL;
4277 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = false;' . M3_NL;
4280 // ##### CKEditor用の設定 #####
4282 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
4283 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
4285 // CKEditor用のCSSファイル
4286 if (!empty($this->ckeditorCssFiles)){
4287 // 編集エリア用のCSSファイルを追加
4288 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4289 //array_unshift($this->ckeditorCssFiles, $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE);
4291 // $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
4292 $fileList = implode(', ', array_map(function($a){ return "'" . $a . "'"; }, $this->ckeditorCssFiles));
4293 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4295 // CKEditor用(レイアウト)のCSSファイル
4296 $cssFiles = array();
4297 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_ADMIN_CSS; // BootstrapのCSSを追加
4298 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4299 // $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
4300 $fileList = implode(', ', array_map(function($a){ return "'" . $a . "'"; }, $cssFiles));
4301 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4303 // CKEditor用のテンプレートタイプ
4304 if (isset($this->ckeditorTemplateType)){
4305 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
4308 // Bootstrap用のスクリプト処理
4309 if ($this->useBootstrap){
4310 $replaceStr .= '$(function(){' . M3_NL;
4311 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
4312 $replaceStr .= '});' . M3_NL;
4315 // プレビュー画面用にテンプレートタイプを出力
4316 $templateType = $gEnvManager->getCurrentTemplateType();
4317 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4319 // ##### ヘルプシステムの組み込み #####
4320 if ($this->useHelp){ // ヘルプ表示のとき
4321 $replaceStr .= '$(function(){' . M3_NL;
4322 $replaceStr .= ' if (jQuery().tooltip) $(\'[rel=m3help]\').tooltip({ placement: \'top\'});' . M3_NL;
4323 $replaceStr .= '});' . M3_NL;
4327 if (!$gEnvManager->isAdminDirAccess()){ // フロント画面のとき
4328 // テンプレートタイプを追加(ファイルローダ等で使用)
4329 $templateType = $gEnvManager->getCurrentTemplateType();
4330 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4334 // ##### パネルメニュー(フロント画面と管理画面の切り替え等)の表示 #####
4335 // PC用、携帯用、スマートフォン用画面とウィジェット付きポジションの管理画面時に表示
4336 if (($gEnvManager->isAdminDirAccess() && $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) || // 管理画面(ウィジェット付きポジション表示)のとき
4337 (!$gEnvManager->isAdminDirAccess() && // 一般用画面のとき
4338 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4339 $cmd != M3_REQUEST_CMD_RSS)){ // RSS配信でない
4340 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
4341 if ($gEnvManager->isSystemManageUser()){ // システム運用権限ありの場合
4343 $menubarTag = ''; // 管理用メニューバー
4344 $adminTag = ''; // 管理画面ボタン
4345 $editTag = ''; // 編集ボタン
4346 $logoutTag = ''; // ログアウトボタン
4348 if ($gEnvManager->isAdminDirAccess()){ // 管理画面(ウィジェット付きポジション表示)の場合
4350 /* $titleStr = '編集終了';
4351 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4352 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4353 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
4354 $editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
4357 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4358 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4359 //$editTag = '<div class="m3editend"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4360 //$editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" /></a></div>';
4361 $editTag = '<div class="m3editend m3topright"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4362 $editTag .= '<i class="glyphicon glyphicon-ok-sign"></i></a></div>';
4363 $menubarTag .= $editTag;
4365 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4366 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4367 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").prepend(\'' . $menubarTag . '\');' . M3_NL; // appendでうまく表示できないのでprependで表示
4368 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4369 } else if ($this->isAccessPointWithAdminMenu){ // 通常画面は、管理メニューを使用するアクセスポイントの場合のみ表示
4371 $titleStr = '管理画面へ遷移';
4372 $linkUrl = $gEnvManager->getDefaultAdminUrl();
4373 $adminTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4374 $adminTag .= '<img src="' . $rootUrl . self::ADMIN_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4377 $titleStr = '画面を編集';
4378 $linkUrl = $gEnvManager->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' .M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET;
4379 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_ID . '=' . $gEnvManager->getCurrentPageId();
4380 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
4381 $linkUrl .= '&' . M3_REQUEST_PARAM_BACKUP_URL . '=' . urlencode($gEnvManager->getCurrentRequestUri()); // URL退避用
4382 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4383 $editTag .= '<img src="' . $rootUrl . self::EDIT_PAGE_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4386 $titleStr = 'ログアウト';
4387 // if ($gEnvManager->isAdminDirAccess()){ // 管理画面の場合
4388 // $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4389 // if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4391 $linkUrl = $gEnvManager->getCurrentRequestUri();
4393 $linkUrl = createUrl($linkUrl, M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_LOGOUT);
4394 $logoutTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4395 $logoutTag .= '<img src="' . $rootUrl . self::LOGOUT_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4398 $widgetToolTag .= '<li><div class="m3widgettoolbutton m3-nav m3-navbar-nav" data-toggle="buttons">';
4399 $widgetToolTag .= '<button type="button" class="m3-navbar-btn btn btn-sm" data-color="success" rel="m3help" data-placement="bottom" data-container="body" title="ウィジェットツール"><span class="title"> ウィジェットツール</span></button>';
4400 $widgetToolTag .= '<input type="checkbox" class="hidden" />';
4401 $widgetToolTag .= '</div></li>';
4403 //$menubarTag .= '<div id="m3slidepanel">';
4404 $menubarTag .= '<div id="m3slidepanel" class="m3panel_top m3-navbar-default" style="top:-60px; visibility: visible;">';
4405 $menubarTag .= '<div class="m3panelopener m3topleft"><a href="#" rel="m3help" data-placement="bottom" data-container="body" title="メニューバーを表示"><i class="glyphicon glyphicon-align-justify"></i></a></div>';
4406 // $menubarTag .= '<div tabindex="0" class="m3panel_wrap">';
4407 $menubarTag .= '<div>';
4408 $menubarTag .= '<ul class="m3-nav m3-navbar-nav">';
4409 if ($gEnvManager->isSystemAdmin()){ // 管理画面、編集モードは、管理者権限がある場合のみ有効
4410 $menubarTag .= $adminTag;
4411 $menubarTag .= $editTag;
4413 $menubarTag .= $logoutTag;
4414 $menubarTag .= $widgetToolTag;
4415 $menubarTag .= '</ul>';
4416 $menubarTag .= '</div>';
4417 $menubarTag .= '</div>';
4418 // $menubarTag .= '</div>';
4420 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4421 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4422 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").append(\'' . $menubarTag . '\');' . M3_NL;
4423 //$this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("#m3slidemenubarpanel").m3SlideMenubar();' . M3_NL;
4424 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(".m3panel_top").m3slidepanel({ "position": "top", "type": "push" });' . M3_NL;
4425 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").css("position", "relative");' . M3_NL;
4426 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetHelp($(\'#m3slidepanel\'));' . M3_NL;
4427 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetupWidgetTool(\'m3widgettoolbutton\');' . M3_NL;
4428 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4432 // ##### フロント画面からのウィジェット操作用ツールバー #####
4433 if (!$gEnvManager->isAdminDirAccess() &&
4434 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4435 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
4436 if ($gEnvManager->isSystemManageUser()){ // 一般用画面で管理者権限がある場合のみ有効
4438 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').each(function(){' . M3_NL;
4439 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var attrs = m3_splitAttr($(this).attr(\'m3\'));' . M3_NL;
4440 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var widgetId = attrs[\'widgetid\'];' . M3_NL;
4441 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var serialNo = attrs[\'serial\'];' . M3_NL;
4442 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var configId = attrs[\'configid\'];' . M3_NL;
4443 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var useconfig = attrs[\'useconfig\'];' . M3_NL;
4445 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'\';' . M3_NL;
4446 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (useconfig == 1){' . M3_NL;
4447 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4448 'html += \'<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\\\'\' + widgetId + \'\\\', \' + configId + \', \' + serialNo + \');return false;" rel="m3help" data-container="body" title="ウィジェット設定">' .
4449 '<img src="' . $rootUrl . self::CONFIG_ICON32_FILE . '" alt="ウィジェット設定" width="32" height="32" /></a>\';' . M3_NL;
4450 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4451 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4452 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) .
4453 'html += \'<a href="javascript:void(0);" onclick="m3ShowAdjustWindow(\' + configId + \', \' + serialNo + \', M3_PAGE_ID, M3_PAGE_SUB_ID);return false;" rel="m3help" data-container="body" title="タイトル・スタイル調整">' .
4454 '<img src="' . $rootUrl . self::ADJUST_ICON32_FILE . '" alt="タイトル・スタイル調整" width="32" height="32" /></a>\';' . M3_NL;
4456 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (html != \'\'){' . M3_NL;
4457 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4458 'html = \'<div class="m3tooltip" style="display:none;">\' + html + \'<a class="m3closebox" href="javascript:void(0);" rel="m3help" data-container="body" title="閉じる">' .
4459 '<img src="' . $rootUrl . self::CLOSE_BOX_ICON32_FILE . '" alt="閉じる" width="11" height="11" /></a></div>\';' . M3_NL;
4461 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).append(html);' . M3_NL;
4462 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4464 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).click(function(){' . M3_NL;
4465 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4466 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (tooltipObj.css(\'display\') == \'none\'){' . M3_NL;
4467 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (_m3ShowWidgetTool){' . M3_NL;
4468 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'tooltipObj.show();' . M3_NL;
4469 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4470 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4471 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.hide();' . M3_NL;
4472 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4473 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4474 // ウィジェットボーダーハイライト、ツールチップ表示
4475 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).hover(function(){' . M3_NL;
4476 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4477 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(this).addClass(\'m3_widget_highlight\');' . M3_NL;
4478 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4479 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var pos = $(this).position();' . M3_NL;
4480 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var width = $(this).outerWidth();' . M3_NL;
4481 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipWidth = tooltipObj.outerWidth(true);' . M3_NL;
4482 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var x = pos.left + width - tooltipWidth;' . M3_NL;
4483 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var y = pos.top;' . M3_NL;
4484 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.css({position: "absolute",top: y + "px", left: x + "px"}).show();' . M3_NL;
4485 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4486 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}, function(){' . M3_NL;
4487 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).removeClass(\'m3_widget_highlight\');' . M3_NL;
4488 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4489 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'tooltipObj.hide();' . M3_NL;
4490 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4492 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3closebox\').click(function(event){' . M3_NL;
4493 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).children(\'.m3tooltip\').hide();' . M3_NL;
4494 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4496 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4497 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var offset = $(this).offset();' . M3_NL;
4498 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).outerWidth();' . M3_NL;
4499 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3edittool\').each(function(){' . M3_NL;
4500 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).offset({left: offset.left});' . M3_NL;
4501 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).width(width);' . M3_NL;
4502 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4503 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4506 $this->initScript .= M3_INDENT_SPACE . 'var widgetWindow = \'<div class="m3_contextmenu" id="m3_widgetmenu" style="visibility:hidden;">\';' . M3_NL;
4507 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<ul>\';' . M3_NL;
4508 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<li id="m3_wconfig"><img src="\' + M3_ROOT_URL + \'/images/system/config.png" /> <span>ウィジェットの設定</span></li>\';' . M3_NL;
4509 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4510 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<li id="m3_wadjust"><img src="\' + M3_ROOT_URL + \'/images/system/adjust_widget.png" /> <span>タイトル・スタイル調整</span></li>\';' . M3_NL;
4512 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</ul>\';' . M3_NL;
4513 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</div>\';' . M3_NL;
4514 $this->initScript .= M3_INDENT_SPACE . '$("body").append(widgetWindow);' . M3_NL;
4515 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').contextMenu(\'m3_widgetmenu\', {' . M3_NL;
4516 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'menuStyle: {' . M3_NL;
4517 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// border : "2px solid green",' . M3_NL;
4518 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'backgroundColor: \'#FFFFFF\',' . M3_NL;
4519 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'width: "150px",' . M3_NL;
4520 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'textAlign: \'left\',' . M3_NL;
4521 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'font: \'12px/1.5 Arial, sans-serif\'' . M3_NL;
4522 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4523 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'itemStyle: {' . M3_NL;
4524 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'padding: \'3px 3px\'' . M3_NL;
4525 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4526 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'bindings: {' . M3_NL;
4527 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wconfig\': function(t){' . M3_NL;
4528 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4529 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4530 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'alert("このウィジェットには設定画面がありません");' . M3_NL;
4531 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'return;' . M3_NL;
4532 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4533 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowConfigWindow(attrs[\'widgetid\'], attrs[\'configid\'], attrs[\'serial\']);' . M3_NL;
4534 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '},' . M3_NL;
4535 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wadjust\': function(t){' . M3_NL;
4536 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4537 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowAdjustWindow(attrs[\'configid\'], attrs[\'serial\'], M3_PAGE_ID, M3_PAGE_SUB_ID);' . M3_NL;
4538 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4539 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4540 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onContextMenu: function(e){' . M3_NL;
4541 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4542 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return true;' . M3_NL;
4543 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4544 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return false;' . M3_NL;
4545 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4546 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4547 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onShowMenu: function(e, menu){' . M3_NL;
4548 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// メニュー項目の変更' . M3_NL;
4549 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var attrs = m3_splitAttr($(e.target).parents(\'dl\').attr(\'m3\'));' . M3_NL;
4550 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4551 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(\'#m3_wconfig\', menu).remove();' . M3_NL;
4552 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4553 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'return menu;' . M3_NL;
4554 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4555 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4558 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3content_private\').each(function(){' . M3_NL;
4559 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4560 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var top = pos.top;' . M3_NL;
4561 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var left = pos.left;' . M3_NL;
4562 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).css(\'width\');' . M3_NL;
4563 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var height = $(this).css(\'height\');' . M3_NL;
4564 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'<div class="m3content_overlay"><div><h2>非公開</h2></div></div>\';' . M3_NL;
4565 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).prepend(html);' . M3_NL;
4566 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var overlayObj = $(this).children(\'.m3content_overlay div\');' . M3_NL;
4567 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'overlayObj.css({ position:"absolute", top:top + "px", left:left + "px" }).show();' . M3_NL;
4568 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4571 // ##### フロント画面のデフォルトのJavaスクリプト #####
4572 // if (!$gEnvManager->isAdminDirAccess()){
4573 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (jQuery().tooltip) $(\'[rel=tooltip]\').tooltip();' . M3_NL; // 標準ツールチップ作成
4575 // ポップアップメッセージがある場合は表示
4576 if (!empty($this->popupMsg)){
4577 $replaceStr .= 'alert("' . $this->popupMsg . '");' . M3_NL;
4580 if ($cleanType == 1){
4581 // HTMLのクリーン処理が必要なときはコードを埋め込む
4582 $this->initScript .= ' $(\'.PostHeaderIcons\').remove();' . M3_NL;// 不要なアイコン表示タグの削除
4583 $this->initScript .= ' $(\'.PostMetadataHeader\').each(function(i){' . M3_NL;
4584 $this->initScript .= ' if ($(this).text().trim() == \'\') $(this).remove();' . M3_NL;
4585 $this->initScript .= ' });' . M3_NL;
4589 $replaceStr .= $this->getLastContents();
4592 if (!empty($this->initScript)){
4593 $replaceStr .= '$(function(){' . M3_NL;
4594 $replaceStr .= $this->initScript;
4595 $replaceStr .= '});' . M3_NL;
4598 //$replaceStr .= '// -->' . M3_NL;
4599 //$replaceStr .= '</script>' . M3_NL;
4600 $replaceStr .= '//]]>' . M3_NL;
4601 $replaceStr .= '</script>' . M3_NL;
4603 // HEADタグに埋め込むCSS,JavaScript,任意文字列
4604 if (count($this->headCss) > 0){
4605 // CSSの場合は全体をstyleタグで囲む
4606 $replaceStr .= '<style type="text/css">' . M3_NL;
4607 $replaceStr .= '<!--' . M3_NL;
4608 for ($i = 0; $i < count($this->headCss); $i++){
4609 $replaceStr .= $this->headCss[$i];
4611 $replaceStr .= M3_NL . '//-->' . M3_NL;
4612 $replaceStr .= '</style>' . M3_NL;
4614 if (count($this->headScript) > 0){
4615 // JavaScriptの場合は全体をscriptタグで囲む
4616 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
4617 //$replaceStr .= '<!--' . M3_NL;
4618 $replaceStr .= '<script type="text/javascript">' . M3_NL;
4619 $replaceStr .= '//<![CDATA[' . M3_NL;
4620 for ($i = 0; $i < count($this->headScript); $i++){
4621 $replaceStr .= $this->headScript[$i];
4623 //$replaceStr .= M3_NL . '//-->' . M3_NL;
4624 //$replaceStr .= '</script>' . M3_NL;
4625 $replaceStr .= M3_NL;
4626 $replaceStr .= '//]]>' . M3_NL;
4627 $replaceStr .= '</script>' . M3_NL;
4629 if (count($this->headString) > 0){
4631 for ($i = 0; $i < count($this->headString); $i++){
4632 $replaceStr .= $this->headString[$i];
4641 * @param string $position HTMLテンプレート上の書き出し位置
4642 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
4643 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
4644 * @param array $attr その他属性
4645 * @return string 出力コンテンツ
4647 function getContents($position, $style = '', $templateVer = 0, $attr = array())
4649 static $render; // HTML生成オブジェクト
4650 global $gRequestManager;
4651 global $gEnvManager;
4654 $filename = $gEnvManager->getCurrentPageId();
4655 $subId = $gEnvManager->getCurrentPageSubId();
4656 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
4658 // ポジション名表示モードに応じて出力を作成
4659 $contents = ''; // 出力コンテンツ
4660 switch ($this->showPositionMode){
4662 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4663 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4664 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
4665 if ($ret){ // 1行以上データが取得できたとき
4666 $this->pageDefRows = $rows; // ページ定義レコード
4667 $this->pageDefPosition = $position;
4669 $this->pageDefRows = array();
4670 $this->pageDefPosition = '';
4674 $count = count($this->pageDefRows);
4676 if ($templateVer == 0){ // ########## Joomla!v1.0テンプレートの場合 ##########
4677 ob_start();// バッファ作成
4679 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4680 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
4681 for ($i = 0; $i < $count; $i++){
4682 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4683 $widgetId = $this->pageDefRows[$i]['wd_id'];
4685 // ### 遅延実行ウィジェットはキャッシュしない ###
4686 // キャッシュデータがあるときはキャッシュデータを使用
4687 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4689 if (empty($cacheData)){ // キャッシュデータがないとき
4691 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $launchWidgetTag, $titleTag, $widgetHeaderType);
4693 $widgetContent = ob_get_contents();
4696 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4698 // ウィジェットの内枠(コンテンツ外枠)を設定
4699 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4702 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4703 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4706 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4707 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4708 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4709 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4710 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4711 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4712 // ウィジェット表示タイプによる表示制御
4713 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4714 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
4715 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4716 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4717 if (!empty($controlType)){
4718 switch ($controlType){
4719 case 1: // ログイン時のみ表示
4720 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4721 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
4723 case 2: // 非ログイン時のみ表示
4724 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4725 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
4731 if (!empty($pageState)){
4732 switch ($pageState){
4734 if (!$this->isPageTopUrl){
4735 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4736 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
4744 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4745 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4746 $hasAdmin = '0'; // 管理画面があるかどうか
4747 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4748 $shared = '0'; // 共通属性があるかどうか
4749 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4750 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4751 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4752 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
4754 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4755 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4757 } else { // キャッシュデータがあるとき
4758 $widgetContent = $cacheData;
4761 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4762 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4763 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4765 $contents .= $widgetContent;
4767 // ##### 外部出力用のCSSがある場合は追加 #####
4768 $exportCss = $this->pageDefRows[$i]['pd_css'];
4769 if (!empty($exportCss)){
4771 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4772 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4773 $this->addExportCss($exportCss);
4776 ob_end_clean(); // バッファ破棄
4778 if ($i < $count) return '';// 処理中断のときは終了
4779 } else if ($templateVer == 100){ // ########## WordPressテンプレートの場合 ##########
4780 ob_start();// バッファ作成
4782 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4783 //$widgetHeaderType = $this->getTemplateWidgetHeaderType();
4784 for ($i = 0; $i < $count; $i++){
4785 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4786 $widgetId = $this->pageDefRows[$i]['wd_id'];
4788 // ### 遅延実行ウィジェットはキャッシュしない ###
4789 // キャッシュデータがあるときはキャッシュデータを使用
4790 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4792 if (empty($cacheData)){ // キャッシュデータがないとき
4793 // WordPressウィジェット用のパラメータ設定
4794 $gEnvManager->setWpWidgetClass(''); // ウィジェットクラス名初期化
4797 // $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $launchWidgetTag, $titleTag, $widgetHeaderType);
4798 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $launchWidgetTag, $titleTag, 0/*タイトル出力なし*/);
4800 $widgetContent = ob_get_contents();
4802 // WordPressウィジェット用のパラメータ設定
4803 $widgetClassName = $gEnvManager->getWpWidgetClass(); // ウィジェットクラス名
4805 $trimContent = trim($widgetContent);
4806 if (!empty($trimContent)){ // 出力が空でない場合
4809 if (!isset($render)) $render = new WPRender(); // WordPress用HTML生成オブジェクト
4811 // デフォルトのウィジェットタイトル取得
4812 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4815 //$joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4817 // 遅延ウィジェットのときはタイトルタグを埋め込む
4818 if (!empty($titleTag)) $defaultTitle = $titleTag;
4820 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4821 $title = $this->pageDefRows[$i]['pd_title'];
4822 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4823 if (empty($title)) $title = $defaultTitle;
4825 $title = ''; // タイトルは非表示
4828 // 強制的にタイトルを非表示にする場合はタイトルを修正
4829 if (!empty($title) && $this->pageDefRows[$i]['wd_hide_title']){
4830 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4831 $title = '[' . $title . ']';
4837 // WordPress用パラメータ作成
4838 $params = array(); // ウィジェットごとの属性
4839 if (!empty($widgetClassName)) $params['moduleclass'] = $widgetClassName; // ウィジェットクラス名
4842 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . ($i + 1); // ウィジェット識別用ユニークタグ
4844 if (strcmp($position, 'main') == 0){// メイン部のとき
4845 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
4847 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
4851 // $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4853 // ウィジェットの内枠(コンテンツ外枠)を設定
4854 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4858 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4859 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4862 // $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4863 // $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4864 // if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4865 // $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4866 // $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4868 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4869 // ウィジェット表示タイプによる表示制御
4870 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4871 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
4872 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4873 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4874 if (!empty($controlType)){
4875 switch ($controlType){
4876 case 1: // ログイン時のみ表示
4877 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4878 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
4880 case 2: // 非ログイン時のみ表示
4881 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4882 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
4888 if (!empty($pageState)){
4889 switch ($pageState){
4891 if (!$this->isPageTopUrl){
4892 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4893 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
4901 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4902 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4903 $hasAdmin = '0'; // 管理画面があるかどうか
4904 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4905 $shared = '0'; // 共通属性があるかどうか
4906 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4907 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4908 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4909 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
4911 // $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4912 // $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4914 } else { // キャッシュデータがあるとき
4915 $widgetContent = $cacheData;
4918 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4919 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4920 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4922 $contents .= $widgetContent;
4924 // ##### 外部出力用のCSSがある場合は追加 #####
4925 $exportCss = $this->pageDefRows[$i]['pd_css'];
4926 if (!empty($exportCss)){
4928 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4929 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4930 $this->addExportCss($exportCss);
4933 ob_end_clean(); // バッファ破棄
4935 if ($i < $count) return '';// 処理中断のときは終了
4936 } else { // ########## Joomla!v1.5テンプレートの場合 ##########
4937 // テンプレート側で指定されたメニューの表示属性を設定
4938 $gEnvManager->setMenuAttr($attr);
4942 if (!empty($attr['type'])) $posType = $attr['type'];
4944 for ($i = 0; $i < $count; $i++){
4945 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4946 $widgetId = $this->pageDefRows[$i]['wd_id'];
4948 // ### 遅延実行ウィジェットはキャッシュしない ###
4949 // キャッシュデータがあるときはキャッシュデータを使用
4950 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4952 if (empty($cacheData)){ // キャッシュデータがないとき
4954 $gEnvManager->setCurrentWidgetTitle('');
4956 // Joomla用のパラメータを初期化
4957 $gEnvManager->setCurrentWidgetJoomlaParam(array());
4961 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $launchWidgetTag, $titleTag, 0/*タイトル出力なし*/);
4962 $widgetContent = ob_get_contents();
4964 $trimContent = trim($widgetContent);
4965 if (!empty($trimContent)){ // 出力が空でない場合
4966 $isRendered = false; // Joomla!の描画処理を行ったかどうか
4967 if (!empty($this->pageDefRows[$i]['pd_use_render'])){ // Joomla!の描画処理を使用する場合
4968 // Joomla!ウィジェットの出力に埋め込む
4969 if (strcasecmp($style, 'none') != 0){
4971 if (!isset($render)) $render = new JRender();
4973 // デフォルトのウィジェットタイトル取得
4974 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4977 $joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4979 // 遅延ウィジェットのときはタイトルタグを埋め込む
4980 if (!empty($titleTag)) $defaultTitle = $titleTag;
4982 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4983 $title = $this->pageDefRows[$i]['pd_title'];
4984 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4985 if (empty($title)) $title = $defaultTitle;
4987 $title = ''; // タイトルは非表示
4990 // 強制的にタイトルを非表示にする場合はタイトルを修正
4991 if (!empty($title) && $this->pageDefRows[$i]['wd_hide_title']){
4992 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4993 $title = '[' . $title . ']';
5000 $params = array(); // ウィジェットごとの属性
5001 $widgetType = $this->pageDefRows[$i]['wd_type']; // ウィジェットタイプ
5003 // オプションのJoomlaクラス(縦型メニュー(art-vmenu)等)
5004 $joomlaClass = $this->pageDefRows[$i]['wd_joomla_class']; // 「wd_joomla_class」は使っていない?
5005 if (!empty($joomlaClass)) $params['moduleclass_sfx'] = $joomlaClass;
5006 if (isset($joomlaParam['moduleclass_sfx'])) $params['moduleclass_sfx'] = $joomlaParam['moduleclass_sfx'];// ウィジェットでjoomla用パラメータの設定があるとき
5008 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
5009 $moduleContent = '';
5011 // ウィジェットタイプがメニューのときはナビゲーションメニューを生成
5012 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5014 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
5015 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5016 $widgetContent = $moduleContent;
5018 // ウィジェットタイプに応じた処理を実行
5019 if ($widgetType == 'breadcrumb'){ // パンくずリスト
5020 $moduleContent = '';
5022 if (empty($launchWidgetTag)){ // 遅延実行の場合はここでパンくずリストを作成しないで遅延実行時に行う
5023 $moduleContent = $render->getBreadcrumbContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5025 $moduleContent = $launchWidgetTag; // 遅延実行ウィジェットのタグのみ取得
5028 // パンくずリストで作成できないときはデフォルトの出力を取得
5029 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5030 $widgetContent = $moduleContent;
5032 if (strcmp($position, 'main') == 0){// メイン部のとき
5033 // ウィジェットの内枠(コンテンツ外枠)を設定
5034 // ウィジェットの内枠はレンダーで設定
5035 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
5036 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5037 } else { // その他の位置のとき
5038 // ウィジェットの内枠(コンテンツ外枠)を設定
5039 // ウィジェットの内枠はレンダーで設定
5040 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
5042 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5046 /* if (strcmp($position, 'main') == 0){// メイン部のとき
5047 // ウィジェットの内枠(コンテンツ外枠)を設定
5048 // ウィジェットの内枠はレンダーで設定
5049 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
5050 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5051 // } else if (strStartsWith($position, 'user') || // ナビゲーションメニュー位置の場合
5052 } else if (strcasecmp($position, 'user3') == 0 || // ナビゲーションメニュー位置の場合
5053 strcasecmp($position, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
5054 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
5056 $moduleContent = '';
5057 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
5058 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5060 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
5061 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5063 $moduleContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5065 $widgetContent = $moduleContent;
5067 // ウィジェットの内枠(コンテンツ外枠)を設定。メニュー処理後に付加。
5068 // ウィジェットの内枠はレンダーで設定
5069 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
5070 } else { // その他の位置のとき
5071 // ウィジェットの内枠(コンテンツ外枠)を設定
5072 // ウィジェットの内枠はレンダーで設定
5073 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
5075 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
5077 $isRendered = true; // Joomla!の描画処理を行ったかどうか
5080 if (!$isRendered){ // Joomla!の描画処理を行っていない場合
5082 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
5084 // ウィジェットの内枠(コンテンツ外枠)を設定
5085 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
5088 if (!$ret) return ''; // 処理中断のときは終了
5091 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
5092 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
5095 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
5096 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
5097 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
5098 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
5099 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
5100 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
5101 // ウィジェット表示タイプによる表示制御
5102 $widgetStatusClass = '';// ウィジェットの状態表示クラス
5103 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
5104 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
5105 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
5106 if (!empty($controlType)){
5107 switch ($controlType){
5108 case 1: // ログイン時のみ表示
5109 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
5110 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
5112 case 2: // 非ログイン時のみ表示
5113 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
5114 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
5120 if (!empty($pageState)){
5121 switch ($pageState){
5123 if (!$this->isPageTopUrl){
5124 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
5125 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
5133 //$editInfo = 'widgetid:' . $this->pageDefRows[$i]['wd_id'];
5134 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
5135 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
5136 $hasAdmin = '0'; // 管理画面があるかどうか
5137 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
5138 $shared = '0'; // 共通属性があるかどうか
5139 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
5140 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
5141 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
5142 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
5144 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
5145 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
5147 } else { // キャッシュデータがあるとき
5148 $widgetContent = $cacheData;
5151 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
5152 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
5153 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
5155 $contents .= $widgetContent;
5157 // ##### 外部出力用のCSSがある場合は追加 #####
5158 $exportCss = $this->pageDefRows[$i]['pd_css'];
5159 if (!empty($exportCss)){
5161 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
5162 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
5163 $this->addExportCss($exportCss);
5168 if ($position == 'main'){ // メイン部のときは、メッセージを出力
5169 /*if (strlen($this->popupMsg) > 0){
5170 echo "\n<script language=\"javascript\">alert('" . addslashes($this->popupMsg) . "');</script>";
5172 } else if ($position == 'debug'){ // デバッグ文出力
5178 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:3px solid #f00;color:#700;">ポジション名: ';
5179 $contents .= '<b>' . $position . '</b>';
5180 $contents .= '</div>';
5183 if (!in_array($position, $this->defPositions)) $this->defPositions[] = $position; // テンプレート上のポジション
5185 case 2: // ポジション表示(ウィジェット付き)
5186 $rev = '555'; // データのリビジョン番号
5187 // ポジションのHTMLタグIDを作成
5190 for ($i = 0; $i < 100; $i++){
5191 $posId = $position . '_' . $num;
5192 $viewPosId = self::POSITION_TAG_HEAD . $posId;
5193 if (!in_array($viewPosId, $this->viewPosId)) break;
5196 $this->viewPosId[] = $viewPosId;// IDを保存
5198 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
5199 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
5200 $ret = $this->db->getPageDef($filename, $subId, $position, $rows);
5201 if ($ret){ // 1行以上データが取得できたとき
5202 $this->pageDefRows = $rows; // ページ定義レコード
5203 $this->pageDefPosition = $position;
5205 $this->pageDefRows = array();
5206 $this->pageDefPosition = '';
5210 // ナビゲーション型のポジションの場合はアイコン付加
5211 //if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5212 if ($style == self::WIDGET_STYLE_NAVMENU){
5213 $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加(ナビゲーションメニュー型)
5214 } else if (strcasecmp($position, 'main') == 0){
5215 $posHead = self::POS_HEAD_MAIN; // 特殊ポジションブロックのアイコン付加(メイン型)
5217 $contents .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5218 $contents .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
5221 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
5222 //$contents .= $this->getWidgetList($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $widgetTagHead, $this->pageDefRows);
5223 $contents .= $this->getWidgetList($filename, $subId, $widgetTagHead, $this->pageDefRows);
5225 $contents .= '</div>' . M3_NL;
5228 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">param error</div>';
5232 $this->viewPositions[] = $position;
5237 * 各部品のHTML出力(WordPressテンプレート専用)
5239 * @param string $position HTMLテンプレート上の書き出し位置
5240 * @param bool $showTitle タイトルを表示するかどうか
5241 * @return string 出力コンテンツ
5243 function getWPContents($position, $showTitle = true)
5246 return $this->getContents($position, self::WIDGET_STYLE_WORDPRESS/*WordPressテンプレート用出力*/, 100/*WordPressテンプレート*/);
5248 return $this->getContents($position, self::WIDGET_STYLE_WORDPRESS_NOTITLE/*WordPressテンプレート(タイトルなし)用出力*/, 100/*WordPressテンプレート*/);
5252 * その他のポジションブロックデータを取得
5254 * @param string ポジション作成用タグ
5256 function getRestPositionData()
5258 global $gEnvManager;
5260 $restPositionData = '';
5262 $pageId = $gEnvManager->getCurrentPageId();
5263 $subId = $gEnvManager->getCurrentPageSubId();
5265 $restPositions = array_values(array_diff($this->defPositions/*全ポジション*/, $this->viewPositions/*表示済みポジション*/));
5266 $positionCount = count($restPositions);
5267 for ($i = 0; $i < $positionCount; $i++){
5268 $posHead = ''; // アイコン付加用
5269 $position = $restPositions[$i];
5270 $posId = $position . '_0';
5271 $viewPosId = self::POSITION_TAG_HEAD . $posId;
5274 $ret = $this->db->getPageDef($pageId, $subId, $position, $rows);
5276 //$pageDefRows = $rows; // ページ定義レコード
5278 $restPositionData .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">'; // リビジョン番号を付加
5279 $restPositionData .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>';
5282 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
5283 $contents = $this->getWidgetList($pageId, $subId, $widgetTagHead, $rows);
5284 $contents = str_replace(M3_NL, '', $contents);
5285 $contents = str_replace('\'', '\\\'', $contents);
5286 $restPositionData .= $contents;
5287 $restPositionData .= '</div>';
5289 $this->viewPosId[] = $viewPosId;// IDを保存
5292 return $restPositionData;
5295 * ウィジェット共通のコンテンツ追加処理
5297 * @param string $src ウィジェット出力
5298 * @param array $pageDefParam 画面定義レコード
5299 * @return string コンテンツを付加したウィジェット出力
5301 function _addOptionContent($src, $pageDefParam)
5304 $dest = $pageDefParam['pd_top_content'] . $src . $pageDefParam['pd_bottom_content'];
5307 if ($pageDefParam['pd_show_readmore']){
5308 $title = $pageDefParam['pd_readmore_title'];
5309 if (empty($title)) $title = self::DEFAULT_READMORE_TITLE;
5310 $dest .= '<div><a href="' . convertUrlToHtmlEntity($pageDefParam['pd_readmore_url']) . '">' . convertToHtmlEntity($title) . '</a></div>';
5315 * BODYタグに付加するスタイルを取得(管理画面用)
5317 * @param string CSS文字列
5319 function getBodyStyle()
5321 // 画面透過モードのときスタイルを追加
5323 if ($this->isTransparentMode) $transCss = ' style="background-color:transparent;"';
5329 * @param string $position HTMLテンプレート上の書き出し位置
5330 * @return int ウィジェットの数
5332 function getWidgetsCount($position)
5334 global $gRequestManager;
5335 global $gEnvManager;
5336 static $widgetCountArray = array();
5338 // 管理画面へのアクセスでログインされていないときは0を返す
5339 if ($gEnvManager->isAdminDirAccess() && !$gEnvManager->isSystemManageUser()){ // 管理画面へのアクセスのときでシステム運用権限がない場合
5344 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
5345 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 管理画面(ウィジェットなしポジション表示)のとき
5346 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
5347 return 1; // ウィジェットが設定されていないポジション名を表示するために固定で値を返す
5350 // 単一ポジション以外の設定のときは固定で返す(or等)
5351 $pos = strpos($position, ' ');
5352 if ($pos !== false) return 1;
5354 // 既にウィジェット数が取得されている場合は保存値を返す
5355 $widgetCount = $widgetCountArray[$position];
5356 if (isset($widgetCount)) return $widgetCount;
5359 $filename = $gEnvManager->getCurrentPageId();
5360 $subId = $gEnvManager->getCurrentPageSubId();
5361 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
5363 // 取得しようとするページ定義のポジションが既に取得しているポジションと異なるときはデータを取得
5364 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // 現在取得しているページ定義のポジション
5365 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
5366 if ($ret){ // 1行以上データが取得できたとき
5367 $this->pageDefRows = $rows; // ページ定義レコード
5368 $this->pageDefPosition = $position;
5370 $this->pageDefRows = array();
5371 $this->pageDefPosition = '';
5374 // ### ウィジェット数を取得 ###
5375 // テンプレートのカラム制御を行うためにウィジェット表示条件でウィジェット数を取得
5377 $rowCount = count($this->pageDefRows);
5378 for ($i = 0; $i < $rowCount; $i++){
5379 // $condition = trim($this->pageDefRows[$i]['wd_visible_condition']);
5380 $condition = trim($this->pageDefRows[$i]['pd_visible_condition']);
5381 if (empty($condition)){ // ウィジェット表示条件が設定されていない場合はウィジェットを表示
5383 } else { // ウィジェット表示条件が設定されている場合はパラメータをチェック
5384 $conds = explode(';', $condition);
5385 for ($j = 0; $j < count($conds); $j++){
5386 $pos = strpos($conds[$j], '=');
5387 if ($pos !== false){ // URLクエリーパラメータ条件がマッチした場合はウィジェットを表示
5388 list($key, $value) = explode('=', trim($conds[$j]));
5390 $value = trim($value);
5391 if (!empty($key) && !empty($value)){
5392 $requestValue = $gRequestManager->trimValueOf($key);
5393 if ($value == $requestValue) $widgetCount++;
5399 // $widgetCount = count($this->pageDefRows);
5400 $widgetCountArray[$position] = $widgetCount;
5401 return $widgetCount;
5404 * ウィジェットのページ定義シリアル番号からウィジェットCSS IDを取得
5406 * @param int $defSerial ページ定義シリアル番号
5407 * @param string $pageId ページID
5408 * @param string $subpage ページサブID
5409 * @param string $position 表示位置ID
5410 * @return string CSSエレメントID
5412 function getWidgetCssId($defSerial, $pageId, $pageSubId, $position)
5415 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
5417 $rowCount = count($rows);
5418 for ($i = 0; $i < $rowCount; $i++){
5420 if ($row['pd_serial'] == $defSerial){
5421 $elementId = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
5431 * 画面作成機能でウィジェット情報を取得するためのAjaxインターフェイス
5433 * @param RequestManager $request HTTPリクエスト処理クラス
5435 function getWidgetInfoByAjax($request)
5437 global $gEnvManager;
5438 global $gDesignManager;
5439 global $gCacheManager;
5441 // アクセスするページIDからPC用、携帯用、スマートフォン用かを判断
5442 $widgetDeviceType = 0; // 端末タイプをPC用に初期化
5443 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
5444 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
5445 $mobilePageIdPrefix = M3_DIR_NAME_MOBILE . '_';
5446 $smartphonePageIdPrefix = M3_DIR_NAME_SMARTPHONE . '_';
5447 if (strncmp($pageId, $mobilePageIdPrefix, strlen($mobilePageIdPrefix)) == 0){
5448 $widgetDeviceType = 1; // 携帯用
5449 } else if (strncmp($pageId, $smartphonePageIdPrefix, strlen($smartphonePageIdPrefix)) == 0){
5450 $widgetDeviceType = 2; // スマートフォン用
5453 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
5454 if ($task == 'list'){
5456 $ret = $this->db->getAvailableWidgetList($widgetDeviceType, $rows);
5458 $currentCategoryId = '_none'; // 現在のウィジェットカテゴリー初期化
5459 for ($i = 0; $i < count($rows); $i++){
5460 $widgetId = $rows[$i]['wd_id'];
5461 $desc = $rows[$i]['wd_description'];
5462 $widgetTag = self::WIDGET_TYPE_TAG_HEAD . $widgetId;
5463 $categoryId = $rows[$i]['wd_category_id'];
5466 if ($categoryId != $currentCategoryId){
5468 echo '</dd>' . M3_NL;
5469 echo '</dl>' . M3_NL;
5471 echo '<dl class="m3accordion">' . M3_NL;
5472 echo '<dt>' . $rows[$i]['wt_name'] . '</dt>' . M3_NL;
5473 echo '<dd>' . M3_NL;
5476 $currentCategoryId = $categoryId;
5479 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
5480 if ($gEnvManager->getUseSslAdmin()){
5481 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
5482 $image = $gEnvManager->getSslUrl($image);
5484 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
5485 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
5486 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
5491 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5492 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5496 if (!empty($rows[$i]['wd_template_type'])){ // 対応テンプレートタイプ
5497 $templateTypeArray = explode(',', $rows[$i]['wd_template_type']);
5498 if (in_array('bootstrap', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_BOOTSTRAP; // Bootstrap型テンプレート対応
5499 if (in_array('wordpress', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_WORDPRESS; // WordPress型テンプレート対応
5501 if (!empty($functionMark)) $functionMark = '<hr />' . $functionMark;
5503 echo '<dl class="m3_widgetlist_item" id="' . $widgetTag . '">' . M3_NL;
5504 echo '<dt>' . $widgetMark . $rows[$i]['wd_name'] . '</dt>' . M3_NL; // ウィジェット名
5505 echo '<dd><table style="width:100%;"><tr style="vertical-align:top;"><td style="width:35px;">' . $imageTag . '</td><td>' . $desc . '</td></tr></table>';
5506 echo $functionMark . '</dd>' . M3_NL;
5507 echo '</dl>' . M3_NL;
5510 if ($i == count($rows) - 1){
5511 echo '</dd>' . M3_NL;
5512 echo '</dl>' . M3_NL;
5516 } else if ($task == 'wget' || $task == 'wdelete' || $task == 'wtoggle' || $task == 'wadd' || $task == 'wmove'){ // ウィジェット再取得、ウィジェット削除,ウィジェット共通属性変更、ウィジェット追加、ウィジェット移動のとき
5517 $rev = $request->trimValueOf('rev'); // リビジョン
5518 $serial = $request->trimValueOf('serial');
5519 $position = $request->trimValueOf('pos');
5520 $widgetsStr = $request->trimValueOf('widgets');
5521 if (empty($widgetsStr)){
5524 $widgets = explode(',', $widgetsStr);
5526 $shared = $request->trimValueOf('shared');
5527 $updatepos = explode(',', $request->trimValueOf('updatepos'));
5528 $index = $request->trimValueOf('index');
5531 if ($task == 'wmove'){
5532 $positions = explode(',', $position);
5533 if (count($positions) >= 2){
5534 $position = $positions[0];
5535 $position2 = $positions[1];
5537 $position = $positions[0];
5541 // ##### エラーチェック #####
5544 $rev = '111'; // データのリビジョン番号
5547 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows); // 0レコードでも正常とする
5549 // 変更前のウィジェットのシリアル番号をチェック
5550 if (count($widgets) == count($rows)){
5551 if (!($task == 'wmove' && empty($position2))){ // 同一ブロック内の移動の場合はチェックなし
5552 for ($i = 0; $i < count($rows); $i++){
5553 if ($widgets[$i] != $rows[$i]['pd_serial']){// シリアル番号
5564 if (!$isErr){ // エラーなしのとき
5565 if ($task == 'wdelete'){
5566 $ret = $this->db->deleteWidget($serial);
5567 } else if ($task == 'wtoggle'){
5569 if (empty($shared)) $newShared = 1;
5570 $ret = $this->db->toggleSharedWidget($pageId, $pageSubId, $serial, $newShared);
5571 } else if ($task == 'wadd'){ // ウィジェットの追加
5572 $widget = $request->trimValueOf('widget');
5575 if (empty($widget)) $isErr = true;
5578 if (!$isErr) $this->db->addWidget($pageId, $pageSubId, $position, $widget, $index);
5579 } else if ($task == 'wmove'){
5581 if (!$isErr) $this->db->moveWidget($pageId, $pageSubId, $position, $serial, $index);
5585 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows);// 0レコードでも正常とする
5587 // 移動のときは、移動元と移動先の再表示データを取得
5588 if ($task == 'wmove' && !empty($position2)){
5589 $ret = $this->db->getPageDef($pageId, $pageSubId, $position2, $rows2);// 0レコードでも正常とする
5592 // ##### 該当するページのテンプレートタイプを取得 #####
5594 $templateGenerator = '';
5596 // ページ用個別に設定されたテンプレートがある場合は取得
5598 $line = $this->getPageInfo($pageId, $pageSubId);
5599 if (!empty($line)) $curTemplate = $line['pn_template_id'];
5602 if (empty($curTemplate)){
5603 if ($pageId == $this->gEnv->getDefaultPageId()){ // 通常サイトのとき
5604 $curTemplate = $this->gSystem->defaultTemplateId();
5605 } else if ($pageId == $this->gEnv->getDefaultSmartphonePageId()){ // スマートフォン用サイトのとき
5606 $curTemplate = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
5611 $ret = $this->db->getTemplate($curTemplate, $row);
5613 $templateType = $row['tm_type'];
5614 $templateGenerator = $row['tm_generator'];
5619 echo '<div>' . M3_NL;
5620 for ($i = 0; $i < count($updatepos); $i++){
5622 $widgetTagHead = str_replace(self::POSITION_TAG_HEAD, self::WIDGET_TAG_HEAD, $updatepos[$i]);
5625 $posName = str_replace(self::POSITION_TAG_HEAD, '', substr($updatepos[$i], 0, strlen($updatepos[$i]) - strlen(strrchr($updatepos[$i], "_"))));
5626 if ($task == 'wmove' && $posName == $position2){
5627 // Themlerテンプレート場合は配置ポジション名が「hmenu」をナビゲーション型とする
5629 if ($templateGenerator == 'themler'){
5630 if (strcasecmp($position2, 'hmenu') == 0){ // Joomla!v3テンプレート対応
5631 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
5634 if (strcasecmp($position2, 'user3') == 0 || // ナビゲーションメニュー位置の場合
5635 strcasecmp($position2, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
5636 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
5642 if ($style == self::WIDGET_STYLE_NAVMENU){
5643 $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加(ナビゲーションメニュー型)
5644 } else if (strcasecmp($position2, 'main') == 0){
5645 $posHead = self::POS_HEAD_MAIN; // 特殊ポジションブロックのアイコン付加(メイン型)
5647 //if (strcasecmp($position2, 'user3') == 0 || strcasecmp($position2, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5648 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position2 . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5649 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position2 . '</h2>' . M3_NL;
5652 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows2);
5654 // Themlerテンプレート場合は配置ポジション名が「hmenu」をナビゲーション型とする
5656 if ($templateGenerator == 'themler'){
5657 if (strcasecmp($position, 'hmenu') == 0){ // Joomla!v3テンプレート対応
5658 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
5661 if (strcasecmp($position, 'user3') == 0 || // ナビゲーションメニュー位置の場合
5662 strcasecmp($position, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
5663 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
5669 if ($style == self::WIDGET_STYLE_NAVMENU){
5670 $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加(ナビゲーションメニュー型)
5671 } else if (strcasecmp($position, 'main') == 0){
5672 $posHead = self::POS_HEAD_MAIN; // 特殊ポジションブロックのアイコン付加(メイン型)
5674 //if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5675 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5676 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
5679 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows);
5682 echo '</div>' . M3_NL;
5684 echo '</div>' . M3_NL;
5687 $gCacheManager->clearAllCache();
5691 * 画面作成用ウィジェット一覧データ出力
5693 * @param string $pageId ページID
5694 * @param string $pageSubId ページサブID
5695 * @param string $widgetTagHead HTMLウィジェットID用のヘッダ
5696 * @param array $rows ウィジェット一覧データ
5697 * @return string ウィジェット一覧出力
5699 function getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows)
5701 global $gEnvManager;
5702 global $gDesignManager;
5703 global $gSystemManager;
5705 if ($gEnvManager->getUseSslAdmin()){
5706 $rootUrl = $gEnvManager->getSslRootUrl();
5708 $rootUrl = $gEnvManager->getRootUrl();
5712 $line = $this->getPageInfo($pageId, $pageSubId);
5713 if (!empty($line)) $pageContentType = $line['pn_content_type'];
5715 $contents = ''; // ウィジェット一覧出力コンテンツ
5716 for ($i = 0; $i < count($rows); $i++){
5717 $widgetId = $rows[$i]['wd_id'];
5718 $desc = $rows[$i]['wd_description'];
5719 $widgetIndex = $rows[$i]['pd_index']; // 表示順
5720 $configId = $rows[$i]['pd_config_id']; // 定義ID
5721 $serial = $rows[$i]['pd_serial']; // シリアル番号
5722 $isShared = empty($rows[$i]['pd_sub_id']); // グローバル属性が設定されているかどうか
5723 $widgetTag = $widgetTagHead . '_' . $i; // ウィジェット識別用ユニークタグ
5724 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
5725 if ($gEnvManager->getUseSslAdmin()){
5726 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
5727 $image = $gEnvManager->getSslUrl($image);
5729 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
5730 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
5731 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
5734 if (empty($rows[$i]['pd_config_name'])){
5735 if ($rows[$i]['wd_use_instance_def'] && $configId == 0){ // インスタンス定義が必要で未定義のとき
5736 $configName = '<span style="color:red;">[未設定]</span>';
5741 $configName = '[' . $rows[$i]['pd_config_name'] . ']';
5743 $hasAdmin = '0'; // 管理画面があるかどうか
5744 $configImg = ''; // 設定アイコンの表示
5746 // ウィジェットの配置位置に問題があるかどうかを表示
5747 // メインコンテンツとページ属性が一致するかどうかチェック
5748 $widgetContentType = $rows[$i]['wd_content_type'];
5749 //if (!empty($widgetContentType) && $widgetContentType != $pageContentType &&
5750 if (!empty($widgetContentType) && $widgetContentType != $pageContentType && empty($rows[$i]['wd_content_widget_id']) && // 編集用のウィジェットが別にある場合は除く(2015/3/24))
5751 (in_array($widgetContentType, $this->_getAllContentType()) || in_array($widgetContentType, $this->_getAllFeatureType()))){
5752 //$title = 'ウィジェット配置注意';
5753 $title = 'ページ属性と不一致';
5754 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::NOTICE_ICON_FILE . '" alt="' . $title . '" /></span> ';
5756 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type']) && $isShared){ // メイン型ウィジェットがグローバル属性を持つとき
5757 $title = 'メイン型ウィジェットはグローバル属性を設定できません';
5758 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::ALERT_ICON_FILE . '" alt="' . $title . '" /></span> ';
5760 if ($rows[$i]['wd_has_admin']){
5762 $title = 'ウィジェット設定';
5763 $configImg .= '<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\'' . $widgetId . '\', \'' . $configId . '\', \'' . $serial . '\');return false;" rel="m3help" data-container="body" title="' . $title . '">' .
5764 '<img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" alt="' . $title . '"/></a> ';
5767 $configImg .= '<span rel="m3help" data-container="body" title="表示順">' . $widgetIndex . '</span>';
5769 $shared = '0'; // 共通属性があるかどうか
5770 $sharedClassName = '';
5771 //if (empty($rows[$i]['pd_sub_id'])){
5772 if ($isShared){ // グローバル属性ウィジェットのとき
5774 $sharedClassName = 'm3_widget_shared'; // 共通ウィジェットのクラス
5776 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
5780 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5781 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5784 $dropdownMenuId = $widgetTag . '_dropdown';
5785 $operationMenu = '<div class="m3widgetdropdown">';
5786 // $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#"><i class="glyphicon glyphicon-list-alt"></i> <b class="caret"></b></a>';
5787 $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#" data-horizontal-offset="4"><b class="caret"></b></a>';
5788 $operationMenu .= '<div id="' . $dropdownMenuId . '" class="m3dropdown m3dropdown-tip m3dropdown-relative m3dropdown-anchor-right">';
5789 $operationMenu .= '<ul class="m3dropdown-menu">';
5790 if ($hasAdmin) $operationMenu .= '<li class="m3_wconfig"><a href="#"><img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" /> <span>ウィジェットの設定</span></a></li>';
5791 $operationMenu .= '<li class="m3_wadjust"><a href="#"><img src="' . $rootUrl . self::ADJUST_ICON_FILE . '" /> <span>タイトル・スタイル調整</span></a></li>';
5793 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を解除</span></a></li>';
5795 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を設定</span></a></li>';
5797 $operationMenu .= '<li class="m3_wdelete"><a href="#"><img src="' . $rootUrl . self::DELETE_ICON_FILE . '" /> <span>このウィジェットを削除</span></a></li>';
5798 $operationMenu .= '</ul>';
5799 $operationMenu .= '</div>';
5800 $operationMenu .= '</div>';
5802 $contents .= '<dl class="m3_widget m3_widget_sortable" id="' . $widgetTag . '" ' . $m3Option . ' >' . M3_NL;
5803 $contents .= '<dt class="m3_widget_with_check_box ' . $sharedClassName . '"><div class="m3widgettitle">' . $widgetMark . $rows[$i]['wd_name'] . '</div>' . $operationMenu . '</dt>' . M3_NL;
5804 $contents .= '<dd><table style="width:100%;"><tr style="vertical-align:top;"><td style="width:35px;border:none;">' . $imageTag . '</td><td style="border:none;">' . $desc . '</td></tr></table><hr />' . M3_NL;
5805 $contents .= '<table style="width:100%;"><tr><td style="border:none;">' . $configName . '</td><td style="text-align:right;border:none;">' . $configImg . '</td></tr></table></dd>' . M3_NL;
5806 $contents .= '</dl>' . M3_NL;
5813 * @param string $position HTMLテンプレート上の書き出し位置
5814 * @param int $index 行番号
5815 * @param array $fetchedRow fetch取得した行
5816 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
5817 * @param string $launchWidgetTag 遅延ウィジェット埋め込み用タグ(遅延ウィジェットの場合のみ作成)
5818 * @param string $titleTag タイトル埋め込み用タグ(遅延ウィジェットの場合のみ作成)
5819 * @param int $widgetHeaderType ウィジェットタイトルを出力方法(0=出力なし、1=Joomla!v1.0PC用出力、2=Joomla!v1.0携帯用出力)
5820 * @return bool 処理を継続するかどうか(true=続行、false=中断)
5822 function pageDefLoop($position, $index, $fetchedRow, $style, &$launchWidgetTag, &$titleTag, $widgetHeaderType = 0)
5824 global $gEnvManager;
5825 global $gErrorManager;
5826 global $gDesignManager;
5828 // ページ作成中断またはウィジェット処理中断のときは終了
5829 if ($this->isAbort || $this->isWidgetAbort) return false;
5831 // ウィジェット実行停止中のときは空で返す
5832 // 管理者、運営者どのレベルで制限をかける?
5833 if (!$fetchedRow['wd_active']) return true;
5835 // グローバル属性ありの場合は現在のページが例外ページにないかチェック
5836 if (empty($fetchedRow['pd_sub_id'])){
5837 $exceptPageStr = $fetchedRow['pd_except_sub_id'];
5838 if (!empty($exceptPageStr)){
5839 $exceptPageArray = explode(',', $exceptPageStr);
5840 if (in_array($gEnvManager->getCurrentPageSubId(), $exceptPageArray)) return true; // 例外ページの場合は出力しない
5844 // ウィジェット表示タイプによる表示制御。システム管理者以上の場合は常時表示。
5845 if (!$gEnvManager->isSystemAdmin()){
5846 if (!empty($fetchedRow['pd_view_control_type'])){
5847 switch ($fetchedRow['pd_view_control_type']){
5848 case 1: // ログイン時のみ表示
5849 if (!$gEnvManager->isCurrentUserLogined()) return true; // ログインしていなければ終了
5851 case 2: // 非ログイン時のみ表示
5852 if ($gEnvManager->isCurrentUserLogined()) return true; // ログインしていれば終了
5858 if (!empty($fetchedRow['pd_view_page_state'])){
5859 switch ($fetchedRow['pd_view_page_state']){
5861 if (!$this->isPageTopUrl) return true; // ページトップ(サブページ内のトップ位置)でなければ終了
5870 $launchWidgetTag = ''; // 遅延ウィジェット埋め込み用タグ
5874 $widgetId = $fetchedRow['wd_id'];
5875 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5878 $configId = $fetchedRow['pd_config_id']; // ウィジェット定義ID
5879 if ($configId == 0) $configId = '';
5880 $prefix = $fetchedRow['wd_suffix']; // サフィックス文字列
5881 $title = $fetchedRow['wd_name']; // デフォルトのウィジェットタイトル
5882 if (empty($title)) $title = $fetchedRow['wd_id'];
5883 $widgetHeadTitle = $fetchedRow['pd_title']; // ウィジェットのヘッドタイトル
5884 if (empty($widgetHeadTitle)) $widgetHeadTitle = $title; // ウィジェットのヘッドタイトルが空の場合はウィジェットタイトルを取得
5885 $serial = $fetchedRow['pd_serial']; // シリアル番号
5886 $cssStyle = $fetchedRow['pd_style']; // CSS
5887 $lateLaunchIndex = $fetchedRow['wd_launch_index']; // 遅延実行インデックス
5889 if (empty($fetchedRow['pd_sub_id'])) $shared = true;// 共通属性あり
5890 if ($this->nonSharedWidgetCount == -1) $this->nonSharedWidgetCount = 0; // 初期化されていない場合は初期化
5891 if (!$shared) $this->nonSharedWidgetCount++; // 非共通ウィジェットの数を更新
5893 // ウィジェットが遅延実行に指定されている場合は、ウィジェットのタグのみ埋め込む
5894 if ($lateLaunchIndex > 0){ // 遅延実行のとき
5896 if (!isset($this->lateLaunchWidgetList[$widgetId])){
5897 $this->lateLaunchWidgetList[$widgetId] = (int)$lateLaunchIndex;
5900 $maxNo = 0; // 最大シリアル番号
5901 $count = count($this->latelaunchWidgetParam);
5902 for ($i = 0; $i < $count; $i++){
5903 list($wId, $maxNo, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5, $tmp6, $tmp7, $tmp8, $tmp9, $tmp10, $tmp11) = $this->latelaunchWidgetParam[$i];
5904 if ($wId == $widgetId) $maxNo = $maxNo + 1;
5906 // Joomla!1.0テンプレートの場合はタイトルを修正
5907 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5908 if (!empty($fetchedRow['pd_title'])) $title = $fetchedRow['pd_title'];
5910 $this->latelaunchWidgetParam[] = array($widgetId, $maxNo, $configId, $prefix, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $fetchedRow);
5913 $launchWidgetTag = self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END; // 遅延ウィジェット埋め込み用タグ
5914 echo $launchWidgetTag;
5917 $titleTag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
5920 if (!file_exists($widgetIndexFile)) {
5921 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5924 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
5925 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
5926 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
5927 $this->lastHeadTitle = ''; // ヘッダ部titleにセットした文字列
5928 $this->lastHeadDescription = ''; // ヘッダ部descriptionにセットした文字列
5929 $this->lastHeadKeywords = ''; // ヘッダ部keywordsにセットした文字列
5932 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
5933 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
5935 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
5936 $joomlaTitleVisble = false;
5937 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5938 if ($fetchedRow['pd_title_visible']){
5939 if ($widgetHeaderType == 1){ // PC用出力のとき
5940 $joomlaTitle = $fetchedRow['pd_title'];
5941 if (empty($joomlaTitle)) $joomlaTitle = $title;
5942 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
5943 echo '<tr><th>' . $joomlaTitle . '</th></tr>' . M3_NL;
5944 echo '<tr><td>' . M3_NL;
5945 $joomlaTitleVisble = true;
5946 } else if ($widgetHeaderType == 2){ // 携帯用出力のとき
5947 $joomlaTitle = $fetchedRow['pd_title'];
5948 if (empty($joomlaTitle)) $joomlaTitle = $title;
5949 echo '<div>' . $joomlaTitle . '</div>' . M3_NL;
5950 $joomlaTitleVisble = true;
5955 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
5956 // ウィジェット親のCSS定義があるときは、タグを追加
5957 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
5960 echo $gDesignManager->getAdditionalWidgetOutput(true);
5963 $gEnvManager->setCurrentWidgetId($widgetId);
5966 $gEnvManager->setCurrentWidgetConfigId($configId);
5969 $gEnvManager->setCurrentPageDefSerial($fetchedRow['pd_serial']);
5972 $gEnvManager->setCurrentPageDefRec($fetchedRow);
5975 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5977 // ウィジェットのヘッドタイトルを設定
5978 $gEnvManager->setCurrentWidgetHeadTitle($widgetHeadTitle);
5981 $gEnvManager->setCurrentWidgetTitle($title);
5984 $gEnvManager->setCurrentWidgetStyle($style);
5986 // ウィジェットのグローバル属性状況を設定
5987 $gEnvManager->setIsCurrentWidgetShared($shared);
5990 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5993 //require_once($widgetIndexFile);
5994 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5995 $msg = 'widget-start(' . $widgetId . ')';
5996 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5997 require($widgetIndexFile);
5998 $msg = 'widget-end(' . $widgetId . ')';
5999 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
6002 $gEnvManager->setCurrentWidgetId('');
6005 $gEnvManager->setCurrentWidgetConfigId('');
6008 $gEnvManager->setCurrentPageDefSerial(0);
6011 $gEnvManager->setCurrentPageDefRec();
6014 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
6017 $gEnvManager->setCurrentWidgetStyle('');
6019 // ウィジェットのグローバル属性状況を解除
6020 $gEnvManager->setIsCurrentWidgetShared(false);
6023 echo $gDesignManager->getAdditionalWidgetOutput(false);
6024 // echo "<!-- ".time()." -->";
6026 // ウィジェット親のCSS定義があるときは、タグを追加
6027 if (!empty($cssStyle)) echo '</div>' . M3_NL;
6029 //echo '</div>' . M3_NL;
6031 // Joomla!1.0テンプレートのときはタイトルを出力
6032 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用出力のとき
6033 echo '</td></tr>' . M3_NL;
6034 echo '</table>' . M3_NL;
6038 return true; // 処理継続
6041 * 定義IDを指定してウィジェットの出力を取得
6043 * @param string $widgetId ウィジェットID
6044 * @param int $configId ウィジェット定義ID
6045 * @return string ウィジェットの出力
6047 function getWidgetOutput($widgetId, $configId = 0)
6049 global $gEnvManager;
6050 global $gErrorManager;
6052 // ウィジェットのアクセス権をチェック
6053 if (!$this->db->canAccessWidget($widgetId)) return '';
6056 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
6059 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
6061 // 必要なJavascriptライブラリを追加
6062 $scritLib = trim($row['wd_add_script_lib']);
6063 if (!empty($scritLib)) $this->addScript('', $scritLib);
6069 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
6072 $saveWidgetId = $gEnvManager->getCurrentWidgetId();
6073 $gEnvManager->setCurrentWidgetId($widgetId);
6076 $saveConfigId = $gEnvManager->getCurrentWidgetConfigId();
6077 $gEnvManager->setCurrentWidgetConfigId($configId);
6080 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
6083 //$gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
6086 //$gEnvManager->setCurrentWidgetTitle($title);
6088 // ウィジェットのグローバル属性状況を設定
6089 //$gEnvManager->setIsCurrentWidgetShared($shared);
6092 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
6095 //require_once($widgetIndexFile);
6096 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
6097 $msg = 'widget-start(' . $widgetId . ')';
6098 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
6099 if (file_exists($widgetIndexFile)){
6100 require($widgetIndexFile);
6102 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
6104 $msg = 'widget-end(' . $widgetId . ')';
6105 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
6108 $gEnvManager->setCurrentWidgetId($saveWidgetId);
6111 $gEnvManager->setCurrentWidgetConfigId($saveConfigId);
6114 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
6117 //$gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
6119 // ウィジェットのグローバル属性状況を解除
6120 //$gEnvManager->setIsCurrentWidgetShared(false);
6122 // 現在のバッファ内容を取得し、バッファを破棄
6123 $output = ob_get_contents();
6131 * @param int $cmdNo 実行コマンド(0=初期化、1=更新、2=計算、10=コンテンツ取得)
6132 * @param string $id ウィジェットID+インナーウィジェットID
6133 * @param string $configId インナーウィジェット定義ID
6134 * @param object $paramObj インナーウィジェットに渡すパラメータオブジェクト
6135 * @param object $optionParamObj インナーウィジェットに渡すパラメータオブジェクト(オプション)
6136 * @param object $resultObj インナーウィジェットから返る結果オブジェクト
6137 * @param string $content 出力内容
6138 * @param bool $isAdmin 管理者機能(adminディレクトリ以下)かどうか
6139 * @return bool true=成功、false=失敗
6141 function commandIWidget($cmdNo, $id, $configId, &$paramObj, &$optionParamObj, &$resultObj, &$content, $isAdmin = false)
6143 global $gEnvManager;
6145 // ウィジェットIDとインナーウィジェットIDを取り出す
6146 list($widgetId, $iWidgetId) = explode(M3_WIDGET_ID_SEPARATOR, $id);
6148 // インナーウィジェットに渡すパラメータを設定
6151 $cmd = self::IWIDTET_CMD_INIT; // 初期化
6152 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
6155 $cmd = self::IWIDTET_CMD_UPDATE; // 更新
6156 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
6159 $cmd = self::IWIDTET_CMD_CALC; // 計算
6160 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
6163 $cmd = self::IWIDTET_CMD_CONTENT; // コンテンツ取得
6164 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
6168 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
6172 // インナーウィジェットのエラー出力は呼び出しウィジェット側で受けるため、出力を抑止する
6173 ob_start();// バッファ作成
6176 if (empty($widgetId)){ // ウィジェットIDが指定されていないときは共通ディレクトリ
6177 //$gEnvManager->getIWidgetsPath() . '/' . $iWidgetId . '/' . $containerClass . '.php';
6180 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/' . M3_DIR_NAME_ADMIN . '/index.php';
6182 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/index.php';
6186 // 作業中のインナーウィジェットIDを設定
6187 $gEnvManager->setCurrentIWidgetId($id); // インナーウィジェットを設定
6189 // インナーウィジェット定義IDを設定
6190 $gEnvManager->setCurrentIWidgetConfigId($configId);
6193 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
6194 if (file_exists($widgetIndexFile)){
6195 require($widgetIndexFile);
6197 echo 'file not found error: ' . $widgetIndexFile;
6201 $gEnvManager->setCurrentIWidgetId('');
6203 // インナーウィジェット定義IDを解除
6204 $gEnvManager->setCurrentIWidgetConfigId('');
6206 // 現在のバッファ内容を取得し、バッファを破棄
6207 $content = ob_get_contents();
6211 if ($this->gInstance->getCmdParamManager()->getParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $obj, $option)){
6213 $optionParamObj = $option;
6217 if ($this->gInstance->getCmdParamManager()->getResult($id . M3_WIDGET_ID_SEPARATOR . $configId, $resObj)) $resultObj = $resObj;
6221 * コールバックメソッドを実行し、出力を返す
6223 * @param array $callback 実行するコールバック
6224 * @return string 出力結果
6226 function getOutputByCallbackMethod($callback)
6228 ob_start();// バッファ作成
6231 if (is_callable($callback)) call_user_func($callback);
6233 // 現在のバッファ内容を取得し、バッファを破棄
6234 $content = ob_get_contents();
6239 * ページ作成処理中断を行った場合のレスポンスヘッダ設定
6241 * @param int $responseCode レスポンスコード
6244 function setResponse($responseCode)
6246 switch ($responseCode){
6247 case 400: // リクエストにエラーがあるとき
6248 header('HTTP/1.1 400 Bad request');
6249 header('Status: 400 Bad request');
6251 case 403: // アクセス禁止のとき
6252 header('HTTP/1.1 403 Forbidden');
6253 header('Status: 403 Forbidden');
6255 case 404: // 存在しないページのとき
6256 header("HTTP/1.1 404 Not Found");
6257 header("Status: 404 Not Found");
6259 case 500: // サーバ内部エラー
6260 header('HTTP/1.1 500 Internal Server Error');
6261 header('Status: 500 Internal Server Error');
6263 case 503: // サイト非公開(システムメンテナンス)
6264 header('HTTP/1.1 503 Service Temporarily Unavailable');
6265 header('Status: 503 Service Temporarily Unavailable');
6272 * @param string $filePath ダウンロードするファイルのファイルパス
6273 * @param string $downloadFilename ダウンロード時のファイル名
6274 * @param bool $deleteFile 実行後ファイルを削除するかどうか(成功失敗に関係なく)
6275 * @return bool true=成功、false=失敗
6277 function downloadFile($filePath, $downloadFilename, $deleteFile=false)
6280 if (!file_exists($filePath)) return false;
6283 $fileSize = filesize($filePath);
6285 // バッファ内容が残っているときは破棄
6286 if (ob_get_level() > 0) ob_end_clean();
6288 header('Cache-Control: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
6289 header('Pragma: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
6290 header('Content-Disposition: attachment; filename=' . $downloadFilename);
6291 header('Content-Length: ' . $fileSize);
6292 header('Content-Type: application/octet-stream; name=' . $downloadFilename);
6293 $fp = fopen($filePath, "r");
6294 echo fread($fp, $fileSize);
6300 if ($deleteFile) unlink($filePath);
6304 * システム制御ページを表示するかどうかを返す
6306 * @return bool true=システム制御ページを表示、false=システム制御ページを表示しない
6308 function isSystemPage()
6310 return $this->isSystemPage;
6315 * @param string $url 遷移先URL。未指定の場合は現在のスクリプト。URLでないときは、現在のスクリプトに付加。
6316 * @param bool $noMessage 画面を遷移させたとき、ドコモ携帯端末でダイアログ(サイトが移動しました(301))が出ないようにするオプション
6317 * @param int $responseCode レスポンスコード
6318 * @param bool $autoSsl リダイレクト先のページの状態に合わせてSSLを制御するかどうか
6321 function redirect($url = '', $noMessage = false, $responseCode = 0, $autoSsl = true)
6323 global $gEnvManager;
6325 // すでにリダイレクトが設定されている場合は終了
6326 if ($this->isRedirect) return; // リダイレクトするかどうか
6330 $toUrl = $gEnvManager->getCurrentScriptUrl();
6331 } else if (strncmp($toUrl, 'http://', 7) != 0 && strncmp($toUrl, 'https://', 8) != 0){ // URL以外のときはクエリー文字列と判断する
6332 $toUrl = $gEnvManager->getCurrentScriptUrl() . $toUrl;
6335 // SSL化が必要な場合はhttpsに変更
6338 if ($gEnvManager->isAdminUrlAccess($toUrl)){ // 管理画面へのアクセスのとき
6339 // ルートURLがSSLの場合は管理画面は常にSSL付き
6340 if ($gEnvManager->isRootUrlSsl()) $isSslPage = true;
6343 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
6344 } else { // フロント画面へのアクセスのとき
6346 $paramArray = array();
6347 //list($filename, $query) = explode('?', basename($toUrl));
6348 list($url, $query) = explode('?', $toUrl);
6349 $baseUrl = dirname($url);
6350 $filename = basename($url);
6351 if (empty($filename)) $filename = M3_FILENAME_INDEX;
6352 if (!empty($query)) parse_str($query, $paramArray); // クエリーの解析
6355 $pageId = basename($filename, '.php');
6356 $pageSubId = $paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID];
6359 $isSslPage = $this->isSslPage($pageId, $pageSubId);
6362 if ($this->gSystem->hierarchicalPage() && $filename == M3_FILENAME_INDEX){
6363 $toUrl = $baseUrl . '/' . $pageSubId . '/';
6364 unset($paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID]);
6366 $paramStr = $this->_createUrlParamStr($paramArray);
6367 if (!empty($paramStr)) $toUrl .= '?' . $paramStr;
6371 //$toUrl = str_replace('http://', 'https://', $toUrl);
6372 $toUrl = $gEnvManager->getSslUrl($toUrl); // SSL用URLに変換
6374 $toUrl = str_replace('https://', 'http://', $toUrl);
6378 // バッファ内容が残っているときは破棄
6379 if (ob_get_level() > 0) ob_end_clean();
6381 if (empty($responseCode)){
6383 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
6385 // header('HTTP/1.1 301 Moved Permanently');
6386 header('HTTP/1.1 302 Moved Temporary'); // ドメインのURLをHTTPからHTTPに変更するとChromeで問題が発生したので301から302リダイレクトに変更(2018/4/30)
6388 } else { // レスポンスコードが指定されている場合
6389 switch ($responseCode){
6391 // ##### 301リダイレクトはChromeではブラウザにキャッシュされてしまうので注意 #####
6392 header('HTTP/1.1 301 Moved Permanently');
6395 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
6398 header('HTTP/1.1 303 See Other');
6400 case 500: // サーバ内部エラー
6401 header('HTTP/1.1 500 Internal Server Error');
6402 header('Status: 500 Internal Server Error');
6404 case 503: // サイト非公開(システムメンテナンス)
6405 header('HTTP/1.1 503 Service Temporarily Unavailable');
6406 header('Status: 503 Service Temporarily Unavailable');
6409 header('HTTP/1.1 ' . (string)$responseCode);
6413 header('Location: ' . $toUrl);
6415 $this->isRedirect = true; // リダイレクトするかどうか
6420 * @return bool true=リダイレクト、false=リダイレクトでない
6422 function isRedirect()
6424 return $this->isRedirect;
6427 * 指定URLのディレクトリへリダイレクト
6431 function redirectToDirectory()
6433 global $gEnvManager;
6436 $dirPath = dirname($gEnvManager->getCurrentScriptUrl()) . '/';
6437 //$this->redirect($dirPath);
6438 $this->redirect($dirPath, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/7/23)
6443 * @param string $url 遷移先URL
6446 function redirectInInstall($url)
6448 $this->redirect($url, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
6455 function redirectToInstall()
6457 global $gEnvManager;
6459 $sytemRootUrl = $gEnvManager->calcSystemRootUrl();
6460 //$this->redirect($sytemRootUrl . '/admin/install.php');
6461 $this->redirect($sytemRootUrl . '/admin/install.php', false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
6464 * ログイン、ログアウト処理を行った後、リダイレクト
6466 * @param RequestManager $request HTTPリクエスト処理クラス
6467 * @param bool $success ログインの成否
6468 * @param string $redirectUrl ログイン成功の場合のリダイレクト先
6469 * @return int 0=何も処理しなかった場合、1=ログイン処理、2=ログアウト処理、3=パスワード送信
6471 function standardLoginLogoutRedirect($request, &$success, $redirectUrl = '')
6473 global $gEnvManager;
6474 global $gAccessManager;
6475 global $gRequestManager;
6477 // ログイン、ログアウト処理、および、コンテナの起動
6478 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
6479 if ($cmd == M3_REQUEST_CMD_LOGIN){ // ログインの場合
6480 $act = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_ACT);
6481 if ($act == 'sendpwd'){ // パスワード送信の場合
6482 $success = $gAccessManager->sendPassword($request);
6486 $ret = $gAccessManager->userLogin($request);
6488 if (empty($redirectUrl)){
6489 // システム運用可能ユーザの場合でリダイレクト先が設定されていない場合はデフォルトの管理画面URLへ遷移
6490 $userInfo = $gEnvManager->getCurrentUserInfo();// ユーザ情報取得
6491 if ($userInfo->userType >= UserInfo::USER_TYPE_MANAGER){
6492 $ret = $this->db->getLoginUserRecordById($userInfo->userId, $userInfoRow);
6493 if ($ret && !empty($userInfoRow['lu_default_admin_url'])){
6494 $redirectUrl = $gEnvManager->getDefaultAdminUrl() . $userInfoRow['lu_default_admin_url'];
6500 $this->redirect($redirectUrl);
6501 $success = true; // ログイン成功
6502 } else { // ログイン失敗のとき
6503 $success = false; // ログイン失敗
6507 } else if ($cmd == M3_REQUEST_CMD_LOGOUT){ // ログアウト
6509 $gAccessManager->userLogout(true);
6512 $this->redirect($redirectUrl);
6521 * @param int $errStatus HTTPエラーステータスコード
6524 function showError($errStatus)
6527 $this->setResponse($errStatus);
6530 $msg = 'NOT DEFINED ERROR';
6531 switch ($errStatus){
6532 case 403: // アクセス禁止のとき
6535 case 404: // 存在しないページのとき
6538 case 500: // サーバ内部エラー
6539 $msg = 'Internal Server Error';
6541 case 503: // サイト非公開(システムメンテナンス)
6542 $msg = 'Service Temporarily Unavailable';
6546 echo '<!doctype html>';
6549 echo '<title>' . $msg . '</title>';
6552 echo '<h2>' . $msg . '</h2>';
6557 * ウィジェットがセットされているページサブIDを取得
6559 * @param string $pageId ページID
6560 * @param string $widgetId 対象ウィジェットID
6561 * @param int $configId ウィジェット定義ID
6562 * @return string ページサブID
6564 function getPageSubIdByWidget($pageId, $widgetId, $configId = 0)
6568 // 対象のウィジェットのページサブIDを取得
6569 $ret = $this->db->getSubPageId($widgetId, $pageId, $rows);
6570 if ($ret){// データが存在する
6571 for ($i = 0; $i < count($rows); $i++){
6572 if (!empty($rows[$i]['pd_sub_id']) && $rows[$i]['pd_config_id'] == $configId){
6573 $pageSubId = $rows[$i]['pd_sub_id'];
6581 * その他のGET,POSTパラメータからページサブID取得
6583 * @param RequestManager $request HTTPリクエスト処理クラス
6584 * @param string $redirectUrl リダイレクト用URL
6585 * @return string ページサブID
6587 function getPageSubIdByParam($request, &$redirectUrl)
6589 global $gEnvManager;
6593 $task = $request->trimValueOf('task');
6594 $option = $request->trimValueOf('option');
6595 if ($task == 'search' && $option == 'com_search'){ // joomla!の検索結果表示の場合
6596 $this->contentType = M3_VIEW_TYPE_SEARCH; // ページのコンテンツタイプ
6598 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_SEARCH, $gEnvManager->getCurrentPageId());// ページサブIDを取得
6599 if (!empty($subId)){
6601 $keyword = $request->trimValueOf('searchword');
6602 $redirectUrl = $gEnvManager->createPageUrl();
6603 $redirectUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subId;
6604 $redirectUrl .= '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=search&' . M3_REQUEST_PARAM_KEYWORD . '=' . urlencode($keyword);
6610 * コンテンツタイプとページIDからページサブID取得
6612 * @param string $contentType コンテンツタイプ
6613 * @param string $pageId ページID
6614 * @return string ページサブID
6616 function getPageSubIdByContentType($contentType, $pageId)
6618 $subId = $this->db->getSubPageIdWithContent($contentType, $pageId);// ページサブIDを取得
6622 * 指定のウィジェットがページ上にあるかを取得
6624 * @param string $pageId ページID
6625 * @param string $widgetId 対象ウィジェットID
6626 * @param bool $activePageOnly 公開中のページのウィジェットに制限するかどうか。falseの場合はすべてのページのウィジェットを対象とする。
6627 * @return bool true=ページ上にあり、false=ページ上になし
6629 function isWidgetOnPage($pageId, $widgetId, $activePageOnly=true)
6631 $ret = $this->db->isWidgetOnPage($pageId, $widgetId, $activePageOnly, 0/*定義セットID*/);
6635 * URLで示されるページ上のウィジェットをウィジェット種別で取得
6637 * @param string $url URL
6638 * @param string $widgetType 対象ウィジェットタイプ
6639 * @return string ウィジェットID
6641 function getWidgetIdByWidgetType($url, $widgetType)
6643 $ret = $this->getPageIdFromUrl($url, $pageId, $pageSubId, $param);
6646 if ($ret) $widgetId = $this->db->getWidgetIdByType($pageId, $pageSubId, $widgetType);
6650 * ページコンテンツタイプ、コンテンツタイプからウィジェットIDを取得
6652 * @param string $pageId ページID
6653 * @param string $contentType コンテンツタイプ
6654 * @return string ウィジェットID
6656 function getWidgetIdWithPageInfoByContentType($pageId, $contentType)
6658 $widgetId = $this->db->getWidgetIdWithPageInfoByContentType($pageId, $contentType);
6662 * ジョブタイプからウィジェットIDを取得
6664 * @param string $jobType ジョブタイプ
6665 * @return string ウィジェットID
6667 function getWidgetIdByJobType($jobType)
6669 global $gEnvManager;
6670 global $gErrorManager;
6674 $linkInfoObj = $this->gInstance->getObject(self::LINKINFO_OBJ_ID);
6675 if (isset($linkInfoObj)) $widgetId = $linkInfoObj->getJobWidget($jobType);
6677 // ウィジェットのアクセス権をチェック
6678 if (!$this->db->canAccessWidget($widgetId)) return '';
6681 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
6684 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
6689 * 現在アクティブなメイン型ウィジェットをウィジェット種別で取得
6691 * @param string $widgetType 対象ウィジェットタイプ
6692 * @return string ウィジェットID
6694 function getActiveMainWidgetIdByWidgetType($widgetType)
6697 $widgetId = $this->db->getActiveMainWidgetIdByType($widgetType);
6701 * URLを解析して、ページID,サブページIDを取得
6703 * @param string $url URL
6704 * @param string $pageId ページID
6705 * @param string $pageSubId ページサブID
6706 * @param array $urlParam URLパラメータ
6707 * @return bool true=成功、false=失敗
6709 function getPageIdFromUrl($url, &$pageId, &$pageSubId, &$urlParam)
6711 global $gEnvManager;
6713 // ページID、ページサブIDを求める
6714 list($page, $other) = explode('?', str_replace($gEnvManager->getRootUrl(), '', $url));
6715 parse_str($other, $urlParam);
6717 $pageId = str_replace('/', '_', trim($page, '/'));
6718 $pageId = basename($pageId, '.php');
6721 $pageSubId = $param[M3_REQUEST_PARAM_PAGE_SUB_ID];
6722 if (empty($pageSubId)) $pageSubId = $gEnvManager->getDefaultPageSubId();
6726 * ウィジェットが組み込まれているページのURLを生成
6728 * @param string $widgetId 送信元ウィジェットID
6729 * @param string $param 実行パラメータ
6730 * @param string $pageId ウィジェットが存在するページID
6731 * @return string 生成したURL
6733 function getDefaultPageUrlByWidget($widgetId, $param = '', $pageId = '')
6735 global $gEnvManager;
6737 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6739 // このウィジェットがマップされているページサブIDを取得
6741 $subPageId = $this->getPageSubIdByWidget($pageId, $widgetId);
6742 if (empty($subPageId)){
6743 // 見つからないときは互換ウィジェットを探す
6744 $targetWidgetId = $this->db->getCompatibleWidgetId($widgetId);
6745 if (!empty($targetWidgetId)){
6746 $subPageId = $this->getPageSubIdByWidget($pageId, $targetWidgetId);
6749 if (!empty($subPageId)) $sub = M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId;
6751 //$url = $gEnvManager->getDefaultUrl();
6752 $url = $gEnvManager->createPageUrl($pageId);
6753 if (!empty($sub)) $url .= '?' . $sub;
6754 if (!empty($param)) $url .= '&' . $param;
6758 * 現在のアクセスポイントの指定のページ属性のページURLを生成
6760 * @param string $contentType コンテンツタイプ
6761 * @param string $param 追加パラメータ
6762 * @param bool $omitPageId ページID省略形を使用するかどうか
6763 * @return string 生成したURL
6765 function createContentPageUrl($contentType, $param = '', $omitPageId = true)
6767 global $gEnvManager;
6768 static $urlArray = array();
6770 // 複数回呼ばれるのでコンテンツタイプごとにページまでのURLは保存しておく
6771 $baseUrl = $urlArray[$contentType];
6772 if (!isset($baseUrl)){
6773 // コンテンツタイプからページサブIDを取得
6774 $pageSubId = $this->getPageSubIdByContentType($contentType, $gEnvManager->getCurrentPageId()); // DBから取得
6776 if (empty($pageSubId)){ // ページサブIDが取得できない場合はデフォルトのページサブIDを取得
6777 $pageSubId = $gEnvManager->getDefaultPageSubId();
6778 } else if ($pageSubId == $gEnvManager->getDefaultPageSubId()){ // デフォルトページの場合
6779 if ($omitPageId) $pageSubId = ''; // ページID省略形を使用する場合はページサブIDを省略
6782 // 現在のアクセスポイントのURLを取得
6783 $baseUrl = $gEnvManager->createPageUrl();
6786 if (!empty($pageSubId)) $baseUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId;
6789 $urlArray[$contentType] = $baseUrl;
6794 if (!empty($param)){
6795 if (strEndsWith($url, '.php') || strEndsWith($url, '/')){
6805 * ウィジェット指定呼び出し用のURLを生成
6807 * @param string $toWidgetId 送信先ウィジェットID
6808 * @param string $fromWidgetId 送信元ウィジェットID
6809 * @param string $todo 実行パラメータ
6810 * @param string $pageId ページID(空のときは現在のURL)
6811 * @return string 生成したURL
6813 function createWidgetCmdUrl($toWidgetId, $fromWidgetId, $todo, $pageId = '')
6815 global $gEnvManager;
6817 $url = $gEnvManager->createPageUrl($pageId);
6819 $url .= '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_FIND_WIDGET;
6820 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $toWidgetId;
6821 if (!empty($fromWidgetId)) $url .= '&' . M3_REQUEST_PARAM_FROM . '=' . $fromWidgetId; // 送信元
6822 if (!empty($todo)) $url .= '&' . M3_REQUEST_PARAM_OPERATION_TODO . '=' . urlencode($todo);
6828 * @param string $widgetId 実行ウィジェットID
6829 * @param string $optionParam 追加パラメータ
6830 * @param string $pageId ページID(空のときは現在のURL)
6831 * @param string $pageSubId ページサブID
6832 * @return string 生成したURL
6834 function createRssCmdUrl($widgetId, $optionParam = '', $pageId = '', $pageSubId = '')
6836 global $gEnvManager;
6839 $url = $gEnvManager->createPageUrl() . '?';
6842 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6843 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6845 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_RSS;
6846 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6847 if (!empty($optionParam)) $url .= '&' . $optionParam;
6853 * @param bool $isSslPage SSLが必要なページかどうか
6854 * @param string $optionParam 追加パラメータ
6855 * @return string 生成したURL
6857 function createCssCmdUrl($isSslPage, $optionParam = '')
6859 global $gEnvManager;
6860 global $gRequestManager;
6863 // $url = $gEnvManager->createPageUrl() . '?';
6864 $url = $gEnvManager->createPageUrl(''/*現在のページ*/, $isSslPage) . '?';
6867 $pageSubId = $this->gEnv->getCurrentPageSubId();
6868 $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6870 // コンテンツ詳細画面の場合はコンテンツパラメータを追加
6871 if ($this->isContentDetailPage){
6872 switch ($this->contentType){
6873 case M3_VIEW_TYPE_CONTENT: // 汎用コンテンツ
6874 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID);
6875 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID_SHORT);
6876 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentsId . '&';
6878 case M3_VIEW_TYPE_PRODUCT: // 製品
6879 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID);
6880 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID_SHORT);
6881 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PRODUCT_ID . '=' . $contentsId . '&';
6883 case M3_VIEW_TYPE_BBS: // BBS
6884 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID);
6885 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT);
6886 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BBS_THREAD_ID . '=' . $contentsId . '&';
6888 case M3_VIEW_TYPE_BLOG: // ブログ
6889 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID);
6890 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT);
6891 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $contentsId . '&';
6893 case M3_VIEW_TYPE_WIKI: // Wiki
6894 $contentsId = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
6895 if (!empty($contentsId)) $url .= $contentsId . '&';
6897 case M3_VIEW_TYPE_USER: // ユーザ作成コンテンツ
6898 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_ROOM_ID);
6899 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_ROOM_ID_SHORT);
6900 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_ROOM_ID . '=' . $contentsId . '&';
6902 case M3_VIEW_TYPE_EVENT: // イベント
6903 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID);
6904 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID_SHORT);
6905 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_EVENT_ID . '=' . $contentsId . '&';
6907 case M3_VIEW_TYPE_PHOTO: // フォトギャラリー
6908 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID);
6909 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID_SHORT);
6910 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PHOTO_ID . '=' . $contentsId . '&';
6915 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_CSS;
6916 if (!empty($optionParam)) $url .= '&' . $optionParam;
6922 * @param string $widgetId 実行ウィジェットID
6923 * @param string $optionParam 追加パラメータ
6924 * @param bool $byMacro マクロ変換で返すかどうか
6925 * @param string $pageId ページID(空のときは現在のURL)
6926 * @param string $pageSubId ページサブID
6927 * @return string 生成したURL
6929 function createDirectWidgetCmdUrl($widgetId, $optionParam = '', $byMacro = false, $pageId = '', $pageSubId = '')
6931 global $gEnvManager;
6935 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . M3_FILENAME_INDEX . '?';
6937 $url = $gEnvManager->createPageUrl() . '?';
6941 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6942 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6944 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_DO_WIDGET;
6945 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6946 if (!empty($optionParam)) $url .= '&' . $optionParam;
6952 * @return array パラメータ文字列の配列
6954 function getUrlParamOrder()
6956 return $this->urlParamOrder; // URLパラメータの並び順
6959 * キャッシュ制御用の付加パラメータを取得
6961 * @return string パラメータ
6963 function getCacheParam()
6965 $addParam = '?' . date('YmdHis');
6969 * 現在のURLにアクセス可能かチェック
6971 * @param bool $isActivePage ページが有効かどうか
6972 * @param int $errCode エラーコード
6973 * @return bool true=可能、false=不可
6975 function canAccessUrl(&$isActivePage, &$errCode)
6977 global $gEnvManager;
6979 $errCode = 0; // エラーコード初期化
6981 // 現在設定されているページIDを取得
6982 $pageId = $gEnvManager->getCurrentPageId();
6983 $pageSubId = $gEnvManager->getCurrentPageSubId();
6984 $ret = $this->db->canAccessPage($pageId, $pageSubId, $pageVisible, $pageSubVisible, $isAdminMenu);
6985 if ($ret){ // アクセス可能なときは、ユーザ制限もチェックする
6986 $isActivePage = true;
6989 if (!$pageVisible || !$pageSubVisible) return false;
6991 if (!$gEnvManager->isCurrentUserLogined() && $this->isUserLimitedPage($pageId, $pageSubId)){ // ユーザがログインされていない状態でユーザ制限されていればアクセス不可
6994 $this->isAccessPointWithAdminMenu = $isAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
6997 } else { // 無効ページのとき
6998 $isActivePage = false;
7000 // ページIDの文字のチェック。ページIDは半角英小文字、数字、アンダーバー、ハイフンのみ使用可能。
7001 if (preg_match("/[^0-9a-z-_]/", $pageSubId)) $errCode = 1; // 不正文字検出
7006 * ウィジェットヘッダ(Joomla!1.0用)を出力タイプを取得
7008 * @return int 0=出力しない、1=Joomla!1.0テンプレートPC用、2=Joomla!1.0テンプレート携帯用
7010 function getTemplateWidgetHeaderType()
7012 global $gEnvManager;
7014 $templateId = $gEnvManager->getCurrentTemplateId();
7015 if ($templateId == self::ADMIN_TEMPLATE || // PC管理用テンプレート
7016 $templateId == self::M_ADMIN_TEMPLATE){ // 携帯管理用テンプレート
7018 } else if(strncmp($templateId, 'm/', 2) == 0){ // 携帯用テンプレート
7019 return 2; // 携帯テンプレート用出力
7021 return 1; // PCテンプレート用出力
7027 * @param string $pageId ページID
7028 * @param string $pageSubId ページサブID
7029 * @return bool true=必要、false=不要
7031 function isSslPage($pageId, $pageSubId)
7033 global $gEnvManager;
7036 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
7039 if ($pageId == $gEnvManager->getDefaultAdminPageId()){
7040 if ($gEnvManager->getUseSslAdmin()){ // 管理用ページにSSLを使用するかどうか
7047 // ##### フロント画面の場合 #####
7048 if ($gEnvManager->isRootUrlSsl()) return true; // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
7050 // 一般用ページにSSLを使用しない場合は不要を返す
7051 if (!$gEnvManager->getUseSsl()) return false;
7053 // 一般用ページでSSLを使用する場合は、データベースの設定をチェックする
7054 $line = $this->getPageInfo($pageId, $pageSubId);
7056 if ($line['pn_use_ssl']){
7065 * ユーザ制限が必要なページかどうかを判断
7067 * @param string $pageId ページID
7068 * @param string $pageSubId ページサブID
7069 * @return bool true=必要、false=不要
7071 function isUserLimitedPage($pageId, $pageSubId)
7073 global $gEnvManager;
7076 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
7078 $line = $this->getPageInfo($pageId, $pageSubId);
7080 if ($line['pn_user_limited']){
7091 * @param string $pageId ページID
7092 * @param string $pageSubId ページサブID
7093 * @return array ページ情報レコード
7095 function getPageInfo($pageId, $pageSubId)
7097 // ページ情報が空のときはデータをロード
7098 if (empty($this->pageInfo)){
7099 $records = $this->db->getPageInfoRecords();
7100 $count = count($records);
7101 $this->pageInfo = array();
7102 for ($i = 0; $i < $count; $i++){
7103 $pId = $records[$i]['pn_id'] . self::PAGE_ID_SEPARATOR . $records[$i]['pn_sub_id'];
7104 $this->pageInfo[$pId] = $records[$i];
7107 return $this->pageInfo[$pageId . self::PAGE_ID_SEPARATOR . $pageSubId];
7112 * @return array ページ情報レコード
7114 function getCurrentPageInfo()
7116 return $this->currentPageInfo;
7119 * 現在のページ情報からテンプレートIDを取得
7121 * @param string $subTemplateId テンプレートIDが取得できるときはサブページIDが返る
7122 * @return string テンプレートID
7124 function getTemplateIdFromCurrentPageInfo(&$subTemplateId)
7127 if (!empty($this->currentPageInfo)){
7128 $templateId = $this->currentPageInfo['pn_template_id'];
7129 $subTemplateId = $this->currentPageInfo['pn_sub_template_id']; // サブテンプレートID
7134 * JavascriptライブラリのIDを取得
7136 * @param int $type 種別(0=すべて、1=jQuery関係すべて、2=jQueryプラグインのみ)
7137 * @return array JavascriptライブラリのID
7139 function getScriptLibId($type = 0)
7141 // Javascriptライブラリのすべてのキーを取得
7142 $keys = array_keys($this->libFiles);
7144 $destKeys = array();
7145 for ($i = 0; $i < count($keys); $i++){
7147 case 1: // jQuery関係すべて
7148 if (strStartsWith($keys[$i], 'jquery')) $destKeys[] = $keys[$i];
7150 case 2: // jQueryプラグインのみ
7151 if (strStartsWith($keys[$i], 'jquery.')) $destKeys[] = $keys[$i];
7158 * Javascriptライブラリの情報を取得
7160 * @param string $id ライブラリID
7161 * @return array ライブラリの情報
7163 function getScriptLibInfo($id)
7165 $libInfo = $this->libFiles[$id];
7166 if (isset($libInfo)){
7173 * 管理画面用jQueryUIテーマのURLを取得
7175 * @return string テーマURL
7177 function getAdminDefaultThemeUrl()
7179 // $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
7180 $themeFile = $this->gEnv->getAdminUrl(true/*「admin」削除*/) . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
7184 * フロント画面用jQueryUIテーマのURLを取得
7186 * @return string テーマURL
7188 function getDefaultThemeUrl()
7192 if (!isset($themeFile)){
7194 $theme = $this->gSystem->defaultTheme();
7195 if (!empty($theme)){
7196 $path = $this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
7197 if (file_exists($path)) $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
7205 * @param array $paramArray URL作成用のパス
7206 * @return string 作成したURLパラメータ
7208 function _createUrlParamStr($paramArray)
7211 if (count($paramArray) == 0) return $destParam;
7213 $sortParam = array();
7214 $keys = array_keys($paramArray);
7215 $keyCount = count($keys);
7216 for ($i = 0; $i < $keyCount; $i++){
7218 $value = $paramArray[$key];
7219 $orderNo = $this->urlParamOrder[$key];
7220 if (!isset($orderNo)) $orderNo = 100;
7221 $sortParam[] = array('key' => $key, 'value' => $value, 'no' => $orderNo);
7223 // usort($sortParam, create_function('$a,$b', 'return $a["no"] - $b["no"];'));
7224 usort($sortParam, function($a, $b)
7226 return $a['no'] - $b['no'];
7230 $sortCount = count($sortParam);
7231 for ($i = 0; $i < $sortCount; $i++){
7232 if ($i > 0) $destParam .= '&';
7233 $destParam .= rawurlencode($sortParam[$i]['key']) . '=' . rawurlencode($sortParam[$i]['value']);
7238 * DBからCSSファイル(テンプレート独自のCSSまたは外部のCSS)を取得
7240 * @param string $templateId テンプレートID
7241 * @return bool true=取得成功、false=取得失敗
7243 function loadCssFiles($templateId = '')
7245 if (empty($templateId)) $templateId = $this->gSystem->defaultTemplateId(); // PC画面デフォルトのテンプレートを取得
7247 $ret = $this->db->getTemplate($templateId, $row);
7248 if (!$ret) return false;
7250 // 編集エディタ用パラメータが初期化されていない場合は初期化
7251 if (empty($row['tm_editor_param'])){
7252 // テンプレートを解析し、使用しているCSSファイルを取得
7253 $editorParamObj = $this->parseTemplate($templateId);
7256 $updateParam = array();
7257 $updateParam['tm_editor_param'] = serialize($editorParamObj);
7258 $ret = $this->db->updateTemplate($templateId, $updateParam);
7260 $editorParamObj = unserialize($row['tm_editor_param']);
7263 if (isset($editorParamObj)){
7264 $this->ckeditorCssFiles = array();
7265 $cssFiles = $editorParamObj->cssFiles;
7266 for ($i = 0; $i < count($cssFiles); $i++){
7267 $cssFile = $cssFiles[$i];
7269 if (strStartsWith($cssFile, '//')){ // URLが「//」で始まる外部ファイルの場合はそのまま追加
7270 $this->ckeditorCssFiles[] = $cssFile;
7271 } else if (strStartsWith($cssFile, '/')){ // URLが「/」で始まる相対パスの場合はURLに変換
7272 $this->ckeditorCssFiles[] = $this->gEnv->getAdminUrl(true/*adminディレクトリ削除*/) . $cssFile;
7274 $this->ckeditorCssFiles[] = $cssFile;
7283 * URLで指定した画面のCSSファイル(テンプレート独自のCSSまたは外部のCSS)を取得
7285 * @param string $url 取得画面のURL
7288 function loadCssFilesByUrl($url)
7290 // ##### cURLを使用する場合はセッションのブロックを解除する #####
7291 session_write_close();
7294 curl_setopt($ch, CURLOPT_URL, $url);
7295 curl_setopt($ch, CURLOPT_USERAGENT, M3_SYSTEM_NAME . '/' . M3_SYSTEM_VERSION); // ユーザエージェント
7296 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 画面に出力しない
7297 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
7298 curl_setopt($ch, CURLOPT_TIMEOUT, 3);
7299 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); // セッションを維持
7300 $content = curl_exec($ch);
7304 $urlArray = array();
7306 $pattern = '/<head\b[^>]*?>(.*?)<\/head\b[^>]*?>/si';
7307 if (preg_match($pattern, $content, $matches)) $headContent = $matches[0];
7310 $pattern = '/<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>/si';
7311 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7312 foreach ($matches as $match){
7313 if (strEndsWith($match[1], '.css')){ // ファイル名の拡張子が「css」の場合
7314 $urlArray[] = $match[1];
7316 // typeが「text/css」を取得
7317 $attrPattern = '/type\s*=\s*[\'"]+(.+?)[\'"]/si';
7318 if (preg_match($attrPattern, $match[0], $attrMatch)){
7319 if (strcasecmp($attrMatch[1], 'text/css') == 0){
7320 $urlArray[] = $match[1];
7324 // relが「stylesheet」を取得
7325 $attrPattern = '/rel\s*=\s*[\'"]+(.+?)[\'"]/si';
7326 if (preg_match($attrPattern, $match[0], $attrMatch)){
7327 if (strcasecmp($attrMatch[1], 'stylesheet') == 0){
7328 $urlArray[] = $match[1];
7336 // ifで制御されているCSSファイルを除く
7337 $delUrlArray = array();
7338 $pattern = '/<!--\[if\b.*?\]>[\s\S]*<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>[\s\S]*<!\[endif\]-->/si';
7339 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7340 foreach ($matches as $match) $delUrlArray[] = $match[1];
7343 // ##### テンプレート独自のCSSまたは外部のCSSを取得する #####
7344 $this->ckeditorCssFiles = array();
7345 $cssFiles = array_merge(array_diff($urlArray, $delUrlArray)); // CKEditor用のCSSファイル
7346 for ($i = 0; $i < count($cssFiles); $i++){
7347 $cssFileUrl = $cssFiles[$i];
7349 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7350 $baseUrl = $this->gEnv->getRootUrl();
7351 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7352 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7355 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7357 if (strStartsWith($relativePath, '//')){ // URLが「//」で始まる外部ファイルの場合
7358 $this->ckeditorCssFiles[] = $cssFileUrl;
7359 } else if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){ // テンプレートディレクトリの場合
7360 $this->ckeditorCssFiles[] = $cssFileUrl;
7361 } else if (strStartsWith($relativePath, '/')){ // テンプレートディレクトリ以外のディレクトリの場合
7362 } else { // 外部URLの場合
7363 $this->ckeditorCssFiles[] = $cssFileUrl;
7368 $pattern = '/var\s*M3_TEMPLATE_TYPE\s*=\s*(\d+?)\s*;/si';
7369 if (preg_match($pattern, $headContent, $matches)) $this->ckeditorTemplateType = $matches[1]; // CKEditor用のテンプレートタイプ
7372 * CKEditor用のテンプレートタイプを取得
7374 * @return int テンプレートタイプ
7376 function getCkeditorTemplateType()
7378 return $this->ckeditorTemplateType;
7383 * @return bool true=正常、false=不正
7385 /* function _checkReferer()
7387 global $gEnvManager;
7388 global $gRequestManager;
7391 $referer = $gRequestManager->trimServerValueOf('HTTP_REFERER');
7392 $uri = $gEnvManager->getCurrentRequestUri();
7393 if (empty($referer) || $referer != $uri){
7400 * テンプレート画面を解析してCSSファイルやポジションの情報を取得
7402 * @param string $templateId テンプレートID
7403 * @return テンプレート情報オブジェクト
7405 function parseTemplate($templateId)
7407 // ##### cURLを使用する場合はセッションのブロックを解除する #####
7408 session_write_close();
7411 $url = $this->gEnv->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_SHOW_POSITION . '&template=' . $templateId;
7414 $tmplateInfoObj = new stdClass;
7415 $tmplateInfoObj->cssFiles = array(); // テンプレートで使用されているCSSファイル
7418 curl_setopt($ch, CURLOPT_URL, $url);
7419 curl_setopt($ch, CURLOPT_USERAGENT, M3_SYSTEM_NAME . '/' . M3_SYSTEM_VERSION); // ユーザエージェント
7420 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 画面に出力しない
7421 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
7422 curl_setopt($ch, CURLOPT_TIMEOUT, 3);
7423 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); // セッションを維持
7424 $content = curl_exec($ch);
7428 $urlArray = array();
7430 $pattern = '/<head\b[^>]*?>(.*?)<\/head\b[^>]*?>/si';
7431 if (preg_match($pattern, $content, $matches)) $headContent = $matches[0];
7434 $pattern = '/<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>/si';
7435 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7436 foreach ($matches as $match){
7437 if (strEndsWith($match[1], '.css')){ // ファイル名の拡張子が「css」の場合
7438 $urlArray[] = $match[1];
7440 // typeが「text/css」を取得
7441 $attrPattern = '/type\s*=\s*[\'"]+(.+?)[\'"]/si';
7442 if (preg_match($attrPattern, $match[0], $attrMatch)){
7443 if (strcasecmp($attrMatch[1], 'text/css') == 0){
7444 $urlArray[] = $match[1];
7448 // relが「stylesheet」を取得
7449 $attrPattern = '/rel\s*=\s*[\'"]+(.+?)[\'"]/si';
7450 if (preg_match($attrPattern, $match[0], $attrMatch)){
7451 if (strcasecmp($attrMatch[1], 'stylesheet') == 0){
7452 $urlArray[] = $match[1];
7460 // ifで制御されているCSSファイルを除く
7461 $delUrlArray = array();
7462 $pattern = '/<!--\[if\b.*?\]>[\s\S]*<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>[\s\S]*<!\[endif\]-->/si';
7463 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7464 foreach ($matches as $match) $delUrlArray[] = $match[1];
7467 // テンプレート独自のCSSまたは外部のCSSを取得する
7468 $cssFiles = array_merge(array_diff($urlArray, $delUrlArray)); // CKEditor用のCSSファイル
7469 for ($i = 0; $i < count($cssFiles); $i++){
7470 $cssFileUrl = $cssFiles[$i];
7472 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7473 $baseUrl = $this->gEnv->getRootUrl();
7474 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7475 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7478 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7480 if (strStartsWith($relativePath, '//')){ // URLが「//」で始まる外部ファイルの場合
7481 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7482 } else if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){ // テンプレートディレクトリの場合
7483 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7484 } else if (strStartsWith($relativePath, '/')){ // テンプレートディレクトリ以外のディレクトリの場合
7485 } else { // 外部URLの場合
7486 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7491 for ($i = 0; $i < count($tmplateInfoObj->cssFiles); $i++){
7492 $cssFileUrl = $tmplateInfoObj->cssFiles[$i];
7495 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7496 $baseUrl = $this->gEnv->getRootUrl();
7497 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7498 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7501 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7503 // テンプレート内のCSSの場合は相対パスに変換
7504 if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){// テンプレートディレクトリの場合
7505 $tmplateInfoObj->cssFiles[$i] = $relativePath;
7507 $tmplateInfoObj->cssFiles[$i] = $cssFileUrl;
7512 $tmplateInfoObj->positions = array();
7513 $pattern = '/var\s*M3_POSITION_DATA\s*=\s*[\'"]+(.+?)[\'"]/si';
7514 if (preg_match($pattern, $headContent, $matches) && !empty($matches[1])){
7515 $tmplateInfoObj->positions = explode(',', $matches[1]);
7517 return $tmplateInfoObj;
7520 * デフォルトのテンプレートからレイアウト用テンプレートで使用していないポジションを取得
7522 * @return array ポジション名の配列
7524 function getLayoutTemplatePosition()
7526 $removePositions = array('header', 'extra1', 'extra2', 'brand', 'hmenu', 'user3', 'banner1', 'top1', 'top2', 'top3',
7527 'left', 'banner2', 'breadcrumb', 'user1', 'user2', 'banner3', 'main-top', 'main', 'main-bottom', 'banner4', 'user4', 'user5', 'banner5',
7528 'right','bottom1', 'bottom2', 'bottom3', 'banner6', 'syndicate', 'copyright', 'footer'); // レイアウト用テンプレートに存在するので削除するポジション
7530 // URLパラメータからデフォルトのテンプレートを取得
7531 $pageId = $this->gRequest->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
7534 if ($pageId == $this->gEnv->getDefaultPageId()){ // 通常サイトのとき
7535 $templateId = $this->gSystem->defaultTemplateId();
7536 } else if ($pageId == $this->gEnv->getDefaultSmartphonePageId()){ // スマートフォン用サイトのとき
7537 $templateId = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
7541 $ret = $this->db->getTemplate($templateId, $row);
7542 if (!$ret) return array();
7543 if (empty($row['tm_editor_param'])) return array();
7545 // レイアウト用テンプレートに存在しないポジション名のみ返す
7546 $editorParamObj = unserialize($row['tm_editor_param']);
7547 if (isset($editorParamObj)){
7548 if (isset($editorParamObj->positions)){
7549 $srcArray = $editorParamObj->positions;
7550 $destArray = array();
7551 for ($i = 0; $i < count($srcArray); $i++){
7552 $position = $srcArray[$i];
7553 if (!in_array($position, $removePositions)) $destArray[] = $position;