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 $isEditMode; // フロント画面編集モード
30 private $isLayout; // 画面レイアウト中かどうか
31 private $isPageTopUrl; // ページトップ(サブページ内のトップ位置)のURLかどうか
32 private $isContentDetailPage; // コンテンツ詳細画面のページかどうか
33 private $tmpData; // データ作成用
34 private $db; // DBオブジェクト
35 private $defaultScriptFiles; // デフォルトで読み込むスクリプトファイル
36 private $defaultCssFiles; // デフォルトで読み込むCSSファイル
37 private $defaultAdminScriptFiles; // デフォルトで読み込むスクリプトファイル(管理用)
38 private $defaultAdminCssFiles; // デフォルトで読み込むCSSファイル(管理用)
39 private $defaultAdminDirScriptFiles; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
40 private $defaultAdminDirCssFiles; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
41 private $headScriptFiles = array(); // ウィジェットからの追加で読み込むスクリプトファイル
42 private $headPreMobileScriptFiles = array();// ウィジェットからの追加で読み込むスクリプトファイル(jQueryMobile用挿入ファイル)
43 private $headCssFiles = array(); // ウィジェットからの追加で読み込むCSSファイル
44 private $headRssFiles = array(); // HTMLヘッダに出力するRSS配信情報
45 private $currentWidgetPosition; // 現在のウィジェットのポジション
46 private $currentWidgetIndex; // 現在のウィジェットのポジション番号
47 private $pageDefPosition; // 現在取得しているページ定義のポジション
48 private $pageDefRows; // ページ定義レコード
49 private $nonSharedWidgetCount = -1; // 非共通ウィジェットの数(-1=ページ作成でないとき)
50 private $replaceHeadDone; // ヘッダマクロ変換処理が完了したかどうか
51 private $useHelp = false; // 標準ヘルプ機能を使用するかどうか
52 private $hasScriptCache = false; // JavaScriptファイルをブラウザにキャッシュさせるかどうか
53 private $isAccessPointWithAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
54 private $lateLaunchWidgetList; // 遅延実行ウィジェットのリスト
55 private $latelaunchWidgetParam; // 遅延実行ウィジェットのパラメータ
56 private $defPositions = array(); // テンプレート上のポジション(画面定義データすべて)
57 private $viewPositions = array(); // テンプレート上のポジション(ウィジェット表示ありのみ)
58 private $viewPosId = array(); // テンプレート上のポジションのタグID
59 private $updateParentWindow; // 親ウィンドウを再描画するかどうか
60 private $updateDefSerial; // 更新する項目のページ定義シリアル番号
61 private $headDescription; // HTMLヘッダ「description」に出力する文字列
62 private $headKeywords; // HTMLヘッダ「keywords」に出力する文字列
63 private $headOthers; // HTMLヘッダに出力するタグ文字列
64 private $adminHeadOthers; // HTMLヘッダに出力するタグ文字列(管理画面用)
65 private $lastHeadTitle; // 最後にヘッダ部titleにセットした文字列
66 private $lastHeadDescription; // 最後にヘッダ部descriptionにセットした文字列
67 private $lastHeadKeywords; // 最後にヘッダ部keywordsにセットした文字列
68 private $headCss = array(); // HTMLヘッダにCSS出力する文字列
69 private $headScript = array(); // HTMLヘッダにJavascript出力する文字列
70 private $headPreMobileScript = array(); // HTMLヘッダにJavascript出力する文字列(jQueryMobile用挿入スクリプト)
71 private $headString = array(); // HTMLヘッダに出力する任意文字列
72 private $exportCss = array(); // 外部出力でCSS出力する文字列
73 private $lastHeadCss; // 最後に設定したHTMLヘッダにCSS出力する文字列
74 private $lastHeadScript; // 最後に設定したHTMLヘッダにJavascript出力する文字列
75 private $lastHeadString; // 最後に設定したHTMLヘッダに出力する任意文字列
76 private $initScript = ''; // ウィンドウ初期化時に実行されるスクリプト
77 private $outputByHtml = true; // HTMLフォーマットで出力するかどうか
78 private $outputHead; // HTMLヘッダ出力を行ったかどうか
79 private $outputTheme; // jQueryUIテーマ出力を行ったかどうか
80 private $outputAjaxResponseBody; // AJAX用のレスポンスボディデータかどうか
81 private $isAbort; // ページ作成処理を中断するかどうか
82 private $isWidgetAbort; // 各ウィジェット処理を中断するかどうか
83 private $isRedirect; // リダイレクトするかどうか
84 private $isSystemPage; // システム制御ページを表示するかどうか
85 private $libFiles; // javascript追加用ライブラリ
86 private $pageDefRev = 234; // 画面定義のリビジョン番号
87 private $headSubTitle = array(); // ヘッダタグサブタイトル
88 private $headSubTitleUrl = array(); // ヘッダサブタイトルのリンク先
89 private $pageInfo; // すべてのページ情報
90 private $currentPageInfo; // 現在のページのページ情報
91 private $configWidgetInfo; // ウィジェット設定画面のウィジェットの情報
92 private $contentType = ''; // ページのコンテンツタイプ
93 private $mainContentTypeInfo; // フロント画面で使用する主要コンテンツタイプ
94 private $subContentTypeInfo; // フロント画面で使用する補助コンテンツタイプ
95 private $mainFeatureTypeInfo; // フロント画面で使用する主要機能タイプ
96 private $adminFeatureTypeInfo; // 管理画面専用で使用する主要機能タイプ
97 private $rssVersion; // RSSバージョン
98 private $rssChannel; // RSSチャンネルデータ
99 private $selectedJQueryFilename; // 使用対象のjQueryファイル
100 private $selectedJQueryUiFilename; // 使用対象のjQuery UIファイル
101 private $selectedJQueryMobileFilename; // 使用対象のjQueryMobileファイル
102 private $urlParamOrder; // URLパラメータの並び順
103 private $wysiwygEditor; // 管理画面用WYSIWYGエディター
104 private $optionTemplateId; // 追加設定するテンプレートID
105 private $optionSubTemplateId; // 追加設定するサブテンプレートID
106 private $isContentGooglemaps; // コンテンツにGoogleマップが含むかどうか
107 private $useGooglemaps; // Googleマップを使用するかどうか
108 private $useBootstrap; // Bootstrapを使用するかどうか
109 private $isHtml5; // HTML5で出力するかどうか
110 private $ckeditorCssFiles = array(); // CKEditor用のCSSファイル
111 private $ckeditorTemplateType; // CKEditor用のテンプレートタイプ
112 private $adminSubNavbarDef = array(); // 管理画面用のサブメニューバーの定義
113 private $adminBreadcrumbDef = array(); // 管理画面用パンくずリスト定義
114 private $adminBreadcrumbDefHelp = array(); // 管理画面用パンくずリストヘルプ定義
115 const CONFIG_KEY_HEAD_TITLE_FORMAT = 'head_title_format'; // ヘッダ作成用フォーマット
116 const ADMIN_WIDGET_ID = 'admin_main'; // 管理用ウィジェットのウィジェットID
117 //const CONTENT_TYPE_WIKI = 'wiki'; // ページのコンテンツタイプ(Wiki)
118 const WIDGET_ID_TAG_START = '{{WIDGETID:'; // 遅延実行用タグ
119 const WIDGET_ID_TAG_END = '}}'; // 遅延実行用タグ
120 const WIDGET_ID_TITLE_TAG_START = '{{WIDGETID_TITLE:'; // 遅延実行用タグ(タイトル埋め込み用)
121 const WIDGET_ID_TITLE_TAG_END = '}}'; // 遅延実行用タグ(タイトル埋め込み用)
122 const WIDGET_ID_SEPARATOR = ',';
123 const HEAD_TAGS = '{{HEAD_TAGS}}'; // HTMLヘッダ出力用タグ
124 const MENUBAR_TAGS = '{{MENUBAR_TAGS}}'; // メニューバー出力用タグ
125 const MENUBAR_SCRIPT_TAGS = '{{MENUBAR_SCRIPT_TAGS}}'; // メニューバー出力用スクリプトタグ
126 const WIDGET_ICON_IMG_SIZE = 32; // ウィジェットアイコンサイズ
127 const WIDGET_INVISIBLE_CLASS = 'm3invisible'; // 非表示ウィジェットクラス
128 const WIDGET_LOGIN_STATUS_CLASS = 'm3loginstatus'; // ログイン状態連動クラス
129 const WIDGET_OUTER_CLASS = 'm3_widget_outer'; // ウィジェット外枠クラス
130 const WIDGET_OUTER_CLASS_HEAD_POSITION = 'm3_pos_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
131 const WIDGET_OUTER_CLASS_WIDGET_TAG = 'm3_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
132 // const WIDGET_INNER_CLASS = 'm3_widget_inner'; // ウィジェットの内側クラス
133 const POSITION_TAG_HEAD = 'm3pos_'; // ポジションの識別用タグIDヘッダ
134 const WIDGET_TAG_HEAD = 'm3widget_'; // ウィジェットの識別用タグIDヘッダ
135 // const WIDGET_TAG_HEAD_SHORT = 'm3_'; // ウィジェットの識別用タグIDヘッダ
136 const WIDGET_TYPE_TAG_HEAD = 'm3widgettype_'; // ウィジェット種別の識別用タグIDヘッダ
137 const WIDTET_CLASS_NAME = 'm3widget'; // ウィジェットオブジェクトのタグクラス名
138 const WIDTET_CLASS_TYPE_0 = 'm3widget_type0'; // ウィジェットオブジェクトのタグクラス(グローバル属性でない)
139 const WIDTET_CLASS_TYPE_1 = 'm3widget_type1'; // ウィジェットオブジェクトのタグクラス(グローバル属性)
140 const POSITION_CLASS_NAME = 'm3position'; // ポジションオブジェクトのタグクラス名
141 const JOOMLA10_DEFAULT_WIDGET_MENU_PARAM = 'class="moduletable"'; // Joomla!1.0用デフォルトメニューパラメータ値
142 const ADMIN_TEMPLATE = '_admin'; // PC管理用テンプレートID
143 const M_ADMIN_TEMPLATE = 'm/_admin'; // 携帯用管理画面テンプレートID
144 const SCRIPT_LIB_SEPARATOR = ';'; // JavaScriptライブラリ読み込み設定のライブラリの区切り
145 const PAGE_ID_SEPARATOR = ','; // ページIDとページサブID連結用
146 const DEFAULT_ADMIN_FAVICON_FILE = '/images/system/favicon.ico'; // デフォルトの管理画面用faviconファイル
147 const DEFAULT_FAVICON_FILE = '/favicon.ico'; // デフォルトのfaviconファイル
148 // const DEFAULT_SITE_NAME = 'サイト名未設定'; // 管理画面用のデフォルトサイト名
149 const DEFAULT_ADMIN_TITLE = '管理画面'; // デフォルトの管理画面名
150 const WIDGET_TITLE_START = '['; // ウィジェットのタイトルの括弧
151 const WIDGET_TITLE_END = ']'; // ウィジェットのタイトルの括弧
152 const DEFAULT_RSS_VERSION = '1.0'; // デフォルトのRSSのバージョン
153 const CF_ACCESS_IN_INTRANET = 'access_in_intranet'; // イントラネット運用かどうか
154 const CF_USE_LATEST_SCRIPT_LIB = 'dev_use_latest_script_lib'; // 最新のJavaScriptライブラリを使用するかどうか
155 const CF_GOOGLE_MAPS_KEY = 'google_maps_key'; // Googleマップ利用キー
156 const CF_CONFIG_WINDOW_OPEN_TYPE = 'config_window_open_type'; // ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
157 const CF_JQUERY_VERSION = 'jquery_version'; // jQueryバージョン
158 const CF_EXTERNAL_JQUERY = 'external_jquery'; // システム外部のjQueryを使用するかどうか
159 const CF_WYSIWYG_EDITOR = 'wysiwyg_editor'; // 管理画面用WYSIWYGエディター
160 const CF_ADMIN_JQUERY_VERSION = 'admin_jquery_version'; // 管理画面用jQueryバージョン
161 const CF_USE_JQUERY = 'use_jquery'; // jQueryを常に使用するかどうか
162 const CF_SMARTPHONE_USE_JQUERY_MOBILE = 'smartphone_use_jquery_mobile'; // スマートフォン画面でjQuery Mobileを使用
163 const SD_HEAD_OTHERS = 'head_others'; // ヘッダその他タグ
164 const DEFAULT_THEME_DIR = '/ui/themes/'; // jQueryUIテーマ格納ディレクトリ
165 const THEME_CSS_FILE = 'jquery-ui.custom.css'; // テーマファイル
166 const CONFIG_ICON_FILE = '/images/system/config.png'; // ウィジェット定義画面アイコン
167 const ADJUST_ICON_FILE = '/images/system/adjust_widget.png'; // 位置調整アイコン
168 const SHARED_ICON_FILE = '/images/system/shared.png'; // グローバル属性
169 const DELETE_ICON_FILE = '/images/system/delete.png'; // ウィジェット削除
170 const CONFIG_ICON32_FILE = '/images/system/config32.png'; // ウィジェット定義画面アイコン(ツールチップ用)
171 const ADJUST_ICON32_FILE = '/images/system/adjust_widget32.png'; // 位置調整アイコン(ツールチップ用)
172 const CLOSE_BOX_ICON32_FILE = '/images/system/close_box.png'; // ウィンドウ閉じるアイコン(ツールチップ用)
173 const NOTICE_ICON_FILE = '/images/system/notice16.png'; // ウィジェット配置注意アイコン
174 const ALERT_ICON_FILE = '/images/system/alert16.png'; // ウィジェット配置警告アイコン
175 // const ADMIN_ICON_FILE = '/images/system/admin64.png'; // パネルメニュー管理画面遷移用アイコン
176 // const LOGOUT_ICON_FILE = '/images/system/logout64.png'; // パネルメニューログアウト用アイコン
177 // const EDIT_PAGE_ICON_FILE = '/images/system/create_page64.png'; // パネルメニュー編集用アイコン
178 const ADMIN_ICON_FILE = '/images/system/home32.png'; // パネルメニュー管理画面遷移用アイコン
179 const LOGOUT_ICON_FILE = '/images/system/logout32.png'; // パネルメニューログアウト用アイコン
180 const EDIT_PAGE_ICON_FILE = '/images/system/create_page32.png'; // パネルメニュー編集用アイコン
181 // const EDIT_END_ICON_FILE = '/images/system/close32.png'; // パネルメニュー編集終了用アイコン
182 const EDIT_END_ICON_FILE = '/images/system/back32.png'; // パネルメニュー編集終了用アイコン
183 const CLOSE_ICON_FILE = '/images/system/close32.png'; // ウィンドウ閉じるアイコン
184 const PREV_ICON_FILE = '/images/system/prev48.png'; // ウィンドウ「前へ」アイコン
185 const NEXT_ICON_FILE = '/images/system/next48.png'; // ウィンドウ「次へ」アイコン
186 const DEFAULT_READMORE_TITLE = 'もっと読む'; // もっと読むボタンのデフォルトタイトル
187 const POS_HEAD_NAV_MENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // 特殊ポジションブロック(ナビゲーションメニュー)
188 const WIDGET_MARK_MAIN = '<i class="glyphicon glyphicon-tower" rel="m3help" title="メイン型" data-placement="auto"></i> '; // ウィジェットの機能マーク(メイン型ウィジェット)
189 const WIDGET_MARK_NAVMENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // ウィジェットの機能マーク(ナビゲーションメニュー)
190 const WIDGET_FUNCTION_MARK_BOOTSTRAP = ' <span class="label label-warning" rel="m3help" title="Bootstrap型テンプレート対応" data-placement="auto">B</span>'; // ウィジェット機能マーク(Boostrap型テンプレート
191 const WIDGET_FUNCTION_MARK_WORDPRESS = ' <span class="label label-warning" rel="m3help" title="WordPress型テンプレート対応" data-placement="auto">W</span>'; // ウィジェット機能マーク(WordPress型テンプレート
192 const WIDGET_STYLE_NAVMENU = '_navmenu'; // ウィジェットの表示スタイル(ナビゲーションメニュー)
193 const WIDGET_STYLE_WORDPRESS = '_wordpress'; // ウィジェットの表示スタイル(WordPressテンプレート用出力)
194 const WIDGET_STYLE_WORDPRESS_NOTITLE = '_wordpress_notitle'; // ウィジェットの表示スタイル(WordPressテンプレート(タイトルなし)用出力)
197 const CONTENT_OBJ_ID = 'contentlib'; // 汎用コンテンツオブジェクトID
198 const BLOG_OBJ_ID = 'bloglib'; // ブログオブジェクトID
199 const LINKINFO_OBJ_ID = 'linkinfo'; // リンク情報オブジェクトID
202 const IWIDTET_CMD_CONTENT = 'content'; // コンテンツ取得
203 const IWIDTET_CMD_INIT = 'init'; // 初期化
204 const IWIDTET_CMD_UPDATE = 'update'; // 更新
205 const IWIDTET_CMD_CALC = 'calc'; // 計算
208 const M3_ADMIN_SCRIPT_FILENAME = 'm3admin2.0.1.js'; // 管理機能用スクリプト(FCKEditor2.6.6、CKEditor4.0.1対応)
209 const M3_ADMIN_WIDGET_SCRIPT_FILENAME = 'm3admin_widget2.0.10.js'; // 管理機能(ウィジェット操作)用スクリプト(Magic3 v1.15.0以降)
210 const M3_ADMIN_WIDGET_CSS_FILE = '/m3/widget.css'; // 管理機能(ウィジェット操作)用CSSファイル
211 const M3_STD_SCRIPT_FILENAME = 'm3std1.5.2.js'; // 一般、管理機能共通スクリプト
212 // const M3_PLUS_SCRIPT_FILENAME = 'm3plus1.6.2.js'; // フロント画面追加用スクリプト(FCKEditor2.6.6対応、CKEditor4.0.1対応)
213 const M3_OPTION_SCRIPT_FILENAME = 'm3opt1.2.1.js'; // AJAXを含んだオプションライブラリファイル(jQuery必須)
214 const M3_ADMIN_CSS_FILE = 'm3/admin.css'; // 管理機能用のCSS
215 const M3_EDIT_CSS_FILE = 'm3/edit.css'; // フロント画面編集用のCSS
216 const M3_DEFAULT_CSS_FILE = 'm3/default.css'; // フロント画面共通のデフォルトCSS
217 const M3_CKEDITOR_CSS_FILE = 'm3/ckeditor.css'; // CKEditorの編集エリア用CSS
220 const USE_BOOTSTRAP_ADMIN = false; // 管理画面でBootstrapを使用するかどうか(デフォルト値)
221 const BOOTSTRAP_BUTTON_CLASS = 'btn btn-default';
224 const FILEBROWSER_WIDTH_RATIO = '0.8'; // ファイルブラウザ幅比率
225 const FILEBROWSER_HEIGHT_RATIO = '0.8'; // ファイルブラウザ高さ比率
230 function __construct()
232 global $gInstanceManager;
234 global $gSystemManager;
235 global $gRequestManager;
238 parent::__construct();
240 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
241 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
244 $this->db = $gInstanceManager->getSytemDbObject();
247 $value = $gSystemManager->getSystemConfig(self::CF_ACCESS_IN_INTRANET); // イントラネット運用かどうか
248 if (empty($value)){ // インターネット運用
249 $this->useGooglemaps = true; // Googleマップを使用するかどうか
251 $this->useHelp = true; // ヘルプ機能
253 // デフォルトのWYSIWYGエディターを取得
254 $this->wysiwygEditor = $gSystemManager->getSystemConfig(self::CF_WYSIWYG_EDITOR); // 管理画面用WYSIWYGエディター
256 // ##### Javascriptライブラリのバージョン設定 #####
258 // アクセスする画面に応じてjQueryのバージョンを設定
259 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
260 $value = $gSystemManager->getSystemConfig(self::CF_ADMIN_JQUERY_VERSION);// 管理画面用jQueryバージョン
262 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET && strStartsWith($widgetId, 'm/')){// 携帯用アクセスポイント用の管理画面の場合はWYSIWYGエディターはFCKEditorに固定
263 $this->wysiwygEditor = ScriptLibInfo::LIB_FCKEDITOR; // FCKEditorに固定
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_ADMIN_KEY => 21, // 管理者一時キー
411 M3_REQUEST_PARAM_OPEN_BY => 22, // ウィンドウの開き方
412 M3_REQUEST_PARAM_SHOW_HEADER => 23, // ヘッダ部表示制御
413 M3_REQUEST_PARAM_SHOW_FOOTER => 24, // フッタ部表示制御
414 M3_REQUEST_PARAM_SHOW_MENU => 25, // メニュー部表示制御
415 M3_REQUEST_PARAM_KEYWORD => 26, // 検索キーワード
416 M3_REQUEST_PARAM_HISTORY => 27, // 履歴インデックスNo
417 M3_REQUEST_PARAM_DEF_PAGE_ID => 28, // ページID(画面編集用)
418 M3_REQUEST_PARAM_DEF_PAGE_SUB_ID => 29, // ページサブID(画面編集用)
419 M3_REQUEST_PARAM_PAGE_DEF_SERIAL => 30, // ページ定義のレコードシリアル番号(設定画面起動時)
420 M3_REQUEST_PARAM_PAGE_DEF_CONFIG_ID => 31, // ページ定義のウィジェット定義ID(設定画面起動時)
421 M3_REQUEST_PARAM_BACK_URL => 32, // 戻り先URL
422 M3_REQUEST_PARAM_BACKUP_URL => 33, // URL退避用(画面編集時)
423 M3_REQUEST_PARAM_SERVER => 34, // サーバ指定
424 M3_REQUEST_PARAM_CATEGORY_ID => 35, // カテゴリID(共通)
425 M3_REQUEST_PARAM_WIDTH => 36, // 幅
426 M3_REQUEST_PARAM_HEIGHT => 37); // 高さ
431 * @return array コンテンツタイプ
433 public function _getAllContentType()
435 global $M3_ALL_CONTENT_TYPE;
437 /* $contentType = array( M3_VIEW_TYPE_CONTENT, // 汎用コンテンツ
438 M3_VIEW_TYPE_PRODUCT, // 製品
439 M3_VIEW_TYPE_BBS, // BBS
440 M3_VIEW_TYPE_BLOG, // ブログ
441 M3_VIEW_TYPE_WIKI, // wiki
442 M3_VIEW_TYPE_USER, // ユーザ作成コンテンツ
443 M3_VIEW_TYPE_EVENT, // イベント
444 M3_VIEW_TYPE_PHOTO); // フォトギャラリー
445 return $contentType;*/
446 return $M3_ALL_CONTENT_TYPE;
451 * @return array 機能タイプ
453 public function _getAllFeatureType()
455 global $M3_ALL_FEATURE_TYPE;
457 /* $featureType = array( M3_VIEW_TYPE_DASHBOARD, // ダッシュボード
458 M3_VIEW_TYPE_SEARCH, // 検索結果
459 M3_VIEW_TYPE_COMMERCE); // Eコマース
460 return $featureType;*/
461 return $M3_ALL_FEATURE_TYPE;
468 function setNoTimeout()
470 if (ini_get('safe_mode') == '0') set_time_limit(0);
475 * @param string $msg メッセージ
477 function setPopupMsg($msg)
479 $this->popupMsg = $msg;
482 * HTMLヘッダ「description」に出力する文字列を設定
484 * @param string $str 出力文字列
486 function setHeadDescription($str)
488 if (is_string($str) && !empty($str)){
489 $this->headDescription = $str;
490 $this->lastHeadDescription = $str; // 最後に設定した値を退避
494 * HTMLヘッダ「description」に出力する文字列を取得
496 * @return string $str 出力文字列
498 function getHeadDescription()
500 return $this->headDescription;
503 * HTMLヘッダ「keywords」に出力する文字列を設定
505 * @param string $str 出力文字列
507 function setHeadKeywords($str)
509 if (is_string($str) && !empty($str)){
510 $this->headKeywords = $str;
511 $this->lastHeadKeywords = $str; // 最後に設定した値を退避
515 * HTMLヘッダ「keywords」に出力する文字列を取得
517 * @return string $str 出力文字列
519 function getHeadKeywords()
521 return $this->headKeywords;
524 * HTMLヘッダに出力するタグ文字列を設定
526 * @param string $str 出力文字列
529 function setHeadOthers($str)
531 if (is_string($str) && !empty($str)){
532 $this->headOthers = $str;
536 * HTMLヘッダに出力するタグ文字列を追加
538 * @param string $str 出力文字列
541 function addHeadOthers($str)
543 if (is_string($str) && !empty($str)){
545 $pos = strpos($this->headOthers, $str);
546 if ($pos === false) $this->headOthers .= $str;
550 * HTMLヘッダに出力するタグ文字列を追加(管理画面用)
552 * @param string $str 出力文字列
555 function addAdminHeadOthers($str)
557 if (is_string($str) && !empty($str)){
559 $pos = strpos($this->adminHeadOthers, $str);
560 if ($pos === false) $this->adminHeadOthers .= $str;
564 * HTMLヘッダ「title」のサブタイトル出力する文字列を設定
566 * @param string $str 出力文字列
567 * @param string $url リンク先
569 function setHeadSubTitle($str = '', $url = '')
573 if (is_string($str)){
574 // 空の場合はウィジェットのヘッドタイトルから取得
575 if (empty($str)) $str = $gEnvManager->getCurrentWidgetHeadTitle();
578 $this->headSubTitle[] = $str;
579 $this->headSubTitleUrl[] = $url;
580 $this->lastHeadTitle = $str; // 最後に設定した値を退避
585 * HTMLヘッダ「title」のサブタイトル出力する文字列を取得
587 * @return $array サブタイトルに設定されている文字列を連想配列(title=タイトル、url=リンク先URL)の配列で返す
589 function getHeadSubTitle()
591 $titleArray = array();
592 $titleCount = count($this->headSubTitle);
593 for ($i = 0; $i < $titleCount; $i++){
594 $line = array('title' => $this->headSubTitle[$i], 'url' => $this->headSubTitleUrl[$i]);
595 $titleArray[] = $line;
600 * HTMLヘッダに出力するCSSの文字列を設定
602 * @param string $css 追加するCSS内容
605 function addHeadCss($css)
607 $destCss = trim($css);
608 if (!empty($destCss)){
609 //if (!in_array($css, $this->headCss)) $this->headCss[] = $css;
610 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css; // CSS動的外部出力
612 $this->lastHeadCss = $css; // 最後に設定したHTMLヘッダにCSS出力する文字列
616 * 外部出力で出力するCSSの文字列を設定(ウィジェット共通設定からの設定値)
618 * @param string $css 追加するCSS内容
621 function addExportCss($css)
623 $destCss = trim($css);
624 if (!empty($destCss)){
625 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css;
629 * HTMLヘッダに出力するJavascriptの文字列を設定
631 * @param string $script 追加するJavascript内容
634 function addHeadScript($script)
636 $destScript = trim($script);
637 if (!empty($destScript)){
638 if (!in_array($script, $this->headScript)) $this->headScript[] = $script;
640 $this->lastHeadScript = $script; // 最後に設定したHTMLヘッダにJavascript出力する文字列
644 * HTMLヘッダに出力するJavascriptの文字列(jQueryMobile用挿入スクリプト)を設定
646 * @param string $script 追加するJavascript内容
649 function addHeadPreMobileScript($script)
651 $destScript = trim($script);
652 if (!empty($destScript)){
653 if (!in_array($script, $this->headPreMobileScript)) $this->headPreMobileScript[] = $script;
657 * HTMLヘッダに出力する任意文字列を設定
659 * @param string $str 追加する任意文字列
662 function addHeadString($str)
664 $destScript = trim($str);
665 if (!empty($destScript)){
666 if (!in_array($str, $this->headString)) $this->headString[] = $str;
668 $this->lastHeadString = $str; // 最後に設定したHTMLヘッダに出力する任意文字列
672 * HTMLヘッダに出力するCSSファイルを追加
674 * @param string,array $cssFile CSSファイルURLパス
677 function addHeadCssFile($cssFile)
679 if (is_array($cssFile)){ // 配列の場合
680 for ($i = 0; $i < count($cssFile); $i++){
681 $destCss = trim($cssFile[$i]);
682 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
685 $destCss = trim($cssFile);
686 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
690 * HTMLヘッダに出力するJavascriptライブラリを追加
692 * @param string,array $scriptLib JavascriptライブラリID
695 function addHeadAdminScriptLib($scriptLib)
697 if (is_array($scriptLib)){ // 配列の場合
698 for ($i = 0; $i < count($scriptLib); $i++){
699 $destScript = trim($scriptLib[$i]);
700 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
703 $destScript = trim($scriptLib);
704 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
708 * HTMLヘッダに出力するJavascriptライブラリを追加
710 * @param string,array $scriptLib JavascriptライブラリID
713 function addHeadScriptLib($scriptLib)
715 if (is_array($scriptLib)){ // 配列の場合
716 for ($i = 0; $i < count($scriptLib); $i++){
717 $destScript = trim($scriptLib[$i]);
718 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
721 $destScript = trim($scriptLib);
722 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
726 * HTMLヘッダに出力するJavascriptファイルを追加
728 * @param string,array $scriptFile JavascriptファイルURLパス
731 function addHeadScriptFile($scriptFile)
733 if (is_array($scriptFile)){ // 配列の場合
734 for ($i = 0; $i < count($scriptFile); $i++){
735 $destScript = trim($scriptFile[$i]);
736 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
739 $destScript = trim($scriptFile);
740 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
744 * HTMLヘッダに出力するJavascriptファイル(jQueryMobile用挿入ファイル)を追加
746 * @param string,array $scriptFile JavascriptファイルURLパス
749 function addHeadPreMobileScriptFile($scriptFile)
751 if (is_array($scriptFile)){ // 配列の場合
752 for ($i = 0; $i < count($scriptFile); $i++){
753 $destScript = trim($scriptFile[$i]);
754 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
757 $destScript = trim($scriptFile);
758 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
762 * HTMLヘッダに出力するRSSファイルを追加
764 * @param array $rssFile タイトル(title)、配信用URL(href)の連想配列。複数の場合は連想配列の配列。
767 function addHeadRssFile($rssFile)
770 if (!is_array($rssFile)) return;
773 if (is_array($line)){ // 複数追加の場合
774 for ($i = 0; $i < count($line); $i++){
776 $url = trim($line[$i]['href']);
778 for ($j = 0; $j < count($this->headRssFiles); $j++){
779 $storedUrl = $this->headRssFiles[$j]['href'];
780 if ($url == $storedUrl) break;
782 if ($j == count($this->headRssFiles)){ // 見つからないときは追加
783 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
784 'title' => $line[$i]['title']); // タイトル
790 $url = trim($rssFile['href']);
792 for ($i = 0; $i < count($this->headRssFiles); $i++){
793 $storedUrl = $this->headRssFiles[$i]['href'];
794 if ($url == $storedUrl) break;
796 if ($i == count($this->headRssFiles)){ // 見つからないときは追加
797 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
798 'title' => $rssFile['title']); // タイトル
804 * RSSチャンネル部に出力するデータを設定
806 * @param array $rssData RSSチャンネル部データ
809 function setRssChannel($rssData)
811 if (!empty($rssData)) $this->rssChannel = $rssData; // RSSチャンネルデータ
816 * @param int $mode 0=ポジション表示しない(通常画面)、1=ポジション表示、2=ウィジェット込みポジション表示
818 function showPosition($mode)
820 $this->showPositionMode = $mode;
825 * @return bool true=レイアウト中、false=レイアウト中でない
829 return $this->isLayout; // 画面レイアウト中かどうか
834 function showWidget()
836 $this->showWidget = true;
841 * @param bool true=単体表示、false=単体表示でない
843 function getShowWidget()
845 return $this->showWidget;
850 * @param int $mode 0=設定なし、1=ログイン画面、10=サイト非公開、11=アクセス不可、12=存在しないページ
852 function setSystemHandleMode($mode)
854 $this->systemHandleMode = $mode;
859 function getSystemHandleMode()
861 return $this->systemHandleMode;
868 function setEditMode()
870 $this->isEditMode = true;
875 * @return bool true=編集モードオン、false=編集モードオフ
877 function idEditMode()
879 return $this->isEditMode;
882 * 出力フォーマットがHTMLであるかを設定
884 * @param bool $isHtml HTMLフォーマットかどうか
887 function setOutputByHtml($isHtml)
889 $this->outputByHtml = $isHtml;
893 * AJAX用のレスポンスボディデータかどうかを設定
895 * @param bool $isResponseBody レスポンスボディデータかどうか
898 function setOutputAjaxResponseBody($isResponseBody)
900 $this->outputAjaxResponseBody = $isResponseBody;
905 * @param bool $status ヘルプ機能を使用するかどうか
908 function setUseHelp($status)
910 $this->useHelp = $status;
915 * @return bool ヘルプ機能を使用するかどうか
917 function getUseHelp()
919 return $this->useHelp;
922 * 表示するコンテンツにGoogleマップが含まれているかを設定
924 * @param bool $status Googleマップを含むかどうか
927 function setIsContentGooglemaps($status)
929 $this->isContentGooglemaps = $status; // コンテンツにGoogleマップが含むかどうか
932 * 表示するコンテンツにGoogleマップが含まれているかを取得
934 * @return bool ヘルプ機能を使用するかどうか
936 function isContentGooglemaps()
938 return $this->isContentGooglemaps;
941 * JavaScriptのブラウザキャッシュの使用可否を設定
943 * @param bool $status ブラウザキャッシュを使用するかどうか
946 function setHasScriptCache($status)
948 $this->hasScriptCache = $status;
955 function useBootstrap()
957 $this->useBootstrap = true; // Bootstrapを使用するかどうか
960 * Bootstrapを強制的に未使用に設定
964 function cancelBootstrap()
966 $this->useBootstrap = false; // Bootstrapを使用するかどうか
971 * @return bool true=使用、false=使用しない
973 function getUseBootstrap()
975 return $this->useBootstrap; // Bootstrapを使用するかどうか
984 $this->isHtml5 = true; // HTML5で出力するかどうか
987 * ページ作成処理を中断するかどうかを取得
989 * @return bool true=中断、false=継続
991 function isPageAbort()
993 return $this->isAbort;
998 * @param string $pos ポジション
999 * @param int $index インデックス番号
1002 function getCurrentWidgetPosition(&$pos, &$index)
1004 $pos = $this->currentWidgetPosition; // 現在のウィジェットのポジション
1005 $index = $this->currentWidgetIndex; // 現在のウィジェットのポジション番号
1010 * @param int $defSerial ページ定義シリアル番号
1013 function updateParentWindow($defSerial = 0)
1015 $this->updateParentWindow = true;
1016 $this->updateDefSerial = $defSerial; // 更新する項目のページ定義シリアル番号
1021 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1024 function addCssFile($path)
1026 $destPath = trim($path, '/');
1027 if (!in_array($destPath, $this->defaultCssFiles)) $this->defaultCssFiles[] = $destPath;
1032 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1035 function addAdminCssFile($path)
1037 $destPath = trim($path, '/');
1038 if (!in_array($destPath, $this->defaultAdminCssFiles)) $this->defaultAdminCssFiles[] = $destPath;
1043 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1046 function addCkeditorCssFile($path)
1048 $destPath = trim($path, '/');
1049 if (!in_array($destPath, $this->ckeditorCssFiles)) $this->ckeditorCssFiles[] = $destPath;
1054 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1057 function addScriptFile($path)
1059 $destPath = trim($path, '/');
1060 if (!empty($destPath) && !in_array($destPath, $this->defaultScriptFiles)) $this->defaultScriptFiles[] = $destPath;
1065 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1068 function addAdminScriptFile($path)
1070 $destPath = trim($path, '/');
1071 if (!in_array($destPath, $this->defaultAdminScriptFiles)) $this->defaultAdminScriptFiles[] = $destPath;
1076 * @return array テンプレートID,サブテンプレートIDの配列
1078 function getOptionTemplateId()
1080 global $gEnvManager;
1083 $pageId = $gEnvManager->getCurrentPageId();
1085 switch ($this->contentType){
1086 case M3_VIEW_TYPE_CONTENT: // ページのコンテンツタイプ
1088 $contentLibObj = $this->gInstance->getObject(self::CONTENT_OBJ_ID);
1089 if (isset($contentLibObj)) list($this->optionTemplateId, $this->optionSubTemplateId) = $contentLibObj->getOptionTemplate();
1091 case M3_VIEW_TYPE_BLOG: // ページがブログタイプのとき
1092 if ($pageId == $this->gEnv->getDefaultPageId()){ // PCサイトのとき
1093 // ブログライブラリオブジェクトからテンプレートを取得
1094 $blogLibObj = $this->gInstance->getObject(self::BLOG_OBJ_ID);
1095 if (isset($blogLibObj)) list($this->optionTemplateId, $this->optionSubTemplateId) = $blogLibObj->getOptionTemplate();
1099 return array($this->optionTemplateId, $this->optionSubTemplateId);
1102 * 使用した非共通ウィジェットの数を取得
1104 * @return int ウィジェット数
1106 function getNonSharedWidgetCount()
1108 return $this->nonSharedWidgetCount;
1113 * @return string コンテンツタイプ
1115 function getContentType()
1117 return $this->contentType;
1120 * フロント画面で使用する主要コンテンツタイプの情報取得
1122 * @return array コンテンツタイプの情報の連想配列
1124 function getMainContentTypeInfo()
1126 return $this->mainContentTypeInfo; // 主要コンテンツタイプ
1129 * フロント画面で使用する補助コンテンツタイプの情報取得
1131 * @return array コンテンツタイプの情報の連想配列
1133 function getSubContentTypeInfo()
1135 return $this->subContentTypeInfo; // 補助コンテンツタイプ
1138 * フロント画面で使用する主要コンテンツタイプを取得
1140 * @return array コンテンツタイプの配列
1142 function getMainContentTypes()
1145 return array_map(create_function('$a', 'return $a["value"];'), $this->mainContentTypeInfo);
1148 * フロント画面で使用するサブコンテンツタイプを取得
1150 * @return array コンテンツタイプの配列
1152 function getSubContentTypes()
1155 return array_map(create_function('$a', 'return $a["value"];'), $this->subContentTypeInfo);
1158 * フロント画面で使用する主要機能タイプ情報を取得
1160 * @return array 機能タイプの情報の連想配列
1162 function getMainFeatureTypeInfo()
1164 return $this->mainFeatureTypeInfo; // 主要機能タイプ
1167 * フロント画面で使用する主要機能タイプを取得
1169 * @return array 機能タイプの配列
1171 function getMainFeatureTypes()
1174 return array_map(create_function('$a', 'return $a["value"];'), $this->mainFeatureTypeInfo);
1180 * @return array ページ属性情報の連想配列
1182 function getAllPageAttributeTypeInfo()
1184 return array_merge($this->mainContentTypeInfo, $this->subContentTypeInfo, $this->mainFeatureTypeInfo, $this->adminFeatureTypeInfo);
1187 * 管理画面用のサブメニューバーの定義を設定
1189 * @param array $def メニューバー定義
1192 function setAdminSubNavbarDef($def)
1194 $this->adminSubNavbarDef = $def;
1197 * 管理画面用のサブメニューバーの定義を取得
1199 * @return array メニューバーの定義
1201 function getAdminSubNavbarDef()
1203 return $this->adminSubNavbarDef;
1208 * @param array $def パンくずリスト定義
1209 * @param array $help ヘルプ(title,bodyの連想配列)
1212 function setAdminBreadcrumbDef($def, $help = array())
1214 $this->adminBreadcrumbDef = $def;
1215 if (!empty($help)) $this->adminBreadcrumbDefHelp = $help; // 管理画面用パンくずリストヘルプ定義
1220 * @param array $help ヘルプ(title,bodyの連想配列)
1221 * @return array パンくずリスト定義
1223 function getAdminBreadcrumbDef(&$help)
1226 $argNum = func_num_args();
1228 // ヘルプ取得用パラメータが存在する場合は定義を設定
1229 if ($argNum > 0) $help = $this->adminBreadcrumbDefHelp;
1231 return $this->adminBreadcrumbDef;
1236 * HTTPヘッダを設定する。セッションを取得する。サブページIDを設定する。
1238 * @param RequestManager $request HTTPリクエスト処理クラス
1241 function startPage($request)
1243 global $gEnvManager;
1244 global $gRequestManager;
1245 global $gInstanceManager;
1246 global $gAccessManager;
1247 global $gSystemManager;
1248 global $gDispManager;
1249 global $gOpeLogManager;
1252 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
1253 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
1254 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
1255 $pageId = $gEnvManager->getCurrentPageId();
1257 // ###### クライアントIDの読み込み、再設定 ######
1258 // この後、クライアントIDがアクセスログに記録される
1259 $clientId = $request->getCookieValue(M3_COOKIE_CLIENT_ID);
1260 if (empty($clientId)){ // クライアントIDが設定されていないとき(初回アクセス)
1262 $clientId = $this->gAccess->createClientId();
1264 $this->gAccess->setClientId($clientId); // クライアントIDを設定
1267 $this->gEnv->setCanUseCookie(true);
1269 $request->setCookieValue(M3_COOKIE_CLIENT_ID, $clientId, M3_COOKIE_EXPIRE_CLIENT_ID);
1271 // インストール時の管理画面用ライブラリを追加(フレームコンテナでの設定を反映)
1272 if (defined('M3_STATE_IN_INSTALL')){
1274 if ($this->useBootstrap){
1275 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
1276 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
1279 // 管理者キーがあればGETまたはPOST値のセッションIDを使用する
1280 if ($gEnvManager->isAdminDirAccess()){
1281 if ($gAccessManager->isValidAdminKey()) session_id($gRequestManager->trimValueOf(session_name()));
1285 // 最終HTML(ページ全体で使用するHTML)の出力
1286 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
1287 $gRequestManager->stopSessionUpdate(); // セッションの更新を停止
1293 // ##### インストール時はここで終了 #####
1294 if (defined('M3_STATE_IN_INSTALL')) return; // インストール時は実行しない
1296 // セッションを再生成する(セキュリティ対策)
1297 if ($gSystemManager->regenerateSessionId()){
1298 $gAccessManager->setOldSessionId(session_id()); // 古いセッションIDを保存
1299 session_regenerate_id(true);
1303 $userInfo = $gRequestManager->getSessionValueWithSerialize(M3_SESSION_USER_INFO);
1304 if (!$gAccessManager->checkSessionSecurity($userInfo)) return; // セキュリティ問題ありの場合はここで終了
1305 // ##### ここで終了した場合はページサブIDが未設定のためページ不正のエラーが発生しアクセスエラー画面が表示される #####
1307 // ##### POST時のリファラーチェック #####
1308 // WooCommerceのAJAX処理が通らないのでチェックしない?
1309 /* if ($gRequestManager->isPostMethod() && !$this->_checkReferer()){
1310 $errMsg = '不正なPOSTデータ(リファラー異常)を検出しました。アクセス元IP: ' . $gAccessManager->getClientIp();
1311 $msgDetail = 'アクセスをブロックしました。account=' . $userInfo->account . ', userid=' . $userInfo->userId;
1312 $gOpeLogManager->writeUserError(__METHOD__, $errMsg, 2210, $msgDetail);
1317 $gRequestManager->_doSessionOpenEventCallback();
1320 $gInstanceManager->setUserInfo($userInfo);
1322 // ##### 自動ログイン #####
1323 // ログイン中でない場合は自動ログインでユーザ情報を取得
1324 $gAccessManager->startAutoLogin();
1327 if (M3_SYSTEM_DEBUG) echo 'Debug mode<br />';
1329 // ##### ページIDの修正 #####
1330 // ポジション表示の場合はページID、ページサブIDを再設定。再設定はシステム管理者のみ可能。
1331 if (($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 管理画面(ウィジェットなしポジション表示)のとき
1332 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) && // 管理画面(ウィジェット付きポジション表示)のとき
1333 $gEnvManager->isSystemAdmin()){
1335 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1336 if (empty($pageId)) $pageId = $this->gEnv->getDefaultPageId(); // 値がないときはデフォルトのページIDを設定
1337 $this->gEnv->setCurrentPageId($pageId);
1338 $subId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1339 if (!empty($subId)) $this->gEnv->setCurrentPageSubId($subId);
1342 // ##### サブページIDの設定 #####
1343 if ($gEnvManager->isAdminDirAccess() && // 管理画面へのアクセスのとき
1344 ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT)){ // ログイン、ログアウト場合は管理画面のページサブIDを指定
1345 $subId = $gEnvManager->getAdminDefaultPageSubId(); // 管理画面用のデフォルトページサブID
1347 if (empty($subId)) $subId = $request->trimValueOf(M3_REQUEST_PARAM_PAGE_SUB_ID);// ページサブIDを取得
1349 if (empty($subId)){ // サブページIDが設定されていないとき
1350 // URLパラメータからコンテンツ形式を取得し、ページを選択
1351 $params = $gRequestManager->getQueryArray();
1352 $paramCount = count($params);
1354 // コマンド以外のパラメータ数が1つだけのときはパラメータからページ属性を判断する
1355 // 値が空でもキーがあれば属性を持つとする
1356 if ($paramCount == 0){
1357 $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1359 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemAdmin() && empty($task)){
1360 // ダッシュボード機能は、パラメータなし、管理者ディレクトリ、システム管理者の条件で使用可能
1361 // POST値にタスクがある場合はダッシュボードとしない
1362 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_DASHBOARD, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1364 } else if ($paramCount > 0 && !$gEnvManager->isAdminDirAccess()){ // パラメータ付きの場合(2013/3/23)
1365 // ##### ページ属性から画面を選択(管理画面は対応しない) ###
1366 // 最初のURLパラメータでコンテンツを判断
1367 // プレビュー(cmd=preview)等のパターンで複数パラメータがある
1369 $firstKey = key($params);
1370 $firstValue = $params[$firstKey];
1372 if (!empty($firstValue)){ // 「key=value」の形式であること
1374 case M3_REQUEST_PARAM_CONTENT_ID: // コンテンツIDのとき
1375 case M3_REQUEST_PARAM_CONTENT_ID_SHORT:
1376 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1377 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1378 if (!$checkStatus) return; // エラーの場合は終了
1380 // ローカルメニューのURLからページを特定。ページが特定できないときはページ属性で取得。
1381 $url = $gEnvManager->getMacroPath($gEnvManager->getCurrentRequestUri());
1382 $ret = $this->db->getSubPageIdByMenuItemUrl($url, $gEnvManager->getCurrentPageId(), M3_VIEW_TYPE_CONTENT, $rows);
1384 $rowCount = count($rows);
1385 for ($i = 0; $i < $rowCount; $i++){
1386 // コンテンツを表示するウィジェットがあるときはページサブIDを確定
1387 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);
1388 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);// コンテンツタイプでの取得に変更(2012/6/20)
1389 if (!empty($widgetId)){
1390 $subId = $rows[$i]['pd_sub_id'];
1395 if (empty($subId)) $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_CONTENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1396 $this->contentType = M3_VIEW_TYPE_CONTENT; // ページのコンテンツタイプ
1398 // コンテンツ詳細ページかどうかを設定
1399 if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT) $this->isContentDetailPage = true;
1401 case M3_REQUEST_PARAM_PRODUCT_ID: // 製品IDのとき
1402 case M3_REQUEST_PARAM_PRODUCT_ID_SHORT:
1403 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1404 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1405 if (!$checkStatus) return; // エラーの場合は終了
1407 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PRODUCT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1408 $this->contentType = M3_VIEW_TYPE_PRODUCT; // ページのコンテンツタイプ
1410 // コンテンツ詳細ページかどうかを設定
1411 $this->isContentDetailPage = true;
1413 case M3_REQUEST_PARAM_BBS_ID: // 掲示板投稿記事のとき
1414 case M3_REQUEST_PARAM_BBS_ID_SHORT:
1415 case M3_REQUEST_PARAM_BBS_THREAD_ID:
1416 case M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT:
1417 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1418 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1419 if (!$checkStatus) return; // エラーの場合は終了
1421 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BBS, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1422 $this->contentType = M3_VIEW_TYPE_BBS; // ページのコンテンツタイプ
1424 // コンテンツ詳細ページかどうかを設定
1425 if ($firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID || $firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT) $this->isContentDetailPage = true;
1427 case M3_REQUEST_PARAM_EVENT_ID: // イベント記事のとき
1428 case M3_REQUEST_PARAM_EVENT_ID_SHORT:
1429 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1430 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1431 if (!$checkStatus) return; // エラーの場合は終了
1433 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_EVENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1434 $this->contentType = M3_VIEW_TYPE_EVENT; // ページのコンテンツタイプ
1436 // コンテンツ詳細ページかどうかを設定
1437 $this->isContentDetailPage = true;
1439 case M3_REQUEST_PARAM_PHOTO_ID: // フォトギャラリー写真のとき
1440 case M3_REQUEST_PARAM_PHOTO_ID_SHORT:
1441 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1442 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1443 if (!$checkStatus) return; // エラーの場合は終了
1445 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PHOTO, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1446 $this->contentType = M3_VIEW_TYPE_PHOTO; // ページのコンテンツタイプ
1448 // コンテンツ詳細ページかどうかを設定
1449 $this->isContentDetailPage = true;
1451 case M3_REQUEST_PARAM_BLOG_ID: // ブログIDのとき
1452 case M3_REQUEST_PARAM_BLOG_ID_SHORT:
1453 case M3_REQUEST_PARAM_BLOG_ENTRY_ID:
1454 case M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT:
1455 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1456 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1457 if (!$checkStatus) return; // エラーの場合は終了
1459 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BLOG, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1460 $this->contentType = M3_VIEW_TYPE_BLOG; // ページのコンテンツタイプ
1462 // コンテンツ詳細ページかどうかを設定
1463 if ($firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT) $this->isContentDetailPage = true;
1465 case M3_REQUEST_PARAM_ROOM_ID: // ユーザ作成コンテンツのとき
1466 case M3_REQUEST_PARAM_ROOM_ID_SHORT:
1467 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1468 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1469 if (!$checkStatus) return; // エラーの場合は終了
1471 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_USER, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1472 $this->contentType = M3_VIEW_TYPE_USER; // ページのコンテンツタイプ
1474 // コンテンツ詳細ページかどうかを設定
1475 $this->isContentDetailPage = true;
1477 // コンテンツを表示するウィジェットを取得
1478 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);
1479 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);// コンテンツタイプでの取得に変更(2012/6/20)
1480 if (!empty($widgetId)){
1481 // ルーム用の定義ID(所属グループID)を取得
1482 $roomId = isset($params[M3_REQUEST_PARAM_ROOM_ID]) ? $params[M3_REQUEST_PARAM_ROOM_ID] : $params[M3_REQUEST_PARAM_ROOM_ID_SHORT];
1483 $configId = $this->db->getWidgetConfigIdForRoom($roomId);
1485 // グループIDを定義IDとするページのページサブIDを取得
1486 $subPageId = $this->getPageSubIdByWidget($gEnvManager->getCurrentPageId(), $widgetId, $configId);
1487 if (!empty($subPageId)) $subId = $subPageId;
1490 default: // オプションのURLコンテンツパラメータからサブページIDを取得
1491 $ret = $this->db->getSubPageIdByUrlContentParam($gEnvManager->getCurrentPageId(), $firstKey, $row);
1492 if ($ret) $subId = $row['pd_sub_id'];
1500 // 「http://www.example.com?ページ名」「wcmd」の場合はwikiコンテンツページを選択
1501 $wikiCmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND);
1502 $pageName = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
1504 if (!empty($wikiCmd) || !empty($pageName)){ // Wikiコンテンツページを指定のとき
1506 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_WIKI, $gEnvManager->getCurrentPageId());
1507 $this->contentType = M3_VIEW_TYPE_WIKI; // ページのコンテンツタイプ
1509 // コンテンツ詳細ページかどうかを設定
1510 $this->isContentDetailPage = true;
1513 // その他のGET,POSTパラメータからページサブID取得
1515 // 検索用パラメータなどでリダイレクト先のURLが取得できた場合は遷移
1516 $subId = $this->getPageSubIdByParam($request, $redirectUrl);
1517 if (!empty($subId) && !empty($redirectUrl)) $this->redirect($redirectUrl);
1520 // ページサブIDが取得できない場合はデフォルトを使用
1521 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
1522 } else { // ページサブIDが設定されているとき
1523 // URLパラメータからコンテンツ形式を取得し、ページを選択
1524 $params = $gRequestManager->getQueryArray();
1525 $paramCount = count($params);
1526 if ($paramCount == 1) $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1529 $gEnvManager->setCurrentPageSubId($subId);// サブページIDを設定
1531 // SSL通信機能がオンの場合は、アクセスされたURLのSSLをチェックし不正の場合は正しいURLにリダイレクト
1532 // 設定に間違いがある場合、管理画面にアクセスできなくなるので、フロント画面のみ制御
1533 // if ($gEnvManager->getUseSsl() || $gEnvManager->getUseSslAdmin()){
1534 if ($gEnvManager->getUseSsl()){ // フロント画面のSSL設定のみチェック(2016/7/30)
1535 if (!$gEnvManager->isAdminDirAccess()){ // 管理画面以外へのアクセスのとき
1536 // ルートURLがSSLの場合はSSLに固定
1537 if ($gEnvManager->isRootUrlSsl()){ // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
1540 $isSsl = $gEnvManager->isSslByCurrentPage();
1542 $currentUrl = $gEnvManager->getCurrentRequestUri();
1544 $correctUrl = str_replace('http://', 'https://', $currentUrl);
1546 $correctUrl = str_replace('https://', 'http://', $currentUrl);
1548 if ($currentUrl != $correctUrl) $this->redirect($correctUrl);
1552 $gEnvManager->initMultiDomain();
1555 $gDispManager->load();
1557 // ##### 画面に必要なスクリプトを追加 #####
1558 // スマートフォン用URLのときはスマートフォン用のjQueryを使用
1559 if ($gEnvManager->getIsSmartphoneSite()){
1560 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(10); // スマートフォン用jQueryファイル
1562 if (isset($this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'])){
1563 $scriptFiles = $this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'];
1564 if (count($scriptFiles) > 0) $this->selectedJQueryMobileFilename = $scriptFiles[0]; // 使用対象のjQueryMobileファイル
1568 // Magic3管理用のスクリプトを追加
1569 if (!$gEnvManager->getIsMobileSite()){ // 携帯用URL以外のとき
1570 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
1571 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
1572 // $this->isEditMode = true; // フロント画面編集モード
1573 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定(コンテキストメニュー表示)
1576 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1577 $this->addAdminScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1579 // Googleマップライブラリの読み込み
1580 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1581 $this->defaultAdminScriptFiles[] = ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS);
1583 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1584 $this->isLayout = true; // 画面レイアウト中かどうか
1585 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_IDTABS); // 管理パネル用スクリプト追加(ポジション表示追加分)
1586 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_DROPDOWN); // 管理パネル用スクリプト追加(ドロップダウンメニュー)
1587 //$this->useBootstrap = true; // Bootstrapを使用
1588 //$this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1590 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1591 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1593 // スクリプトが必要なウィジェットをすべて取得
1594 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1595 for ($i = 0; $i < count($rows); $i++){
1596 $this->addAdminScript($task, trim($rows[$i]['wd_add_script_lib']));
1598 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1600 $widgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
1601 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
1602 if ($ret) $this->addAdminScript($task, trim($this->configWidgetInfo['wd_add_script_lib_a'])); // 管理機能用スクリプト
1605 } else { // フロント画面へのアクセスのとき
1606 // フロント画面用スクリプトファイル追加
1607 $value = $gSystemManager->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
1608 if ($value) $this->addScriptFile($this->selectedJQueryFilename);
1610 if ($cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
1611 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
1612 if ($gEnvManager->isSystemManageUser()){
1613 $this->isEditMode = true; // フロント画面編集モード
1614 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定
1616 // システム運用権限がある場合は管理用スクリプトを追加
1617 // フロント画面と管理画面の切り替え用のスライドメニューバーには管理用スクリプト,CSSが必要
1618 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1619 $this->addScriptFile(ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME); // jQuery Contextmenu Lib
1620 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1621 //$this->addScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1622 $this->addScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用スクリプト追加
1623 $this->addScript('', ScriptLibInfo::LIB_JQUERY_COOKIE); // 管理パネル用スクリプト追加
1624 $this->addScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用スクリプト追加
1625 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1626 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1628 $this->addCssFile(self::M3_ADMIN_CSS_FILE); // 管理機能用CSS
1629 } else if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1630 $this->isEditMode = true; // フロント画面編集モード
1632 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
1633 if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1634 $this->isEditMode = true; // フロント画面編集モード
1636 // $this->addScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
1637 $this->addScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1638 // $this->addScriptFile(self::M3_PLUS_SCRIPT_FILENAME); // フロント画面追加用スクリプト追加(PLUSライブラリを追加する場合はFCKEditorも使用可能にする)
1639 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1640 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
1641 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1642 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1644 // Googleマップライブラリの読み込み
1645 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1646 $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS));
1654 $row = $this->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
1656 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1657 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1660 $this->currentPageInfo = $row; // 現在のページのページ情報
1663 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1664 /* $defPageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1665 $defPageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1668 $row = $this->getPageInfo($defPageId, $defPageSubId);
1670 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1671 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1674 $this->currentPageInfo = $row; // 現在のページのページ情報
1678 // $ret = $this->db->getPageDefOnPage($defPageId, $defPageSubId, $rows);
1679 $ret = $this->db->getPageDefOnPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1681 for ($i = 0; $i < count($rows); $i++){
1682 $position = $rows[$i]['pd_position_id'];
1683 if (!in_array($position, $this->defPositions)) $this->defPositions[] = $position; // 画面定義データのポジション(すべて)
1689 if ($openBy == 'tabs') $this->isTransparentMode = true; // 画面透過モード
1692 * URLの最初のパラメータが不正文字の場合はエラー画面へリダイレクト
1694 * @param string $value URLの最初のパラメータ値
1695 * @return bool true=正常、false=異常
1697 function _checkFirstValueRedirect($value)
1699 global $gEnvManager;
1700 global $gOpeLogManager;
1702 // 半角英小文字大文字、数字、アンダーバー、ハイフン、カンマのみ使用可能。
1703 if (preg_match("/[^0-9a-zA-Z-_,]/", $value)){
1704 $errMessage = 'URLパラメータの不正。';
1705 $gOpeLogManager->writeUserAccess(__METHOD__, '不正なアクセスを検出しました。' . $errMessage, 2200, 'アクセスをブロックしました。URL: ' . $gEnvManager->getCurrentRequestUri());
1707 // $this->redirect('?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=_accessdeny');
1709 $this->isSystemPage = true;
1722 global $gEnvManager;
1723 global $gSystemManager;
1725 $lang = $gEnvManager->getCurrentLanguage();
1727 // デフォルト言語とカレント言語が異なる場合のみ実行
1728 if ($lang != $gEnvManager->getDefaultLanguage()){
1730 $gSystemManager->roadSiteDefByLang($lang);
1734 $this->headDescription = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_DESCRIPTION); // HTMLヘッダ「description」に出力する文字列
1735 $this->headKeywords = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_KEYWORDS); // HTMLヘッダ「keywords」に出力する文字列
1736 $this->headOthers = $gSystemManager->getSiteDef(self::SD_HEAD_OTHERS); // HTMLヘッダに出力するタグ文字列
1738 // デフォルトのページ情報でヘッダを更新
1739 if (!empty($this->currentPageInfo)){
1740 $title = $this->currentPageInfo['pn_meta_title']; // 画面タイトル
1741 $desc = $this->currentPageInfo['pn_meta_description']; // ページ要約
1742 $keyword = $this->currentPageInfo['pn_meta_keywords']; // ページキーワード
1743 $headOthers = $this->currentPageInfo['pn_head_others']; // ヘッダその他タグ
1745 if (!empty($title)) $this->setHeadSubTitle($title);
1746 if (!empty($desc)) $this->setHeadDescription($desc);
1747 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1748 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1751 // 現在の言語のページ情報でヘッダを更新
1752 $ret = $this->db->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $lang, $row);
1754 $title = $row['pn_meta_title']; // 画面タイトル
1755 $desc = $row['pn_meta_description']; // ページ要約
1756 $keyword = $row['pn_meta_keywords']; // ページキーワード
1757 $headOthers = $row['pn_head_others']; // ヘッダその他タグ
1759 if (!empty($title)) $this->setHeadSubTitle($title);
1760 if (!empty($desc)) $this->setHeadDescription($desc);
1761 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1762 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1765 // $this->currentPageInfo = $row; // 現在のページのページ情報
1769 * スクリプト追加情報から、管理機能用のJavascriptファイル、CSSを追加する
1771 * @param string $task 指定タスク
1772 * @param string $scriptInfo スクリプト追加情報
1775 function addAdminScript($task, $scriptInfo)
1777 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1778 for ($i = 0; $i < count($itemArray); $i++){
1779 $pos = strpos($itemArray[$i], '=');
1780 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1781 $libs = trim($itemArray[$i]);
1782 } else { // タスク指定のとき
1783 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1784 $libTask = trim($libTask);
1785 $libs = trim($libs);
1787 if (strEndsWith($libTask, '_')){ // 「task_subtask」形式のタスクのとき
1788 if (!strStartsWith($task, $libTask)) $libs = ''; // タスクIDの先頭部が異なるときは追加しない
1790 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1793 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1794 $libsArray = explode(',', $libs);
1795 for ($j = 0; $j < count($libsArray); $j++){
1796 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1799 $setLibArray = ScriptLibInfo::getLibSet($lib);
1800 $setLibCount = count($setLibArray);
1801 if ($setLibCount > 0){ // ライブラリセットの場合
1802 for ($k = 0; $k < $setLibCount; $k++){
1803 $this->_addAdminScript($setLibArray[$k]);
1806 $this->_addAdminScript($lib);
1813 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1815 * @param string $lib ライブラリID
1818 function _addAdminScript($lib)
1821 if (!isset($this->libFiles[$lib])) return;
1824 // if (strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1825 // jQuery UIライブラリを追加
1826 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1827 if (isset($dependentLib)){
1828 for ($i = 0; $i < count($dependentLib); $i++){
1829 $addLib = $dependentLib[$i];
1832 if (isset($this->libFiles[$addLib]['script'])){
1833 $scriptFiles = $this->libFiles[$addLib]['script'];
1834 for ($m = 0; $m < count($scriptFiles); $m++){
1835 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1839 if (isset($this->libFiles[$addLib]['script_lang'])){
1840 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1841 for ($m = 0; $m < count($scriptFiles); $m++){
1842 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1846 if (isset($this->libFiles[$addLib]['css'])){
1847 $cssFiles = $this->libFiles[$addLib]['css'];
1848 for ($m = 0; $m < count($cssFiles); $m++){
1849 $this->addAdminCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1854 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1855 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1856 $this->outputTheme = true;
1861 if (isset($this->libFiles[$lib]['script'])){
1862 $scriptFiles = $this->libFiles[$lib]['script'];
1864 // ##### ライブラリ情報を作成する場合 #####
1865 if (empty($scriptFiles)){
1866 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
1867 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
1870 for ($i = 0; $i < count($scriptFiles); $i++){
1871 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1875 if (isset($this->libFiles[$lib]['script_lang'])){
1876 $scriptFiles = ScriptLibInfo::getLangScript($lib);
1877 for ($i = 0; $i < count($scriptFiles); $i++){
1878 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1882 if (isset($this->libFiles[$lib]['css'])){
1883 $cssFiles = $this->libFiles[$lib]['css'];
1884 for ($i = 0; $i < count($cssFiles); $i++){
1885 $this->addAdminCssFile($cssFiles[$i]); // 管理機能用のCSS追加
1889 if (strncmp($lib, 'jquery-ui.', 10) == 0){ // jQuery UIのwidgetsまたはeffectsのとき。jQuery UI Coreはデフォルトで読み込まれている。
1891 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1892 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1893 $this->outputTheme = true;
1898 * スクリプト追加情報から、通常機能用のJavascriptファイル、CSSを追加する
1900 * @param string $task 指定タスク
1901 * @param string $scriptInfo スクリプト追加情報
1904 function addScript($task, $scriptInfo)
1906 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1907 for ($i = 0; $i < count($itemArray); $i++){
1908 $pos = strpos($itemArray[$i], '=');
1909 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1910 $libs = trim($itemArray[$i]);
1911 } else { // タスク指定のとき
1912 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1913 $libTask = trim($libTask);
1914 $libs = trim($libs);
1915 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1917 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1918 $libsArray = explode(',', $libs);
1919 for ($j = 0; $j < count($libsArray); $j++){
1920 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1922 // jQueryライブラリ等、デフォルトでは追加されないライブラリを追加
1923 $setLibArray = ScriptLibInfo::getLibSet($lib);// ライブラリセットを展開
1924 $setLibCount = count($setLibArray);
1925 if ($setLibCount > 0){ // ライブラリセットの場合
1926 for ($k = 0; $k < $setLibCount; $k++){
1927 $this->_addScript($setLibArray[$k]);
1930 $this->_addScript($lib);
1937 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1939 * @param string $lib ライブラリID
1942 function _addScript($lib)
1945 if (!isset($this->libFiles[$lib])) return;
1947 // ライブラリの依存ライブラリファイルを追加
1948 if (strcmp($lib, 'jquery') == 0){// jQuery本体のとき
1949 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1950 } else if (strncmp($lib, 'jquery.', 7) == 0){ // jQueryプラグインのとき
1951 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1952 if (strcmp($lib, 'jquery.mobile') == 0){ // jQueryMobileファイルのとき
1953 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
1954 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
1955 for ($i = 0; $i < count($this->headPreMobileScriptFiles); $i++){
1956 $this->addScriptFile($this->headPreMobileScriptFiles[$i]); // 通常機能用のスクリプト追加
1961 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1962 if (isset($dependentLib)){
1963 for ($i = 0; $i < count($dependentLib); $i++){
1964 $addLib = $dependentLib[$i];
1967 if (isset($this->libFiles[$addLib]['script'])){
1968 $scriptFiles = $this->libFiles[$addLib]['script'];
1969 for ($m = 0; $m < count($scriptFiles); $m++){
1970 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1974 if (isset($this->libFiles[$addLib]['script_lang'])){
1975 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1976 for ($m = 0; $m < count($scriptFiles); $m++){
1977 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1981 if (isset($this->libFiles[$addLib]['css'])){
1982 $cssFiles = $this->libFiles[$addLib]['css'];
1983 for ($m = 0; $m < count($cssFiles); $m++){
1984 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1990 } else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI) == 0){ // jQuery UI
1991 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1992 //} else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI_PLUS) == 0){ // jQuery UI plus
1993 // $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1994 // $this->addScriptFile($this->selectedJQueryUiFilename); // jQuery Coreスクリプト追加
1995 } else if (strncmp($lib, 'jquery-ui.', 10) == 0 || // jQuery UIのwidgetsまたはeffectsのとき
1996 strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1999 if (strncmp($lib, 'jquery-ui.', 10) == 0){
2000 $jQueryUiInfo = ScriptLibInfo::getJQueryUiInfo();// ライブラリ情報取得
2001 $dependentLib = $jQueryUiInfo[$lib]; // 依存ライブラリ取得
2003 $dependentLib = ScriptLibInfo::getDependentLib($lib);
2005 for ($i = 0; $i < count($dependentLib); $i++){
2006 $addLib = $dependentLib[$i];
2009 if (isset($this->libFiles[$addLib]['script'])){
2010 $scriptFiles = $this->libFiles[$addLib]['script'];
2011 for ($m = 0; $m < count($scriptFiles); $m++){
2012 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
2016 if (isset($this->libFiles[$addLib]['script_lang'])){
2017 $scriptFiles = ScriptLibInfo::getLangScript($addLib);;
2018 for ($m = 0; $m < count($scriptFiles); $m++){
2019 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
2023 if (isset($this->libFiles[$addLib]['css'])){
2024 $cssFiles = $this->libFiles[$addLib]['css'];
2025 for ($m = 0; $m < count($cssFiles); $m++){
2026 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
2031 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
2032 $this->addCssFile($this->getDefaultThemeUrl()); // 通常機能用のCSS追加
2033 $this->outputTheme = true;
2038 if (isset($this->libFiles[$lib]['script'])){
2039 $scriptFiles = $this->libFiles[$lib]['script'];
2041 // ##### ライブラリ情報を作成する場合 #####
2042 if (empty($scriptFiles)){
2043 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
2044 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2047 for ($i = 0; $i < count($scriptFiles); $i++){
2048 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
2052 if (isset($this->libFiles[$lib]['script_lang'])){
2053 $scriptFiles = ScriptLibInfo::getLangScript($lib);
2054 for ($i = 0; $i < count($scriptFiles); $i++){
2055 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
2059 if (isset($this->libFiles[$lib]['css'])){
2060 $cssFiles = $this->libFiles[$lib]['css'];
2061 for ($i = 0; $i < count($cssFiles); $i++){
2062 $this->addCssFile($cssFiles[$i]); // 通常機能用のCSS追加
2067 * 非ログイン時の管理機能用のJavascriptファイル、CSSを追加する
2069 * @param array, string $lib 追加ライブラリID
2072 function addPermittedAdminScript($lib)
2074 if (is_array($lib)){
2075 for ($j = 0; $j < count($lib); $j++){
2079 if (isset($this->libFiles[$libId]['script'])){
2080 $scriptFiles = $this->libFiles[$libId]['script'];
2082 // ##### ライブラリ情報を作成する場合 #####
2083 if (empty($scriptFiles)){
2084 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
2085 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2088 for ($i = 0; $i < count($scriptFiles); $i++){
2089 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2093 if (isset($this->libFiles[$libId]['script_lang'])){
2094 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2095 for ($i = 0; $i < count($scriptFiles); $i++){
2096 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2100 if (isset($this->libFiles[$libId]['css'])){
2101 $cssFiles = $this->libFiles[$libId]['css'];
2102 for ($i = 0; $i < count($cssFiles); $i++){
2103 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2111 if (isset($this->libFiles[$libId]['script'])){
2112 $scriptFiles = $this->libFiles[$libId]['script'];
2114 // ##### ライブラリ情報を作成する場合 #####
2115 if (empty($scriptFiles)){
2116 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
2117 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2120 for ($i = 0; $i < count($scriptFiles); $i++){
2121 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2125 if (isset($this->libFiles[$libId]['script_lang'])){
2126 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2127 for ($i = 0; $i < count($scriptFiles); $i++){
2128 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2132 if (isset($this->libFiles[$libId]['css'])){
2133 $cssFiles = $this->libFiles[$libId]['css'];
2134 for ($i = 0; $i < count($cssFiles); $i++){
2135 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2145 * ・ウィジェットで生成されたHTTPヘッダを設定する
2147 * @param RequestManager $request HTTPリクエスト処理クラス
2148 * @param bool $getOutput 出力を取得するかどうか
2149 * @return string 最終出力HTML
2151 function endPage($request, $getOutput = false)
2153 global $gRequestManager;
2154 global $gInstanceManager;
2155 global $gEnvManager;
2156 global $gDispManager;
2157 global $gAccessManager;
2160 if ($this->isAbort) return '';
2165 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2167 // 最終HTML(ページ全体で使用するHTML)の出力
2168 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
2170 if (count($this->exportCss) > 0){
2171 for ($i = 0; $i < count($this->exportCss); $i++){
2172 $contents .= $this->exportCss[$i] . M3_NL;
2177 header('Content-type: text/css');
2179 // 画面情報、ユーザ情報の保存は行わない
2181 } else if ($cmd != M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体オペレーションのときは出力しない
2183 $contents = $this->getLastContents($request);
2185 echo $this->getLastContents($request);
2190 $userInfo = $gInstanceManager->getUserInfo();
2191 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2194 $gRequestManager->_doSessionCloseEventCallback();
2197 $gDispManager->save();
2199 // キャッシュリミッタは、各リクエスト毎に(アウトプットバッファー が無効な場合は、
2200 // session_start()がコールされる 前に) session_cache_limiter()をコールする必要がある。
2202 // session_cache_limiter('private');
2203 // session_cache_expire(5);
2204 if ($this->isRedirect) return ''; // リダイレクトの場合は終了
2206 // ########## HTTPヘッダ出力処理 ########
2207 if (headers_sent($filename, $linenum)){ // HTTPヘッダが既に送信されているとき
2208 echo "$filename の $linenum 行目でヘッダがすでに送信されています。";
2210 if ($gEnvManager->isMobile()){ // 携帯の場合
2211 // ドコモ端末の場合はリクエストヘッダにXHTMLを指定しないとXHTMLを処理しない
2212 $agent = $gInstanceManager->getMobileAgent();
2213 if ($agent->isDoCoMo()){ // ドコモ端末のとき
2214 header('Content-Type: application/xhtml+xml;');
2218 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// 過去の日付
2219 header('Cache-Control: no-store, no-cache, must-revalidate');// HTTP/1.1
2220 header('Cache-Control: post-check=0, pre-check=0', false);
2221 header('Pragma: no-cache');
2224 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
2226 // Ajax用JSON型データをHTTPヘッダに格納
2227 $gInstanceManager->getAjaxManager()->header();
2229 // システム制御画面が設定されている場合はステータスコードを変更
2230 //if ($this->gEnv->getIsMaintenance()){
2231 if (!$this->isRedirect){ // リダイレクトがセットされていない場合
2232 switch ($this->systemHandleMode){
2233 case 10: // サイト非公開(システムメンテナンス)
2234 header('HTTP/1.1 503 Service Temporarily Unavailable');
2235 header('Status: 503 Service Temporarily Unavailable');
2237 case 11: // アクセス禁止のとき
2238 header('HTTP/1.1 403 Forbidden');
2239 header('Status: 403 Forbidden');
2241 case 12: // 存在しないページのとき
2242 header("HTTP/1.1 404 Not Found");
2243 header("Status: 404 Not Found");
2248 // ##### 自動ログイン #####
2249 $gAccessManager->endAutoLogin();
2256 * 注意)exitSystem()でシステムを終了させる必要あり
2260 function abortPage()
2262 global $gInstanceManager;
2263 global $gRequestManager;
2265 // HTTPヘッダを削除(PHP 5.3以上で有効)
2266 if (version_compare(PHP_VERSION, '5.3.0') >= 0) header_remove();
2268 // exit()等でabortPage()が最後の処理になってしまう可能性があるのでなるべく必要な処理を行う
2269 //if (ob_get_level() > 0) ob_end_clean();// バッファ内容が残っているときは破棄
2270 while (ob_get_level()) ob_end_clean(); // バッファ削除方法変更(2009/12/2)
2273 $userInfo = $gInstanceManager->getUserInfo();
2274 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2277 $gRequestManager->_doSessionCloseEventCallback();
2279 $this->isAbort = true; // ページ作成処理を中断するかどうか
2286 function abortWidget()
2288 $this->isWidgetAbort = true; // 各ウィジェット処理を中断するかどうか
2295 function exitSystem()
2297 global $gEnvManager;
2298 global $gAccessManager;
2300 // DBが使用可能であれば、アクセスログのユーザを登録
2301 if ($gEnvManager->canUseDb()) $gAccessManager->accessLogUser();
2306 * Joomla!v1.5タグを読み込んでウィジェット実行
2308 * @param string $srcBuf バッファデータ
2309 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
2310 * @return string 変換後文字列
2312 function launchWidgetByJoomlaTag($srcBuf, $templateVer)
2318 if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\s*\/>#iU', $srcBuf, $matches)){
2319 $count = count($matches[1]);
2320 for ($i = 0; $i < $count; $i++)
2323 $type = $matches[1][$i];
2325 if (strcasecmp($type, 'head') == 0){ // ヘッダ埋め込みタグの場合
2328 $contents = ob_get_contents();
2329 } else if (strcasecmp($type, 'modules') == 0 || strcasecmp($type, 'module') == 0 || // 一般ウィジェット用配置ブロックの場合
2330 strcasecmp($type, 'navmenu') == 0){ // ナビゲーションメニューウィジェット用配置ブロックの場合
2331 $name = ''; // ポジション名
2332 $posType = ''; // ポジションのタイプ
2333 $style = ''; // 表示スタイル
2334 $params = explode(' ', $matches[2][$i]);
2335 $paramArray = array();
2336 for ($j = 0; $j < count($params); $j++){
2337 list($key, $value) = explode('=', $params[$j]);
2339 $value = trim($value, "\"'");
2340 if (!empty($key)) $paramArray[$key] = $value;
2342 $value = $paramArray['name'];
2345 $attr['name'] = $value;
2347 $value = $paramArray['type']; // 配置ブロックのタイプを属性に格納。テンプレート内での参照用。
2350 $attr['type'] = $value;
2352 $value = $paramArray['id'];
2353 if (isset($value)) $attr['id'] = $value;
2355 // スタイルが設定されている場合はオプションスタイルを取得
2356 $value = $paramArray['style'];
2359 $attr['style'] = $value;
2361 $optionStyle = $paramArray[$value]; // オプションのスタイル
2362 if (isset($optionStyle)) $attr[$value] = $optionStyle;
2364 /* for ($j = 0; $j < count($params); $j++){
2365 list($key, $value) = explode('=', $params[$j]);
2366 if (strcasecmp($key, 'name') == 0){
2367 $name = strtolower(trim($value, "\"'"));
2368 $attr['name'] = $name;
2369 } else if (strcasecmp($key, 'style') == 0){
2371 $style = trim($value, "\"'");
2372 } else if (strcasecmp($key, 'artstyle') == 0){ // テンプレート側指定の表示スタイル(Artisteer用)
2373 $attr['artstyle'] = trim($value, "\"'");
2374 } else if (strcasecmp($key, 'bootstyle') == 0){ // テンプレート側指定の表示スタイル(Bootstrap用)
2375 $attr['bootstyle'] = trim($value, "\"'");
2376 } else if (strcasecmp($key, 'drstyle') == 0){ // テンプレート側指定の表示スタイル(Themer用)
2377 $attr['drstyle'] = trim($value, "\"'");
2381 if (!empty($name)){ // ポジション名が取得できたとき
2382 // Joomla!では、テンプレートの「jdoc:include」タグの属性styleが空のときは「none」で処理される
2383 // Joomla!デフォルトで設定可能なのは「none,table,horz,xhtml,rounded,outline」
2384 /* if (empty($style)){
2385 if (strStartsWith($name, 'user') || // ナビゲーションメニュー位置の場合
2386 strcasecmp($name, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
2387 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2392 if (strcasecmp($type, 'navmenu') == 0){ // メニューウィジェット用配置ブロックの場合
2393 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2394 $attr['type'] = $type; // テンプレート内での参照用
2395 } else if (strcasecmp($name, 'user3') == 0 || // ナビゲーションメニュー位置の場合
2396 strcasecmp($name, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
2397 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
2398 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2399 } else if (empty($style)){
2403 $contents = $this->getContents($name, $style, $templateVer, $attr);
2405 } else if (strcasecmp($type, 'component') == 0){ // メインポジションタグの場合
2407 $style = ''; // 表示スタイル
2408 $params = explode(' ', $matches[2][$i]);
2409 for ($j = 0; $j < count($params); $j++){
2410 list($key, $value) = explode('=', $params[$j]);
2411 if (strcasecmp($key, 'style') == 0){
2413 $style = trim($value, "\"'");
2417 if ($style != 'none') $style = 'xhtml';
2418 $contents = $this->getContents('main', $style, $templateVer, $attr);
2419 } else if (strcasecmp($type, 'message') == 0){ // メッセージタグの場合
2421 $replace[$i] = $contents;
2424 $destBuf = str_replace($matches[0], $replace, $srcBuf);
2431 * 遅延実行インデックスのついているウィジェットをインデックス順に実行し、出力バッファデータ内のタグの位置に出力を埋め込む
2433 * @param RequestManager $request HTTPリクエスト処理クラス
2434 * @param string $srcBuf バッファデータ
2435 * @return string 変換後文字列
2437 function lateLaunchWidget($request, $srcBuf)
2439 global $gEnvManager;
2440 global $gErrorManager;
2441 global $gDesignManager;
2443 // ページ作成中断またはウィジェット処理中断のときは終了
2444 if ($this->isAbort || $this->isWidgetAbort) return '';
2446 // ウィジェットヘッダ(Joomla!1.0用)を出力のタイプを取得
2447 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
2449 // 遅延実行ウィジェットをインデックス順にソート
2450 asort($this->lateLaunchWidgetList, SORT_NUMERIC);
2454 foreach ($this->lateLaunchWidgetList as $widgetId => $value){
2456 $count = count($this->latelaunchWidgetParam);
2457 for ($i = 0; $i < $count; $i++){
2458 list($wId, $maxNo, $confId, $preId, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $pageDefRec) = $this->latelaunchWidgetParam[$i];
2459 if ($wId == $widgetId){
2461 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
2462 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
2463 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
2466 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
2467 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
2473 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
2476 $configId = $confId; // ウィジェット定義ID
2477 if ($configId == 0) $configId = '';
2478 $prefix = $preId; // サフィックス文字列
2480 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
2481 $joomlaTitleVisble = false;
2482 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
2483 if (!empty($title)){
2484 if ($widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2485 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
2486 echo '<tr><th>' . $title . '</th></tr>' . M3_NL;
2487 echo '<tr><td>' . M3_NL;
2488 $joomlaTitleVisble = true;
2489 } else if ($widgetHeaderType == 2){ // 携帯用ウィジェットヘッダ出力
2490 echo '<div>' . $title . '</div>' . M3_NL;
2491 $joomlaTitleVisble = true;
2496 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
2497 // ウィジェット親のCSS定義があるときは、タグを追加
2498 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
2501 echo $gDesignManager->getAdditionalWidgetOutput(true);
2504 $gEnvManager->setCurrentWidgetId($widgetId);
2507 $gEnvManager->setCurrentWidgetConfigId($configId);
2510 $gEnvManager->setCurrentPageDefSerial($serial);
2513 $gEnvManager->setCurrentPageDefRec($pageDefRec);
2516 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
2519 $gEnvManager->setCurrentWidgetTitle('');
2522 $gEnvManager->setCurrentWidgetStyle($style);
2524 // ウィジェットのグローバル属性状況を設定
2525 $gEnvManager->setIsCurrentWidgetShared($shared);
2528 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
2531 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
2532 $msg = 'widget-start(' . $widgetId . ')';
2533 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2534 require($widgetIndexFile);
2535 $msg = 'widget-end(' . $widgetId . ')';
2536 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2539 $gEnvManager->setCurrentWidgetId('');
2542 $gEnvManager->setCurrentWidgetConfigId('');
2545 $gEnvManager->setCurrentPageDefSerial(0);
2548 $gEnvManager->setCurrentPageDefRec();
2551 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
2554 $gEnvManager->setCurrentWidgetStyle('');
2556 // ウィジェットのグローバル属性状況を解除
2557 $gEnvManager->setIsCurrentWidgetShared(false);
2560 $newTitle = $gEnvManager->getCurrentWidgetTitle();
2563 echo $gDesignManager->getAdditionalWidgetOutput(false);
2565 // ウィジェット親のCSS定義があるときは、タグを追加
2566 if (!empty($cssStyle)) echo '</div>' . M3_NL;
2568 //echo '</div>' . M3_NL;
2570 // Joomla!1.0テンプレートのときはタイトルを出力
2571 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2572 echo '</td></tr>' . M3_NL;
2573 echo '</table>' . M3_NL;
2576 // 現在のバッファ内容を取得し、バッファを破棄
2577 $srcContents = ob_get_contents();
2581 $tag = self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
2582 $destBuf = str_replace($tag, $srcContents, $destBuf);
2585 if (!empty($newTitle)) $title = $newTitle;
2586 $tag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
2587 $destBuf = str_replace($tag, $title, $destBuf);
2589 // ##### 外部出力用のCSSがある場合は追加 #####
2590 if (!empty($exportCss)){
2592 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $index; // ウィジェット識別用ユニークタグ
2593 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
2594 $this->addExportCss($exportCss);
2600 // ##### HTMLヘッダ出力処理 #####
2601 $destBuf = $this->replaceHead($destBuf);
2608 * @param string $jobType ジョブタイプ
2611 function launchJob($jobType)
2613 global $gEnvManager;
2615 // ジョブタイプから実行するウィジェットIDを取得
2616 $widgetId = $this->getWidgetIdByJobType($jobType);
2617 if (empty($widgetId)) return;
2620 $gEnvManager->setCurrentWidgetId($widgetId);
2623 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/admin/job.php';
2625 if (file_exists($widgetIndexFile)){
2627 // $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd);
2629 require_once($widgetIndexFile);
2631 echo 'file not found: ' . $widgetIndexFile;
2635 $gEnvManager->setCurrentWidgetId();
2640 * @param string $srcBuf 変換元
2641 * @return string 変換後文字列
2643 function replaceHead($srcBuf)
2647 // ##### ヘッダ部分の置換 #####
2648 if ($this->outputHead){ // HTMLヘッダ出力を行っているとき
2650 $replaceStr = $this->getHeaderOutput();
2653 $destBuf = str_replace(self::HEAD_TAGS, $replaceStr, $destBuf);
2655 $this->replaceHeadDone = true; // ヘッダマクロ変換処理が完了したかどうか
2663 function enableReplaceHead()
2665 $this->outputHead = true;
2668 * ウィジェット検索モードの場合のページサブIDの設定
2670 * @param RequestManager $request HTTPリクエスト処理クラス
2672 function redirectToUpdatedPageSubId($request)
2674 global $gEnvManager;
2676 // 現在設定されているページIDを取得
2677 $pageId = $gEnvManager->getCurrentPageId();
2678 $pageSubId = $gEnvManager->getCurrentPageSubId();
2681 $fromWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_FROM);
2684 $targetWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
2686 // 対象のウィジェットのページサブIDを取得
2687 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2688 if ($ret){// データが存在する
2689 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2690 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2691 if ($ret){// データが存在する
2692 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2694 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2699 for ($i = 0; $i < count($rows); $i++){
2700 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2705 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2706 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2708 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2711 } else { // 対象のウィジェットが見つからない場合は、互換ウィジェットを探す
2712 $widgetId = $this->db->getCompatibleWidgetId($targetWidgetId);
2713 if (!empty($widgetId)){
2714 $targetWidgetId = $widgetId;
2716 // 対象のウィジェットのページサブIDを取得
2717 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2718 if ($ret){// データが存在する
2719 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2720 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2721 if ($ret){// データが存在する
2722 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2724 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2729 for ($i = 0; $i < count($rows); $i++){
2730 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2735 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2736 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2738 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2744 // ページサブIDが見つからないときは、既に設定されている値を使用
2745 // 既に設定されている値は、URL「sub」パラメータで指定されている値か
2746 // 設定されていない場合はデフォルトのサブページID
2747 // ********** 指定ページへリダイレクト ***********
2749 $todo = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TODO);
2750 $todo = str_replace(M3_TODO_SEPARATOR, '&', $todo); // セパレータを変換
2751 // $redirectUrl = '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2752 $redirectUrl = $gEnvManager->createPageUrl() . '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2753 if (!empty($todo)) $redirectUrl .= '&' . $todo;
2754 if ($gEnvManager->getIsMobileSite()){ // 携帯用アクセスポイントの場合
2755 $this->redirect($redirectUrl, true/*遷移時のダイアログ表示を抑止*/);
2757 $this->redirect($redirectUrl);
2763 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2764 * 追加するHTMLは主にウィンドウ制御用のスクリプト
2766 * @return string 最終HTML
2768 function getLastContents()
2770 global $gEnvManager;
2771 global $gRequestManager;
2774 $initScript = ''; // 初期化用スクリプト
2775 $pageId = $gEnvManager->getCurrentPageId();
2776 $pageSubId = $gEnvManager->getCurrentPageSubId();
2777 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2779 if (!$gEnvManager->isSystemManageUser()) return ''; // システム運用権限がない場合は終了
2782 if ($cmd == M3_REQUEST_CMD_RSS || // RSS配信のときは終了
2783 $cmd == M3_REQUEST_CMD_DO_WIDGET) return ''; // ウィジェット単体オペレーションのときは出力しない
2785 if ($gEnvManager->getIsMobileSite()) return ''; // 携帯用URLのときは終了
2787 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2789 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
2790 /* // テンプレート上のポジション名
2791 if (count($this->viewPosId) > 0){
2793 for ($i = 0; $i < count($this->viewPosId); $i++){
2794 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
2795 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
2797 $posArrayStr .= ']';
2798 $contents .= 'var M3_POSITIONS=' . $posArrayStr . ';' . M3_NL;
2801 $contents .= 'var M3_REVISION=' . $this->pageDefRev . ';' . M3_NL;*/
2804 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2805 $contents .= M3_INDENT_SPACE . 'window.m3.m3UpdateByConfig(serial);' . M3_NL;
2806 $contents .= '}' . M3_NL;
2807 } else if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定画面
2808 } else { // ダッシュボード画面、メイン管理画面
2810 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2811 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2812 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2813 $contents .= '}' . M3_NL;
2816 // ウィジェット単体実行以外のときの処理
2817 if (!$this->showWidget){
2818 if ($this->updateParentWindow){ // 管理画面からの親画面の更新
2819 $initScript .= M3_INDENT_SPACE . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
2824 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2825 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2826 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2827 $contents .= '}' . M3_NL;
2831 if (!empty($contents) || !empty($initScript)){
2832 // $destContents .= '<script type="text/javascript">' . M3_NL;
2833 // $destContents .= '//<![CDATA[' . M3_NL;
2834 $destContents .= $contents;
2835 if (!empty($initScript)){ // 初期化用スクリプト
2836 $destContents .= '$(function(){' . M3_NL;
2837 $destContents .= $initScript;
2838 $destContents .= '});' . M3_NL;
2840 // $destContents .= '//]]>' . M3_NL;
2841 // $destContents .= '</script>' . M3_NL;
2843 return $destContents;
2848 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2850 * @param RequestManager $request HTTPリクエスト処理クラス
2851 * @return string 最終HTML
2853 function getOptionContents($request)
2855 global $gEnvManager;
2860 if ($this->isAbort) return '';
2862 // AJAX用のレスポンスボディデータのときは終了
2863 if ($this->outputAjaxResponseBody) return '';
2866 // AJAXを送信する場合は空文字列では送信できないので、ダミーデータを返す
2867 if ($this->isWidgetAbort) $contents .= 'NO DATA' . M3_NL;
2870 if (!$gEnvManager->isMobile() && $this->outputByHtml){ // 携帯以外で、HTML出力のとき
2871 $contents .= '<!-- created by ' . M3_SYSTEM_NAME . ' v' . M3_SYSTEM_VERSION . ' - http://www.magic3.org -->' . M3_NL;
2872 $contents .= '<!-- convert time: ' . sprintf('%01.03f', microtime(true) - M3_MTIME) . ' -->' . M3_NL;
2877 * Widget単体起動用のHTMLのヘッダ部(headタグ)出力
2879 * startWidget(),endWidget()は、以下のコマンドを処理する
2880 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
2881 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
2882 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
2883 * Widgetの出力方法は、以下のパターンがある
2884 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
2885 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
2887 * @param string $cmd 起動コマンド
2889 function startWidget($cmd)
2891 global $gEnvManager;
2892 global $gRequestManager;
2894 // ウィジェット単体表示のときのみ出力
2895 if (!$this->showWidget) return;
2898 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
2899 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
2901 // $isHtml5 = false; // HTML5で出力するかどうか
2902 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
2903 if (intval($tempVer) >= 2) $this->isHtml5 = true; // HTML5で出力するかどうか
2906 if ($this->isHtml5){
2907 echo '<!DOCTYPE html>' . M3_NL;
2908 echo '<html dir="ltr" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2909 echo '<head>' . M3_NL;
2911 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . M3_NL;
2912 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $gEnvManager->getCurrentLanguage() . '" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2913 echo '<head>' . M3_NL;
2914 // echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' . M3_NL;
2917 // HTMLのヘッダ部(headタグ内)出力
2921 $widgetId = $gEnvManager->getCurrentWidgetId(); // カレントのウィジェットID
2924 if ($gEnvManager->getUseSslAdmin()){
2925 $rootUrl = $gEnvManager->getSslRootUrl();
2926 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
2927 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
2929 $rootUrl = $gEnvManager->getRootUrl();
2930 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
2931 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
2934 // ##### テンプレートのCSSの読み込み #####
2935 // テンプレートは管理用テンプレートに固定されている
2936 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット設定のとき
2937 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
2938 $curTemplateUrl = $templatesUrl . '/' . $gEnvManager->getCurrentTemplateId();
2939 if ($this->isHtml5){
2940 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/style.css" media="screen">' . M3_NL;
2941 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/widget.css" media="screen">' . M3_NL; // ウィジェット設定画面用CSS
2942 echo '<!--[if IE]><link rel="stylesheet" href="' . $curTemplateUrl . '/css/iestyles.css" media="screen"><![endif]-->' . M3_NL;
2943 echo '<!--[if lt IE 9]><script src="' . $curTemplateUrl . '/html5shiv.js"></script><![endif]-->' . M3_NL;
2945 echo '<link href="' . $curTemplateUrl . '/css/style.css" rel="stylesheet" type="text/css" />' . M3_NL;
2946 echo '<!--[if IE]><link rel="stylesheet" type="text/css" media="screen" href="' . $curTemplateUrl . '/css/iestyles.css" /><![endif]-->' . M3_NL;
2950 $ret = $this->db->getWidgetInfo($widgetId, $row);
2952 // ##### 共通ライブラリ読み込み設定 #####
2953 if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
2954 $scritLib = trim($row['wd_add_script_lib']);
2955 if (!empty($scritLib)) $this->addScript($task, $scritLib);
2958 // CSS読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2959 if ($row['wd_read_css']){
2960 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_CSS;
2961 if (is_dir($searchPath)){
2962 $dir = dir($searchPath);
2963 while (($file = $dir->read()) !== false){
2964 $filePath = $searchPath . '/' . $file;
2965 if ($file != '.' && $file != '..' && is_file($filePath)
2966 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
2969 $cssURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_CSS . '/' . $file;
2970 echo '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2977 // スクリプト読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2978 if ($row['wd_read_scripts']){
2979 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS;
2980 if (is_dir($searchPath)){
2981 $dir = dir($searchPath);
2982 while (($file = $dir->read()) !== false){
2983 $filePath = $searchPath . '/' . $file;
2984 if ($file != '.' && $file != '..' && is_file($filePath)
2985 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
2988 $scriptURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
2990 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
2991 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
2992 echo '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
2998 // ##### スクリプト用出力用タグを埋め込む #####
2999 // ウィジェット設定画面用メニューバーの作成
3000 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3001 echo self::MENUBAR_SCRIPT_TAGS; // メニューバー出力用タグ
3005 $title = $row['wd_name'];
3006 if (empty($title)) $title = $row['wd_id'];
3007 $gEnvManager->setCurrentWidgetTitle($title);
3008 echo '<title>' . self::WIDGET_TITLE_START . htmlspecialchars($title) . self::WIDGET_TITLE_END . '</title>' . M3_NL;
3009 echo '</head>' . M3_NL;
3010 // タブでウィンドウを開く場合は背景を透過モードにする
3011 if ($this->isTransparentMode){
3012 echo '<body style="background-color:transparent;">' . M3_NL;
3014 echo '<body>' . M3_NL;
3016 // ウィジェット設定画面用メニューバーの作成
3017 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3019 $desc = $row['wd_description']; // 説明
3020 $gEnvManager->setCurrentWidgetParams('desc', $desc);
3022 echo self::MENUBAR_TAGS; // メニューバー出力用タグ
3025 if ($this->useBootstrap) echo '<div class="container">' . M3_NL;
3027 // 別ウィンドウで表示のときは、「閉じる」ボタンを表示
3028 if ($cmd == M3_REQUEST_CMD_SHOW_WIDGET || // ウィジェットの単体表示のとき
3029 $cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット詳細設定画面のとき
3030 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット単体実行でフロント画面編集モードのとき
3032 // if ($this->isEditMode){// フロント画面編集モードのとき
3033 if (!empty($openBy)){
3034 // サーバ指定されている場合はサーバ情報を取得
3036 $server = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_SERVER);
3037 if (!empty($server)){
3039 $ret = $this->db->getServerById($server, $row);
3041 $serverName = 'サーバ名:' . $row['ts_name'];// サーバ名
3042 echo '<div align="left" style="float:left;padding-left:30px;"><label>' . convertToHtmlEntity($serverName) . '</label></div>';
3045 // タブ、インナーフレーム、ダイアログ表示以外のときは「閉じる」ボタンを表示
3046 if ($openBy != 'tabs' && $openBy != 'iframe' && $openBy != 'dialog'){ // 以外
3047 if ($openBy == 'logout'){
3048 $titleStr = 'ログアウト';
3049 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 .
3050 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
3053 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 .
3054 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
3060 echo '<div class="m3configprev" style="display:none;"><a id="m3configprev" href="#"><img src="' . $rootUrl . self::PREV_ICON_FILE .
3061 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
3063 echo '<div class="m3confignext" style="display:none;"><a id="m3confignext" href="#"><img src="' . $rootUrl . self::NEXT_ICON_FILE .
3064 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
3067 // echo '<div class="row">' . M3_NL;
3068 echo '<!-- Widget Start -->' . M3_NL;
3073 * startWidget(),endWidget()は、以下のコマンドを処理する
3074 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
3075 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
3076 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
3078 * @param string $cmd 起動コマンド
3079 * @param string $srcContent HTML出力ソース
3081 function endWidget($cmd, $srcContent)
3083 global $gDesignManager;
3085 // ウィジェット単体表示のときのみ出力
3086 if (!$this->showWidget) return;
3090 $breadcrumbHtml = '';
3091 if (!empty($this->adminSubNavbarDef)) $breadcrumbHtml .= $gDesignManager->createSubMenubar($this->adminSubNavbarDef);
3092 if (!empty($this->adminBreadcrumbDef)) $breadcrumbHtml .= $gDesignManager->createAdminBreadcrumb($this->adminBreadcrumbDef);
3093 $destContent = str_replace(self::MENUBAR_TAGS, $breadcrumbHtml, $srcContent);
3096 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3097 $replaceStr .= '//<![CDATA[' . M3_NL;
3101 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェットの設定管理
3103 $replaceStr .= 'function m3UpdateByConfig(serial){' . M3_NL;
3104 $replaceStr .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
3105 $replaceStr .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
3106 $replaceStr .= M3_INDENT_SPACE . 'm3UpdateParentWindow();' . M3_NL; // 親ウィンドウ更新
3107 $replaceStr .= '}' . M3_NL;
3110 $replaceStr .= 'function hideIEErrors(){' . M3_NL;
3111 $replaceStr .= M3_INDENT_SPACE . 'return true;' . M3_NL;
3112 $replaceStr .= '}' . M3_NL;
3113 $replaceStr .= 'window.onerror = hideIEErrors;' . M3_NL;
3117 $replaceStr .= '$(function(){' . M3_NL;
3119 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3120 if (!empty($this->adminSubNavbarDef) || !empty($this->adminBreadcrumbDef)){
3121 $menubarHeight = $gDesignManager->getSubMenubarHeight();
3122 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("nav.secondlevel").css("margin-top", "0");' . M3_NL;
3123 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("body").css("padding-top", "' . $menubarHeight . 'px");' . M3_NL;
3126 // ##### ウィジェットからの指定による処理 #####
3127 if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
3128 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
3129 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
3130 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
3131 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
3134 $replaceStr .= '});' . M3_NL;
3135 $replaceStr .= '//]]>' . M3_NL;
3136 $replaceStr .= '</script>' . M3_NL;
3137 $destContent = str_replace(self::MENUBAR_SCRIPT_TAGS, $replaceStr, $destContent);
3138 echo $destContent;// 変換したコンテンツを出力
3140 // echo '</div>' . M3_NL; // row
3141 echo '<!-- Widget End -->' . M3_NL;
3143 // ##### ウィジェットからの指定による処理 #####
3144 /* if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
3145 echo '<script type="text/javascript">' . M3_NL;
3146 echo '//<![CDATA[' . M3_NL;
3147 echo '$(function(){' . M3_NL;
3148 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
3149 echo str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
3150 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
3151 echo str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
3154 echo '//]]>' . M3_NL;
3155 echo '</script>' . M3_NL;
3159 if ($this->useBootstrap) echo '</div>' . M3_NL;
3161 echo '</body>' . M3_NL;
3162 echo '</html>' . M3_NL;
3165 * Widget単体RSS出力用のHTMLのヘッダ部(headタグ)出力
3167 * Widgetの出力方法は、以下のパターンがある
3168 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
3169 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
3171 * @param string $cmd 起動コマンド
3173 function startWidgetRss($cmd)
3177 * Widget単体RSS出力用のタグを閉じる
3179 * @param string $cmd 起動コマンド
3180 * @param string $rssContent RSS配信内容
3182 function endWidgetRss($cmd, $rssContent)
3184 global $gEnvManager;
3187 if ($this->isAbort) return;
3189 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3192 $lang = $gEnvManager->getCurrentLanguage();
3193 $date = getW3CDate(); // RSS1.0用日付
3194 $copyright = $gEnvManager->getSiteCopyRight(); // 著作権
3195 $title = $this->rssChannel['title']; // タイトル
3196 $link = $this->rssChannel['link']; // RSS取得用URL
3197 $desc = $this->rssChannel['description']; // 説明
3198 $seq = $this->rssChannel['seq']; // 項目の並び順(URL)
3200 switch ($this->rssVersion){ // RSSバージョン
3203 echo '<rdf:RDF xmlns="http://purl.org/rss/1.0/" ';
3204 echo 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
3205 echo 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
3206 echo 'xml:lang="' . $lang . '">' . M3_NL;
3207 echo '<channel rdf:about="' . convertUrlToHtmlEntity($link) . '">' . M3_NL;
3208 echo '<title>' . convertToHtmlEntity($title) . '</title>' . M3_NL;
3209 echo '<link>' . convertUrlToHtmlEntity($link) . '</link>' . M3_NL; // 「convertUrlToHtmlEntity」が必要
3210 echo '<description>' . convertToHtmlEntity($desc) . '</description>' . M3_NL;
3211 echo '<dc:language>' . $lang . '</dc:language>' . M3_NL;
3212 if (!empty($copyright)) echo '<dc:rights>' . convertToHtmlEntity($copyright) . '</dc:rights>' . M3_NL;
3213 echo '<dc:date>' . $date . '</dc:date>' . M3_NL;
3214 echo '<items>' . M3_NL;
3215 if (count($seq) > 0){
3216 echo str_repeat(M3_INDENT_SPACE, 1) . '<rdf:Seq>' . M3_NL;
3217 for ($i = 0; $i < count($seq); $i++){
3218 echo str_repeat(M3_INDENT_SPACE, 2) . '<rdf:li rdf:resource="' . convertUrlToHtmlEntity($seq[$i]) . '" />' . M3_NL;
3220 echo str_repeat(M3_INDENT_SPACE, 1) . '</rdf:Seq>' . M3_NL;
3222 echo '</items>' . M3_NL;
3223 echo '</channel>' . M3_NL;
3225 echo '</rdf:RDF>' . M3_NL;
3232 header("Content-type: text/xml; charset=utf-8");
3235 * 直サーバ接続時のXML出力用のHTMLのヘッダ部(headタグ)出力
3237 * @param string $cmd 起動コマンド
3240 function startWidgetXml($cmd)
3243 //header("Content-type: text/xml; charset=utf-8");
3248 * @param string $cmd 起動コマンド
3251 function endWidgetXml()
3257 * @return string ドキュメントタイプ出力
3259 function getMobileDocType()
3261 global $gEnvManager;
3262 global $gInstanceManager;
3263 global $gRequestManager;
3265 $docTypeStr = ''; // 出力するDocType
3266 $agent = $gInstanceManager->getMobileAgent();
3267 if ($agent->isDoCoMo()){ // ドコモ端末のとき
3268 $htmlVer = $agent->getHTMLVersion();
3271 $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">';
3274 $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">';
3277 $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">';
3280 $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">';
3283 $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">';
3286 $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">';
3289 if (preg_match("/^DoCoMo\/1\.0/i", $gRequestManager->trimServerValueOf('HTTP_USER_AGENT'))){ // mova端末のとき
3290 // mova端末のときはドキュメントタイプなしにすると画面表示可能
3295 } else if ($agent->isEZweb()){ // au端末のとき
3296 if ($agent->isWAP2()){
3297 $docTypeStr = '<!DOCTYPE html PUBLIC "-//OPENWAVE//DTD XHTML 1.0//EN" "http://www.openwave.com/DTD/xhtml-basic.dtd">';
3299 } else if ($agent->isSoftBank()){ // ソフトバンク端末のとき
3300 if ($agent->isTypeW() || $agent->isType3GC()){
3301 $docTypeStr = '<!DOCTYPE html PUBLIC "-//J-PHONE//DTD XHTML Basic 1.0 Plus//EN" "xhtml-basic10-plus.dtd">';
3304 if ($gEnvManager->getIsMobileSite()){ // 携帯用サイトへのアクセスの場合
3305 echo '<?xml version="1.0" encoding="' . $gEnvManager->getMobileCharset() . '" ?>' . M3_NL;
3307 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3309 if (empty($docTypeStr)) $docTypeStr = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
3310 echo $docTypeStr . M3_NL;
3315 * @return string XML宣言
3317 function getDefaultXmlDeclaration()
3319 return '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>';
3322 * HTMLのヘッダ部(headタグ内)出力
3324 * システムに共通な定義をHTMLのheadタグ内に出力する
3325 * mosFunc.phpからも実行されるので、このメソッドは引数なしに固定。
3326 * この関数は、以下の「形式1」または「形式2」でheadタグ内に記述する
3328 * 形式1: <!-- m3:HTMLHeader -->
3329 * 形式2(old style): <?php mosShowHead(); ?>
3331 function getHeader()
3333 global $gEnvManager;
3334 global $gRequestManager;
3336 $this->outputHead = true; // HTMLヘッダ出力を行ったかどうか
3339 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3341 // ######### 携帯用サイトの場合は別にヘッダを作成する #########
3342 if ($gEnvManager->getIsMobileSite()){
3344 echo '<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=' . $gEnvManager->getMobileCharset() . '" />' . M3_NL;
3347 echo '<meta http-equiv="Pragma" content="no-cache" />' . M3_NL;
3348 echo '<meta http-equiv="Cache-Control" content="no-cache" />' . M3_NL;
3349 echo '<meta http-equiv="Expires" content="-1" />' . M3_NL;
3352 echo '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
3353 } else { // PC用サイト、管理用サイト、スマートフォン用サイトのとき
3354 // $isHtml5 = false; // HTML5で出力するかどうか
3355 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
3356 $this->isHtml5 = true;
3358 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
3359 if (intval($tempVer) >= 2) $this->isHtml5 = true;
3362 // ********** メタタグの設定 **********
3364 //if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
3365 if ($this->isHtml5){
3366 //echo '<meta http-equiv="content-type" content="text/html; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
3367 echo '<meta charset="' . M3_HTML_CHARSET . '">' . M3_NL;
3369 echo '<meta http-equiv="content-script-type" content="text/javascript" />' . M3_NL;
3370 echo '<meta http-equiv="content-style-type" content="text/css" />' . M3_NL;
3371 echo '<meta http-equiv="content-type" content="application/xhtml+xml; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
3373 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3374 // Bootstrapで必要なMETAタグを追加
3375 echo '<meta name="viewport" content="width=device-width, initial-scale=1">' . M3_NL;
3379 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 表示位置を表示するとき
3380 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
3382 if ($gEnvManager->getUseSslAdmin()){
3383 $rootUrl = $gEnvManager->getSslRootUrl();
3385 $rootUrl = $gEnvManager->getRootUrl();
3387 echo '<base href="' . $rootUrl . '/" />' . M3_NL;
3390 echo self::HEAD_TAGS; // HTMLヘッダの埋め込みデータ
3395 * @return string HTMLヘッダ出力文字列
3397 function getHeaderOutput()
3399 global $gEnvManager;
3400 global $gRequestManager;
3401 global $gInstanceManager;
3402 global $gSystemManager;
3404 $replaceStr = ''; // 変換文字列
3407 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3408 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
3409 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
3410 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
3412 // ********************************************************
3414 // ********************************************************
3415 // ##### テンプレートの設定、フレームの設定から必要なライブラリを取得 #####
3417 // if (!$this->useBootstrap) $this->useBootstrap = $gEnvManager->getCurrentTemplateUseBootstrap();
3418 if ($this->useBootstrap){
3419 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3420 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3421 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
3422 if ($cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)以外のとき
3423 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3425 } else { // ログインしていない場合(ログイン画面等)
3426 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP);
3427 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP_ADMIN);// Bootstrap管理画面オプション
3429 } else { // フロント画面へのアクセスの場合
3430 // ### Bootstrapのjsとcssはテンプレート側で読み込む ###
3431 // $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP); // Bootstrapライブラリ
3432 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW || // ログイン、ログアウト場合
3433 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
3434 $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3438 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3439 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3440 $this->addAdminScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3442 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3444 } else if ($gEnvManager->isContentEditableUser()){ // 投稿ユーザの場合
3445 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3449 // ********************************************************
3451 // ********************************************************
3452 // ##### インストール時のヘッダ出力 #####
3453 if (defined('M3_STATE_IN_INSTALL')){
3456 if (count($this->headSubTitle) > 0) $title = htmlspecialchars(trim($this->headSubTitle[0]));
3458 // ********** メタタグの設定 **********
3459 $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3461 // ##### インストーラ用のファイルの読み込み #####
3462 $scriptsUrl = '../scripts';
3464 // 管理機能用共通ライブラリのCSSの読み込み
3465 $count = count($this->defaultAdminCssFiles);
3466 for ($i = 0; $i < $count; $i++){
3468 $cssFilename = $this->defaultAdminCssFiles[$i];
3469 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3470 $cssURL = $cssFilename;
3472 $cssURL = $scriptsUrl . '/' . $cssFilename;
3474 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3477 // 管理画面用の共通スクリプトを読み込む
3478 $count = count($this->defaultAdminScriptFiles);
3479 for ($i = 0; $i < $count; $i++){
3480 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3483 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3484 $scriptURL = $scriptFilename;
3488 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3490 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3493 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3496 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3497 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3498 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3501 // ##### ページへJavascriptの埋め込む #####
3502 // JavaScriptグローバル変数の設定
3503 $rootUrl = $gEnvManager->getRootUrl();
3504 if (empty($rootUrl)) $rootUrl = $gEnvManager->calcSystemRootUrl();
3505 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3506 $replaceStr .= '//<![CDATA[' . M3_NL;
3507 $replaceStr .= '// Magic3 Global values' . M3_NL;
3508 if (!empty($rootUrl)) $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3509 $replaceStr .= '//]]>' . M3_NL;
3510 $replaceStr .= '</script>' . M3_NL;
3515 $cleanType = $gEnvManager->getCurrentTemplateCleanType(); // テンプレートクリーンタイプ
3516 /* if ($this->db->getTemplate($gEnvManager->getCurrentTemplateId(), $templateRow)){
3517 $cleanType = $templateRow['tm_clean_type'];
3522 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3524 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
3526 $isSslPage = $this->isSslPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
3529 $rootUrl = $gEnvManager->getSslRootUrl();
3530 $scriptsUrl = $gEnvManager->getSslScriptsUrl(); // スクリプト読み込み用パス
3531 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
3532 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
3534 $rootUrl = $gEnvManager->getRootUrl();
3535 $scriptsUrl = $gEnvManager->getScriptsUrl(); // スクリプト読み込み用パス
3536 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
3537 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
3541 if (!$this->showWidget){// 単体実行以外のとき
3542 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスの場合
3544 // メイン画面は「サイト名 - 管理画面」、サブ画面は個別画面名
3545 $siteName = $gEnvManager->getSiteName();
3546 // if (empty($siteName)) $siteName = self::DEFAULT_SITE_NAME;
3547 $title = $siteName . ' - ' . self::DEFAULT_ADMIN_TITLE;
3548 $titleCount = count($this->headSubTitle);
3549 if ($titleCount > 0) $title = $this->headSubTitle[$titleCount -1]; // サブタイトルが設定されている場合は変更
3550 $replaceStr .= '<title>' . htmlspecialchars($title) . '</title>' . M3_NL;
3552 // その他HTMLヘッダに出力するタグ文字列
3553 if (!empty($this->adminHeadOthers)){
3555 $this->adminHeadOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->adminHeadOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3556 $replaceStr .= $this->adminHeadOthers . M3_NL;
3558 } else { // 管理画面以外の画面へのアクセスの場合
3560 $titleItemCount = 0; // タイトル項目数
3561 $defaultTitle = trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_TITLE));
3562 if (!empty($defaultTitle)) $titleItemCount++;
3563 if (!empty($this->headSubTitle)){ // サブタイトルが設定されているとき
3564 $titleItemCount += count($this->headSubTitle);
3568 if ($titleItemCount > 0){
3569 $format = $this->gSystem->getSystemConfig(self::CONFIG_KEY_HEAD_TITLE_FORMAT);
3570 if (empty($format)){
3571 $title = htmlspecialchars($defaultTitle);
3573 $formats = explode(';', $format);
3574 $titleItemCount = ($titleItemCount > count($formats)) ? count($formats) : $titleItemCount;
3575 $title = $formats[$titleItemCount -1];
3577 if (!empty($defaultTitle)){
3578 $title = str_replace('$1', htmlspecialchars($defaultTitle), $title);
3581 for ($i = 0; $i < count($this->headSubTitle); $i++){
3582 $key = '$' . $number;
3583 $value = htmlspecialchars(trim($this->headSubTitle[$i]));
3584 $title = str_replace($key, $value, $title);
3589 if (!empty($title)) $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3592 if (!empty($this->headDescription)) $replaceStr .= '<meta name="description" content="' . htmlspecialchars($this->headDescription) . '" />' . M3_NL;
3595 if (!empty($this->headKeywords)) $replaceStr .= '<meta name="keywords" content="' . htmlspecialchars($this->headKeywords) . '" />' . M3_NL;
3597 // その他HTMLヘッダに出力するタグ文字列
3598 if (!empty($this->headOthers)){
3600 $this->headOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->headOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3601 $replaceStr .= $this->headOthers . M3_NL;
3606 // ##### PC用URLと携帯用URLのアクセス別に処理 #####
3607 if ($gEnvManager->getIsMobileSite()){ // 携帯用URLのとき
3608 } else { // PC用URLまたはスマートフォン用URLのとき
3609 // ##### テンプレート情報に応じた処理 #####
3610 // テンプレートクリーンが必要な場合はJQueryを追加
3611 if ($cleanType != 0) $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
3614 $robots = htmlspecialchars(trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_ROBOTS)));
3615 if (!empty($robots)){
3616 $replaceStr .= '<meta name="robots" content="' . $robots . '" />' . M3_NL;
3620 $replaceStr .= '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
3623 $templateId = $gEnvManager->getCurrentTemplateId();
3624 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3625 // テンプレートのFaviconがない場合はシステムのデフォルトのFaviconを使用
3626 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3627 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3628 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3629 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3632 $faviconPath = $gEnvManager->getSystemRootPath() . self::DEFAULT_ADMIN_FAVICON_FILE;
3633 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3634 $faviconFile = $rootUrl . self::DEFAULT_ADMIN_FAVICON_FILE;
3635 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3639 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3640 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3641 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3642 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3645 // ##### 追加ライブラリの読み込み #####
3646 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用URLのとき
3647 $value = $gSystemManager->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面で常にjQuery Mobileを使用
3649 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
3650 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
3651 for ($l = 0; $l < count($this->headPreMobileScriptFiles); $l++){
3652 $this->addScriptFile($this->headPreMobileScriptFiles[$l]); // 通常機能用のスクリプト追加
3655 $this->addScriptFile($this->selectedJQueryMobileFilename);
3659 // ##### Ajaxライブラリの読み込み #####
3660 if (!$gEnvManager->isAdminDirAccess()){ // 通常画面へのアクセスのとき
3661 if ($this->db->isExistsWidgetWithAjax($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId())){// Ajaxライブラリを使用しているウィジェットがあるときは追加
3662 $this->addScriptFile($this->selectedJQueryFilename); // デフォルトAjaxライブラリ追加
3663 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
3667 // ##### 共通ライブラリの読み込み #####
3668 if (!$this->showWidget){// 単体実行以外のとき
3669 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3670 for ($i = 0; $i < count($rows); $i++){
3671 $this->addScript($task, trim($rows[$i]['wd_add_script_lib']));
3675 // ##### 共通CSS読み込み #####
3676 if (($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()) || $this->isEditMode){ // フロント画面編集モード
3677 $cssURL = $scriptsUrl . '/' . self::M3_EDIT_CSS_FILE;
3678 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3680 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3681 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
3682 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3683 // 管理機能用共通ライブラリのCSSの読み込み
3684 $count = count($this->defaultAdminCssFiles);
3685 for ($i = 0; $i < $count; $i++){
3687 //$cssURL = $scriptsUrl . '/' . $this->defaultAdminCssFiles[$i];
3688 $cssFilename = $this->defaultAdminCssFiles[$i];
3689 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3690 $cssURL = $cssFilename;
3692 $cssURL = $scriptsUrl . '/' . $cssFilename;
3694 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3697 // 管理権限なしで管理ディレクトリアクセスで必要なCSSファイルを読み込む
3698 $count = count($this->defaultAdminDirCssFiles);
3699 for ($i = 0; $i < $count; $i++){
3701 $cssURL = $scriptsUrl . '/' . $this->defaultAdminDirCssFiles[$i];
3702 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3707 $count = count($this->defaultCssFiles);
3708 for ($i = 0; $i < $count; $i++){
3710 $cssFilename = $this->defaultCssFiles[$i];
3711 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3712 $cssURL = $cssFilename;
3714 $cssURL = $scriptsUrl . '/' . $cssFilename;
3716 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3720 // ##### 表示モードによるCSS読み込み #####
3721 // ウィジェット付きポジション画面は管理画面のアクセスではない
3722 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3724 $cssURL = $scriptsUrl . self::M3_ADMIN_WIDGET_CSS_FILE;
3725 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3728 // ##### ウィジェットごとのCSS読み込み #####
3730 $this->db->getWidgetsIdWithCss($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3731 for ($i = 0; $i < count($rows); $i++){
3732 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS;
3733 // ディレクトリがあるときはディレクトリ内読み込み
3734 if (is_dir($searchPath)){
3735 $dir = dir($searchPath);
3736 while (($file = $dir->read()) !== false){
3737 $filePath = $searchPath . '/' . $file;
3738 if ($file != '.' && $file != '..' && is_file($filePath)
3739 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3742 $cssURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS . '/' . $file;
3743 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3749 // ##### 外部出力用CSS読み込み #####
3750 // ウィジェットからの追加のCSS読み込み
3751 $count = count($this->headCssFiles);
3752 for ($i = 0; $i < $count; $i++){
3753 $cssUrl = $this->headCssFiles[$i];
3754 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3755 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3758 // 外部出力用CSSデータがある場合はURLを追加
3759 if (!empty($this->exportCss)){
3760 $cssUrl = $this->createCssCmdUrl($isSslPage, date('YmdHis'));
3761 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3762 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3765 // ##### RSS配信情報の読み込み #####
3766 $count = count($this->headRssFiles);
3767 for ($i = 0; $i < $count; $i++){
3768 $rssUrl = $this->headRssFiles[$i]['href'];// リンク先URL
3769 $rssTitle = $this->headRssFiles[$i]['title'];// タイトル
3770 $replaceStr .= '<link rel="alternate" type="application/rss+xml" title="' . $rssTitle . '" href="' . convertUrlToHtmlEntity($rssUrl) . '" />' . M3_NL;
3773 // ##### 共通Javascriptの読み込み #####
3774 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3775 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3776 // 管理画面用の共通スクリプトを読み込む
3777 $count = count($this->defaultAdminScriptFiles);
3778 for ($i = 0; $i < $count; $i++){
3779 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3782 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3783 $scriptURL = $scriptFilename;
3787 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3789 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3792 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3795 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3796 //$scriptURL = $scriptsUrl . '/' . $scriptFilename;
3797 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3798 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3800 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示のときは、ウィジェット操作ライブラリを読み込む
3802 $scriptURL = $scriptsUrl . '/' . self::M3_ADMIN_WIDGET_SCRIPT_FILENAME;
3803 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();// スクリプトをキャッシュ保存しない場合は、パラメータを付加
3804 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3806 } else { // システム運用権限がない場合
3807 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3808 $count = count($this->defaultAdminDirScriptFiles);
3809 for ($i = 0; $i < $count; $i++){
3810 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3812 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3813 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3814 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3815 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3819 // Googleマップライブラリの読み込み
3820 if ($this->useGooglemaps && $this->isContentGooglemaps) $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS)); // コンテンツにGoogleマップが含むかどうか
3822 $useExternalJquery = $gSystemManager->getSystemConfig(self::CF_EXTERNAL_JQUERY); // システム外部のjQueryを使用するかどうか
3824 $count = count($this->defaultScriptFiles);
3825 for ($i = 0; $i < $count; $i++){
3826 $defaultScriptFile = $this->defaultScriptFiles[$i];
3828 // 外部のjQueryを使用する場合はSCRIPTタグを出力しない
3829 if ($defaultScriptFile == $this->selectedJQueryFilename && $useExternalJquery) continue;
3831 // ##### jQueryMobileスクリプトを追加する場合は直前に初期化スクリプトを追加 #####
3832 if ($defaultScriptFile == $this->selectedJQueryMobileFilename){
3833 if (count($this->headPreMobileScript) > 0){
3834 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3835 $replaceStr .= '//<![CDATA[' . M3_NL;
3836 for ($j = 0; $j < count($this->headPreMobileScript); $j++){
3837 $replaceStr .= $this->headPreMobileScript[$j];
3839 $replaceStr .= M3_NL;
3840 $replaceStr .= '//]]>' . M3_NL;
3841 $replaceStr .= '</script>' . M3_NL;
3846 if (strncasecmp($defaultScriptFile, 'http://', 7) == 0 || strncasecmp($defaultScriptFile, 'https://', 8) == 0){
3847 $scriptURL = $defaultScriptFile;
3851 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3853 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3856 $scriptURL = $scriptsUrl . '/' . $defaultScriptFile;
3859 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3860 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3861 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3864 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW){ // ログイン、ログアウト場合
3865 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3866 $count = count($this->defaultAdminDirScriptFiles);
3867 for ($i = 0; $i < $count; $i++){
3868 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3869 if (!in_array($scriptFilename, $this->defaultScriptFiles)){ // 既に追加されていない場合のみ追加
3870 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3871 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3872 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3873 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3878 // ***** [WordPressテンプレート] jQueryの読み込み後、ヘッダ部に出力するテンプレート用のJavascriptがあれば読み込む *****
3879 $headData = $this->gEnv->getWpHeadScriptsData();
3880 if (!empty($headData)) $replaceStr .= $headData;
3882 // ##### ウィジェットごとのJavaScript読み込み #####
3883 // スクリプトがあるウィジェットを取得
3884 $this->db->getWidgetsIdWithScript($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3885 for ($i = 0; $i < count($rows); $i++){
3886 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS;
3888 // ディレクトリがあるときはディレクトリ内読み込み
3889 if (is_dir($searchPath)){
3890 $dir = dir($searchPath);
3891 while (($file = $dir->read()) !== false){
3892 $filePath = $searchPath . '/' . $file;
3893 if ($file != '.' && $file != '..' && is_file($filePath)
3894 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3897 $scriptURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
3898 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3899 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3900 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3906 // ウィジェットからの追加のCSS読み込み
3907 $count = count($this->headScriptFiles);
3908 for ($i = 0; $i < $count; $i++){
3909 $scriptUrl = $this->headScriptFiles[$i];
3910 if ($isSslPage) $scriptUrl = str_replace('http://', 'https://', $scriptUrl); // SSL化が必要なときは変換
3912 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3913 if (!$this->hasScriptCache) $scriptUrl .= $this->getCacheParam();
3914 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptUrl) . '"></script>' . M3_NL;
3918 $openType = $this->gSystem->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE);// ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
3920 // ##### ページへJavascriptの埋め込む #####
3921 // JavaScriptグローバル変数の設定
3922 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
3923 //$replaceStr .= '<!--' . M3_NL;
3924 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3925 $replaceStr .= '//<![CDATA[' . M3_NL;
3926 $replaceStr .= '// Magic3 Global values' . M3_NL;
3927 $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3929 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()){ // 管理画面へのアクセス、システム運用権限があり
3930 $pageId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID); // ページID
3931 $pageSubId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);// ページサブID
3934 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
3935 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
3938 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
3939 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
3941 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3944 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
3945 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
3946 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
3948 // Googleマップライブラリの読み込み
3949 if ($this->useGooglemaps){
3950 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
3952 // CKEditor拡張プラグイン用の定義
3953 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
3954 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
3956 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
3959 // 管理画面の小画面デバイス最適化を行うかどうか
3960 if ($gEnvManager->isSmallDeviceAdmin()){
3961 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = true;' . M3_NL;
3963 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = false;' . M3_NL;
3966 // ウィジェット詳細設定画面専用のJavaScriptグローバル変数
3967 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){
3968 // ##### CKEditor用の設定 #####
3969 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3971 // CKEditor用のCSSファイル
3972 if (!empty($this->ckeditorCssFiles)){
3973 // 編集エリア用のCSSファイルを追加
3974 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3975 //array_unshift($this->ckeditorCssFiles, $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE);
3977 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
3978 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3980 // CKEditor用(レイアウト)のCSSファイル
3981 $cssFiles = array();
3982 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_ADMIN_CSS; // BootstrapのCSSを追加
3983 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3984 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
3985 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3987 // CKEditor用のテンプレートタイプ
3988 if (isset($this->ckeditorTemplateType)){
3989 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
3991 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION){ // ポジション表示
3992 $replaceStr .= 'var M3_POSITION_DATA = "' . implode(',', $this->defPositions) . '";' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
3993 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = 0;' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
3994 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3996 $positionData = $this->getRestPositionData();
3999 if (count($this->viewPosId) > 0){
4001 for ($i = 0; $i < count($this->viewPosId); $i++){
4002 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
4003 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
4005 $posArrayStr .= ']';
4006 $replaceStr .= 'var M3_POSITIONS = ' . $posArrayStr . ';' . M3_NL;
4009 $replaceStr .= 'var M3_REVISION = ' . $this->pageDefRev . ';' . M3_NL;
4012 $replaceStr .= 'var M3_REST_POSITION_DATA = \'' . $positionData . '\';' . M3_NL;
4013 } else if (!empty($pageId)){
4014 $accessPoint = $this->gEnv->getAllDefaultPageId();
4015 for ($i = 0; $i < count($accessPoint); $i++){
4016 if ($pageId == $accessPoint[$i]){
4017 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $i . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
4021 } else { // メインの管理画面の場合
4022 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = 0;' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
4025 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
4026 if (!empty($task)){ // 戻りタスクが設定されているときのみ最大化可能
4027 $replaceStr .= 'function gobackPagedef(){' . M3_NL;
4028 $replaceStr .= ' window.location.href = "' . $gEnvManager->getDefaultAdminUrl() . '?pageid=' . $pageId . '&pagesubid=' . $pageSubId . '&task=' . $task . '";' . M3_NL;
4029 $replaceStr .= '}' . M3_NL;
4030 $replaceStr .= '$(function(){' . M3_NL;
4031 $replaceStr .= ' $(document).keyup(function(e){' . M3_NL;
4032 $replaceStr .= ' if (e.which == 36) gobackPagedef();' . M3_NL;
4033 $replaceStr .= ' });' . M3_NL;
4034 $replaceStr .= '});' . M3_NL;
4037 // ##### 管理用テンプレートを使用している場合の処理 #####
4038 // Bootstrap用のスクリプト処理
4039 if ($this->useBootstrap){
4040 $replaceStr .= '$(function(){' . M3_NL;
4041 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
4042 $replaceStr .= '});' . M3_NL;
4045 } else if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4046 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
4047 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
4050 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
4051 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
4053 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4056 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4057 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4058 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4061 $templateType = $gEnvManager->getCurrentTemplateType();
4062 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4063 } else if ($this->isEditMode){ // フロント画面編集モード(コンテンツ編集可能ユーザ)
4064 if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
4066 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4069 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4070 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4071 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4073 // Googleマップライブラリの読み込み
4074 if ($this->useGooglemaps){
4075 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
4077 // CKEditor拡張プラグイン用の定義
4078 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
4079 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
4081 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
4084 // 管理画面の小画面デバイス最適化を行うかどうか
4085 if ($gEnvManager->isSmallDeviceAdmin()){
4086 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = true;' . M3_NL;
4088 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = false;' . M3_NL;
4091 // ##### CKEditor用の設定 #####
4093 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
4094 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
4096 // CKEditor用のCSSファイル
4097 if (!empty($this->ckeditorCssFiles)){
4098 // 編集エリア用のCSSファイルを追加
4099 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4100 //array_unshift($this->ckeditorCssFiles, $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE);
4102 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
4103 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4105 // CKEditor用(レイアウト)のCSSファイル
4106 $cssFiles = array();
4107 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_ADMIN_CSS; // BootstrapのCSSを追加
4108 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4109 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
4110 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4112 // CKEditor用のテンプレートタイプ
4113 if (isset($this->ckeditorTemplateType)){
4114 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
4117 // Bootstrap用のスクリプト処理
4118 if ($this->useBootstrap){
4119 $replaceStr .= '$(function(){' . M3_NL;
4120 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
4121 $replaceStr .= '});' . M3_NL;
4124 // プレビュー画面用にテンプレートタイプを出力
4125 $templateType = $gEnvManager->getCurrentTemplateType();
4126 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4128 // ##### ヘルプシステムの組み込み #####
4129 if ($this->useHelp){ // ヘルプ表示のとき
4130 $replaceStr .= '$(function(){' . M3_NL;
4131 $replaceStr .= ' if (jQuery().tooltip) $(\'[rel=m3help]\').tooltip({ placement: \'top\'});' . M3_NL;
4132 $replaceStr .= '});' . M3_NL;
4136 if (!$gEnvManager->isAdminDirAccess()){ // フロント画面のとき
4137 // テンプレートタイプを追加(ファイルローダ等で使用)
4138 $templateType = $gEnvManager->getCurrentTemplateType();
4139 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4143 // ##### パネルメニュー(フロント画面と管理画面の切り替え等)の表示 #####
4144 // PC用、携帯用、スマートフォン用画面とウィジェット付きポジションの管理画面時に表示
4145 if (($gEnvManager->isAdminDirAccess() && $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) || // 管理画面(ウィジェット付きポジション表示)のとき
4146 (!$gEnvManager->isAdminDirAccess() && // 一般用画面のとき
4147 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4148 $cmd != M3_REQUEST_CMD_RSS)){ // RSS配信でない
4149 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
4150 if ($gEnvManager->isSystemManageUser()){ // システム運用権限ありの場合
4152 $menubarTag = ''; // 管理用メニューバー
4153 $adminTag = ''; // 管理画面ボタン
4154 $editTag = ''; // 編集ボタン
4155 $logoutTag = ''; // ログアウトボタン
4157 if ($gEnvManager->isAdminDirAccess()){ // 管理画面(ウィジェット付きポジション表示)の場合
4159 /* $titleStr = '編集終了';
4160 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4161 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4162 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
4163 $editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
4166 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4167 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4168 //$editTag = '<div class="m3editend"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4169 //$editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" /></a></div>';
4170 $editTag = '<div class="m3editend m3topright"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4171 $editTag .= '<i class="glyphicon glyphicon-ok-sign"></i></a></div>';
4172 $menubarTag .= $editTag;
4174 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4175 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4176 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").prepend(\'' . $menubarTag . '\');' . M3_NL; // appendでうまく表示できないのでprependで表示
4177 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4178 } else if ($this->isAccessPointWithAdminMenu){ // 通常画面は、管理メニューを使用するアクセスポイントの場合のみ表示
4180 $titleStr = '管理画面へ遷移';
4181 $linkUrl = $gEnvManager->getDefaultAdminUrl();
4182 $adminTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4183 $adminTag .= '<img src="' . $rootUrl . self::ADMIN_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4186 $titleStr = '画面を編集';
4187 $linkUrl = $gEnvManager->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' .M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET;
4188 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_ID . '=' . $gEnvManager->getCurrentPageId();
4189 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
4190 $linkUrl .= '&' . M3_REQUEST_PARAM_BACKUP_URL . '=' . urlencode($gEnvManager->getCurrentRequestUri()); // URL退避用
4191 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4192 $editTag .= '<img src="' . $rootUrl . self::EDIT_PAGE_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4195 $titleStr = 'ログアウト';
4196 // if ($gEnvManager->isAdminDirAccess()){ // 管理画面の場合
4197 // $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4198 // if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4200 $linkUrl = $gEnvManager->getCurrentRequestUri();
4202 $linkUrl = createUrl($linkUrl, M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_LOGOUT);
4203 $logoutTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4204 $logoutTag .= '<img src="' . $rootUrl . self::LOGOUT_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4207 $widgetToolTag .= '<li><div class="m3widgettoolbutton m3-nav m3-navbar-nav" data-toggle="buttons">';
4208 $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>';
4209 $widgetToolTag .= '<input type="checkbox" class="hidden" />';
4210 $widgetToolTag .= '</div></li>';
4212 //$menubarTag .= '<div id="m3slidepanel">';
4213 $menubarTag .= '<div id="m3slidepanel" class="m3panel_top m3-navbar-default" style="top:-60px; visibility: visible;">';
4214 $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>';
4215 // $menubarTag .= '<div tabindex="0" class="m3panel_wrap">';
4216 $menubarTag .= '<div>';
4217 $menubarTag .= '<ul class="m3-nav m3-navbar-nav">';
4218 if ($gEnvManager->isSystemAdmin()){ // 管理画面、編集モードは、管理者権限がある場合のみ有効
4219 $menubarTag .= $adminTag;
4220 $menubarTag .= $editTag;
4222 $menubarTag .= $logoutTag;
4223 $menubarTag .= $widgetToolTag;
4224 $menubarTag .= '</ul>';
4225 $menubarTag .= '</div>';
4226 $menubarTag .= '</div>';
4227 // $menubarTag .= '</div>';
4229 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4230 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4231 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").append(\'' . $menubarTag . '\');' . M3_NL;
4232 //$this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("#m3slidemenubarpanel").m3SlideMenubar();' . M3_NL;
4233 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(".m3panel_top").m3slidepanel({ "position": "top", "type": "push" });' . M3_NL;
4234 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").css("position", "relative");' . M3_NL;
4235 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetHelp($(\'#m3slidepanel\'));' . M3_NL;
4236 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetupWidgetTool(\'m3widgettoolbutton\');' . M3_NL;
4237 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4241 // ##### フロント画面からのウィジェット操作用ツールバー #####
4242 if (!$gEnvManager->isAdminDirAccess() &&
4243 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4244 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
4245 if ($gEnvManager->isSystemManageUser()){ // 一般用画面で管理者権限がある場合のみ有効
4247 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').each(function(){' . M3_NL;
4248 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var attrs = m3_splitAttr($(this).attr(\'m3\'));' . M3_NL;
4249 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var widgetId = attrs[\'widgetid\'];' . M3_NL;
4250 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var serialNo = attrs[\'serial\'];' . M3_NL;
4251 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var configId = attrs[\'configid\'];' . M3_NL;
4252 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var useconfig = attrs[\'useconfig\'];' . M3_NL;
4254 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'\';' . M3_NL;
4255 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (useconfig == 1){' . M3_NL;
4256 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4257 'html += \'<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\\\'\' + widgetId + \'\\\', \' + configId + \', \' + serialNo + \');return false;" rel="m3help" data-container="body" title="ウィジェット設定">' .
4258 '<img src="' . $rootUrl . self::CONFIG_ICON32_FILE . '" alt="ウィジェット設定" width="32" height="32" /></a>\';' . M3_NL;
4259 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4260 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4261 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) .
4262 '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="タイトル・スタイル調整">' .
4263 '<img src="' . $rootUrl . self::ADJUST_ICON32_FILE . '" alt="タイトル・スタイル調整" width="32" height="32" /></a>\';' . M3_NL;
4265 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (html != \'\'){' . M3_NL;
4266 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4267 'html = \'<div class="m3tooltip" style="display:none;">\' + html + \'<a class="m3closebox" href="javascript:void(0);" rel="m3help" data-container="body" title="閉じる">' .
4268 '<img src="' . $rootUrl . self::CLOSE_BOX_ICON32_FILE . '" alt="閉じる" width="11" height="11" /></a></div>\';' . M3_NL;
4270 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).append(html);' . M3_NL;
4271 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4273 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).click(function(){' . M3_NL;
4274 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4275 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (tooltipObj.css(\'display\') == \'none\'){' . M3_NL;
4276 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (_m3ShowWidgetTool){' . M3_NL;
4277 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'tooltipObj.show();' . M3_NL;
4278 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4279 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4280 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.hide();' . M3_NL;
4281 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4282 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4283 // ウィジェットボーダーハイライト、ツールチップ表示
4284 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).hover(function(){' . M3_NL;
4285 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4286 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(this).addClass(\'m3_widget_highlight\');' . M3_NL;
4287 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4288 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var pos = $(this).position();' . M3_NL;
4289 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var width = $(this).outerWidth();' . M3_NL;
4290 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipWidth = tooltipObj.outerWidth(true);' . M3_NL;
4291 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var x = pos.left + width - tooltipWidth;' . M3_NL;
4292 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var y = pos.top;' . M3_NL;
4293 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.css({position: "absolute",top: y + "px", left: x + "px"}).show();' . M3_NL;
4294 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4295 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}, function(){' . M3_NL;
4296 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).removeClass(\'m3_widget_highlight\');' . M3_NL;
4297 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4298 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'tooltipObj.hide();' . M3_NL;
4299 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4301 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3closebox\').click(function(event){' . M3_NL;
4302 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).children(\'.m3tooltip\').hide();' . M3_NL;
4303 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4305 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4306 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var offset = $(this).offset();' . M3_NL;
4307 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).outerWidth();' . M3_NL;
4308 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3edittool\').each(function(){' . M3_NL;
4309 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).offset({left: offset.left});' . M3_NL;
4310 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).width(width);' . M3_NL;
4311 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4312 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4315 $this->initScript .= M3_INDENT_SPACE . 'var widgetWindow = \'<div class="m3_contextmenu" id="m3_widgetmenu" style="visibility:hidden;">\';' . M3_NL;
4316 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<ul>\';' . M3_NL;
4317 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<li id="m3_wconfig"><img src="\' + M3_ROOT_URL + \'/images/system/config.png" /> <span>ウィジェットの設定</span></li>\';' . M3_NL;
4318 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4319 $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;
4321 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</ul>\';' . M3_NL;
4322 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</div>\';' . M3_NL;
4323 $this->initScript .= M3_INDENT_SPACE . '$("body").append(widgetWindow);' . M3_NL;
4324 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').contextMenu(\'m3_widgetmenu\', {' . M3_NL;
4325 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'menuStyle: {' . M3_NL;
4326 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// border : "2px solid green",' . M3_NL;
4327 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'backgroundColor: \'#FFFFFF\',' . M3_NL;
4328 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'width: "150px",' . M3_NL;
4329 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'textAlign: \'left\',' . M3_NL;
4330 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'font: \'12px/1.5 Arial, sans-serif\'' . M3_NL;
4331 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4332 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'itemStyle: {' . M3_NL;
4333 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'padding: \'3px 3px\'' . M3_NL;
4334 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4335 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'bindings: {' . M3_NL;
4336 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wconfig\': function(t){' . M3_NL;
4337 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4338 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4339 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'alert("このウィジェットには設定画面がありません");' . M3_NL;
4340 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'return;' . M3_NL;
4341 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4342 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowConfigWindow(attrs[\'widgetid\'], attrs[\'configid\'], attrs[\'serial\']);' . M3_NL;
4343 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '},' . M3_NL;
4344 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wadjust\': function(t){' . M3_NL;
4345 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4346 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowAdjustWindow(attrs[\'configid\'], attrs[\'serial\'], M3_PAGE_ID, M3_PAGE_SUB_ID);' . M3_NL;
4347 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4348 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4349 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onContextMenu: function(e){' . M3_NL;
4350 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4351 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return true;' . M3_NL;
4352 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4353 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return false;' . M3_NL;
4354 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4355 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4356 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onShowMenu: function(e, menu){' . M3_NL;
4357 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// メニュー項目の変更' . M3_NL;
4358 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var attrs = m3_splitAttr($(e.target).parents(\'dl\').attr(\'m3\'));' . M3_NL;
4359 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4360 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(\'#m3_wconfig\', menu).remove();' . M3_NL;
4361 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4362 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'return menu;' . M3_NL;
4363 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4364 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4367 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3content_private\').each(function(){' . M3_NL;
4368 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4369 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var top = pos.top;' . M3_NL;
4370 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var left = pos.left;' . M3_NL;
4371 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).css(\'width\');' . M3_NL;
4372 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var height = $(this).css(\'height\');' . M3_NL;
4373 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'<div class="m3content_overlay"><div><h2>非公開</h2></div></div>\';' . M3_NL;
4374 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).prepend(html);' . M3_NL;
4375 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var overlayObj = $(this).children(\'.m3content_overlay div\');' . M3_NL;
4376 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'overlayObj.css({ position:"absolute", top:top + "px", left:left + "px" }).show();' . M3_NL;
4377 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4380 // ##### フロント画面のデフォルトのJavaスクリプト #####
4381 // if (!$gEnvManager->isAdminDirAccess()){
4382 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (jQuery().tooltip) $(\'[rel=tooltip]\').tooltip();' . M3_NL; // 標準ツールチップ作成
4384 // ポップアップメッセージがある場合は表示
4385 if (!empty($this->popupMsg)){
4386 $replaceStr .= 'alert("' . $this->popupMsg . '");' . M3_NL;
4389 if ($cleanType == 1){
4390 // HTMLのクリーン処理が必要なときはコードを埋め込む
4391 $this->initScript .= ' $(\'.PostHeaderIcons\').remove();' . M3_NL;// 不要なアイコン表示タグの削除
4392 $this->initScript .= ' $(\'.PostMetadataHeader\').each(function(i){' . M3_NL;
4393 $this->initScript .= ' if ($(this).text().trim() == \'\') $(this).remove();' . M3_NL;
4394 $this->initScript .= ' });' . M3_NL;
4398 $replaceStr .= $this->getLastContents();
4401 if (!empty($this->initScript)){
4402 $replaceStr .= '$(function(){' . M3_NL;
4403 $replaceStr .= $this->initScript;
4404 $replaceStr .= '});' . M3_NL;
4407 //$replaceStr .= '// -->' . M3_NL;
4408 //$replaceStr .= '</script>' . M3_NL;
4409 $replaceStr .= '//]]>' . M3_NL;
4410 $replaceStr .= '</script>' . M3_NL;
4412 // HEADタグに埋め込むCSS,JavaScript,任意文字列
4413 if (count($this->headCss) > 0){
4414 // CSSの場合は全体をstyleタグで囲む
4415 $replaceStr .= '<style type="text/css">' . M3_NL;
4416 $replaceStr .= '<!--' . M3_NL;
4417 for ($i = 0; $i < count($this->headCss); $i++){
4418 $replaceStr .= $this->headCss[$i];
4420 $replaceStr .= M3_NL . '//-->' . M3_NL;
4421 $replaceStr .= '</style>' . M3_NL;
4423 if (count($this->headScript) > 0){
4424 // JavaScriptの場合は全体をscriptタグで囲む
4425 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
4426 //$replaceStr .= '<!--' . M3_NL;
4427 $replaceStr .= '<script type="text/javascript">' . M3_NL;
4428 $replaceStr .= '//<![CDATA[' . M3_NL;
4429 for ($i = 0; $i < count($this->headScript); $i++){
4430 $replaceStr .= $this->headScript[$i];
4432 //$replaceStr .= M3_NL . '//-->' . M3_NL;
4433 //$replaceStr .= '</script>' . M3_NL;
4434 $replaceStr .= M3_NL;
4435 $replaceStr .= '//]]>' . M3_NL;
4436 $replaceStr .= '</script>' . M3_NL;
4438 if (count($this->headString) > 0){
4440 for ($i = 0; $i < count($this->headString); $i++){
4441 $replaceStr .= $this->headString[$i];
4450 * @param string $position HTMLテンプレート上の書き出し位置
4451 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
4452 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
4453 * @param array $attr その他属性
4454 * @return string 出力コンテンツ
4456 function getContents($position, $style = '', $templateVer = 0, $attr = array())
4458 static $render; // HTML生成オブジェクト
4459 global $gRequestManager;
4460 global $gEnvManager;
4463 $filename = $gEnvManager->getCurrentPageId();
4464 $subId = $gEnvManager->getCurrentPageSubId();
4465 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
4467 // ポジション名表示モードに応じて出力を作成
4468 $contents = ''; // 出力コンテンツ
4469 switch ($this->showPositionMode){
4471 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4472 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4473 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
4474 if ($ret){ // 1行以上データが取得できたとき
4475 $this->pageDefRows = $rows; // ページ定義レコード
4476 $this->pageDefPosition = $position;
4478 $this->pageDefRows = array();
4479 $this->pageDefPosition = '';
4483 $count = count($this->pageDefRows);
4485 if ($templateVer == 0){ // ########## Joomla!v1.0テンプレートの場合 ##########
4486 ob_start();// バッファ作成
4488 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4489 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
4490 for ($i = 0; $i < $count; $i++){
4491 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4492 $widgetId = $this->pageDefRows[$i]['wd_id'];
4494 // ### 遅延実行ウィジェットはキャッシュしない ###
4495 // キャッシュデータがあるときはキャッシュデータを使用
4496 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4498 if (empty($cacheData)){ // キャッシュデータがないとき
4500 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, $widgetHeaderType);
4502 $widgetContent = ob_get_contents();
4505 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4507 // ウィジェットの内枠(コンテンツ外枠)を設定
4508 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4511 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4512 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4515 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4516 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4517 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4518 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4519 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4520 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4521 // ウィジェット表示タイプによる表示制御
4522 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4523 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
4524 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4525 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4526 if (!empty($controlType)){
4527 switch ($controlType){
4528 case 1: // ログイン時のみ表示
4529 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4530 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
4532 case 2: // 非ログイン時のみ表示
4533 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4534 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
4540 if (!empty($pageState)){
4541 switch ($pageState){
4543 if (!$this->isPageTopUrl){
4544 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4545 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
4553 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4554 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4555 $hasAdmin = '0'; // 管理画面があるかどうか
4556 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4557 $shared = '0'; // 共通属性があるかどうか
4558 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4559 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4560 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4561 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
4563 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4564 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4566 } else { // キャッシュデータがあるとき
4567 $widgetContent = $cacheData;
4570 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4571 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4572 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4574 $contents .= $widgetContent;
4576 // ##### 外部出力用のCSSがある場合は追加 #####
4577 $exportCss = $this->pageDefRows[$i]['pd_css'];
4578 if (!empty($exportCss)){
4580 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4581 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4582 $this->addExportCss($exportCss);
4585 ob_end_clean(); // バッファ破棄
4587 if ($i < $count) return '';// 処理中断のときは終了
4588 } else if ($templateVer == 100){ // ########## WordPressテンプレートの場合 ##########
4589 ob_start();// バッファ作成
4591 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4592 //$widgetHeaderType = $this->getTemplateWidgetHeaderType();
4593 for ($i = 0; $i < $count; $i++){
4594 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4595 $widgetId = $this->pageDefRows[$i]['wd_id'];
4597 // ### 遅延実行ウィジェットはキャッシュしない ###
4598 // キャッシュデータがあるときはキャッシュデータを使用
4599 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4601 if (empty($cacheData)){ // キャッシュデータがないとき
4602 // WordPressウィジェット用のパラメータ設定
4603 $gEnvManager->setWpWidgetClass(''); // ウィジェットクラス名初期化
4606 // $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, $widgetHeaderType);
4607 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, 0/*タイトル出力なし*/);
4609 $widgetContent = ob_get_contents();
4611 // WordPressウィジェット用のパラメータ設定
4612 $widgetClassName = $gEnvManager->getWpWidgetClass(); // ウィジェットクラス名
4614 $trimContent = trim($widgetContent);
4615 if (!empty($trimContent)){ // 出力が空でない場合
4618 if (!isset($render)) $render = new WPRender(); // WordPress用HTML生成オブジェクト
4620 // デフォルトのウィジェットタイトル取得
4621 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4624 //$joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4626 // 遅延ウィジェットのときはタイトルタグを埋め込む
4627 if (!empty($titleTag)) $defaultTitle = $titleTag;
4629 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4630 $title = $this->pageDefRows[$i]['pd_title'];
4631 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4632 if (empty($title)) $title = $defaultTitle;
4634 $title = ''; // タイトルは非表示
4637 // WordPress用パラメータ作成
4638 $params = array(); // ウィジェットごとの属性
4639 if (!empty($widgetClassName)) $params['moduleclass'] = $widgetClassName; // ウィジェットクラス名
4642 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . ($i + 1); // ウィジェット識別用ユニークタグ
4644 if (strcmp($position, 'main') == 0){// メイン部のとき
4645 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
4647 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
4651 // $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4653 // ウィジェットの内枠(コンテンツ外枠)を設定
4654 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4658 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4659 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4662 // $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4663 // $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4664 // if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4665 // $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4666 // $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4668 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4669 // ウィジェット表示タイプによる表示制御
4670 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4671 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
4672 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4673 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4674 if (!empty($controlType)){
4675 switch ($controlType){
4676 case 1: // ログイン時のみ表示
4677 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4678 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
4680 case 2: // 非ログイン時のみ表示
4681 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4682 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
4688 if (!empty($pageState)){
4689 switch ($pageState){
4691 if (!$this->isPageTopUrl){
4692 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4693 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
4701 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4702 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4703 $hasAdmin = '0'; // 管理画面があるかどうか
4704 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4705 $shared = '0'; // 共通属性があるかどうか
4706 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4707 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4708 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4709 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
4711 // $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4712 // $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4714 } else { // キャッシュデータがあるとき
4715 $widgetContent = $cacheData;
4718 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4719 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4720 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4722 $contents .= $widgetContent;
4724 // ##### 外部出力用のCSSがある場合は追加 #####
4725 $exportCss = $this->pageDefRows[$i]['pd_css'];
4726 if (!empty($exportCss)){
4728 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4729 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4730 $this->addExportCss($exportCss);
4733 ob_end_clean(); // バッファ破棄
4735 if ($i < $count) return '';// 処理中断のときは終了
4736 } else { // ########## Joomla!v1.5テンプレートの場合 ##########
4737 // テンプレート側で指定されたメニューの表示属性を設定
4738 $gEnvManager->setMenuAttr($attr);
4742 if (!empty($attr['type'])) $posType = $attr['type'];
4744 for ($i = 0; $i < $count; $i++){
4745 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4746 $widgetId = $this->pageDefRows[$i]['wd_id'];
4748 // ### 遅延実行ウィジェットはキャッシュしない ###
4749 // キャッシュデータがあるときはキャッシュデータを使用
4750 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4752 if (empty($cacheData)){ // キャッシュデータがないとき
4754 $gEnvManager->setCurrentWidgetTitle('');
4756 // Joomla用のパラメータを初期化
4757 $gEnvManager->setCurrentWidgetJoomlaParam(array());
4761 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, 0/*タイトル出力なし*/);
4762 $widgetContent = ob_get_contents();
4764 $trimContent = trim($widgetContent);
4765 if (!empty($trimContent)){ // 出力が空でない場合
4766 $isRendered = false; // Joomla!の描画処理を行ったかどうか
4767 if (!empty($this->pageDefRows[$i]['pd_use_render'])){ // Joomla!の描画処理を使用する場合
4768 // Joomla!ウィジェットの出力に埋め込む
4769 if (strcasecmp($style, 'none') != 0){
4771 if (!isset($render)) $render = new JRender();
4773 // デフォルトのウィジェットタイトル取得
4774 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4777 $joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4779 // 遅延ウィジェットのときはタイトルタグを埋め込む
4780 if (!empty($titleTag)) $defaultTitle = $titleTag;
4782 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4783 $title = $this->pageDefRows[$i]['pd_title'];
4784 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4785 if (empty($title)) $title = $defaultTitle;
4787 $title = ''; // タイトルは非表示
4791 $params = array(); // ウィジェットごとの属性
4792 $widgetType = $this->pageDefRows[$i]['wd_type']; // ウィジェットタイプ
4794 // オプションのJoomlaクラス(縦型メニュー(art-vmenu)等)
4795 $joomlaClass = $this->pageDefRows[$i]['wd_joomla_class']; // 「wd_joomla_class」は使っていない?
4796 if (!empty($joomlaClass)) $params['moduleclass_sfx'] = $joomlaClass;
4797 if (isset($joomlaParam['moduleclass_sfx'])) $params['moduleclass_sfx'] = $joomlaParam['moduleclass_sfx'];// ウィジェットでjoomla用パラメータの設定があるとき
4799 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
4800 $moduleContent = '';
4802 // ウィジェットタイプがメニューのときはナビゲーションメニューを生成
4803 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4805 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
4806 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4807 $widgetContent = $moduleContent;
4809 // ウィジェットタイプに応じた処理を実行
4810 if ($widgetType == 'breadcrumb'){ // パンくずリスト
4811 $moduleContent = $render->getBreadcrumbContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4813 // パンくずリストで作成できないときはデフォルトの出力を取得
4814 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4815 $widgetContent = $moduleContent;
4817 if (strcmp($position, 'main') == 0){// メイン部のとき
4818 // ウィジェットの内枠(コンテンツ外枠)を設定
4819 // ウィジェットの内枠はレンダーで設定
4820 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4821 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4822 } else { // その他の位置のとき
4823 // ウィジェットの内枠(コンテンツ外枠)を設定
4824 // ウィジェットの内枠はレンダーで設定
4825 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4827 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4831 /* if (strcmp($position, 'main') == 0){// メイン部のとき
4832 // ウィジェットの内枠(コンテンツ外枠)を設定
4833 // ウィジェットの内枠はレンダーで設定
4834 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4835 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4836 // } else if (strStartsWith($position, 'user') || // ナビゲーションメニュー位置の場合
4837 } else if (strcasecmp($position, 'user3') == 0 || // ナビゲーションメニュー位置の場合
4838 strcasecmp($position, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
4839 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
4841 $moduleContent = '';
4842 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
4843 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4845 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
4846 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4848 $moduleContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4850 $widgetContent = $moduleContent;
4852 // ウィジェットの内枠(コンテンツ外枠)を設定。メニュー処理後に付加。
4853 // ウィジェットの内枠はレンダーで設定
4854 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4855 } else { // その他の位置のとき
4856 // ウィジェットの内枠(コンテンツ外枠)を設定
4857 // ウィジェットの内枠はレンダーで設定
4858 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4860 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4862 $isRendered = true; // Joomla!の描画処理を行ったかどうか
4865 if (!$isRendered){ // Joomla!の描画処理を行っていない場合
4867 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4869 // ウィジェットの内枠(コンテンツ外枠)を設定
4870 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4873 if (!$ret) return ''; // 処理中断のときは終了
4876 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4877 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4880 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4881 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4882 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4883 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4884 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4885 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4886 // ウィジェット表示タイプによる表示制御
4887 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4888 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
4889 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4890 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4891 if (!empty($controlType)){
4892 switch ($controlType){
4893 case 1: // ログイン時のみ表示
4894 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4895 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
4897 case 2: // 非ログイン時のみ表示
4898 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4899 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
4905 if (!empty($pageState)){
4906 switch ($pageState){
4908 if (!$this->isPageTopUrl){
4909 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4910 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
4918 //$editInfo = 'widgetid:' . $this->pageDefRows[$i]['wd_id'];
4919 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4920 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4921 $hasAdmin = '0'; // 管理画面があるかどうか
4922 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4923 $shared = '0'; // 共通属性があるかどうか
4924 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4925 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4926 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4927 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
4929 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4930 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4932 } else { // キャッシュデータがあるとき
4933 $widgetContent = $cacheData;
4936 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4937 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4938 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4940 $contents .= $widgetContent;
4942 // ##### 外部出力用のCSSがある場合は追加 #####
4943 $exportCss = $this->pageDefRows[$i]['pd_css'];
4944 if (!empty($exportCss)){
4946 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4947 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4948 $this->addExportCss($exportCss);
4953 if ($position == 'main'){ // メイン部のときは、メッセージを出力
4954 /*if (strlen($this->popupMsg) > 0){
4955 echo "\n<script language=\"javascript\">alert('" . addslashes($this->popupMsg) . "');</script>";
4957 } else if ($position == 'debug'){ // デバッグ文出力
4963 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:3px solid #f00;color:#700;">ポジション名: ';
4964 $contents .= '<b>' . $position . '</b>';
4965 $contents .= '</div>';
4968 if (!in_array($position, $this->defPositions)) $this->defPositions[] = $position; // テンプレート上のポジション
4970 case 2: // ポジション表示(ウィジェット付き)
4971 $rev = '555'; // データのリビジョン番号
4972 // ポジションのHTMLタグIDを作成
4975 for ($i = 0; $i < 100; $i++){
4976 $posId = $position . '_' . $num;
4977 $viewPosId = self::POSITION_TAG_HEAD . $posId;
4978 if (!in_array($viewPosId, $this->viewPosId)) break;
4981 $this->viewPosId[] = $viewPosId;// IDを保存
4983 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4984 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4985 $ret = $this->db->getPageDef($filename, $subId, $position, $rows);
4986 if ($ret){ // 1行以上データが取得できたとき
4987 $this->pageDefRows = $rows; // ページ定義レコード
4988 $this->pageDefPosition = $position;
4990 $this->pageDefRows = array();
4991 $this->pageDefPosition = '';
4995 // ナビゲーション型のポジションの場合はアイコン付加
4996 //if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4997 if ($style == self::WIDGET_STYLE_NAVMENU) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4998 $contents .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
4999 $contents .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
5002 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
5003 //$contents .= $this->getWidgetList($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $widgetTagHead, $this->pageDefRows);
5004 $contents .= $this->getWidgetList($filename, $subId, $widgetTagHead, $this->pageDefRows);
5006 $contents .= '</div>' . M3_NL;
5009 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">param error</div>';
5013 $this->viewPositions[] = $position;
5018 * 各部品のHTML出力(WordPressテンプレート専用)
5020 * @param string $position HTMLテンプレート上の書き出し位置
5021 * @param bool $showTitle タイトルを表示するかどうか
5022 * @return string 出力コンテンツ
5024 function getWPContents($position, $showTitle = true)
5027 return $this->getContents($position, self::WIDGET_STYLE_WORDPRESS/*WordPressテンプレート用出力*/, 100/*WordPressテンプレート*/);
5029 return $this->getContents($position, self::WIDGET_STYLE_WORDPRESS_NOTITLE/*WordPressテンプレート(タイトルなし)用出力*/, 100/*WordPressテンプレート*/);
5033 * その他のポジションブロックデータを取得
5035 * @param string ポジション作成用タグ
5037 function getRestPositionData()
5039 global $gEnvManager;
5041 $restPositionData = '';
5043 $pageId = $gEnvManager->getCurrentPageId();
5044 $subId = $gEnvManager->getCurrentPageSubId();
5046 $restPositions = array_values(array_diff($this->defPositions/*全ポジション*/, $this->viewPositions/*表示済みポジション*/));
5047 $positionCount = count($restPositions);
5048 for ($i = 0; $i < $positionCount; $i++){
5049 $posHead = ''; // アイコン付加用
5050 $position = $restPositions[$i];
5051 $posId = $position . '_0';
5052 $viewPosId = self::POSITION_TAG_HEAD . $posId;
5055 $ret = $this->db->getPageDef($pageId, $subId, $position, $rows);
5057 //$pageDefRows = $rows; // ページ定義レコード
5059 $restPositionData .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">'; // リビジョン番号を付加
5060 $restPositionData .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>';
5063 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
5064 $contents = $this->getWidgetList($pageId, $subId, $widgetTagHead, $rows);
5065 $contents = str_replace(M3_NL, '', $contents);
5066 $contents = str_replace('\'', '\\\'', $contents);
5067 $restPositionData .= $contents;
5068 $restPositionData .= '</div>';
5070 $this->viewPosId[] = $viewPosId;// IDを保存
5073 return $restPositionData;
5076 * ウィジェット共通のコンテンツ追加処理
5078 * @param string $src ウィジェット出力
5079 * @param array $pageDefParam 画面定義レコード
5080 * @return string コンテンツを付加したウィジェット出力
5082 function _addOptionContent($src, $pageDefParam)
5085 $dest = $pageDefParam['pd_top_content'] . $src . $pageDefParam['pd_bottom_content'];
5088 if ($pageDefParam['pd_show_readmore']){
5089 $title = $pageDefParam['pd_readmore_title'];
5090 if (empty($title)) $title = self::DEFAULT_READMORE_TITLE;
5091 $dest .= '<div><a href="' . convertUrlToHtmlEntity($pageDefParam['pd_readmore_url']) . '">' . convertToHtmlEntity($title) . '</a></div>';
5096 * BODYタグに付加するスタイルを取得(管理画面用)
5098 * @param string CSS文字列
5100 function getBodyStyle()
5102 // 画面透過モードのときスタイルを追加
5104 if ($this->isTransparentMode) $transCss = ' style="background-color:transparent;"';
5110 * @param string $position HTMLテンプレート上の書き出し位置
5111 * @return int ウィジェットの数
5113 function getWidgetsCount($position)
5115 global $gRequestManager;
5116 global $gEnvManager;
5117 static $widgetCountArray = array();
5119 // 管理画面へのアクセスでログインされていないときは0を返す
5120 if ($gEnvManager->isAdminDirAccess() && !$gEnvManager->isSystemManageUser()){ // 管理画面へのアクセスのときでシステム運用権限がない場合
5125 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
5126 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 管理画面(ウィジェットなしポジション表示)のとき
5127 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
5128 return 1; // ウィジェットが設定されていないポジション名を表示するために固定で値を返す
5131 // 単一ポジション以外の設定のときは固定で返す(or等)
5132 $pos = strpos($position, ' ');
5133 if ($pos !== false) return 1;
5135 // 既にウィジェット数が取得されている場合は保存値を返す
5136 $widgetCount = $widgetCountArray[$position];
5137 if (isset($widgetCount)) return $widgetCount;
5140 $filename = $gEnvManager->getCurrentPageId();
5141 $subId = $gEnvManager->getCurrentPageSubId();
5142 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
5144 // 取得しようとするページ定義のポジションが既に取得しているポジションと異なるときはデータを取得
5145 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // 現在取得しているページ定義のポジション
5146 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
5147 if ($ret){ // 1行以上データが取得できたとき
5148 $this->pageDefRows = $rows; // ページ定義レコード
5149 $this->pageDefPosition = $position;
5151 $this->pageDefRows = array();
5152 $this->pageDefPosition = '';
5155 // ### ウィジェット数を取得 ###
5156 // テンプレートのカラム制御を行うためにウィジェット表示条件でウィジェット数を取得
5158 $rowCount = count($this->pageDefRows);
5159 for ($i = 0; $i < $rowCount; $i++){
5160 // $condition = trim($this->pageDefRows[$i]['wd_visible_condition']);
5161 $condition = trim($this->pageDefRows[$i]['pd_visible_condition']);
5162 if (empty($condition)){ // ウィジェット表示条件が設定されていない場合はウィジェットを表示
5164 } else { // ウィジェット表示条件が設定されている場合はパラメータをチェック
5165 $conds = explode(';', $condition);
5166 for ($j = 0; $j < count($conds); $j++){
5167 $pos = strpos($conds[$j], '=');
5168 if ($pos !== false){ // URLクエリーパラメータ条件がマッチした場合はウィジェットを表示
5169 list($key, $value) = explode('=', trim($conds[$j]));
5171 $value = trim($value);
5172 if (!empty($key) && !empty($value)){
5173 $requestValue = $gRequestManager->trimValueOf($key);
5174 if ($value == $requestValue) $widgetCount++;
5180 // $widgetCount = count($this->pageDefRows);
5181 $widgetCountArray[$position] = $widgetCount;
5182 return $widgetCount;
5185 * ウィジェットのページ定義シリアル番号からウィジェットCSS IDを取得
5187 * @param int $defSerial ページ定義シリアル番号
5188 * @param string $pageId ページID
5189 * @param string $subpage ページサブID
5190 * @param string $position 表示位置ID
5191 * @return string CSSエレメントID
5193 function getWidgetCssId($defSerial, $pageId, $pageSubId, $position)
5196 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
5198 $rowCount = count($rows);
5199 for ($i = 0; $i < $rowCount; $i++){
5201 if ($row['pd_serial'] == $defSerial){
5202 $elementId = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
5212 * 画面作成機能でウィジェット情報を取得するためのAjaxインターフェイス
5214 * @param RequestManager $request HTTPリクエスト処理クラス
5216 function getWidgetInfoByAjax($request)
5218 global $gEnvManager;
5219 global $gDesignManager;
5220 global $gCacheManager;
5222 // アクセスするページIDからPC用、携帯用、スマートフォン用かを判断
5223 $widgetDeviceType = 0; // 端末タイプをPC用に初期化
5224 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
5225 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
5226 $mobilePageIdPrefix = M3_DIR_NAME_MOBILE . '_';
5227 $smartphonePageIdPrefix = M3_DIR_NAME_SMARTPHONE . '_';
5228 if (strncmp($pageId, $mobilePageIdPrefix, strlen($mobilePageIdPrefix)) == 0){
5229 $widgetDeviceType = 1; // 携帯用
5230 } else if (strncmp($pageId, $smartphonePageIdPrefix, strlen($smartphonePageIdPrefix)) == 0){
5231 $widgetDeviceType = 2; // スマートフォン用
5234 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
5235 if ($task == 'list'){
5237 $ret = $this->db->getAvailableWidgetList($widgetDeviceType, $rows);
5239 $currentCategoryId = '_none'; // 現在のウィジェットカテゴリー初期化
5240 for ($i = 0; $i < count($rows); $i++){
5241 $widgetId = $rows[$i]['wd_id'];
5242 $desc = $rows[$i]['wd_description'];
5243 $widgetTag = self::WIDGET_TYPE_TAG_HEAD . $widgetId;
5244 $categoryId = $rows[$i]['wd_category_id'];
5247 if ($categoryId != $currentCategoryId){
5249 echo '</dd>' . M3_NL;
5250 echo '</dl>' . M3_NL;
5252 echo '<dl class="m3accordion">' . M3_NL;
5253 echo '<dt>' . $rows[$i]['wt_name'] . '</dt>' . M3_NL;
5254 echo '<dd>' . M3_NL;
5257 $currentCategoryId = $categoryId;
5260 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
5261 if ($gEnvManager->getUseSslAdmin()){
5262 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
5263 $image = $gEnvManager->getSslUrl($image);
5265 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
5266 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
5267 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
5272 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5273 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5277 if (!empty($rows[$i]['wd_template_type'])){ // 対応テンプレートタイプ
5278 $templateTypeArray = explode(',', $rows[$i]['wd_template_type']);
5279 if (in_array('bootstrap', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_BOOTSTRAP; // Bootstrap型テンプレート対応
5280 if (in_array('wordpress', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_WORDPRESS; // WordPress型テンプレート対応
5282 if (!empty($functionMark)) $functionMark = '<hr />' . $functionMark;
5284 echo '<dl class="m3_widgetlist_item" id="' . $widgetTag . '">' . M3_NL;
5285 echo '<dt>' . $widgetMark . $rows[$i]['wd_name'] . '</dt>' . M3_NL; // ウィジェット名
5286 echo '<dd><table style="width:100%;"><tr style="vertical-align:top;"><td style="width:35px;">' . $imageTag . '</td><td>' . $desc . '</td></tr></table>';
5287 echo $functionMark . '</dd>' . M3_NL;
5288 echo '</dl>' . M3_NL;
5291 if ($i == count($rows) - 1){
5292 echo '</dd>' . M3_NL;
5293 echo '</dl>' . M3_NL;
5297 } else if ($task == 'wget' || $task == 'wdelete' || $task == 'wtoggle' || $task == 'wadd' || $task == 'wmove'){ // ウィジェット再取得、ウィジェット削除,ウィジェット共通属性変更、ウィジェット追加、ウィジェット移動のとき
5298 $rev = $request->trimValueOf('rev'); // リビジョン
5299 $serial = $request->trimValueOf('serial');
5300 $position = $request->trimValueOf('pos');
5301 $widgetsStr = $request->trimValueOf('widgets');
5302 if (empty($widgetsStr)){
5305 $widgets = explode(',', $widgetsStr);
5307 $shared = $request->trimValueOf('shared');
5308 $updatepos = explode(',', $request->trimValueOf('updatepos'));
5309 $index = $request->trimValueOf('index');
5312 if ($task == 'wmove'){
5313 $positions = explode(',', $position);
5314 if (count($positions) >= 2){
5315 $position = $positions[0];
5316 $position2 = $positions[1];
5318 $position = $positions[0];
5322 // ##### エラーチェック #####
5325 $rev = '111'; // データのリビジョン番号
5328 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows); // 0レコードでも正常とする
5330 // 変更前のウィジェットのシリアル番号をチェック
5331 if (count($widgets) == count($rows)){
5332 if (!($task == 'wmove' && empty($position2))){ // 同一ブロック内の移動の場合はチェックなし
5333 for ($i = 0; $i < count($rows); $i++){
5334 if ($widgets[$i] != $rows[$i]['pd_serial']){// シリアル番号
5345 if (!$isErr){ // エラーなしのとき
5346 if ($task == 'wdelete'){
5347 $ret = $this->db->deleteWidget($serial);
5348 } else if ($task == 'wtoggle'){
5350 if (empty($shared)) $newShared = 1;
5351 $ret = $this->db->toggleSharedWidget($pageId, $pageSubId, $serial, $newShared);
5352 } else if ($task == 'wadd'){ // ウィジェットの追加
5353 $widget = $request->trimValueOf('widget');
5356 if (empty($widget)) $isErr = true;
5359 if (!$isErr) $this->db->addWidget($pageId, $pageSubId, $position, $widget, $index);
5360 } else if ($task == 'wmove'){
5362 if (!$isErr) $this->db->moveWidget($pageId, $pageSubId, $position, $serial, $index);
5366 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows);// 0レコードでも正常とする
5368 // 移動のときは、移動元と移動先の再表示データを取得
5369 if ($task == 'wmove' && !empty($position2)){
5370 $ret = $this->db->getPageDef($pageId, $pageSubId, $position2, $rows2);// 0レコードでも正常とする
5375 echo '<div>' . M3_NL;
5376 for ($i = 0; $i < count($updatepos); $i++){
5378 $widgetTagHead = str_replace(self::POSITION_TAG_HEAD, self::WIDGET_TAG_HEAD, $updatepos[$i]);
5381 $posName = str_replace(self::POSITION_TAG_HEAD, '', substr($updatepos[$i], 0, strlen($updatepos[$i]) - strlen(strrchr($updatepos[$i], "_"))));
5382 if ($task == 'wmove' && $posName == $position2){
5385 if (strcasecmp($position2, 'user3') == 0 || strcasecmp($position2, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5386 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position2 . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5387 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position2 . '</h2>' . M3_NL;
5390 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows2);
5394 if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5395 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5396 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
5399 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows);
5402 echo '</div>' . M3_NL;
5404 echo '</div>' . M3_NL;
5407 $gCacheManager->clearAllCache();
5411 * 画面作成用ウィジェット一覧データ出力
5413 * @param string $pageId ページID
5414 * @param string $pageSubId ページサブID
5415 * @param string $widgetTagHead HTMLウィジェットID用のヘッダ
5416 * @param array $rows ウィジェット一覧データ
5417 * @return string ウィジェット一覧出力
5419 function getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows)
5421 global $gEnvManager;
5422 global $gDesignManager;
5423 global $gSystemManager;
5425 if ($gEnvManager->getUseSslAdmin()){
5426 $rootUrl = $gEnvManager->getSslRootUrl();
5428 $rootUrl = $gEnvManager->getRootUrl();
5432 $line = $this->getPageInfo($pageId, $pageSubId);
5433 if (!empty($line)) $pageContentType = $line['pn_content_type'];
5435 $contents = ''; // ウィジェット一覧出力コンテンツ
5436 for ($i = 0; $i < count($rows); $i++){
5437 $widgetId = $rows[$i]['wd_id'];
5438 $desc = $rows[$i]['wd_description'];
5439 $widgetIndex = $rows[$i]['pd_index']; // 表示順
5440 $configId = $rows[$i]['pd_config_id']; // 定義ID
5441 $serial = $rows[$i]['pd_serial']; // シリアル番号
5442 $isShared = empty($rows[$i]['pd_sub_id']); // グローバル属性が設定されているかどうか
5443 $widgetTag = $widgetTagHead . '_' . $i; // ウィジェット識別用ユニークタグ
5444 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
5445 if ($gEnvManager->getUseSslAdmin()){
5446 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
5447 $image = $gEnvManager->getSslUrl($image);
5449 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
5450 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
5451 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
5454 if (empty($rows[$i]['pd_config_name'])){
5455 if ($rows[$i]['wd_use_instance_def'] && $configId == 0){ // インスタンス定義が必要で未定義のとき
5456 $configName = '<span style="color:red;">[未設定]</span>';
5461 $configName = '[' . $rows[$i]['pd_config_name'] . ']';
5463 $hasAdmin = '0'; // 管理画面があるかどうか
5464 $configImg = ''; // 設定アイコンの表示
5466 // ウィジェットの配置位置に問題があるかどうかを表示
5467 // メインコンテンツとページ属性が一致するかどうかチェック
5468 $widgetContentType = $rows[$i]['wd_content_type'];
5469 //if (!empty($widgetContentType) && $widgetContentType != $pageContentType &&
5470 if (!empty($widgetContentType) && $widgetContentType != $pageContentType && empty($rows[$i]['wd_content_widget_id']) && // 編集用のウィジェットが別にある場合は除く(2015/3/24))
5471 (in_array($widgetContentType, $this->_getAllContentType()) || in_array($widgetContentType, $this->_getAllFeatureType()))){
5472 //$title = 'ウィジェット配置注意';
5473 $title = 'ページ属性と不一致';
5474 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::NOTICE_ICON_FILE . '" alt="' . $title . '" /></span> ';
5476 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type']) && $isShared){ // メイン型ウィジェットがグローバル属性を持つとき
5477 $title = 'メイン型ウィジェットはグローバル属性を設定できません';
5478 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::ALERT_ICON_FILE . '" alt="' . $title . '" /></span> ';
5480 if ($rows[$i]['wd_has_admin']){
5482 $title = 'ウィジェット設定';
5483 $configImg .= '<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\'' . $widgetId . '\', \'' . $configId . '\', \'' . $serial . '\');return false;" rel="m3help" data-container="body" title="' . $title . '">' .
5484 '<img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" alt="' . $title . '"/></a> ';
5487 $configImg .= '<span rel="m3help" data-container="body" title="表示順">' . $widgetIndex . '</span>';
5489 $shared = '0'; // 共通属性があるかどうか
5490 $sharedClassName = '';
5491 //if (empty($rows[$i]['pd_sub_id'])){
5492 if ($isShared){ // グローバル属性ウィジェットのとき
5494 $sharedClassName = 'm3_widget_shared'; // 共通ウィジェットのクラス
5496 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
5500 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5501 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5504 $dropdownMenuId = $widgetTag . '_dropdown';
5505 $operationMenu = '<div class="m3widgetdropdown">';
5506 // $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#"><i class="glyphicon glyphicon-list-alt"></i> <b class="caret"></b></a>';
5507 $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#" data-horizontal-offset="4"><b class="caret"></b></a>';
5508 $operationMenu .= '<div id="' . $dropdownMenuId . '" class="m3dropdown m3dropdown-tip m3dropdown-relative m3dropdown-anchor-right">';
5509 $operationMenu .= '<ul class="m3dropdown-menu">';
5510 if ($hasAdmin) $operationMenu .= '<li class="m3_wconfig"><a href="#"><img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" /> <span>ウィジェットの設定</span></a></li>';
5511 $operationMenu .= '<li class="m3_wadjust"><a href="#"><img src="' . $rootUrl . self::ADJUST_ICON_FILE . '" /> <span>タイトル・スタイル調整</span></a></li>';
5513 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を解除</span></a></li>';
5515 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を設定</span></a></li>';
5517 $operationMenu .= '<li class="m3_wdelete"><a href="#"><img src="' . $rootUrl . self::DELETE_ICON_FILE . '" /> <span>このウィジェットを削除</span></a></li>';
5518 $operationMenu .= '</ul>';
5519 $operationMenu .= '</div>';
5520 $operationMenu .= '</div>';
5522 $contents .= '<dl class="m3_widget m3_widget_sortable" id="' . $widgetTag . '" ' . $m3Option . ' >' . M3_NL;
5523 $contents .= '<dt class="m3_widget_with_check_box ' . $sharedClassName . '"><div class="m3widgettitle">' . $widgetMark . $rows[$i]['wd_name'] . '</div>' . $operationMenu . '</dt>' . M3_NL;
5524 $contents .= '<dd><table style="width:100%;"><tr style="vertical-align:top;"><td style="width:35px;">' . $imageTag . '</td><td>' . $desc . '</td></tr></table><hr />' . M3_NL;
5525 $contents .= '<table style="width:100%;"><tr><td>' . $configName . '</td><td style="text-align:right;">' . $configImg . '</td></tr></table></dd>' . M3_NL;
5526 $contents .= '</dl>' . M3_NL;
5533 * @param string $position HTMLテンプレート上の書き出し位置
5534 * @param int $index 行番号
5535 * @param array $fetchedRow fetch取得した行
5536 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
5537 * @param string $titleTag タイトル埋め込み用タグ(遅延ウィジェットの場合のみ作成)
5538 * @param int $widgetHeaderType ウィジェットタイトルを出力方法(0=出力なし、1=Joomla!v1.0PC用出力、2=Joomla!v1.0携帯用出力)
5539 * @return bool 処理を継続するかどうか(true=続行、false=中断)
5541 function pageDefLoop($position, $index, $fetchedRow, $style, &$titleTag, $widgetHeaderType = 0)
5543 global $gEnvManager;
5544 global $gErrorManager;
5545 global $gDesignManager;
5547 // ページ作成中断またはウィジェット処理中断のときは終了
5548 if ($this->isAbort || $this->isWidgetAbort) return false;
5550 // ウィジェット実行停止中のときは空で返す
5551 // 管理者、運営者どのレベルで制限をかける?
5552 if (!$fetchedRow['wd_active']) return true;
5554 // グローバル属性ありの場合は現在のページが例外ページにないかチェック
5555 if (empty($fetchedRow['pd_sub_id'])){
5556 $exceptPageStr = $fetchedRow['pd_except_sub_id'];
5557 if (!empty($exceptPageStr)){
5558 $exceptPageArray = explode(',', $exceptPageStr);
5559 if (in_array($gEnvManager->getCurrentPageSubId(), $exceptPageArray)) return true; // 例外ページの場合は出力しない
5563 // ウィジェット表示タイプによる表示制御。システム管理者以上の場合は常時表示。
5564 if (!$gEnvManager->isSystemAdmin()){
5565 if (!empty($fetchedRow['pd_view_control_type'])){
5566 switch ($fetchedRow['pd_view_control_type']){
5567 case 1: // ログイン時のみ表示
5568 if (!$gEnvManager->isCurrentUserLogined()) return true; // ログインしていなければ終了
5570 case 2: // 非ログイン時のみ表示
5571 if ($gEnvManager->isCurrentUserLogined()) return true; // ログインしていれば終了
5577 if (!empty($fetchedRow['pd_view_page_state'])){
5578 switch ($fetchedRow['pd_view_page_state']){
5580 if (!$this->isPageTopUrl) return true; // ページトップ(サブページ内のトップ位置)でなければ終了
5592 $widgetId = $fetchedRow['wd_id'];
5593 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5596 $configId = $fetchedRow['pd_config_id']; // ウィジェット定義ID
5597 if ($configId == 0) $configId = '';
5598 $prefix = $fetchedRow['wd_suffix']; // サフィックス文字列
5599 $title = $fetchedRow['wd_name']; // デフォルトのウィジェットタイトル
5600 if (empty($title)) $title = $fetchedRow['wd_id'];
5601 $widgetHeadTitle = $fetchedRow['pd_title']; // ウィジェットのヘッドタイトル
5602 if (empty($widgetHeadTitle)) $widgetHeadTitle = $title; // ウィジェットのヘッドタイトルが空の場合はウィジェットタイトルを取得
5603 $serial = $fetchedRow['pd_serial']; // シリアル番号
5604 $cssStyle = $fetchedRow['pd_style']; // CSS
5605 $lateLaunchIndex = $fetchedRow['wd_launch_index']; // 遅延実行インデックス
5607 if (empty($fetchedRow['pd_sub_id'])) $shared = true;// 共通属性あり
5608 if ($this->nonSharedWidgetCount == -1) $this->nonSharedWidgetCount = 0; // 初期化されていない場合は初期化
5609 if (!$shared) $this->nonSharedWidgetCount++; // 非共通ウィジェットの数を更新
5611 // ウィジェットが遅延実行に指定されている場合は、ウィジェットのタグのみ埋め込む
5612 if ($lateLaunchIndex > 0){ // 遅延実行のとき
5614 if (!isset($this->lateLaunchWidgetList[$widgetId])){
5615 $this->lateLaunchWidgetList[$widgetId] = (int)$lateLaunchIndex;
5618 $maxNo = 0; // 最大シリアル番号
5619 $count = count($this->latelaunchWidgetParam);
5620 for ($i = 0; $i < $count; $i++){
5621 list($wId, $maxNo, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5, $tmp6, $tmp7, $tmp8, $tmp9, $tmp10, $tmp11) = $this->latelaunchWidgetParam[$i];
5622 if ($wId == $widgetId) $maxNo = $maxNo + 1;
5624 // Joomla!1.0テンプレートの場合はタイトルを修正
5625 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5626 if (!empty($fetchedRow['pd_title'])) $title = $fetchedRow['pd_title'];
5628 $this->latelaunchWidgetParam[] = array($widgetId, $maxNo, $configId, $prefix, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $fetchedRow);
5631 echo self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
5634 $titleTag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
5637 if (!file_exists($widgetIndexFile)) {
5638 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5641 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
5642 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
5643 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
5644 $this->lastHeadTitle = ''; // ヘッダ部titleにセットした文字列
5645 $this->lastHeadDescription = ''; // ヘッダ部descriptionにセットした文字列
5646 $this->lastHeadKeywords = ''; // ヘッダ部keywordsにセットした文字列
5649 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
5650 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
5652 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
5653 $joomlaTitleVisble = false;
5654 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5655 if ($fetchedRow['pd_title_visible']){
5656 if ($widgetHeaderType == 1){ // PC用出力のとき
5657 $joomlaTitle = $fetchedRow['pd_title'];
5658 if (empty($joomlaTitle)) $joomlaTitle = $title;
5659 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
5660 echo '<tr><th>' . $joomlaTitle . '</th></tr>' . M3_NL;
5661 echo '<tr><td>' . M3_NL;
5662 $joomlaTitleVisble = true;
5663 } else if ($widgetHeaderType == 2){ // 携帯用出力のとき
5664 $joomlaTitle = $fetchedRow['pd_title'];
5665 if (empty($joomlaTitle)) $joomlaTitle = $title;
5666 echo '<div>' . $joomlaTitle . '</div>' . M3_NL;
5667 $joomlaTitleVisble = true;
5672 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
5673 // ウィジェット親のCSS定義があるときは、タグを追加
5674 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
5677 echo $gDesignManager->getAdditionalWidgetOutput(true);
5680 $gEnvManager->setCurrentWidgetId($widgetId);
5683 $gEnvManager->setCurrentWidgetConfigId($configId);
5686 $gEnvManager->setCurrentPageDefSerial($fetchedRow['pd_serial']);
5689 $gEnvManager->setCurrentPageDefRec($fetchedRow);
5692 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5694 // ウィジェットのヘッドタイトルを設定
5695 $gEnvManager->setCurrentWidgetHeadTitle($widgetHeadTitle);
5698 $gEnvManager->setCurrentWidgetTitle($title);
5701 $gEnvManager->setCurrentWidgetStyle($style);
5703 // ウィジェットのグローバル属性状況を設定
5704 $gEnvManager->setIsCurrentWidgetShared($shared);
5707 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5710 //require_once($widgetIndexFile);
5711 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5712 $msg = 'widget-start(' . $widgetId . ')';
5713 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5714 require($widgetIndexFile);
5715 $msg = 'widget-end(' . $widgetId . ')';
5716 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5719 $gEnvManager->setCurrentWidgetId('');
5722 $gEnvManager->setCurrentWidgetConfigId('');
5725 $gEnvManager->setCurrentPageDefSerial(0);
5728 $gEnvManager->setCurrentPageDefRec();
5731 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
5734 $gEnvManager->setCurrentWidgetStyle('');
5736 // ウィジェットのグローバル属性状況を解除
5737 $gEnvManager->setIsCurrentWidgetShared(false);
5740 echo $gDesignManager->getAdditionalWidgetOutput(false);
5741 // echo "<!-- ".time()." -->";
5743 // ウィジェット親のCSS定義があるときは、タグを追加
5744 if (!empty($cssStyle)) echo '</div>' . M3_NL;
5746 //echo '</div>' . M3_NL;
5748 // Joomla!1.0テンプレートのときはタイトルを出力
5749 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用出力のとき
5750 echo '</td></tr>' . M3_NL;
5751 echo '</table>' . M3_NL;
5755 return true; // 処理継続
5758 * 定義IDを指定してウィジェットの出力を取得
5760 * @param string $widgetId ウィジェットID
5761 * @param int $configId ウィジェット定義ID
5762 * @return string ウィジェットの出力
5764 function getWidgetOutput($widgetId, $configId = 0)
5766 global $gEnvManager;
5767 global $gErrorManager;
5769 // ウィジェットのアクセス権をチェック
5770 if (!$this->db->canAccessWidget($widgetId)) return '';
5773 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
5776 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
5778 // 必要なJavascriptライブラリを追加
5779 $scritLib = trim($row['wd_add_script_lib']);
5780 if (!empty($scritLib)) $this->addScript('', $scritLib);
5786 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5789 $saveWidgetId = $gEnvManager->getCurrentWidgetId();
5790 $gEnvManager->setCurrentWidgetId($widgetId);
5793 $saveConfigId = $gEnvManager->getCurrentWidgetConfigId();
5794 $gEnvManager->setCurrentWidgetConfigId($configId);
5797 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
5800 //$gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5803 //$gEnvManager->setCurrentWidgetTitle($title);
5805 // ウィジェットのグローバル属性状況を設定
5806 //$gEnvManager->setIsCurrentWidgetShared($shared);
5809 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5812 //require_once($widgetIndexFile);
5813 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5814 $msg = 'widget-start(' . $widgetId . ')';
5815 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5816 if (file_exists($widgetIndexFile)){
5817 require($widgetIndexFile);
5819 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5821 $msg = 'widget-end(' . $widgetId . ')';
5822 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5825 $gEnvManager->setCurrentWidgetId($saveWidgetId);
5828 $gEnvManager->setCurrentWidgetConfigId($saveConfigId);
5831 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
5834 //$gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
5836 // ウィジェットのグローバル属性状況を解除
5837 //$gEnvManager->setIsCurrentWidgetShared(false);
5839 // 現在のバッファ内容を取得し、バッファを破棄
5840 $output = ob_get_contents();
5848 * @param int $cmdNo 実行コマンド(0=初期化、1=更新、2=計算、10=コンテンツ取得)
5849 * @param string $id ウィジェットID+インナーウィジェットID
5850 * @param string $configId インナーウィジェット定義ID
5851 * @param object $paramObj インナーウィジェットに渡すパラメータオブジェクト
5852 * @param object $optionParamObj インナーウィジェットに渡すパラメータオブジェクト(オプション)
5853 * @param object $resultObj インナーウィジェットから返る結果オブジェクト
5854 * @param string $content 出力内容
5855 * @param bool $isAdmin 管理者機能(adminディレクトリ以下)かどうか
5856 * @return bool true=成功、false=失敗
5858 function commandIWidget($cmdNo, $id, $configId, &$paramObj, &$optionParamObj, &$resultObj, &$content, $isAdmin = false)
5860 global $gEnvManager;
5862 // ウィジェットIDとインナーウィジェットIDを取り出す
5863 list($widgetId, $iWidgetId) = explode(M3_WIDGET_ID_SEPARATOR, $id);
5865 // インナーウィジェットに渡すパラメータを設定
5868 $cmd = self::IWIDTET_CMD_INIT; // 初期化
5869 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5872 $cmd = self::IWIDTET_CMD_UPDATE; // 更新
5873 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
5876 $cmd = self::IWIDTET_CMD_CALC; // 計算
5877 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5880 $cmd = self::IWIDTET_CMD_CONTENT; // コンテンツ取得
5881 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
5885 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5889 // インナーウィジェットのエラー出力は呼び出しウィジェット側で受けるため、出力を抑止する
5890 ob_start();// バッファ作成
5893 if (empty($widgetId)){ // ウィジェットIDが指定されていないときは共通ディレクトリ
5894 //$gEnvManager->getIWidgetsPath() . '/' . $iWidgetId . '/' . $containerClass . '.php';
5897 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/' . M3_DIR_NAME_ADMIN . '/index.php';
5899 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/index.php';
5903 // 作業中のインナーウィジェットIDを設定
5904 $gEnvManager->setCurrentIWidgetId($id); // インナーウィジェットを設定
5906 // インナーウィジェット定義IDを設定
5907 $gEnvManager->setCurrentIWidgetConfigId($configId);
5910 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5911 if (file_exists($widgetIndexFile)){
5912 require($widgetIndexFile);
5914 echo 'file not found error: ' . $widgetIndexFile;
5918 $gEnvManager->setCurrentIWidgetId('');
5920 // インナーウィジェット定義IDを解除
5921 $gEnvManager->setCurrentIWidgetConfigId('');
5923 // 現在のバッファ内容を取得し、バッファを破棄
5924 $content = ob_get_contents();
5928 if ($this->gInstance->getCmdParamManager()->getParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $obj, $option)){
5930 $optionParamObj = $option;
5934 if ($this->gInstance->getCmdParamManager()->getResult($id . M3_WIDGET_ID_SEPARATOR . $configId, $resObj)) $resultObj = $resObj;
5938 * コールバックメソッドを実行し、出力を返す
5940 * @param array $callback 実行するコールバック
5941 * @return string 出力結果
5943 function getOutputByCallbackMethod($callback)
5945 ob_start();// バッファ作成
5948 if (is_callable($callback)) call_user_func($callback);
5950 // 現在のバッファ内容を取得し、バッファを破棄
5951 $content = ob_get_contents();
5956 * ページ作成処理中断を行った場合のレスポンスヘッダ設定
5958 * @param int $responseCode レスポンスコード
5961 function setResponse($responseCode)
5963 switch ($responseCode){
5964 case 403: // アクセス禁止のとき
5965 header('HTTP/1.1 403 Forbidden');
5966 header('Status: 403 Forbidden');
5968 case 404: // 存在しないページのとき
5969 header("HTTP/1.1 404 Not Found");
5970 header("Status: 404 Not Found");
5972 case 500: // サーバ内部エラー
5973 header('HTTP/1.1 500 Internal Server Error');
5974 header('Status: 500 Internal Server Error');
5976 case 503: // サイト非公開(システムメンテナンス)
5977 header('HTTP/1.1 503 Service Temporarily Unavailable');
5978 header('Status: 503 Service Temporarily Unavailable');
5985 * @param string $filePath ダウンロードするファイルのファイルパス
5986 * @param string $downloadFilename ダウンロード時のファイル名
5987 * @param bool $deleteFile 実行後ファイルを削除するかどうか(成功失敗に関係なく)
5988 * @return bool true=成功、false=失敗
5990 function downloadFile($filePath, $downloadFilename, $deleteFile=false)
5993 if (!file_exists($filePath)) return false;
5996 $fileSize = filesize($filePath);
5998 // バッファ内容が残っているときは破棄
5999 if (ob_get_level() > 0) ob_end_clean();
6001 header('Cache-Control: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
6002 header('Pragma: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
6003 header('Content-Disposition: attachment; filename=' . $downloadFilename);
6004 header('Content-Length: ' . $fileSize);
6005 header('Content-Type: application/octet-stream; name=' . $downloadFilename);
6006 $fp = fopen($filePath, "r");
6007 echo fread($fp, $fileSize);
6013 if ($deleteFile) unlink($filePath);
6017 * システム制御ページを表示するかどうかを返す
6019 * @return bool true=システム制御ページを表示、false=システム制御ページを表示しない
6021 function isSystemPage()
6023 return $this->isSystemPage;
6028 * @param string $url 遷移先URL。未指定の場合は現在のスクリプト。URLでないときは、現在のスクリプトに付加。
6029 * @param bool $noMessage 画面を遷移させたとき、ドコモ携帯端末でダイアログ(サイトが移動しました(301))が出ないようにするオプション
6030 * @param int $responseCode レスポンスコード
6031 * @param bool $autoSsl リダイレクト先のページの状態に合わせてSSLを制御するかどうか
6034 function redirect($url = '', $noMessage = false, $responseCode = 0, $autoSsl = true)
6036 global $gEnvManager;
6038 // すでにリダイレクトが設定されている場合は終了
6039 if ($this->isRedirect) return; // リダイレクトするかどうか
6043 $toUrl = $gEnvManager->getCurrentScriptUrl();
6044 } else if (strncmp($toUrl, 'http://', 7) != 0 && strncmp($toUrl, 'https://', 8) != 0){ // URL以外のときはクエリー文字列と判断する
6045 $toUrl = $gEnvManager->getCurrentScriptUrl() . $toUrl;
6048 // SSL化が必要な場合はhttpsに変更
6051 if ($gEnvManager->isAdminUrlAccess($toUrl)){ // 管理画面へのアクセスのとき
6053 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
6054 } else { // フロント画面へのアクセスのとき
6056 $paramArray = array();
6057 //list($filename, $query) = explode('?', basename($toUrl));
6058 list($url, $query) = explode('?', $toUrl);
6059 $baseUrl = dirname($url);
6060 $filename = basename($url);
6061 if (empty($filename)) $filename = M3_FILENAME_INDEX;
6062 if (!empty($query)) parse_str($query, $paramArray); // クエリーの解析
6065 $pageId = basename($filename, '.php');
6066 $pageSubId = $paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID];
6069 $isSslPage = $this->isSslPage($pageId, $pageSubId);
6072 if ($this->gSystem->hierarchicalPage() && $filename == M3_FILENAME_INDEX){
6073 $toUrl = $baseUrl . '/' . $pageSubId . '/';
6074 unset($paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID]);
6076 $paramStr = $this->_createUrlParamStr($paramArray);
6077 if (!empty($paramStr)) $toUrl .= '?' . $paramStr;
6081 //$toUrl = str_replace('http://', 'https://', $toUrl);
6082 $toUrl = $gEnvManager->getSslUrl($toUrl); // SSL用URLに変換
6084 $toUrl = str_replace('https://', 'http://', $toUrl);
6088 // バッファ内容が残っているときは破棄
6089 if (ob_get_level() > 0) ob_end_clean();
6091 if (empty($responseCode)){
6093 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
6095 header('HTTP/1.1 301 Moved Permanently');
6097 } else { // レスポンスコードが指定されている場合
6098 switch ($responseCode){
6100 header('HTTP/1.1 301 Moved Permanently');
6103 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
6106 header('HTTP/1.1 303 See Other');
6108 case 500: // サーバ内部エラー
6109 header('HTTP/1.1 500 Internal Server Error');
6110 header('Status: 500 Internal Server Error');
6112 case 503: // サイト非公開(システムメンテナンス)
6113 header('HTTP/1.1 503 Service Temporarily Unavailable');
6114 header('Status: 503 Service Temporarily Unavailable');
6117 header('HTTP/1.1 ' . (string)$responseCode);
6121 header('Location: ' . $toUrl);
6123 $this->isRedirect = true; // リダイレクトするかどうか
6128 * @return bool true=リダイレクト、false=リダイレクトでない
6130 function isRedirect()
6132 return $this->isRedirect;
6135 * 指定URLのディレクトリへリダイレクト
6139 function redirectToDirectory()
6141 global $gEnvManager;
6144 $dirPath = dirname($gEnvManager->getCurrentScriptUrl()) . '/';
6145 //$this->redirect($dirPath);
6146 $this->redirect($dirPath, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/7/23)
6151 * @param string $url 遷移先URL
6154 function redirectInInstall($url)
6156 $this->redirect($url, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
6163 function redirectToInstall()
6165 global $gEnvManager;
6167 $sytemRootUrl = $gEnvManager->calcSystemRootUrl();
6168 //$this->redirect($sytemRootUrl . '/admin/install.php');
6169 $this->redirect($sytemRootUrl . '/admin/install.php', false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
6172 * ログイン、ログアウト処理を行った後、リダイレクト
6174 * @param RequestManager $request HTTPリクエスト処理クラス
6175 * @param bool $success ログインの成否
6176 * @param string $redirectUrl ログイン成功の場合のリダイレクト先
6177 * @return int 0=何も処理しなかった場合、1=ログイン処理、2=ログアウト処理、3=パスワード送信
6179 function standardLoginLogoutRedirect($request, &$success, $redirectUrl = '')
6181 global $gEnvManager;
6182 global $gAccessManager;
6183 global $gRequestManager;
6185 // ログイン、ログアウト処理、および、コンテナの起動
6186 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
6187 if ($cmd == M3_REQUEST_CMD_LOGIN){ // ログインの場合
6188 $act = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_ACT);
6189 if ($act == 'sendpwd'){ // パスワード送信の場合
6190 $success = $gAccessManager->sendPassword($request);
6194 $ret = $gAccessManager->userLogin($request);
6196 if (empty($redirectUrl)){
6197 // システム運用可能ユーザの場合でリダイレクト先が設定されていない場合はデフォルトの管理画面URLへ遷移
6198 $userInfo = $gEnvManager->getCurrentUserInfo();// ユーザ情報取得
6199 if ($userInfo->userType >= UserInfo::USER_TYPE_MANAGER){
6200 $ret = $this->db->getLoginUserRecordById($userInfo->userId, $userInfoRow);
6201 if ($ret && !empty($userInfoRow['lu_default_admin_url'])){
6202 $redirectUrl = $gEnvManager->getDefaultAdminUrl() . $userInfoRow['lu_default_admin_url'];
6208 $this->redirect($redirectUrl);
6209 $success = true; // ログイン成功
6210 } else { // ログイン失敗のとき
6211 $success = false; // ログイン失敗
6215 } else if ($cmd == M3_REQUEST_CMD_LOGOUT){ // ログアウト
6217 $gAccessManager->userLogout(true);
6220 $this->redirect($redirectUrl);
6229 * @param int $errStatus HTTPエラーステータスコード
6232 function showError($errStatus)
6235 $this->setResponse($errStatus);
6238 $msg = 'NOT DEFINED ERROR';
6239 switch ($errStatus){
6240 case 403: // アクセス禁止のとき
6243 case 404: // 存在しないページのとき
6246 case 500: // サーバ内部エラー
6247 $msg = 'Internal Server Error';
6249 case 503: // サイト非公開(システムメンテナンス)
6250 $msg = 'Service Temporarily Unavailable';
6254 echo '<!doctype html>';
6257 echo '<title>' . $msg . '</title>';
6260 echo '<h2>' . $msg . '</h2>';
6265 * ウィジェットがセットされているページサブIDを取得
6267 * @param string $pageId ページID
6268 * @param string $widgetId 対象ウィジェットID
6269 * @param int $configId ウィジェット定義ID
6270 * @return string ページサブID
6272 function getPageSubIdByWidget($pageId, $widgetId, $configId = 0)
6276 // 対象のウィジェットのページサブIDを取得
6277 $ret = $this->db->getSubPageId($widgetId, $pageId, $rows);
6278 if ($ret){// データが存在する
6279 for ($i = 0; $i < count($rows); $i++){
6280 if (!empty($rows[$i]['pd_sub_id']) && $rows[$i]['pd_config_id'] == $configId){
6281 $pageSubId = $rows[$i]['pd_sub_id'];
6289 * その他のGET,POSTパラメータからページサブID取得
6291 * @param RequestManager $request HTTPリクエスト処理クラス
6292 * @param string $redirectUrl リダイレクト用URL
6293 * @return string ページサブID
6295 function getPageSubIdByParam($request, &$redirectUrl)
6297 global $gEnvManager;
6301 $task = $request->trimValueOf('task');
6302 $option = $request->trimValueOf('option');
6303 if ($task == 'search' && $option == 'com_search'){ // joomla!の検索結果表示の場合
6304 $this->contentType = M3_VIEW_TYPE_SEARCH; // ページのコンテンツタイプ
6306 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_SEARCH, $gEnvManager->getCurrentPageId());// ページサブIDを取得
6307 if (!empty($subId)){
6309 $keyword = $request->trimValueOf('searchword');
6310 $redirectUrl = $gEnvManager->createPageUrl();
6311 $redirectUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subId;
6312 $redirectUrl .= '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=search&' . M3_REQUEST_PARAM_KEYWORD . '=' . urlencode($keyword);
6318 * コンテンツタイプとページIDからページサブID取得
6320 * @param string $contentType コンテンツタイプ
6321 * @param string $pageId ページID
6322 * @return string ページサブID
6324 function getPageSubIdByContentType($contentType, $pageId)
6326 $subId = $this->db->getSubPageIdWithContent($contentType, $pageId);// ページサブIDを取得
6330 * 指定のウィジェットがページ上にあるかを取得
6332 * @param string $pageId ページID
6333 * @param string $widgetId 対象ウィジェットID
6334 * @param bool $activePageOnly 公開中のページのウィジェットに制限するかどうか。falseの場合はすべてのページのウィジェットを対象とする。
6335 * @return bool true=ページ上にあり、false=ページ上になし
6337 function isWidgetOnPage($pageId, $widgetId, $activePageOnly=true)
6339 $ret = $this->db->isWidgetOnPage($pageId, $widgetId, $activePageOnly, 0/*定義セットID*/);
6343 * URLで示されるページ上のウィジェットをウィジェット種別で取得
6345 * @param string $url URL
6346 * @param string $widgetType 対象ウィジェットタイプ
6347 * @return string ウィジェットID
6349 function getWidgetIdByWidgetType($url, $widgetType)
6351 $ret = $this->getPageIdFromUrl($url, $pageId, $pageSubId, $param);
6354 if ($ret) $widgetId = $this->db->getWidgetIdByType($pageId, $pageSubId, $widgetType);
6358 * ページコンテンツタイプ、コンテンツタイプからウィジェットIDを取得
6360 * @param string $pageId ページID
6361 * @param string $contentType コンテンツタイプ
6362 * @return string ウィジェットID
6364 function getWidgetIdWithPageInfoByContentType($pageId, $contentType)
6366 $widgetId = $this->db->getWidgetIdWithPageInfoByContentType($pageId, $contentType);
6370 * ジョブタイプからウィジェットIDを取得
6372 * @param string $jobType ジョブタイプ
6373 * @return string ウィジェットID
6375 function getWidgetIdByJobType($jobType)
6377 global $gEnvManager;
6378 global $gErrorManager;
6382 $linkInfoObj = $this->gInstance->getObject(self::LINKINFO_OBJ_ID);
6383 if (isset($linkInfoObj)) $widgetId = $linkInfoObj->getJobWidget($jobType);
6385 // ウィジェットのアクセス権をチェック
6386 if (!$this->db->canAccessWidget($widgetId)) return '';
6389 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
6392 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
6397 * 現在アクティブなメイン型ウィジェットをウィジェット種別で取得
6399 * @param string $widgetType 対象ウィジェットタイプ
6400 * @return string ウィジェットID
6402 function getActiveMainWidgetIdByWidgetType($widgetType)
6405 $widgetId = $this->db->getActiveMainWidgetIdByType($widgetType);
6409 * URLを解析して、ページID,サブページIDを取得
6411 * @param string $url URL
6412 * @param string $pageId ページID
6413 * @param string $pageSubId ページサブID
6414 * @param array $urlParam URLパラメータ
6415 * @return bool true=成功、false=失敗
6417 function getPageIdFromUrl($url, &$pageId, &$pageSubId, &$urlParam)
6419 global $gEnvManager;
6421 // ページID、ページサブIDを求める
6422 list($page, $other) = explode('?', str_replace($gEnvManager->getRootUrl(), '', $url));
6423 parse_str($other, $urlParam);
6425 $pageId = str_replace('/', '_', trim($page, '/'));
6426 $pageId = basename($pageId, '.php');
6429 $pageSubId = $param[M3_REQUEST_PARAM_PAGE_SUB_ID];
6430 if (empty($pageSubId)) $pageSubId = $gEnvManager->getDefaultPageSubId();
6434 * ウィジェットが組み込まれているページのURLを生成
6436 * @param string $widgetId 送信元ウィジェットID
6437 * @param string $param 実行パラメータ
6438 * @param string $pageId ウィジェットが存在するページID
6439 * @return string 生成したURL
6441 function getDefaultPageUrlByWidget($widgetId, $param = '', $pageId = '')
6443 global $gEnvManager;
6445 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6447 // このウィジェットがマップされているページサブIDを取得
6449 $subPageId = $this->getPageSubIdByWidget($pageId, $widgetId);
6450 if (empty($subPageId)){
6451 // 見つからないときは互換ウィジェットを探す
6452 $targetWidgetId = $this->db->getCompatibleWidgetId($widgetId);
6453 if (!empty($targetWidgetId)){
6454 $subPageId = $this->getPageSubIdByWidget($pageId, $targetWidgetId);
6457 if (!empty($subPageId)) $sub = M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId;
6459 //$url = $gEnvManager->getDefaultUrl();
6460 $url = $gEnvManager->createPageUrl($pageId);
6461 if (!empty($sub)) $url .= '?' . $sub;
6462 if (!empty($param)) $url .= '&' . $param;
6466 * 現在のアクセスポイントの指定のページ属性のページURLを生成
6468 * @param string $contentType コンテンツタイプ
6469 * @param string $param 追加パラメータ
6470 * @param bool $omitPageId ページID省略形を使用するかどうか
6471 * @return string 生成したURL
6473 function createContentPageUrl($contentType, $param = '', $omitPageId = true)
6475 global $gEnvManager;
6476 static $urlArray = array();
6478 // 複数回呼ばれるのでコンテンツタイプごとにページまでのURLは保存しておく
6479 $baseUrl = $urlArray[$contentType];
6480 if (!isset($baseUrl)){
6481 // コンテンツタイプからページサブIDを取得
6482 $pageSubId = $this->getPageSubIdByContentType($contentType, $gEnvManager->getCurrentPageId()); // DBから取得
6484 if (empty($pageSubId)){ // ページサブIDが取得できない場合はデフォルトのページサブIDを取得
6485 $pageSubId = $gEnvManager->getDefaultPageSubId();
6486 } else if ($pageSubId == $gEnvManager->getDefaultPageSubId()){ // デフォルトページの場合
6487 if ($omitPageId) $pageSubId = ''; // ページID省略形を使用する場合はページサブIDを省略
6490 // 現在のアクセスポイントのURLを取得
6491 $baseUrl = $gEnvManager->createPageUrl();
6494 if (!empty($pageSubId)) $baseUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId;
6497 $urlArray[$contentType] = $baseUrl;
6502 if (!empty($param)){
6503 if (strEndsWith($url, '.php') || strEndsWith($url, '/')){
6513 * ウィジェット指定呼び出し用のURLを生成
6515 * @param string $toWidgetId 送信先ウィジェットID
6516 * @param string $fromWidgetId 送信元ウィジェットID
6517 * @param string $todo 実行パラメータ
6518 * @param string $pageId ページID(空のときは現在のURL)
6519 * @return string 生成したURL
6521 function createWidgetCmdUrl($toWidgetId, $fromWidgetId, $todo, $pageId = '')
6523 global $gEnvManager;
6525 $url = $gEnvManager->createPageUrl($pageId);
6527 $url .= '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_FIND_WIDGET;
6528 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $toWidgetId;
6529 if (!empty($fromWidgetId)) $url .= '&' . M3_REQUEST_PARAM_FROM . '=' . $fromWidgetId; // 送信元
6530 if (!empty($todo)) $url .= '&' . M3_REQUEST_PARAM_OPERATION_TODO . '=' . urlencode($todo);
6536 * @param string $widgetId 実行ウィジェットID
6537 * @param string $optionParam 追加パラメータ
6538 * @param string $pageId ページID(空のときは現在のURL)
6539 * @param string $pageSubId ページサブID
6540 * @return string 生成したURL
6542 function createRssCmdUrl($widgetId, $optionParam = '', $pageId = '', $pageSubId = '')
6544 global $gEnvManager;
6547 $url = $gEnvManager->createPageUrl() . '?';
6550 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6551 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6553 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_RSS;
6554 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6555 if (!empty($optionParam)) $url .= '&' . $optionParam;
6561 * @param bool $isSslPage SSLが必要なページかどうか
6562 * @param string $optionParam 追加パラメータ
6563 * @return string 生成したURL
6565 function createCssCmdUrl($isSslPage, $optionParam = '')
6567 global $gEnvManager;
6568 global $gRequestManager;
6571 // $url = $gEnvManager->createPageUrl() . '?';
6572 $url = $gEnvManager->createPageUrl(''/*現在のページ*/, $isSslPage) . '?';
6575 $pageSubId = $this->gEnv->getCurrentPageSubId();
6576 $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6578 // コンテンツ詳細画面の場合はコンテンツパラメータを追加
6579 if ($this->isContentDetailPage){
6580 switch ($this->contentType){
6581 case M3_VIEW_TYPE_CONTENT: // 汎用コンテンツ
6582 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID);
6583 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID_SHORT);
6584 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentsId . '&';
6586 case M3_VIEW_TYPE_PRODUCT: // 製品
6587 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID);
6588 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID_SHORT);
6589 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PRODUCT_ID . '=' . $contentsId . '&';
6591 case M3_VIEW_TYPE_BBS: // BBS
6592 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID);
6593 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT);
6594 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BBS_THREAD_ID . '=' . $contentsId . '&';
6596 case M3_VIEW_TYPE_BLOG: // ブログ
6597 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID);
6598 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT);
6599 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $contentsId . '&';
6601 case M3_VIEW_TYPE_WIKI: // Wiki
6602 $contentsId = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
6603 if (!empty($contentsId)) $url .= $contentsId . '&';
6605 case M3_VIEW_TYPE_USER: // ユーザ作成コンテンツ
6606 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_ROOM_ID);
6607 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_ROOM_ID_SHORT);
6608 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_ROOM_ID . '=' . $contentsId . '&';
6610 case M3_VIEW_TYPE_EVENT: // イベント
6611 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID);
6612 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID_SHORT);
6613 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_EVENT_ID . '=' . $contentsId . '&';
6615 case M3_VIEW_TYPE_PHOTO: // フォトギャラリー
6616 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID);
6617 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID_SHORT);
6618 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PHOTO_ID . '=' . $contentsId . '&';
6623 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_CSS;
6624 if (!empty($optionParam)) $url .= '&' . $optionParam;
6630 * @param string $widgetId 実行ウィジェットID
6631 * @param string $optionParam 追加パラメータ
6632 * @param bool $byMacro マクロ変換で返すかどうか
6633 * @param string $pageId ページID(空のときは現在のURL)
6634 * @param string $pageSubId ページサブID
6635 * @return string 生成したURL
6637 function createDirectWidgetCmdUrl($widgetId, $optionParam = '', $byMacro = false, $pageId = '', $pageSubId = '')
6639 global $gEnvManager;
6643 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . M3_FILENAME_INDEX . '?';
6645 $url = $gEnvManager->createPageUrl() . '?';
6649 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6650 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6652 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_DO_WIDGET;
6653 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6654 if (!empty($optionParam)) $url .= '&' . $optionParam;
6660 * @return array パラメータ文字列の配列
6662 function getUrlParamOrder()
6664 return $this->urlParamOrder; // URLパラメータの並び順
6667 * キャッシュ制御用の付加パラメータを取得
6669 * @return string パラメータ
6671 function getCacheParam()
6673 $addParam = '?' . date('YmdHis');
6677 * 現在のURLにアクセス可能かチェック
6679 * @param bool $isActivePage ページが有効かどうか
6680 * @param int $errCode エラーコード
6681 * @return bool true=可能、false=不可
6683 function canAccessUrl(&$isActivePage, &$errCode)
6685 global $gEnvManager;
6687 $errCode = 0; // エラーコード初期化
6689 // 現在設定されているページIDを取得
6690 $pageId = $gEnvManager->getCurrentPageId();
6691 $pageSubId = $gEnvManager->getCurrentPageSubId();
6692 $ret = $this->db->canAccessPage($pageId, $pageSubId, $pageVisible, $pageSubVisible, $isAdminMenu);
6693 if ($ret){ // アクセス可能なときは、ユーザ制限もチェックする
6694 $isActivePage = true;
6697 if (!$pageVisible || !$pageSubVisible) return false;
6699 if (!$gEnvManager->isCurrentUserLogined() && $this->isUserLimitedPage($pageId, $pageSubId)){ // ユーザがログインされていない状態でユーザ制限されていればアクセス不可
6702 $this->isAccessPointWithAdminMenu = $isAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
6705 } else { // 無効ページのとき
6706 $isActivePage = false;
6708 // ページIDの文字のチェック。ページIDは半角英小文字、数字、アンダーバー、ハイフンのみ使用可能。
6709 if (preg_match("/[^0-9a-z-_]/", $pageSubId)) $errCode = 1; // 不正文字検出
6714 * ウィジェットヘッダ(Joomla!1.0用)を出力タイプを取得
6716 * @return int 0=出力しない、1=Joomla!1.0テンプレートPC用、2=Joomla!1.0テンプレート携帯用
6718 function getTemplateWidgetHeaderType()
6720 global $gEnvManager;
6722 $templateId = $gEnvManager->getCurrentTemplateId();
6723 if ($templateId == self::ADMIN_TEMPLATE || // PC管理用テンプレート
6724 $templateId == self::M_ADMIN_TEMPLATE){ // 携帯管理用テンプレート
6726 } else if(strncmp($templateId, 'm/', 2) == 0){ // 携帯用テンプレート
6727 return 2; // 携帯テンプレート用出力
6729 return 1; // PCテンプレート用出力
6735 * @param string $pageId ページID
6736 * @param string $pageSubId ページサブID
6737 * @return bool true=必要、false=不要
6739 function isSslPage($pageId, $pageSubId)
6741 global $gEnvManager;
6744 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6747 if ($pageId == $gEnvManager->getDefaultAdminPageId()){
6748 if ($gEnvManager->getUseSslAdmin()){ // 管理用ページにSSLを使用するかどうか
6755 // ##### フロント画面の場合 #####
6756 if ($gEnvManager->isRootUrlSsl()) return true; // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
6758 // 一般用ページにSSLを使用しない場合は不要を返す
6759 if (!$gEnvManager->getUseSsl()) return false;
6761 // 一般用ページでSSLを使用する場合は、データベースの設定をチェックする
6762 $line = $this->getPageInfo($pageId, $pageSubId);
6764 if ($line['pn_use_ssl']){
6773 * ユーザ制限が必要なページかどうかを判断
6775 * @param string $pageId ページID
6776 * @param string $pageSubId ページサブID
6777 * @return bool true=必要、false=不要
6779 function isUserLimitedPage($pageId, $pageSubId)
6781 global $gEnvManager;
6784 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6786 $line = $this->getPageInfo($pageId, $pageSubId);
6788 if ($line['pn_user_limited']){
6799 * @param string $pageId ページID
6800 * @param string $pageSubId ページサブID
6801 * @return array ページ情報レコード
6803 function getPageInfo($pageId, $pageSubId)
6805 // ページ情報が空のときはデータをロード
6806 if (empty($this->pageInfo)){
6807 $records = $this->db->getPageInfoRecords();
6808 $count = count($records);
6809 $this->pageInfo = array();
6810 for ($i = 0; $i < $count; $i++){
6811 $pId = $records[$i]['pn_id'] . self::PAGE_ID_SEPARATOR . $records[$i]['pn_sub_id'];
6812 $this->pageInfo[$pId] = $records[$i];
6815 return $this->pageInfo[$pageId . self::PAGE_ID_SEPARATOR . $pageSubId];
6820 * @return array ページ情報レコード
6822 function getCurrentPageInfo()
6824 return $this->currentPageInfo;
6827 * 現在のページ情報からテンプレートIDを取得
6829 * @param string $subTemplateId テンプレートIDが取得できるときはサブページIDが返る
6830 * @return string テンプレートID
6832 function getTemplateIdFromCurrentPageInfo(&$subTemplateId)
6835 if (!empty($this->currentPageInfo)){
6836 $templateId = $this->currentPageInfo['pn_template_id'];
6837 $subTemplateId = $this->currentPageInfo['pn_sub_template_id']; // サブテンプレートID
6842 * JavascriptライブラリのIDを取得
6844 * @param int $type 種別(0=すべて、1=jQuery関係すべて、2=jQueryプラグインのみ)
6845 * @return array JavascriptライブラリのID
6847 function getScriptLibId($type = 0)
6849 // Javascriptライブラリのすべてのキーを取得
6850 $keys = array_keys($this->libFiles);
6852 $destKeys = array();
6853 for ($i = 0; $i < count($keys); $i++){
6855 case 1: // jQuery関係すべて
6856 if (strStartsWith($keys[$i], 'jquery')) $destKeys[] = $keys[$i];
6858 case 2: // jQueryプラグインのみ
6859 if (strStartsWith($keys[$i], 'jquery.')) $destKeys[] = $keys[$i];
6866 * Javascriptライブラリの情報を取得
6868 * @param string $id ライブラリID
6869 * @return array ライブラリの情報
6871 function getScriptLibInfo($id)
6873 $libInfo = $this->libFiles[$id];
6874 if (isset($libInfo)){
6881 * 管理画面用jQueryUIテーマのURLを取得
6883 * @return string テーマURL
6885 function getAdminDefaultThemeUrl()
6887 // $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
6888 $themeFile = $this->gEnv->getAdminUrl(true/*「admin」削除*/) . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
6892 * フロント画面用jQueryUIテーマのURLを取得
6894 * @return string テーマURL
6896 function getDefaultThemeUrl()
6900 if (!isset($themeFile)){
6902 $theme = $this->gSystem->defaultTheme();
6903 if (!empty($theme)){
6904 $path = $this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
6905 if (file_exists($path)) $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
6913 * @param array $paramArray URL作成用のパス
6914 * @return string 作成したURLパラメータ
6916 function _createUrlParamStr($paramArray)
6919 if (count($paramArray) == 0) return $destParam;
6921 $sortParam = array();
6922 $keys = array_keys($paramArray);
6923 $keyCount = count($keys);
6924 for ($i = 0; $i < $keyCount; $i++){
6926 $value = $paramArray[$key];
6927 $orderNo = $this->urlParamOrder[$key];
6928 if (!isset($orderNo)) $orderNo = 100;
6929 $sortParam[] = array('key' => $key, 'value' => $value, 'no' => $orderNo);
6931 // usort($sortParam, create_function('$a,$b', 'return $a["no"] - $b["no"];'));
6932 usort($sortParam, function($a, $b)
6934 return $a['no'] - $b['no'];
6938 $sortCount = count($sortParam);
6939 for ($i = 0; $i < $sortCount; $i++){
6940 if ($i > 0) $destParam .= '&';
6941 $destParam .= rawurlencode($sortParam[$i]['key']) . '=' . rawurlencode($sortParam[$i]['value']);
6946 * DBからCSSファイル(テンプレート独自のCSSまたは外部のCSS)を取得
6948 * @param string $templateId テンプレートID
6949 * @return bool true=取得成功、false=取得失敗
6951 function loadCssFiles($templateId = '')
6953 if (empty($templateId)) $templateId = $this->gSystem->defaultTemplateId(); // PC画面デフォルトのテンプレートを取得
6955 $ret = $this->db->getTemplate($templateId, $row);
6956 if (!$ret) return false;
6957 if (empty($row['tm_editor_param'])) return false;
6959 $editorParamObj = unserialize($row['tm_editor_param']);
6960 if (isset($editorParamObj)){
6961 $this->ckeditorCssFiles = array();
6962 $cssFiles = $editorParamObj->cssFiles;
6963 for ($i = 0; $i < count($cssFiles); $i++){
6964 $cssFile = $cssFiles[$i];
6966 if (strStartsWith($cssFile, '//')){ // URLが「//」で始まる外部ファイルの場合はそのまま追加
6967 $this->ckeditorCssFiles[] = $cssFile;
6968 } else if (strStartsWith($cssFile, '/')){ // URLが「/」で始まる相対パスの場合はURLに変換
6969 $this->ckeditorCssFiles[] = $this->gEnv->getAdminUrl(true/*adminディレクトリ削除*/) . $cssFile;
6971 $this->ckeditorCssFiles[] = $cssFile;
6980 * URLで指定した画面のCSSファイル(テンプレート独自のCSSまたは外部のCSS)を取得
6982 * @param string $url 取得画面のURL
6985 function loadCssFilesByUrl($url)
6988 curl_setopt($ch, CURLOPT_URL, $url);
6989 curl_setopt($ch, CURLOPT_USERAGENT, M3_SYSTEM_NAME . '/' . M3_SYSTEM_VERSION); // ユーザエージェント
6990 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 画面に出力しない
6991 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
6992 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
6993 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); // セッションを維持
6994 $content = curl_exec($ch);
6998 $urlArray = array();
7000 $pattern = '/<head\b[^>]*?>(.*?)<\/head\b[^>]*?>/si';
7001 if (preg_match($pattern, $content, $matches)) $headContent = $matches[0];
7004 $pattern = '/<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>/si';
7005 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7006 foreach ($matches as $match){
7007 if (strEndsWith($match[1], '.css')){ // ファイル名の拡張子が「css」の場合
7008 $urlArray[] = $match[1];
7010 // typeが「text/css」を取得
7011 $attrPattern = '/type\s*=\s*[\'"]+(.+?)[\'"]/si';
7012 if (preg_match($attrPattern, $match[0], $attrMatch)){
7013 if (strcasecmp($attrMatch[1], 'text/css') == 0){
7014 $urlArray[] = $match[1];
7018 // relが「stylesheet」を取得
7019 $attrPattern = '/rel\s*=\s*[\'"]+(.+?)[\'"]/si';
7020 if (preg_match($attrPattern, $match[0], $attrMatch)){
7021 if (strcasecmp($attrMatch[1], 'stylesheet') == 0){
7022 $urlArray[] = $match[1];
7030 // ifで制御されているCSSファイルを除く
7031 $delUrlArray = array();
7032 $pattern = '/<!--\[if\b.*?\]>[\s\S]*<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>[\s\S]*<!\[endif\]-->/si';
7033 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7034 foreach ($matches as $match) $delUrlArray[] = $match[1];
7037 // ##### テンプレート独自のCSSまたは外部のCSSを取得する #####
7038 $this->ckeditorCssFiles = array();
7039 $cssFiles = array_merge(array_diff($urlArray, $delUrlArray)); // CKEditor用のCSSファイル
7040 for ($i = 0; $i < count($cssFiles); $i++){
7041 $cssFileUrl = $cssFiles[$i];
7043 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7044 $baseUrl = $this->gEnv->getRootUrl();
7045 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7046 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7049 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7051 if (strStartsWith($relativePath, '//')){ // URLが「//」で始まる外部ファイルの場合
7052 $this->ckeditorCssFiles[] = $cssFileUrl;
7053 } else if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){ // テンプレートディレクトリの場合
7054 $this->ckeditorCssFiles[] = $cssFileUrl;
7055 } else if (strStartsWith($relativePath, '/')){ // テンプレートディレクトリ以外のディレクトリの場合
7056 } else { // 外部URLの場合
7057 $this->ckeditorCssFiles[] = $cssFileUrl;
7062 $pattern = '/var\s*M3_TEMPLATE_TYPE\s*=\s*(\d+?)\s*;/si';
7063 if (preg_match($pattern, $headContent, $matches)) $this->ckeditorTemplateType = $matches[1]; // CKEditor用のテンプレートタイプ
7066 * CKEditor用のテンプレートタイプを取得
7068 * @return int テンプレートタイプ
7070 function getCkeditorTemplateType()
7072 return $this->ckeditorTemplateType;
7077 * @return bool true=正常、false=不正
7079 /* function _checkReferer()
7081 global $gEnvManager;
7082 global $gRequestManager;
7085 $referer = $gRequestManager->trimServerValueOf('HTTP_REFERER');
7086 $uri = $gEnvManager->getCurrentRequestUri();
7087 if (empty($referer) || $referer != $uri){
7094 * テンプレート画面を解析してCSSファイルやポジションの情報を取得
7096 * @param string $templateId テンプレートID
7097 * @return テンプレート情報オブジェクト
7099 function parseTemplate($templateId)
7102 $url = $this->gEnv->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_SHOW_POSITION . '&template=' . $templateId;
7105 $tmplateInfoObj = new stdClass;
7106 $tmplateInfoObj->cssFiles = array(); // テンプレートで使用されているCSSファイル
7109 curl_setopt($ch, CURLOPT_URL, $url);
7110 curl_setopt($ch, CURLOPT_USERAGENT, M3_SYSTEM_NAME . '/' . M3_SYSTEM_VERSION); // ユーザエージェント
7111 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 画面に出力しない
7112 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
7113 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
7114 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); // セッションを維持
7115 $content = curl_exec($ch);
7119 $urlArray = array();
7121 $pattern = '/<head\b[^>]*?>(.*?)<\/head\b[^>]*?>/si';
7122 if (preg_match($pattern, $content, $matches)) $headContent = $matches[0];
7125 $pattern = '/<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>/si';
7126 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7127 foreach ($matches as $match){
7128 if (strEndsWith($match[1], '.css')){ // ファイル名の拡張子が「css」の場合
7129 $urlArray[] = $match[1];
7131 // typeが「text/css」を取得
7132 $attrPattern = '/type\s*=\s*[\'"]+(.+?)[\'"]/si';
7133 if (preg_match($attrPattern, $match[0], $attrMatch)){
7134 if (strcasecmp($attrMatch[1], 'text/css') == 0){
7135 $urlArray[] = $match[1];
7139 // relが「stylesheet」を取得
7140 $attrPattern = '/rel\s*=\s*[\'"]+(.+?)[\'"]/si';
7141 if (preg_match($attrPattern, $match[0], $attrMatch)){
7142 if (strcasecmp($attrMatch[1], 'stylesheet') == 0){
7143 $urlArray[] = $match[1];
7151 // ifで制御されているCSSファイルを除く
7152 $delUrlArray = array();
7153 $pattern = '/<!--\[if\b.*?\]>[\s\S]*<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>[\s\S]*<!\[endif\]-->/si';
7154 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7155 foreach ($matches as $match) $delUrlArray[] = $match[1];
7158 // テンプレート独自のCSSまたは外部のCSSを取得する
7159 $cssFiles = array_merge(array_diff($urlArray, $delUrlArray)); // CKEditor用のCSSファイル
7160 for ($i = 0; $i < count($cssFiles); $i++){
7161 $cssFileUrl = $cssFiles[$i];
7163 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7164 $baseUrl = $this->gEnv->getRootUrl();
7165 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7166 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7169 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7171 if (strStartsWith($relativePath, '//')){ // URLが「//」で始まる外部ファイルの場合
7172 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7173 } else if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){ // テンプレートディレクトリの場合
7174 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7175 } else if (strStartsWith($relativePath, '/')){ // テンプレートディレクトリ以外のディレクトリの場合
7176 } else { // 外部URLの場合
7177 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7182 for ($i = 0; $i < count($tmplateInfoObj->cssFiles); $i++){
7183 $cssFileUrl = $tmplateInfoObj->cssFiles[$i];
7186 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7187 $baseUrl = $this->gEnv->getRootUrl();
7188 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7189 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7192 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7194 // テンプレート内のCSSの場合は相対パスに変換
7195 if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){// テンプレートディレクトリの場合
7196 $tmplateInfoObj->cssFiles[$i] = $relativePath;
7198 $tmplateInfoObj->cssFiles[$i] = $cssFileUrl;
7203 $tmplateInfoObj->positions = array();
7204 $pattern = '/var\s*M3_POSITION_DATA\s*=\s*[\'"]+(.+?)[\'"]/si';
7205 if (preg_match($pattern, $headContent, $matches) && !empty($matches[1])){
7206 $tmplateInfoObj->positions = explode(',', $matches[1]);
7208 return $tmplateInfoObj;
7211 * デフォルトのテンプレートからレイアウト用テンプレートで使用していないポジションを取得
7213 * @return array ポジション名の配列
7215 function getLayoutTemplatePosition()
7217 $removePositions = array('header', 'extra1', 'extra2', 'brand', 'hmenu', 'user3', 'banner1', 'top1', 'top2', 'top3',
7218 'left', 'banner2', 'breadcrumb', 'user1', 'user2', 'banner3', 'main-top', 'main', 'main-bottom', 'banner4', 'user4', 'user5', 'banner5',
7219 'right','bottom1', 'bottom2', 'bottom3', 'banner6', 'syndicate', 'copyright', 'footer'); // レイアウト用テンプレートに存在するので削除するポジション
7221 // URLパラメータからデフォルトのテンプレートを取得
7222 $pageId = $this->gRequest->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
7225 if ($pageId == $this->gEnv->getDefaultPageId()){ // 通常サイトのとき
7226 $templateId = $this->gSystem->defaultTemplateId();
7227 } else if ($pageId == $this->gEnv->getDefaultMobilePageId()){ // 携帯サイトのとき
7228 $templateId = $this->gSystem->defaultMobileTemplateId(); // 携帯用デフォルトテンプレート
7229 } else if ($pageId == $this->gEnv->getDefaultSmartphonePageId()){ // スマートフォン用サイトのとき
7230 $templateId = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
7234 $ret = $this->db->getTemplate($templateId, $row);
7235 if (!$ret) return array();
7236 if (empty($row['tm_editor_param'])) return array();
7238 // レイアウト用テンプレートに存在しないポジション名のみ返す
7239 $editorParamObj = unserialize($row['tm_editor_param']);
7240 if (isset($editorParamObj)){
7241 if (isset($editorParamObj->positions)){
7242 $srcArray = $editorParamObj->positions;
7243 $destArray = array();
7244 for ($i = 0; $i < count($srcArray); $i++){
7245 $position = $srcArray[$i];
7246 if (!in_array($position, $removePositions)) $destArray[] = $position;