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-2017 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_VISIBLE_IN_LOGIN_CLASS = 'm3visible_in_login'; // ログイン時のみ表示ウィジェットクラス
129 const WIDGET_VISIBLE_IN_NOT_LOGIN_CLASS = 'm3visible_in_not_login'; // 非ログイン時のみ表示ウィジェットクラス
130 const WIDGET_OUTER_CLASS = 'm3_widget_outer'; // ウィジェット外枠クラス
131 const WIDGET_OUTER_CLASS_HEAD_POSITION = 'm3_pos_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
132 const WIDGET_OUTER_CLASS_WIDGET_TAG = 'm3_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
133 // const WIDGET_INNER_CLASS = 'm3_widget_inner'; // ウィジェットの内側クラス
134 const POSITION_TAG_HEAD = 'm3pos_'; // ポジションの識別用タグIDヘッダ
135 const WIDGET_TAG_HEAD = 'm3widget_'; // ウィジェットの識別用タグIDヘッダ
136 // const WIDGET_TAG_HEAD_SHORT = 'm3_'; // ウィジェットの識別用タグIDヘッダ
137 const WIDGET_TYPE_TAG_HEAD = 'm3widgettype_'; // ウィジェット種別の識別用タグIDヘッダ
138 const WIDTET_CLASS_NAME = 'm3widget'; // ウィジェットオブジェクトのタグクラス名
139 const WIDTET_CLASS_TYPE_0 = 'm3widget_type0'; // ウィジェットオブジェクトのタグクラス(グローバル属性でない)
140 const WIDTET_CLASS_TYPE_1 = 'm3widget_type1'; // ウィジェットオブジェクトのタグクラス(グローバル属性)
141 const POSITION_CLASS_NAME = 'm3position'; // ポジションオブジェクトのタグクラス名
142 const JOOMLA10_DEFAULT_WIDGET_MENU_PARAM = 'class="moduletable"'; // Joomla!1.0用デフォルトメニューパラメータ値
143 const ADMIN_TEMPLATE = '_admin'; // PC管理用テンプレートID
144 const M_ADMIN_TEMPLATE = 'm/_admin'; // 携帯用管理画面テンプレートID
145 const SCRIPT_LIB_SEPARATOR = ';'; // JavaScriptライブラリ読み込み設定のライブラリの区切り
146 const PAGE_ID_SEPARATOR = ','; // ページIDとページサブID連結用
147 const DEFAULT_ADMIN_FAVICON_FILE = '/images/system/favicon.ico'; // デフォルトの管理画面用faviconファイル
148 const DEFAULT_FAVICON_FILE = '/favicon.ico'; // デフォルトのfaviconファイル
149 // const DEFAULT_SITE_NAME = 'サイト名未設定'; // 管理画面用のデフォルトサイト名
150 const DEFAULT_ADMIN_TITLE = '管理画面'; // デフォルトの管理画面名
151 const WIDGET_TITLE_START = '['; // ウィジェットのタイトルの括弧
152 const WIDGET_TITLE_END = ']'; // ウィジェットのタイトルの括弧
153 const DEFAULT_RSS_VERSION = '1.0'; // デフォルトのRSSのバージョン
154 const CF_ACCESS_IN_INTRANET = 'access_in_intranet'; // イントラネット運用かどうか
155 const CF_USE_LATEST_SCRIPT_LIB = 'dev_use_latest_script_lib'; // 最新のJavaScriptライブラリを使用するかどうか
156 const CF_GOOGLE_MAPS_KEY = 'google_maps_key'; // Googleマップ利用キー
157 const CF_CONFIG_WINDOW_OPEN_TYPE = 'config_window_open_type'; // ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
158 const CF_JQUERY_VERSION = 'jquery_version'; // jQueryバージョン
159 const CF_EXTERNAL_JQUERY = 'external_jquery'; // システム外部のjQueryを使用するかどうか
160 const CF_WYSIWYG_EDITOR = 'wysiwyg_editor'; // 管理画面用WYSIWYGエディター
161 const CF_ADMIN_JQUERY_VERSION = 'admin_jquery_version'; // 管理画面用jQueryバージョン
162 const CF_USE_JQUERY = 'use_jquery'; // jQueryを常に使用するかどうか
163 const CF_SMARTPHONE_USE_JQUERY_MOBILE = 'smartphone_use_jquery_mobile'; // スマートフォン画面でjQuery Mobileを使用
164 const SD_HEAD_OTHERS = 'head_others'; // ヘッダその他タグ
165 const DEFAULT_THEME_DIR = '/ui/themes/'; // jQueryUIテーマ格納ディレクトリ
166 const THEME_CSS_FILE = 'jquery-ui.custom.css'; // テーマファイル
167 const CONFIG_ICON_FILE = '/images/system/config.png'; // ウィジェット定義画面アイコン
168 const ADJUST_ICON_FILE = '/images/system/adjust_widget.png'; // 位置調整アイコン
169 const SHARED_ICON_FILE = '/images/system/shared.png'; // グローバル属性
170 const DELETE_ICON_FILE = '/images/system/delete.png'; // ウィジェット削除
171 const CONFIG_ICON32_FILE = '/images/system/config32.png'; // ウィジェット定義画面アイコン(ツールチップ用)
172 const ADJUST_ICON32_FILE = '/images/system/adjust_widget32.png'; // 位置調整アイコン(ツールチップ用)
173 const CLOSE_BOX_ICON32_FILE = '/images/system/close_box.png'; // ウィンドウ閉じるアイコン(ツールチップ用)
174 const NOTICE_ICON_FILE = '/images/system/notice16.png'; // ウィジェット配置注意アイコン
175 const ALERT_ICON_FILE = '/images/system/alert16.png'; // ウィジェット配置警告アイコン
176 // const ADMIN_ICON_FILE = '/images/system/admin64.png'; // パネルメニュー管理画面遷移用アイコン
177 // const LOGOUT_ICON_FILE = '/images/system/logout64.png'; // パネルメニューログアウト用アイコン
178 // const EDIT_PAGE_ICON_FILE = '/images/system/create_page64.png'; // パネルメニュー編集用アイコン
179 const ADMIN_ICON_FILE = '/images/system/home32.png'; // パネルメニュー管理画面遷移用アイコン
180 const LOGOUT_ICON_FILE = '/images/system/logout32.png'; // パネルメニューログアウト用アイコン
181 const EDIT_PAGE_ICON_FILE = '/images/system/create_page32.png'; // パネルメニュー編集用アイコン
182 // const EDIT_END_ICON_FILE = '/images/system/close32.png'; // パネルメニュー編集終了用アイコン
183 const EDIT_END_ICON_FILE = '/images/system/back32.png'; // パネルメニュー編集終了用アイコン
184 const CLOSE_ICON_FILE = '/images/system/close32.png'; // ウィンドウ閉じるアイコン
185 const PREV_ICON_FILE = '/images/system/prev48.png'; // ウィンドウ「前へ」アイコン
186 const NEXT_ICON_FILE = '/images/system/next48.png'; // ウィンドウ「次へ」アイコン
187 const DEFAULT_READMORE_TITLE = 'もっと読む'; // もっと読むボタンのデフォルトタイトル
188 const POS_HEAD_NAV_MENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // 特殊ポジションブロック(ナビゲーションメニュー)
189 const WIDGET_MARK_MAIN = '<i class="glyphicon glyphicon-tower" rel="m3help" title="メイン型" data-placement="auto"></i> '; // ウィジェットの機能マーク(メイン型ウィジェット)
190 const WIDGET_MARK_NAVMENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // ウィジェットの機能マーク(ナビゲーションメニュー)
191 const WIDGET_FUNCTION_MARK_BOOTSTRAP = ' <span class="label label-warning" rel="m3help" title="Bootstrap型テンプレート対応" data-placement="auto">B</span>'; // ウィジェット機能マーク(Boostrap型テンプレート
192 const WIDGET_FUNCTION_MARK_WORDPRESS = ' <span class="label label-warning" rel="m3help" title="WordPress型テンプレート対応" data-placement="auto">W</span>'; // ウィジェット機能マーク(WordPress型テンプレート
193 const WIDGET_STYLE_NAVMENU = '_navmenu'; // ウィジェットの表示スタイル(ナビゲーションメニュー)
194 const WIDGET_STYLE_WORDPRESS = '_wordpress'; // ウィジェットの表示スタイル(WordPressテンプレート用出力)
195 const WIDGET_STYLE_WORDPRESS_NOTITLE = '_wordpress_notitle'; // ウィジェットの表示スタイル(WordPressテンプレート(タイトルなし)用出力)
198 const CONTENT_OBJ_ID = 'contentlib'; // 汎用コンテンツオブジェクトID
199 const BLOG_OBJ_ID = 'bloglib'; // ブログオブジェクトID
200 const LINKINFO_OBJ_ID = 'linkinfo'; // リンク情報オブジェクトID
203 const IWIDTET_CMD_CONTENT = 'content'; // コンテンツ取得
204 const IWIDTET_CMD_INIT = 'init'; // 初期化
205 const IWIDTET_CMD_UPDATE = 'update'; // 更新
206 const IWIDTET_CMD_CALC = 'calc'; // 計算
209 const M3_ADMIN_SCRIPT_FILENAME = 'm3admin2.0.1.js'; // 管理機能用スクリプト(FCKEditor2.6.6、CKEditor4.0.1対応)
210 const M3_ADMIN_WIDGET_SCRIPT_FILENAME = 'm3admin_widget2.0.10.js'; // 管理機能(ウィジェット操作)用スクリプト(Magic3 v1.15.0以降)
211 const M3_ADMIN_WIDGET_CSS_FILE = '/m3/widget.css'; // 管理機能(ウィジェット操作)用CSSファイル
212 const M3_STD_SCRIPT_FILENAME = 'm3std1.5.2.js'; // 一般、管理機能共通スクリプト
213 // const M3_PLUS_SCRIPT_FILENAME = 'm3plus1.6.2.js'; // フロント画面追加用スクリプト(FCKEditor2.6.6対応、CKEditor4.0.1対応)
214 const M3_OPTION_SCRIPT_FILENAME = 'm3opt1.2.1.js'; // AJAXを含んだオプションライブラリファイル(jQuery必須)
215 const M3_ADMIN_CSS_FILE = 'm3/admin.css'; // 管理機能用のCSS
216 const M3_EDIT_CSS_FILE = 'm3/edit.css'; // フロント画面編集用のCSS
217 const M3_DEFAULT_CSS_FILE = 'm3/default.css'; // フロント画面共通のデフォルトCSS
218 const M3_CKEDITOR_CSS_FILE = 'm3/ckeditor.css'; // CKEditorの編集エリア用CSS
221 const USE_BOOTSTRAP_ADMIN = false; // 管理画面でBootstrapを使用するかどうか(デフォルト値)
222 const BOOTSTRAP_BUTTON_CLASS = 'btn btn-default';
225 const FILEBROWSER_WIDTH_RATIO = '0.8'; // ファイルブラウザ幅比率
226 const FILEBROWSER_HEIGHT_RATIO = '0.8'; // ファイルブラウザ高さ比率
231 function __construct()
233 global $gInstanceManager;
235 global $gSystemManager;
236 global $gRequestManager;
239 parent::__construct();
241 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
242 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
245 $this->db = $gInstanceManager->getSytemDbObject();
248 $value = $gSystemManager->getSystemConfig(self::CF_ACCESS_IN_INTRANET); // イントラネット運用かどうか
249 if (empty($value)){ // インターネット運用
250 $this->useGooglemaps = true; // Googleマップを使用するかどうか
252 $this->useHelp = true; // ヘルプ機能
254 // デフォルトのWYSIWYGエディターを取得
255 $this->wysiwygEditor = $gSystemManager->getSystemConfig(self::CF_WYSIWYG_EDITOR); // 管理画面用WYSIWYGエディター
257 // ##### Javascriptライブラリのバージョン設定 #####
259 // アクセスする画面に応じてjQueryのバージョンを設定
260 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
261 $value = $gSystemManager->getSystemConfig(self::CF_ADMIN_JQUERY_VERSION);// 管理画面用jQueryバージョン
263 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET && strStartsWith($widgetId, 'm/')){// 携帯用アクセスポイント用の管理画面の場合はWYSIWYGエディターはFCKEditorに固定
264 $this->wysiwygEditor = ScriptLibInfo::LIB_FCKEDITOR; // FCKEditorに固定
267 // 管理画面にBOOTSTRAPを使用するかどうか(初期値)
268 $this->useBootstrap = self::USE_BOOTSTRAP_ADMIN;
271 // 小画面デバイス最適化の場合は最新バージョンを使用
272 if ($gEnvManager->isSmallDeviceAdmin()) ScriptLibInfo::setCkeditorVer(1/*最新*/);
274 $value = $gSystemManager->getSystemConfig(self::CF_JQUERY_VERSION);// jQueryバージョン
276 ScriptLibInfo::setJQueryVer($value);
278 // WYSISIGエディターのタイプを設定。ScriptLibInfo::getLib()を実行する前に設定。
279 ScriptLibInfo::setWysiwygEditorType($this->wysiwygEditor);
282 $this->libFiles = ScriptLibInfo::getLib(); // ライブラリ取得
285 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(0); // 使用対象のjQueryファイル
286 $this->selectedJQueryUiFilename = ScriptLibInfo::getJQueryFilename(1); // 使用対象のjQuery UIファイル
288 // ##### フロント画面用のデフォルトのJavascript、CSSを取得 #####
289 $this->defaultScriptFiles = array(
290 $this->selectedJQueryFilename, // jQuery
291 self::M3_STD_SCRIPT_FILENAME
293 $this->defaultCssFiles = array(
294 self::M3_DEFAULT_CSS_FILE // フロント画面共通のデフォルトCSS
297 // ##### 管理機能用のデフォルトのJavascript、CSSを取得 #####
298 if (defined('M3_STATE_IN_INSTALL')){ // インストーラの場合のスクリプト
299 $this->defaultAdminScriptFiles = array(
300 $this->selectedJQueryFilename, // jQuery
301 // self::M3_STD_SCRIPT_FILENAME,
302 self::M3_ADMIN_SCRIPT_FILENAME
304 $this->defaultAdminCssFiles = array(); // 管理機能用のCSS
306 $this->defaultAdminScriptFiles = array(
307 $this->selectedJQueryFilename, // jQuery
308 $this->selectedJQueryUiFilename, // jQuery UI Core
309 ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME, // jQuery Contextmenu Lib
310 self::M3_STD_SCRIPT_FILENAME,
311 self::M3_ADMIN_SCRIPT_FILENAME,
312 self::M3_OPTION_SCRIPT_FILENAME
314 $this->defaultAdminCssFiles = array(
315 self::M3_ADMIN_CSS_FILE // 管理機能用のCSS
319 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用
320 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用
321 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_NUMERIC); // 入力制限プラグイン
322 // $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
325 // 管理権限なしで管理ディレクトリアクセスで読み込むスクリプトファイル
326 $this->defaultAdminDirScriptFiles = array($this->selectedJQueryFilename); // jQuery
329 $this->lateLaunchWidgetList = array();
330 $this->latelaunchWidgetParam = array();
333 if ($gEnvManager->canUseDb()){
334 $value = $this->gSystem->getSystemConfig('script_cache_in_browser'); // ブラウザにJavaScriptファイルのキャッシュを保持するかどうか
335 if ($value != '') $this->hasScriptCache = $value;
338 $this->rssVersion = self::DEFAULT_RSS_VERSION; // RSSバージョン
340 // フロント画面で使用する主要コンテンツタイプ
341 $this->mainContentTypeInfo = array(
342 array( 'name' => '会員情報', 'value' => M3_VIEW_TYPE_MEMBER),
343 array( 'name' => '汎用コンテンツ', 'value' => M3_VIEW_TYPE_CONTENT),
344 array( 'name' => '製品', 'value' => M3_VIEW_TYPE_PRODUCT),
345 array( 'name' => 'BBS', 'value' => M3_VIEW_TYPE_BBS),
346 array( 'name' => 'ブログ', 'value' => M3_VIEW_TYPE_BLOG),
347 array( 'name' => 'Wiki', 'value' => M3_VIEW_TYPE_WIKI),
348 array( 'name' => 'ユーザ作成コンテンツ', 'value' => M3_VIEW_TYPE_USER),
349 array( 'name' => 'イベント情報', 'value' => M3_VIEW_TYPE_EVENT),
350 array( 'name' => 'フォトギャラリー', 'value' => M3_VIEW_TYPE_PHOTO)
352 // フロント画面で使用する補助コンテンツタイプ(ページ属性に対応しない)
353 $this->subContentTypeInfo = array( array( 'name' => '新着情報', 'value' => M3_VIEW_TYPE_NEWS),
354 array( 'name' => 'コメント', 'value' => M3_VIEW_TYPE_COMMENT),
355 array( 'name' => 'イベント予約', 'value' => M3_VIEW_TYPE_EVENTENTRY),
356 array( 'name' => 'バナー', 'value' => M3_VIEW_TYPE_BANNER)
358 // フロント画面で使用する主要機能タイプ(「ダッシュボード」は含まない)
359 $this->mainFeatureTypeInfo = array( array( 'name' => '検索', 'value' => M3_VIEW_TYPE_SEARCH),
360 array( 'name' => 'Eコマース', 'value' => M3_VIEW_TYPE_COMMERCE),
361 array( 'name' => 'カレンダー', 'value' => M3_VIEW_TYPE_CALENDAR)
364 $this->adminFeatureTypeInfo = array( array( 'name' => 'ダッシュボード', 'value' => M3_VIEW_TYPE_DASHBOARD)
368 $this->urlParamOrder = array(
370 M3_REQUEST_PARAM_CONTENT_ID => -20, // 汎用コンテンツID
371 M3_REQUEST_PARAM_CONTENT_ID_SHORT => -19, // 汎用コンテンツID(略式)
372 M3_REQUEST_PARAM_PRODUCT_ID => -18, // 製品ID
373 M3_REQUEST_PARAM_PRODUCT_ID_SHORT => -17, // 製品ID(略式)
374 M3_REQUEST_PARAM_BLOG_ID => -16, // ブログID
375 M3_REQUEST_PARAM_BLOG_ID_SHORT => -15, // ブログID(略式)
376 M3_REQUEST_PARAM_BLOG_ENTRY_ID => -14, // ブログ記事ID
377 M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT => -13, // ブログ記事ID(略式)
378 M3_REQUEST_PARAM_BBS_ID => -12, // 掲示板投稿記事ID
379 M3_REQUEST_PARAM_BBS_ID_SHORT => -11, // 掲示板投稿記事ID(略式)
380 M3_REQUEST_PARAM_BBS_THREAD_ID => -10, // 掲示板投稿スレッドID
381 M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT => -9, // 掲示板投稿スレッドID(略式)
382 M3_REQUEST_PARAM_USER_ID => -8, // ユーザ作成コンテンツID
383 M3_REQUEST_PARAM_USER_ID_SHORT => -7, // ユーザ作成コンテンツID(略式)
384 M3_REQUEST_PARAM_ROOM_ID => -6, // ユーザ作成コンテンツ区画ID
385 M3_REQUEST_PARAM_ROOM_ID_SHORT => -5, // ユーザ作成コンテンツ区画ID(略式)
386 M3_REQUEST_PARAM_EVENT_ID => -4, // イベントID
387 M3_REQUEST_PARAM_EVENT_ID_SHORT => -3, // イベントID(略式)
388 M3_REQUEST_PARAM_PHOTO_ID => -2, // 画像ID
389 M3_REQUEST_PARAM_PHOTO_ID_SHORT => -1, // 画像ID(略式)
391 M3_REQUEST_PARAM_PAGE_SUB_ID => 1, // ページサブID
392 M3_REQUEST_PARAM_PAGE_CONTENT_ID => 2, // ページコンテンツID
393 M3_REQUEST_PARAM_WIDGET_ID => 3, // ウィジェットID
394 M3_REQUEST_PARAM_TEMPLATE_ID => 4, // テンプレートID
395 M3_REQUEST_PARAM_URL => 5, // リンク先等のURL
396 M3_REQUEST_PARAM_STAMP => 6, // 公開発行ID
397 M3_REQUEST_PARAM_OPTION => 7, // 通信オプション
398 M3_REQUEST_PARAM_OPERATION_COMMAND => 8, // 実行処理
399 M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND => 9, // Wikiコマンド実行
400 M3_REQUEST_PARAM_OPERATION_TASK => 10, // ウィジェット間共通処理
401 M3_REQUEST_PARAM_OPERATION_ACT => 11, // クライアントからの実行処理
402 M3_REQUEST_PARAM_OPERATION_LANG => 12, // 言語指定表示
403 M3_REQUEST_PARAM_SERIAL_NO => 13, // シリアル番号
404 M3_REQUEST_PARAM_PAGE_NO => 14, // ページ番号
405 M3_REQUEST_PARAM_LIST_NO => 15, // 一覧番号
406 M3_REQUEST_PARAM_ITEM_NO => 16, // 項目番号
407 M3_REQUEST_PARAM_OPERATION_TODO => 17, // 指定ウィジェットに実行させる処理
408 M3_REQUEST_PARAM_FROM => 18, // メッセージの送信元ウィジェットID
409 M3_REQUEST_PARAM_VIEW_STYLE => 19, // 表示スタイル
410 M3_REQUEST_PARAM_FORWARD => 20, // 画面遷移用パラメータ
411 M3_REQUEST_PARAM_ADMIN_KEY => 21, // 管理者一時キー
412 M3_REQUEST_PARAM_OPEN_BY => 22, // ウィンドウの開き方
413 M3_REQUEST_PARAM_SHOW_HEADER => 23, // ヘッダ部表示制御
414 M3_REQUEST_PARAM_SHOW_FOOTER => 24, // フッタ部表示制御
415 M3_REQUEST_PARAM_SHOW_MENU => 25, // メニュー部表示制御
416 M3_REQUEST_PARAM_KEYWORD => 26, // 検索キーワード
417 M3_REQUEST_PARAM_HISTORY => 27, // 履歴インデックスNo
418 M3_REQUEST_PARAM_DEF_PAGE_ID => 28, // ページID(画面編集用)
419 M3_REQUEST_PARAM_DEF_PAGE_SUB_ID => 29, // ページサブID(画面編集用)
420 M3_REQUEST_PARAM_PAGE_DEF_SERIAL => 30, // ページ定義のレコードシリアル番号(設定画面起動時)
421 M3_REQUEST_PARAM_PAGE_DEF_CONFIG_ID => 31, // ページ定義のウィジェット定義ID(設定画面起動時)
422 M3_REQUEST_PARAM_BACK_URL => 32, // 戻り先URL
423 M3_REQUEST_PARAM_BACKUP_URL => 33, // URL退避用(画面編集時)
424 M3_REQUEST_PARAM_SERVER => 34, // サーバ指定
425 M3_REQUEST_PARAM_CATEGORY_ID => 35, // カテゴリID(共通)
426 M3_REQUEST_PARAM_WIDTH => 36, // 幅
427 M3_REQUEST_PARAM_HEIGHT => 37); // 高さ
432 * @return array コンテンツタイプ
434 public function _getAllContentType()
436 global $M3_ALL_CONTENT_TYPE;
438 /* $contentType = array( M3_VIEW_TYPE_CONTENT, // 汎用コンテンツ
439 M3_VIEW_TYPE_PRODUCT, // 製品
440 M3_VIEW_TYPE_BBS, // BBS
441 M3_VIEW_TYPE_BLOG, // ブログ
442 M3_VIEW_TYPE_WIKI, // wiki
443 M3_VIEW_TYPE_USER, // ユーザ作成コンテンツ
444 M3_VIEW_TYPE_EVENT, // イベント
445 M3_VIEW_TYPE_PHOTO); // フォトギャラリー
446 return $contentType;*/
447 return $M3_ALL_CONTENT_TYPE;
452 * @return array 機能タイプ
454 public function _getAllFeatureType()
456 global $M3_ALL_FEATURE_TYPE;
458 /* $featureType = array( M3_VIEW_TYPE_DASHBOARD, // ダッシュボード
459 M3_VIEW_TYPE_SEARCH, // 検索結果
460 M3_VIEW_TYPE_COMMERCE); // Eコマース
461 return $featureType;*/
462 return $M3_ALL_FEATURE_TYPE;
469 function setNoTimeout()
471 if (ini_get('safe_mode') == '0') set_time_limit(0);
476 * @param string $msg メッセージ
478 function setPopupMsg($msg)
480 $this->popupMsg = $msg;
483 * HTMLヘッダ「description」に出力する文字列を設定
485 * @param string $str 出力文字列
487 function setHeadDescription($str)
489 if (is_string($str) && !empty($str)){
490 $this->headDescription = $str;
491 $this->lastHeadDescription = $str; // 最後に設定した値を退避
495 * HTMLヘッダ「description」に出力する文字列を取得
497 * @return string $str 出力文字列
499 function getHeadDescription()
501 return $this->headDescription;
504 * HTMLヘッダ「keywords」に出力する文字列を設定
506 * @param string $str 出力文字列
508 function setHeadKeywords($str)
510 if (is_string($str) && !empty($str)){
511 $this->headKeywords = $str;
512 $this->lastHeadKeywords = $str; // 最後に設定した値を退避
516 * HTMLヘッダ「keywords」に出力する文字列を取得
518 * @return string $str 出力文字列
520 function getHeadKeywords()
522 return $this->headKeywords;
525 * HTMLヘッダに出力するタグ文字列を設定
527 * @param string $str 出力文字列
530 function setHeadOthers($str)
532 if (is_string($str) && !empty($str)){
533 $this->headOthers = $str;
537 * HTMLヘッダに出力するタグ文字列を追加
539 * @param string $str 出力文字列
542 function addHeadOthers($str)
544 if (is_string($str) && !empty($str)){
546 $pos = strpos($this->headOthers, $str);
547 if ($pos === false) $this->headOthers .= $str;
551 * HTMLヘッダに出力するタグ文字列を追加(管理画面用)
553 * @param string $str 出力文字列
556 function addAdminHeadOthers($str)
558 if (is_string($str) && !empty($str)){
560 $pos = strpos($this->adminHeadOthers, $str);
561 if ($pos === false) $this->adminHeadOthers .= $str;
565 * HTMLヘッダ「title」のサブタイトル出力する文字列を設定
567 * @param string $str 出力文字列
568 * @param string $url リンク先
570 function setHeadSubTitle($str = '', $url = '')
574 if (is_string($str)){
575 // 空の場合はウィジェットのヘッドタイトルから取得
576 if (empty($str)) $str = $gEnvManager->getCurrentWidgetHeadTitle();
579 $this->headSubTitle[] = $str;
580 $this->headSubTitleUrl[] = $url;
581 $this->lastHeadTitle = $str; // 最後に設定した値を退避
586 * HTMLヘッダ「title」のサブタイトル出力する文字列を取得
588 * @return $array サブタイトルに設定されている文字列を連想配列(title=タイトル、url=リンク先URL)の配列で返す
590 function getHeadSubTitle()
592 $titleArray = array();
593 $titleCount = count($this->headSubTitle);
594 for ($i = 0; $i < $titleCount; $i++){
595 $line = array('title' => $this->headSubTitle[$i], 'url' => $this->headSubTitleUrl[$i]);
596 $titleArray[] = $line;
601 * HTMLヘッダに出力するCSSの文字列を設定
603 * @param string $css 追加するCSS内容
606 function addHeadCss($css)
608 $destCss = trim($css);
609 if (!empty($destCss)){
610 //if (!in_array($css, $this->headCss)) $this->headCss[] = $css;
611 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css; // CSS動的外部出力
613 $this->lastHeadCss = $css; // 最後に設定したHTMLヘッダにCSS出力する文字列
617 * 外部出力で出力するCSSの文字列を設定(ウィジェット共通設定からの設定値)
619 * @param string $css 追加するCSS内容
622 function addExportCss($css)
624 $destCss = trim($css);
625 if (!empty($destCss)){
626 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css;
630 * HTMLヘッダに出力するJavascriptの文字列を設定
632 * @param string $script 追加するJavascript内容
635 function addHeadScript($script)
637 $destScript = trim($script);
638 if (!empty($destScript)){
639 if (!in_array($script, $this->headScript)) $this->headScript[] = $script;
641 $this->lastHeadScript = $script; // 最後に設定したHTMLヘッダにJavascript出力する文字列
645 * HTMLヘッダに出力するJavascriptの文字列(jQueryMobile用挿入スクリプト)を設定
647 * @param string $script 追加するJavascript内容
650 function addHeadPreMobileScript($script)
652 $destScript = trim($script);
653 if (!empty($destScript)){
654 if (!in_array($script, $this->headPreMobileScript)) $this->headPreMobileScript[] = $script;
658 * HTMLヘッダに出力する任意文字列を設定
660 * @param string $str 追加する任意文字列
663 function addHeadString($str)
665 $destScript = trim($str);
666 if (!empty($destScript)){
667 if (!in_array($str, $this->headString)) $this->headString[] = $str;
669 $this->lastHeadString = $str; // 最後に設定したHTMLヘッダに出力する任意文字列
673 * HTMLヘッダに出力するCSSファイルを追加
675 * @param string,array $cssFile CSSファイルURLパス
678 function addHeadCssFile($cssFile)
680 if (is_array($cssFile)){ // 配列の場合
681 for ($i = 0; $i < count($cssFile); $i++){
682 $destCss = trim($cssFile[$i]);
683 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
686 $destCss = trim($cssFile);
687 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
691 * HTMLヘッダに出力するJavascriptライブラリを追加
693 * @param string,array $scriptLib JavascriptライブラリID
696 function addHeadAdminScriptLib($scriptLib)
698 if (is_array($scriptLib)){ // 配列の場合
699 for ($i = 0; $i < count($scriptLib); $i++){
700 $destScript = trim($scriptLib[$i]);
701 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
704 $destScript = trim($scriptLib);
705 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
709 * HTMLヘッダに出力するJavascriptライブラリを追加
711 * @param string,array $scriptLib JavascriptライブラリID
714 function addHeadScriptLib($scriptLib)
716 if (is_array($scriptLib)){ // 配列の場合
717 for ($i = 0; $i < count($scriptLib); $i++){
718 $destScript = trim($scriptLib[$i]);
719 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
722 $destScript = trim($scriptLib);
723 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
727 * HTMLヘッダに出力するJavascriptファイルを追加
729 * @param string,array $scriptFile JavascriptファイルURLパス
732 function addHeadScriptFile($scriptFile)
734 if (is_array($scriptFile)){ // 配列の場合
735 for ($i = 0; $i < count($scriptFile); $i++){
736 $destScript = trim($scriptFile[$i]);
737 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
740 $destScript = trim($scriptFile);
741 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
745 * HTMLヘッダに出力するJavascriptファイル(jQueryMobile用挿入ファイル)を追加
747 * @param string,array $scriptFile JavascriptファイルURLパス
750 function addHeadPreMobileScriptFile($scriptFile)
752 if (is_array($scriptFile)){ // 配列の場合
753 for ($i = 0; $i < count($scriptFile); $i++){
754 $destScript = trim($scriptFile[$i]);
755 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
758 $destScript = trim($scriptFile);
759 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
763 * HTMLヘッダに出力するRSSファイルを追加
765 * @param array $rssFile タイトル(title)、配信用URL(href)の連想配列。複数の場合は連想配列の配列。
768 function addHeadRssFile($rssFile)
771 if (!is_array($rssFile)) return;
774 if (is_array($line)){ // 複数追加の場合
775 for ($i = 0; $i < count($line); $i++){
777 $url = trim($line[$i]['href']);
779 for ($j = 0; $j < count($this->headRssFiles); $j++){
780 $storedUrl = $this->headRssFiles[$j]['href'];
781 if ($url == $storedUrl) break;
783 if ($j == count($this->headRssFiles)){ // 見つからないときは追加
784 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
785 'title' => $line[$i]['title']); // タイトル
791 $url = trim($rssFile['href']);
793 for ($i = 0; $i < count($this->headRssFiles); $i++){
794 $storedUrl = $this->headRssFiles[$i]['href'];
795 if ($url == $storedUrl) break;
797 if ($i == count($this->headRssFiles)){ // 見つからないときは追加
798 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
799 'title' => $rssFile['title']); // タイトル
805 * RSSチャンネル部に出力するデータを設定
807 * @param array $rssData RSSチャンネル部データ
810 function setRssChannel($rssData)
812 if (!empty($rssData)) $this->rssChannel = $rssData; // RSSチャンネルデータ
817 * @param int $mode 0=ポジション表示しない(通常画面)、1=ポジション表示、2=ウィジェット込みポジション表示
819 function showPosition($mode)
821 $this->showPositionMode = $mode;
826 * @return bool true=レイアウト中、false=レイアウト中でない
830 return $this->isLayout; // 画面レイアウト中かどうか
835 function showWidget()
837 $this->showWidget = true;
842 * @param bool true=単体表示、false=単体表示でない
844 function getShowWidget()
846 return $this->showWidget;
851 * @param int $mode 0=設定なし、1=ログイン画面、10=サイト非公開、11=アクセス不可、12=存在しないページ
853 function setSystemHandleMode($mode)
855 $this->systemHandleMode = $mode;
860 function getSystemHandleMode()
862 return $this->systemHandleMode;
869 function setEditMode()
871 $this->isEditMode = true;
876 * @return bool true=編集モードオン、false=編集モードオフ
878 function idEditMode()
880 return $this->isEditMode;
883 * 出力フォーマットがHTMLであるかを設定
885 * @param bool $isHtml HTMLフォーマットかどうか
888 function setOutputByHtml($isHtml)
890 $this->outputByHtml = $isHtml;
894 * AJAX用のレスポンスボディデータかどうかを設定
896 * @param bool $isResponseBody レスポンスボディデータかどうか
899 function setOutputAjaxResponseBody($isResponseBody)
901 $this->outputAjaxResponseBody = $isResponseBody;
906 * @param bool $status ヘルプ機能を使用するかどうか
909 function setUseHelp($status)
911 $this->useHelp = $status;
916 * @return bool ヘルプ機能を使用するかどうか
918 function getUseHelp()
920 return $this->useHelp;
923 * 表示するコンテンツにGoogleマップが含まれているかを設定
925 * @param bool $status Googleマップを含むかどうか
928 function setIsContentGooglemaps($status)
930 $this->isContentGooglemaps = $status; // コンテンツにGoogleマップが含むかどうか
933 * 表示するコンテンツにGoogleマップが含まれているかを取得
935 * @return bool ヘルプ機能を使用するかどうか
937 function isContentGooglemaps()
939 return $this->isContentGooglemaps;
942 * JavaScriptのブラウザキャッシュの使用可否を設定
944 * @param bool $status ブラウザキャッシュを使用するかどうか
947 function setHasScriptCache($status)
949 $this->hasScriptCache = $status;
956 function useBootstrap()
958 $this->useBootstrap = true; // Bootstrapを使用するかどうか
961 * Bootstrapを強制的に未使用に設定
965 function cancelBootstrap()
967 $this->useBootstrap = false; // Bootstrapを使用するかどうか
972 * @return bool true=使用、false=使用しない
974 function getUseBootstrap()
976 return $this->useBootstrap; // Bootstrapを使用するかどうか
985 $this->isHtml5 = true; // HTML5で出力するかどうか
988 * ページ作成処理を中断するかどうかを取得
990 * @return bool true=中断、false=継続
992 function isPageAbort()
994 return $this->isAbort;
999 * @param string $pos ポジション
1000 * @param int $index インデックス番号
1003 function getCurrentWidgetPosition(&$pos, &$index)
1005 $pos = $this->currentWidgetPosition; // 現在のウィジェットのポジション
1006 $index = $this->currentWidgetIndex; // 現在のウィジェットのポジション番号
1011 * @param int $defSerial ページ定義シリアル番号
1014 function updateParentWindow($defSerial = 0)
1016 $this->updateParentWindow = true;
1017 $this->updateDefSerial = $defSerial; // 更新する項目のページ定義シリアル番号
1022 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1025 function addCssFile($path)
1027 $destPath = trim($path, '/');
1028 if (!in_array($destPath, $this->defaultCssFiles)) $this->defaultCssFiles[] = $destPath;
1033 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1036 function addAdminCssFile($path)
1038 $destPath = trim($path, '/');
1039 if (!in_array($destPath, $this->defaultAdminCssFiles)) $this->defaultAdminCssFiles[] = $destPath;
1044 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1047 function addCkeditorCssFile($path)
1049 $destPath = trim($path, '/');
1050 if (!in_array($destPath, $this->ckeditorCssFiles)) $this->ckeditorCssFiles[] = $destPath;
1055 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1058 function addScriptFile($path)
1060 $destPath = trim($path, '/');
1061 if (!empty($destPath) && !in_array($destPath, $this->defaultScriptFiles)) $this->defaultScriptFiles[] = $destPath;
1066 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1069 function addAdminScriptFile($path)
1071 $destPath = trim($path, '/');
1072 if (!in_array($destPath, $this->defaultAdminScriptFiles)) $this->defaultAdminScriptFiles[] = $destPath;
1077 * @return array テンプレートID,サブテンプレートIDの配列
1079 function getOptionTemplateId()
1081 global $gEnvManager;
1084 $pageId = $gEnvManager->getCurrentPageId();
1086 switch ($this->contentType){
1087 case M3_VIEW_TYPE_CONTENT: // ページのコンテンツタイプ
1089 $contentLibObj = $this->gInstance->getObject(self::CONTENT_OBJ_ID);
1090 if (isset($contentLibObj)) list($this->optionTemplateId, $this->optionSubTemplateId) = $contentLibObj->getOptionTemplate();
1092 case M3_VIEW_TYPE_BLOG: // ページがブログタイプのとき
1093 if ($pageId == $this->gEnv->getDefaultPageId()){ // PCサイトのとき
1094 // ブログライブラリオブジェクトからテンプレートを取得
1095 $blogLibObj = $this->gInstance->getObject(self::BLOG_OBJ_ID);
1096 if (isset($blogLibObj)) list($this->optionTemplateId, $this->optionSubTemplateId) = $blogLibObj->getOptionTemplate();
1100 return array($this->optionTemplateId, $this->optionSubTemplateId);
1103 * 使用した非共通ウィジェットの数を取得
1105 * @return int ウィジェット数
1107 function getNonSharedWidgetCount()
1109 return $this->nonSharedWidgetCount;
1114 * @return string コンテンツタイプ
1116 function getContentType()
1118 return $this->contentType;
1121 * フロント画面で使用する主要コンテンツタイプの情報取得
1123 * @return array コンテンツタイプの情報の連想配列
1125 function getMainContentTypeInfo()
1127 return $this->mainContentTypeInfo; // 主要コンテンツタイプ
1130 * フロント画面で使用する補助コンテンツタイプの情報取得
1132 * @return array コンテンツタイプの情報の連想配列
1134 function getSubContentTypeInfo()
1136 return $this->subContentTypeInfo; // 補助コンテンツタイプ
1139 * フロント画面で使用する主要コンテンツタイプを取得
1141 * @return array コンテンツタイプの配列
1143 function getMainContentTypes()
1146 return array_map(create_function('$a', 'return $a["value"];'), $this->mainContentTypeInfo);
1149 * フロント画面で使用するサブコンテンツタイプを取得
1151 * @return array コンテンツタイプの配列
1153 function getSubContentTypes()
1156 return array_map(create_function('$a', 'return $a["value"];'), $this->subContentTypeInfo);
1159 * フロント画面で使用する主要機能タイプ情報を取得
1161 * @return array 機能タイプの情報の連想配列
1163 function getMainFeatureTypeInfo()
1165 return $this->mainFeatureTypeInfo; // 主要機能タイプ
1168 * フロント画面で使用する主要機能タイプを取得
1170 * @return array 機能タイプの配列
1172 function getMainFeatureTypes()
1175 return array_map(create_function('$a', 'return $a["value"];'), $this->mainFeatureTypeInfo);
1181 * @return array ページ属性情報の連想配列
1183 function getAllPageAttributeTypeInfo()
1185 return array_merge($this->mainContentTypeInfo, $this->subContentTypeInfo, $this->mainFeatureTypeInfo, $this->adminFeatureTypeInfo);
1188 * 管理画面用のサブメニューバーの定義を設定
1190 * @param array $def メニューバー定義
1193 function setAdminSubNavbarDef($def)
1195 $this->adminSubNavbarDef = $def;
1198 * 管理画面用のサブメニューバーの定義を取得
1200 * @return array メニューバーの定義
1202 function getAdminSubNavbarDef()
1204 return $this->adminSubNavbarDef;
1209 * @param array $def パンくずリスト定義
1210 * @param array $help ヘルプ(title,bodyの連想配列)
1213 function setAdminBreadcrumbDef($def, $help = array())
1215 $this->adminBreadcrumbDef = $def;
1216 if (!empty($help)) $this->adminBreadcrumbDefHelp = $help; // 管理画面用パンくずリストヘルプ定義
1221 * @param array $help ヘルプ(title,bodyの連想配列)
1222 * @return array パンくずリスト定義
1224 function getAdminBreadcrumbDef(&$help)
1227 $argNum = func_num_args();
1229 // ヘルプ取得用パラメータが存在する場合は定義を設定
1230 if ($argNum > 0) $help = $this->adminBreadcrumbDefHelp;
1232 return $this->adminBreadcrumbDef;
1237 * HTTPヘッダを設定する。セッションを取得する。サブページIDを設定する。
1239 * @param RequestManager $request HTTPリクエスト処理クラス
1242 function startPage($request)
1244 global $gEnvManager;
1245 global $gRequestManager;
1246 global $gInstanceManager;
1247 global $gAccessManager;
1248 global $gSystemManager;
1249 global $gDispManager;
1250 global $gOpeLogManager;
1253 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
1254 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
1255 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
1256 $pageId = $gEnvManager->getCurrentPageId();
1258 // ###### クライアントIDの読み込み、再設定 ######
1259 // この後、クライアントIDがアクセスログに記録される
1260 $clientId = $request->getCookieValue(M3_COOKIE_CLIENT_ID);
1261 if (empty($clientId)){ // クライアントIDが設定されていないとき(初回アクセス)
1263 $clientId = $this->gAccess->createClientId();
1265 $this->gAccess->setClientId($clientId); // クライアントIDを設定
1268 $this->gEnv->setCanUseCookie(true);
1270 $request->setCookieValue(M3_COOKIE_CLIENT_ID, $clientId, M3_COOKIE_EXPIRE_CLIENT_ID);
1272 // インストール時の管理画面用ライブラリを追加(フレームコンテナでの設定を反映)
1273 if (defined('M3_STATE_IN_INSTALL')){
1275 if ($this->useBootstrap){
1276 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
1277 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
1280 // 管理者キーがあればGETまたはPOST値のセッションIDを使用する
1281 if ($gEnvManager->isAdminDirAccess()){
1282 if ($gAccessManager->isValidAdminKey()) session_id($gRequestManager->trimValueOf(session_name()));
1286 // 最終HTML(ページ全体で使用するHTML)の出力
1287 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
1288 $gRequestManager->stopSessionUpdate(); // セッションの更新を停止
1294 // ##### インストール時はここで終了 #####
1295 if (defined('M3_STATE_IN_INSTALL')) return; // インストール時は実行しない
1297 // セッションを再生成する(セキュリティ対策)
1298 if ($gSystemManager->regenerateSessionId()){
1299 $gAccessManager->setOldSessionId(session_id()); // 古いセッションIDを保存
1300 session_regenerate_id(true);
1304 $userInfo = $gRequestManager->getSessionValueWithSerialize(M3_SESSION_USER_INFO);
1305 if (!$gAccessManager->checkSessionSecurity($userInfo)) return; // セキュリティ問題ありの場合はここで終了
1306 // ##### ここで終了した場合はページサブIDが未設定のためページ不正のエラーが発生しアクセスエラー画面が表示される #####
1308 // ##### POST時のリファラーチェック #####
1309 // WooCommerceのAJAX処理が通らないのでチェックしない?
1310 /* if ($gRequestManager->isPostMethod() && !$this->_checkReferer()){
1311 $errMsg = '不正なPOSTデータ(リファラー異常)を検出しました。アクセス元IP: ' . $gAccessManager->getClientIp();
1312 $msgDetail = 'アクセスをブロックしました。account=' . $userInfo->account . ', userid=' . $userInfo->userId;
1313 $gOpeLogManager->writeUserError(__METHOD__, $errMsg, 2210, $msgDetail);
1318 $gRequestManager->_doSessionOpenEventCallback();
1321 $gInstanceManager->setUserInfo($userInfo);
1323 // ##### 自動ログイン #####
1324 // ログイン中でない場合は自動ログインでユーザ情報を取得
1325 $gAccessManager->startAutoLogin();
1328 if (M3_SYSTEM_DEBUG) echo 'Debug mode<br />';
1330 // ##### ページIDの修正 #####
1331 // ポジション表示の場合はページID、ページサブIDを再設定。再設定はシステム管理者のみ可能。
1332 if (($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 管理画面(ウィジェットなしポジション表示)のとき
1333 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) && // 管理画面(ウィジェット付きポジション表示)のとき
1334 $gEnvManager->isSystemAdmin()){
1336 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1337 if (empty($pageId)) $pageId = $this->gEnv->getDefaultPageId(); // 値がないときはデフォルトのページIDを設定
1338 $this->gEnv->setCurrentPageId($pageId);
1339 $subId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1340 if (!empty($subId)) $this->gEnv->setCurrentPageSubId($subId);
1343 // ##### サブページIDの設定 #####
1344 if ($gEnvManager->isAdminDirAccess() && // 管理画面へのアクセスのとき
1345 ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT)){ // ログイン、ログアウト場合は管理画面のページサブIDを指定
1346 $subId = $gEnvManager->getAdminDefaultPageSubId(); // 管理画面用のデフォルトページサブID
1348 if (empty($subId)) $subId = $request->trimValueOf(M3_REQUEST_PARAM_PAGE_SUB_ID);// ページサブIDを取得
1350 if (empty($subId)){ // サブページIDが設定されていないとき
1351 // URLパラメータからコンテンツ形式を取得し、ページを選択
1352 $params = $gRequestManager->getQueryArray();
1353 $paramCount = count($params);
1355 // コマンド以外のパラメータ数が1つだけのときはパラメータからページ属性を判断する
1356 // 値が空でもキーがあれば属性を持つとする
1357 if ($paramCount == 0){
1358 $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1360 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemAdmin() && empty($task)){
1361 // ダッシュボード機能は、パラメータなし、管理者ディレクトリ、システム管理者の条件で使用可能
1362 // POST値にタスクがある場合はダッシュボードとしない
1363 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_DASHBOARD, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1365 } else if ($paramCount > 0 && !$gEnvManager->isAdminDirAccess()){ // パラメータ付きの場合(2013/3/23)
1366 // ##### ページ属性から画面を選択(管理画面は対応しない) ###
1367 // 最初のURLパラメータでコンテンツを判断
1368 // プレビュー(cmd=preview)等のパターンで複数パラメータがある
1370 $firstKey = key($params);
1371 $firstValue = $params[$firstKey];
1373 if (!empty($firstValue)){ // 「key=value」の形式であること
1375 case M3_REQUEST_PARAM_CONTENT_ID: // コンテンツIDのとき
1376 case M3_REQUEST_PARAM_CONTENT_ID_SHORT:
1377 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1378 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1379 if (!$checkStatus) return; // エラーの場合は終了
1381 // ローカルメニューのURLからページを特定。ページが特定できないときはページ属性で取得。
1382 $url = $gEnvManager->getMacroPath($gEnvManager->getCurrentRequestUri());
1383 $ret = $this->db->getSubPageIdByMenuItemUrl($url, $gEnvManager->getCurrentPageId(), M3_VIEW_TYPE_CONTENT, $rows);
1385 $rowCount = count($rows);
1386 for ($i = 0; $i < $rowCount; $i++){
1387 // コンテンツを表示するウィジェットがあるときはページサブIDを確定
1388 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);
1389 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);// コンテンツタイプでの取得に変更(2012/6/20)
1390 if (!empty($widgetId)){
1391 $subId = $rows[$i]['pd_sub_id'];
1396 if (empty($subId)) $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_CONTENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1397 $this->contentType = M3_VIEW_TYPE_CONTENT; // ページのコンテンツタイプ
1399 // コンテンツ詳細ページかどうかを設定
1400 if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT) $this->isContentDetailPage = true;
1402 case M3_REQUEST_PARAM_PRODUCT_ID: // 製品IDのとき
1403 case M3_REQUEST_PARAM_PRODUCT_ID_SHORT:
1404 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1405 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1406 if (!$checkStatus) return; // エラーの場合は終了
1408 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PRODUCT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1409 $this->contentType = M3_VIEW_TYPE_PRODUCT; // ページのコンテンツタイプ
1411 // コンテンツ詳細ページかどうかを設定
1412 $this->isContentDetailPage = true;
1414 case M3_REQUEST_PARAM_BBS_ID: // 掲示板投稿記事のとき
1415 case M3_REQUEST_PARAM_BBS_ID_SHORT:
1416 case M3_REQUEST_PARAM_BBS_THREAD_ID:
1417 case M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT:
1418 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1419 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1420 if (!$checkStatus) return; // エラーの場合は終了
1422 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BBS, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1423 $this->contentType = M3_VIEW_TYPE_BBS; // ページのコンテンツタイプ
1425 // コンテンツ詳細ページかどうかを設定
1426 if ($firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID || $firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT) $this->isContentDetailPage = true;
1428 case M3_REQUEST_PARAM_EVENT_ID: // イベント記事のとき
1429 case M3_REQUEST_PARAM_EVENT_ID_SHORT:
1430 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1431 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1432 if (!$checkStatus) return; // エラーの場合は終了
1434 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_EVENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1435 $this->contentType = M3_VIEW_TYPE_EVENT; // ページのコンテンツタイプ
1437 // コンテンツ詳細ページかどうかを設定
1438 $this->isContentDetailPage = true;
1440 case M3_REQUEST_PARAM_PHOTO_ID: // フォトギャラリー写真のとき
1441 case M3_REQUEST_PARAM_PHOTO_ID_SHORT:
1442 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1443 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1444 if (!$checkStatus) return; // エラーの場合は終了
1446 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PHOTO, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1447 $this->contentType = M3_VIEW_TYPE_PHOTO; // ページのコンテンツタイプ
1449 // コンテンツ詳細ページかどうかを設定
1450 $this->isContentDetailPage = true;
1452 case M3_REQUEST_PARAM_BLOG_ID: // ブログIDのとき
1453 case M3_REQUEST_PARAM_BLOG_ID_SHORT:
1454 case M3_REQUEST_PARAM_BLOG_ENTRY_ID:
1455 case M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT:
1456 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1457 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1458 if (!$checkStatus) return; // エラーの場合は終了
1460 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BLOG, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1461 $this->contentType = M3_VIEW_TYPE_BLOG; // ページのコンテンツタイプ
1463 // コンテンツ詳細ページかどうかを設定
1464 if ($firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT) $this->isContentDetailPage = true;
1466 case M3_REQUEST_PARAM_ROOM_ID: // ユーザ作成コンテンツのとき
1467 case M3_REQUEST_PARAM_ROOM_ID_SHORT:
1468 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1469 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1470 if (!$checkStatus) return; // エラーの場合は終了
1472 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_USER, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1473 $this->contentType = M3_VIEW_TYPE_USER; // ページのコンテンツタイプ
1475 // コンテンツ詳細ページかどうかを設定
1476 $this->isContentDetailPage = true;
1478 // コンテンツを表示するウィジェットを取得
1479 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);
1480 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);// コンテンツタイプでの取得に変更(2012/6/20)
1481 if (!empty($widgetId)){
1482 // ルーム用の定義ID(所属グループID)を取得
1483 $roomId = isset($params[M3_REQUEST_PARAM_ROOM_ID]) ? $params[M3_REQUEST_PARAM_ROOM_ID] : $params[M3_REQUEST_PARAM_ROOM_ID_SHORT];
1484 $configId = $this->db->getWidgetConfigIdForRoom($roomId);
1486 // グループIDを定義IDとするページのページサブIDを取得
1487 $subPageId = $this->getPageSubIdByWidget($gEnvManager->getCurrentPageId(), $widgetId, $configId);
1488 if (!empty($subPageId)) $subId = $subPageId;
1491 default: // オプションのURLコンテンツパラメータからサブページIDを取得
1492 $ret = $this->db->getSubPageIdByUrlContentParam($gEnvManager->getCurrentPageId(), $firstKey, $row);
1493 if ($ret) $subId = $row['pd_sub_id'];
1501 // 「http://www.example.com?ページ名」「wcmd」の場合はwikiコンテンツページを選択
1502 $wikiCmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND);
1503 $pageName = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
1505 if (!empty($wikiCmd) || !empty($pageName)){ // Wikiコンテンツページを指定のとき
1507 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_WIKI, $gEnvManager->getCurrentPageId());
1508 $this->contentType = M3_VIEW_TYPE_WIKI; // ページのコンテンツタイプ
1510 // コンテンツ詳細ページかどうかを設定
1511 $this->isContentDetailPage = true;
1514 // その他のGET,POSTパラメータからページサブID取得
1516 // 検索用パラメータなどでリダイレクト先のURLが取得できた場合は遷移
1517 $subId = $this->getPageSubIdByParam($request, $redirectUrl);
1518 if (!empty($subId) && !empty($redirectUrl)) $this->redirect($redirectUrl);
1521 // ページサブIDが取得できない場合はデフォルトを使用
1522 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
1523 } else { // ページサブIDが設定されているとき
1524 // URLパラメータからコンテンツ形式を取得し、ページを選択
1525 $params = $gRequestManager->getQueryArray();
1526 $paramCount = count($params);
1527 if ($paramCount == 1) $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1530 $gEnvManager->setCurrentPageSubId($subId);// サブページIDを設定
1532 // SSL通信機能がオンの場合は、アクセスされたURLのSSLをチェックし不正の場合は正しいURLにリダイレクト
1533 // 設定に間違いがある場合、管理画面にアクセスできなくなるので、フロント画面のみ制御
1534 // if ($gEnvManager->getUseSsl() || $gEnvManager->getUseSslAdmin()){
1535 if ($gEnvManager->getUseSsl()){ // フロント画面のSSL設定のみチェック(2016/7/30)
1536 if (!$gEnvManager->isAdminDirAccess()){ // 管理画面以外へのアクセスのとき
1537 // ルートURLがSSLの場合はSSLに固定
1538 if ($gEnvManager->isRootUrlSsl()){ // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
1541 $isSsl = $gEnvManager->isSslByCurrentPage();
1543 $currentUrl = $gEnvManager->getCurrentRequestUri();
1545 $correctUrl = str_replace('http://', 'https://', $currentUrl);
1547 $correctUrl = str_replace('https://', 'http://', $currentUrl);
1549 if ($currentUrl != $correctUrl) $this->redirect($correctUrl);
1553 $gEnvManager->initMultiDomain();
1556 $gDispManager->load();
1558 // ##### 画面に必要なスクリプトを追加 #####
1559 // スマートフォン用URLのときはスマートフォン用のjQueryを使用
1560 if ($gEnvManager->getIsSmartphoneSite()){
1561 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(10); // スマートフォン用jQueryファイル
1563 if (isset($this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'])){
1564 $scriptFiles = $this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'];
1565 if (count($scriptFiles) > 0) $this->selectedJQueryMobileFilename = $scriptFiles[0]; // 使用対象のjQueryMobileファイル
1569 // Magic3管理用のスクリプトを追加
1570 if (!$gEnvManager->getIsMobileSite()){ // 携帯用URL以外のとき
1571 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
1572 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
1573 // $this->isEditMode = true; // フロント画面編集モード
1574 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定(コンテキストメニュー表示)
1577 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1578 $this->addAdminScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1580 // Googleマップライブラリの読み込み
1581 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1582 $this->defaultAdminScriptFiles[] = ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS);
1584 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1585 $this->isLayout = true; // 画面レイアウト中かどうか
1586 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_IDTABS); // 管理パネル用スクリプト追加(ポジション表示追加分)
1587 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_DROPDOWN); // 管理パネル用スクリプト追加(ドロップダウンメニュー)
1588 //$this->useBootstrap = true; // Bootstrapを使用
1589 //$this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1591 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1592 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1594 // スクリプトが必要なウィジェットをすべて取得
1595 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1596 for ($i = 0; $i < count($rows); $i++){
1597 $this->addAdminScript($task, trim($rows[$i]['wd_add_script_lib']));
1599 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1601 $widgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
1602 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
1603 if ($ret) $this->addAdminScript($task, trim($this->configWidgetInfo['wd_add_script_lib_a'])); // 管理機能用スクリプト
1606 } else { // フロント画面へのアクセスのとき
1607 // フロント画面用スクリプトファイル追加
1608 $value = $gSystemManager->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
1609 if ($value) $this->addScriptFile($this->selectedJQueryFilename);
1611 if ($cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
1612 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
1613 if ($gEnvManager->isSystemManageUser()){
1614 $this->isEditMode = true; // フロント画面編集モード
1615 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定
1617 // システム運用権限がある場合は管理用スクリプトを追加
1618 // フロント画面と管理画面の切り替え用のスライドメニューバーには管理用スクリプト,CSSが必要
1619 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1620 $this->addScriptFile(ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME); // jQuery Contextmenu Lib
1621 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1622 //$this->addScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1623 $this->addScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用スクリプト追加
1624 $this->addScript('', ScriptLibInfo::LIB_JQUERY_COOKIE); // 管理パネル用スクリプト追加
1625 $this->addScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用スクリプト追加
1626 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1627 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1629 $this->addCssFile(self::M3_ADMIN_CSS_FILE); // 管理機能用CSS
1630 } else if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1631 $this->isEditMode = true; // フロント画面編集モード
1633 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
1634 if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1635 $this->isEditMode = true; // フロント画面編集モード
1637 // $this->addScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
1638 $this->addScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1639 // $this->addScriptFile(self::M3_PLUS_SCRIPT_FILENAME); // フロント画面追加用スクリプト追加(PLUSライブラリを追加する場合はFCKEditorも使用可能にする)
1640 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1641 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
1642 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1643 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1645 // Googleマップライブラリの読み込み
1646 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1647 $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS));
1655 $row = $this->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
1657 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1658 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1661 $this->currentPageInfo = $row; // 現在のページのページ情報
1664 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1665 /* $defPageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1666 $defPageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1669 $row = $this->getPageInfo($defPageId, $defPageSubId);
1671 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1672 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1675 $this->currentPageInfo = $row; // 現在のページのページ情報
1679 // $ret = $this->db->getPageDefOnPage($defPageId, $defPageSubId, $rows);
1680 $ret = $this->db->getPageDefOnPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1682 for ($i = 0; $i < count($rows); $i++){
1683 $position = $rows[$i]['pd_position_id'];
1684 if (!in_array($position, $this->defPositions)) $this->defPositions[] = $position; // 画面定義データのポジション(すべて)
1690 if ($openBy == 'tabs') $this->isTransparentMode = true; // 画面透過モード
1693 * URLの最初のパラメータが不正文字の場合はエラー画面へリダイレクト
1695 * @param string $value URLの最初のパラメータ値
1696 * @return bool true=正常、false=異常
1698 function _checkFirstValueRedirect($value)
1700 global $gEnvManager;
1701 global $gOpeLogManager;
1703 // 半角英小文字大文字、数字、アンダーバー、ハイフン、カンマのみ使用可能。
1704 if (preg_match("/[^0-9a-zA-Z-_,]/", $value)){
1705 $errMessage = 'URLパラメータの不正。';
1706 $gOpeLogManager->writeUserAccess(__METHOD__, '不正なアクセスを検出しました。' . $errMessage, 2200, 'アクセスをブロックしました。URL: ' . $gEnvManager->getCurrentRequestUri());
1708 // $this->redirect('?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=_accessdeny');
1710 $this->isSystemPage = true;
1723 global $gEnvManager;
1724 global $gSystemManager;
1726 $lang = $gEnvManager->getCurrentLanguage();
1728 // デフォルト言語とカレント言語が異なる場合のみ実行
1729 if ($lang != $gEnvManager->getDefaultLanguage()){
1731 $gSystemManager->roadSiteDefByLang($lang);
1735 $this->headDescription = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_DESCRIPTION); // HTMLヘッダ「description」に出力する文字列
1736 $this->headKeywords = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_KEYWORDS); // HTMLヘッダ「keywords」に出力する文字列
1737 $this->headOthers = $gSystemManager->getSiteDef(self::SD_HEAD_OTHERS); // HTMLヘッダに出力するタグ文字列
1739 // デフォルトのページ情報でヘッダを更新
1740 if (!empty($this->currentPageInfo)){
1741 $title = $this->currentPageInfo['pn_meta_title']; // 画面タイトル
1742 $desc = $this->currentPageInfo['pn_meta_description']; // ページ要約
1743 $keyword = $this->currentPageInfo['pn_meta_keywords']; // ページキーワード
1744 $headOthers = $this->currentPageInfo['pn_head_others']; // ヘッダその他タグ
1746 if (!empty($title)) $this->setHeadSubTitle($title);
1747 if (!empty($desc)) $this->setHeadDescription($desc);
1748 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1749 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1752 // 現在の言語のページ情報でヘッダを更新
1753 $ret = $this->db->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $lang, $row);
1755 $title = $row['pn_meta_title']; // 画面タイトル
1756 $desc = $row['pn_meta_description']; // ページ要約
1757 $keyword = $row['pn_meta_keywords']; // ページキーワード
1758 $headOthers = $row['pn_head_others']; // ヘッダその他タグ
1760 if (!empty($title)) $this->setHeadSubTitle($title);
1761 if (!empty($desc)) $this->setHeadDescription($desc);
1762 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1763 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1766 // $this->currentPageInfo = $row; // 現在のページのページ情報
1770 * スクリプト追加情報から、管理機能用のJavascriptファイル、CSSを追加する
1772 * @param string $task 指定タスク
1773 * @param string $scriptInfo スクリプト追加情報
1776 function addAdminScript($task, $scriptInfo)
1778 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1779 for ($i = 0; $i < count($itemArray); $i++){
1780 $pos = strpos($itemArray[$i], '=');
1781 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1782 $libs = trim($itemArray[$i]);
1783 } else { // タスク指定のとき
1784 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1785 $libTask = trim($libTask);
1786 $libs = trim($libs);
1788 if (strEndsWith($libTask, '_')){ // 「task_subtask」形式のタスクのとき
1789 if (!strStartsWith($task, $libTask)) $libs = ''; // タスクIDの先頭部が異なるときは追加しない
1791 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1794 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1795 $libsArray = explode(',', $libs);
1796 for ($j = 0; $j < count($libsArray); $j++){
1797 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1800 $setLibArray = ScriptLibInfo::getLibSet($lib);
1801 $setLibCount = count($setLibArray);
1802 if ($setLibCount > 0){ // ライブラリセットの場合
1803 for ($k = 0; $k < $setLibCount; $k++){
1804 $this->_addAdminScript($setLibArray[$k]);
1807 $this->_addAdminScript($lib);
1814 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1816 * @param string $lib ライブラリID
1819 function _addAdminScript($lib)
1822 if (!isset($this->libFiles[$lib])) return;
1825 // if (strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1826 // jQuery UIライブラリを追加
1827 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1828 if (isset($dependentLib)){
1829 for ($i = 0; $i < count($dependentLib); $i++){
1830 $addLib = $dependentLib[$i];
1833 if (isset($this->libFiles[$addLib]['script'])){
1834 $scriptFiles = $this->libFiles[$addLib]['script'];
1835 for ($m = 0; $m < count($scriptFiles); $m++){
1836 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1840 if (isset($this->libFiles[$addLib]['script_lang'])){
1841 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1842 for ($m = 0; $m < count($scriptFiles); $m++){
1843 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1847 if (isset($this->libFiles[$addLib]['css'])){
1848 $cssFiles = $this->libFiles[$addLib]['css'];
1849 for ($m = 0; $m < count($cssFiles); $m++){
1850 $this->addAdminCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1855 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1856 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1857 $this->outputTheme = true;
1862 if (isset($this->libFiles[$lib]['script'])){
1863 $scriptFiles = $this->libFiles[$lib]['script'];
1865 // ##### ライブラリ情報を作成する場合 #####
1866 if (empty($scriptFiles)){
1867 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
1868 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
1871 for ($i = 0; $i < count($scriptFiles); $i++){
1872 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1876 if (isset($this->libFiles[$lib]['script_lang'])){
1877 $scriptFiles = ScriptLibInfo::getLangScript($lib);
1878 for ($i = 0; $i < count($scriptFiles); $i++){
1879 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1883 if (isset($this->libFiles[$lib]['css'])){
1884 $cssFiles = $this->libFiles[$lib]['css'];
1885 for ($i = 0; $i < count($cssFiles); $i++){
1886 $this->addAdminCssFile($cssFiles[$i]); // 管理機能用のCSS追加
1890 if (strncmp($lib, 'jquery-ui.', 10) == 0){ // jQuery UIのwidgetsまたはeffectsのとき。jQuery UI Coreはデフォルトで読み込まれている。
1892 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1893 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1894 $this->outputTheme = true;
1899 * スクリプト追加情報から、通常機能用のJavascriptファイル、CSSを追加する
1901 * @param string $task 指定タスク
1902 * @param string $scriptInfo スクリプト追加情報
1905 function addScript($task, $scriptInfo)
1907 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1908 for ($i = 0; $i < count($itemArray); $i++){
1909 $pos = strpos($itemArray[$i], '=');
1910 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1911 $libs = trim($itemArray[$i]);
1912 } else { // タスク指定のとき
1913 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1914 $libTask = trim($libTask);
1915 $libs = trim($libs);
1916 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1918 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1919 $libsArray = explode(',', $libs);
1920 for ($j = 0; $j < count($libsArray); $j++){
1921 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1923 // jQueryライブラリ等、デフォルトでは追加されないライブラリを追加
1924 $setLibArray = ScriptLibInfo::getLibSet($lib);// ライブラリセットを展開
1925 $setLibCount = count($setLibArray);
1926 if ($setLibCount > 0){ // ライブラリセットの場合
1927 for ($k = 0; $k < $setLibCount; $k++){
1928 $this->_addScript($setLibArray[$k]);
1931 $this->_addScript($lib);
1938 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1940 * @param string $lib ライブラリID
1943 function _addScript($lib)
1946 if (!isset($this->libFiles[$lib])) return;
1948 // ライブラリの依存ライブラリファイルを追加
1949 if (strcmp($lib, 'jquery') == 0){// jQuery本体のとき
1950 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1951 } else if (strncmp($lib, 'jquery.', 7) == 0){ // jQueryプラグインのとき
1952 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1953 if (strcmp($lib, 'jquery.mobile') == 0){ // jQueryMobileファイルのとき
1954 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
1955 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
1956 for ($i = 0; $i < count($this->headPreMobileScriptFiles); $i++){
1957 $this->addScriptFile($this->headPreMobileScriptFiles[$i]); // 通常機能用のスクリプト追加
1962 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1963 if (isset($dependentLib)){
1964 for ($i = 0; $i < count($dependentLib); $i++){
1965 $addLib = $dependentLib[$i];
1968 if (isset($this->libFiles[$addLib]['script'])){
1969 $scriptFiles = $this->libFiles[$addLib]['script'];
1970 for ($m = 0; $m < count($scriptFiles); $m++){
1971 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1975 if (isset($this->libFiles[$addLib]['script_lang'])){
1976 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1977 for ($m = 0; $m < count($scriptFiles); $m++){
1978 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1982 if (isset($this->libFiles[$addLib]['css'])){
1983 $cssFiles = $this->libFiles[$addLib]['css'];
1984 for ($m = 0; $m < count($cssFiles); $m++){
1985 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1991 } else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI) == 0){ // jQuery UI
1992 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1993 //} else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI_PLUS) == 0){ // jQuery UI plus
1994 // $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1995 // $this->addScriptFile($this->selectedJQueryUiFilename); // jQuery Coreスクリプト追加
1996 } else if (strncmp($lib, 'jquery-ui.', 10) == 0 || // jQuery UIのwidgetsまたはeffectsのとき
1997 strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
2000 if (strncmp($lib, 'jquery-ui.', 10) == 0){
2001 $jQueryUiInfo = ScriptLibInfo::getJQueryUiInfo();// ライブラリ情報取得
2002 $dependentLib = $jQueryUiInfo[$lib]; // 依存ライブラリ取得
2004 $dependentLib = ScriptLibInfo::getDependentLib($lib);
2006 for ($i = 0; $i < count($dependentLib); $i++){
2007 $addLib = $dependentLib[$i];
2010 if (isset($this->libFiles[$addLib]['script'])){
2011 $scriptFiles = $this->libFiles[$addLib]['script'];
2012 for ($m = 0; $m < count($scriptFiles); $m++){
2013 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
2017 if (isset($this->libFiles[$addLib]['script_lang'])){
2018 $scriptFiles = ScriptLibInfo::getLangScript($addLib);;
2019 for ($m = 0; $m < count($scriptFiles); $m++){
2020 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
2024 if (isset($this->libFiles[$addLib]['css'])){
2025 $cssFiles = $this->libFiles[$addLib]['css'];
2026 for ($m = 0; $m < count($cssFiles); $m++){
2027 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
2032 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
2033 $this->addCssFile($this->getDefaultThemeUrl()); // 通常機能用のCSS追加
2034 $this->outputTheme = true;
2039 if (isset($this->libFiles[$lib]['script'])){
2040 $scriptFiles = $this->libFiles[$lib]['script'];
2042 // ##### ライブラリ情報を作成する場合 #####
2043 if (empty($scriptFiles)){
2044 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
2045 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2048 for ($i = 0; $i < count($scriptFiles); $i++){
2049 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
2053 if (isset($this->libFiles[$lib]['script_lang'])){
2054 $scriptFiles = ScriptLibInfo::getLangScript($lib);
2055 for ($i = 0; $i < count($scriptFiles); $i++){
2056 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
2060 if (isset($this->libFiles[$lib]['css'])){
2061 $cssFiles = $this->libFiles[$lib]['css'];
2062 for ($i = 0; $i < count($cssFiles); $i++){
2063 $this->addCssFile($cssFiles[$i]); // 通常機能用のCSS追加
2068 * 非ログイン時の管理機能用のJavascriptファイル、CSSを追加する
2070 * @param array, string $lib 追加ライブラリID
2073 function addPermittedAdminScript($lib)
2075 if (is_array($lib)){
2076 for ($j = 0; $j < count($lib); $j++){
2080 if (isset($this->libFiles[$libId]['script'])){
2081 $scriptFiles = $this->libFiles[$libId]['script'];
2083 // ##### ライブラリ情報を作成する場合 #####
2084 if (empty($scriptFiles)){
2085 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
2086 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2089 for ($i = 0; $i < count($scriptFiles); $i++){
2090 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2094 if (isset($this->libFiles[$libId]['script_lang'])){
2095 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2096 for ($i = 0; $i < count($scriptFiles); $i++){
2097 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2101 if (isset($this->libFiles[$libId]['css'])){
2102 $cssFiles = $this->libFiles[$libId]['css'];
2103 for ($i = 0; $i < count($cssFiles); $i++){
2104 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2112 if (isset($this->libFiles[$libId]['script'])){
2113 $scriptFiles = $this->libFiles[$libId]['script'];
2115 // ##### ライブラリ情報を作成する場合 #####
2116 if (empty($scriptFiles)){
2117 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
2118 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2121 for ($i = 0; $i < count($scriptFiles); $i++){
2122 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2126 if (isset($this->libFiles[$libId]['script_lang'])){
2127 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2128 for ($i = 0; $i < count($scriptFiles); $i++){
2129 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2133 if (isset($this->libFiles[$libId]['css'])){
2134 $cssFiles = $this->libFiles[$libId]['css'];
2135 for ($i = 0; $i < count($cssFiles); $i++){
2136 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2146 * ・ウィジェットで生成されたHTTPヘッダを設定する
2148 * @param RequestManager $request HTTPリクエスト処理クラス
2149 * @param bool $getOutput 出力を取得するかどうか
2150 * @return string 最終出力HTML
2152 function endPage($request, $getOutput = false)
2154 global $gRequestManager;
2155 global $gInstanceManager;
2156 global $gEnvManager;
2157 global $gDispManager;
2158 global $gAccessManager;
2161 if ($this->isAbort) return '';
2166 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2168 // 最終HTML(ページ全体で使用するHTML)の出力
2169 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
2171 if (count($this->exportCss) > 0){
2172 for ($i = 0; $i < count($this->exportCss); $i++){
2173 $contents .= $this->exportCss[$i] . M3_NL;
2178 header('Content-type: text/css');
2180 // 画面情報、ユーザ情報の保存は行わない
2182 } else if ($cmd != M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体オペレーションのときは出力しない
2184 $contents = $this->getLastContents($request);
2186 echo $this->getLastContents($request);
2191 $userInfo = $gInstanceManager->getUserInfo();
2192 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2195 $gRequestManager->_doSessionCloseEventCallback();
2198 $gDispManager->save();
2200 // キャッシュリミッタは、各リクエスト毎に(アウトプットバッファー が無効な場合は、
2201 // session_start()がコールされる 前に) session_cache_limiter()をコールする必要がある。
2203 // session_cache_limiter('private');
2204 // session_cache_expire(5);
2205 if ($this->isRedirect) return ''; // リダイレクトの場合は終了
2207 // ########## HTTPヘッダ出力処理 ########
2208 if (headers_sent($filename, $linenum)){ // HTTPヘッダが既に送信されているとき
2209 echo "$filename の $linenum 行目でヘッダがすでに送信されています。";
2211 if ($gEnvManager->isMobile()){ // 携帯の場合
2212 // ドコモ端末の場合はリクエストヘッダにXHTMLを指定しないとXHTMLを処理しない
2213 $agent = $gInstanceManager->getMobileAgent();
2214 if ($agent->isDoCoMo()){ // ドコモ端末のとき
2215 header('Content-Type: application/xhtml+xml;');
2219 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// 過去の日付
2220 header('Cache-Control: no-store, no-cache, must-revalidate');// HTTP/1.1
2221 header('Cache-Control: post-check=0, pre-check=0', false);
2222 header('Pragma: no-cache');
2225 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
2227 // Ajax用JSON型データをHTTPヘッダに格納
2228 $gInstanceManager->getAjaxManager()->header();
2230 // システム制御画面が設定されている場合はステータスコードを変更
2231 //if ($this->gEnv->getIsMaintenance()){
2232 if (!$this->isRedirect){ // リダイレクトがセットされていない場合
2233 switch ($this->systemHandleMode){
2234 case 10: // サイト非公開(システムメンテナンス)
2235 header('HTTP/1.1 503 Service Temporarily Unavailable');
2236 header('Status: 503 Service Temporarily Unavailable');
2238 case 11: // アクセス禁止のとき
2239 header('HTTP/1.1 403 Forbidden');
2240 header('Status: 403 Forbidden');
2242 case 12: // 存在しないページのとき
2243 header("HTTP/1.1 404 Not Found");
2244 header("Status: 404 Not Found");
2249 // ##### 自動ログイン #####
2250 $gAccessManager->endAutoLogin();
2257 * 注意)exitSystem()でシステムを終了させる必要あり
2261 function abortPage()
2263 global $gInstanceManager;
2264 global $gRequestManager;
2266 // HTTPヘッダを削除(PHP 5.3以上で有効)
2267 if (version_compare(PHP_VERSION, '5.3.0') >= 0) header_remove();
2269 // exit()等でabortPage()が最後の処理になってしまう可能性があるのでなるべく必要な処理を行う
2270 //if (ob_get_level() > 0) ob_end_clean();// バッファ内容が残っているときは破棄
2271 while (ob_get_level()) ob_end_clean(); // バッファ削除方法変更(2009/12/2)
2274 $userInfo = $gInstanceManager->getUserInfo();
2275 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2278 $gRequestManager->_doSessionCloseEventCallback();
2280 $this->isAbort = true; // ページ作成処理を中断するかどうか
2287 function abortWidget()
2289 $this->isWidgetAbort = true; // 各ウィジェット処理を中断するかどうか
2296 function exitSystem()
2298 global $gEnvManager;
2299 global $gAccessManager;
2301 // DBが使用可能であれば、アクセスログのユーザを登録
2302 if ($gEnvManager->canUseDb()) $gAccessManager->accessLogUser();
2307 * Joomla!v1.5タグを読み込んでウィジェット実行
2309 * @param string $srcBuf バッファデータ
2310 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
2311 * @return string 変換後文字列
2313 function launchWidgetByJoomlaTag($srcBuf, $templateVer)
2319 if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\s*\/>#iU', $srcBuf, $matches)){
2320 $count = count($matches[1]);
2321 for ($i = 0; $i < $count; $i++)
2324 $type = $matches[1][$i];
2326 if (strcasecmp($type, 'head') == 0){ // ヘッダ埋め込みタグの場合
2329 $contents = ob_get_contents();
2330 } else if (strcasecmp($type, 'modules') == 0 || strcasecmp($type, 'module') == 0 || // 一般ウィジェット用配置ブロックの場合
2331 strcasecmp($type, 'navmenu') == 0){ // ナビゲーションメニューウィジェット用配置ブロックの場合
2332 $name = ''; // ポジション名
2333 $posType = ''; // ポジションのタイプ
2334 $style = ''; // 表示スタイル
2335 $params = explode(' ', $matches[2][$i]);
2336 $paramArray = array();
2337 for ($j = 0; $j < count($params); $j++){
2338 list($key, $value) = explode('=', $params[$j]);
2340 $value = trim($value, "\"'");
2341 if (!empty($key)) $paramArray[$key] = $value;
2343 $value = $paramArray['name'];
2346 $attr['name'] = $value;
2348 $value = $paramArray['type']; // 配置ブロックのタイプを属性に格納。テンプレート内での参照用。
2351 $attr['type'] = $value;
2353 $value = $paramArray['id'];
2354 if (isset($value)) $attr['id'] = $value;
2356 // スタイルが設定されている場合はオプションスタイルを取得
2357 $value = $paramArray['style'];
2360 $attr['style'] = $value;
2362 $optionStyle = $paramArray[$value]; // オプションのスタイル
2363 if (isset($optionStyle)) $attr[$value] = $optionStyle;
2365 /* for ($j = 0; $j < count($params); $j++){
2366 list($key, $value) = explode('=', $params[$j]);
2367 if (strcasecmp($key, 'name') == 0){
2368 $name = strtolower(trim($value, "\"'"));
2369 $attr['name'] = $name;
2370 } else if (strcasecmp($key, 'style') == 0){
2372 $style = trim($value, "\"'");
2373 } else if (strcasecmp($key, 'artstyle') == 0){ // テンプレート側指定の表示スタイル(Artisteer用)
2374 $attr['artstyle'] = trim($value, "\"'");
2375 } else if (strcasecmp($key, 'bootstyle') == 0){ // テンプレート側指定の表示スタイル(Bootstrap用)
2376 $attr['bootstyle'] = trim($value, "\"'");
2377 } else if (strcasecmp($key, 'drstyle') == 0){ // テンプレート側指定の表示スタイル(Themer用)
2378 $attr['drstyle'] = trim($value, "\"'");
2382 if (!empty($name)){ // ポジション名が取得できたとき
2383 // Joomla!では、テンプレートの「jdoc:include」タグの属性styleが空のときは「none」で処理される
2384 // Joomla!デフォルトで設定可能なのは「none,table,horz,xhtml,rounded,outline」
2385 /* if (empty($style)){
2386 if (strStartsWith($name, 'user') || // ナビゲーションメニュー位置の場合
2387 strcasecmp($name, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
2388 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2393 if (strcasecmp($type, 'navmenu') == 0){ // メニューウィジェット用配置ブロックの場合
2394 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2395 $attr['type'] = $type; // テンプレート内での参照用
2396 } else if (strcasecmp($name, 'user3') == 0 || // ナビゲーションメニュー位置の場合
2397 strcasecmp($name, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
2398 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
2399 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2400 } else if (empty($style)){
2404 $contents = $this->getContents($name, $style, $templateVer, $attr);
2406 } else if (strcasecmp($type, 'component') == 0){ // メインポジションタグの場合
2408 $style = ''; // 表示スタイル
2409 $params = explode(' ', $matches[2][$i]);
2410 for ($j = 0; $j < count($params); $j++){
2411 list($key, $value) = explode('=', $params[$j]);
2412 if (strcasecmp($key, 'style') == 0){
2414 $style = trim($value, "\"'");
2418 if ($style != 'none') $style = 'xhtml';
2419 $contents = $this->getContents('main', $style, $templateVer, $attr);
2420 } else if (strcasecmp($type, 'message') == 0){ // メッセージタグの場合
2422 $replace[$i] = $contents;
2425 $destBuf = str_replace($matches[0], $replace, $srcBuf);
2432 * 遅延実行インデックスのついているウィジェットをインデックス順に実行し、出力バッファデータ内のタグの位置に出力を埋め込む
2434 * @param RequestManager $request HTTPリクエスト処理クラス
2435 * @param string $srcBuf バッファデータ
2436 * @return string 変換後文字列
2438 function lateLaunchWidget($request, $srcBuf)
2440 global $gEnvManager;
2441 global $gErrorManager;
2442 global $gDesignManager;
2444 // ページ作成中断またはウィジェット処理中断のときは終了
2445 if ($this->isAbort || $this->isWidgetAbort) return '';
2447 // ウィジェットヘッダ(Joomla!1.0用)を出力のタイプを取得
2448 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
2450 // 遅延実行ウィジェットをインデックス順にソート
2451 asort($this->lateLaunchWidgetList, SORT_NUMERIC);
2455 foreach ($this->lateLaunchWidgetList as $widgetId => $value){
2457 $count = count($this->latelaunchWidgetParam);
2458 for ($i = 0; $i < $count; $i++){
2459 list($wId, $maxNo, $confId, $preId, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $pageDefRec) = $this->latelaunchWidgetParam[$i];
2460 if ($wId == $widgetId){
2462 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
2463 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
2464 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
2467 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
2468 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
2474 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
2477 $configId = $confId; // ウィジェット定義ID
2478 if ($configId == 0) $configId = '';
2479 $prefix = $preId; // サフィックス文字列
2481 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
2482 $joomlaTitleVisble = false;
2483 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
2484 if (!empty($title)){
2485 if ($widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2486 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
2487 echo '<tr><th>' . $title . '</th></tr>' . M3_NL;
2488 echo '<tr><td>' . M3_NL;
2489 $joomlaTitleVisble = true;
2490 } else if ($widgetHeaderType == 2){ // 携帯用ウィジェットヘッダ出力
2491 echo '<div>' . $title . '</div>' . M3_NL;
2492 $joomlaTitleVisble = true;
2497 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
2498 // ウィジェット親のCSS定義があるときは、タグを追加
2499 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
2502 echo $gDesignManager->getAdditionalWidgetOutput(true);
2505 $gEnvManager->setCurrentWidgetId($widgetId);
2508 $gEnvManager->setCurrentWidgetConfigId($configId);
2511 $gEnvManager->setCurrentPageDefSerial($serial);
2514 $gEnvManager->setCurrentPageDefRec($pageDefRec);
2517 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
2520 $gEnvManager->setCurrentWidgetTitle('');
2523 $gEnvManager->setCurrentWidgetStyle($style);
2525 // ウィジェットのグローバル属性状況を設定
2526 $gEnvManager->setIsCurrentWidgetShared($shared);
2529 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
2532 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
2533 $msg = 'widget-start(' . $widgetId . ')';
2534 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2535 require($widgetIndexFile);
2536 $msg = 'widget-end(' . $widgetId . ')';
2537 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2540 $gEnvManager->setCurrentWidgetId('');
2543 $gEnvManager->setCurrentWidgetConfigId('');
2546 $gEnvManager->setCurrentPageDefSerial(0);
2549 $gEnvManager->setCurrentPageDefRec();
2552 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
2555 $gEnvManager->setCurrentWidgetStyle('');
2557 // ウィジェットのグローバル属性状況を解除
2558 $gEnvManager->setIsCurrentWidgetShared(false);
2561 $newTitle = $gEnvManager->getCurrentWidgetTitle();
2564 echo $gDesignManager->getAdditionalWidgetOutput(false);
2566 // ウィジェット親のCSS定義があるときは、タグを追加
2567 if (!empty($cssStyle)) echo '</div>' . M3_NL;
2569 //echo '</div>' . M3_NL;
2571 // Joomla!1.0テンプレートのときはタイトルを出力
2572 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2573 echo '</td></tr>' . M3_NL;
2574 echo '</table>' . M3_NL;
2577 // 現在のバッファ内容を取得し、バッファを破棄
2578 $srcContents = ob_get_contents();
2582 $tag = self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
2583 $destBuf = str_replace($tag, $srcContents, $destBuf);
2586 if (!empty($newTitle)) $title = $newTitle;
2587 $tag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
2588 $destBuf = str_replace($tag, $title, $destBuf);
2590 // ##### 外部出力用のCSSがある場合は追加 #####
2591 if (!empty($exportCss)){
2593 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $index; // ウィジェット識別用ユニークタグ
2594 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
2595 $this->addExportCss($exportCss);
2601 // ##### HTMLヘッダ出力処理 #####
2602 $destBuf = $this->replaceHead($destBuf);
2609 * @param string $jobType ジョブタイプ
2612 function launchJob($jobType)
2614 global $gEnvManager;
2616 // ジョブタイプから実行するウィジェットIDを取得
2617 $widgetId = $this->getWidgetIdByJobType($jobType);
2618 if (empty($widgetId)) return;
2621 $gEnvManager->setCurrentWidgetId($widgetId);
2624 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/admin/job.php';
2626 if (file_exists($widgetIndexFile)){
2628 // $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd);
2630 require_once($widgetIndexFile);
2632 echo 'file not found: ' . $widgetIndexFile;
2636 $gEnvManager->setCurrentWidgetId();
2641 * @param string $srcBuf 変換元
2642 * @return string 変換後文字列
2644 function replaceHead($srcBuf)
2648 // ##### ヘッダ部分の置換 #####
2649 if ($this->outputHead){ // HTMLヘッダ出力を行っているとき
2651 $replaceStr = $this->getHeaderOutput();
2654 $destBuf = str_replace(self::HEAD_TAGS, $replaceStr, $destBuf);
2656 $this->replaceHeadDone = true; // ヘッダマクロ変換処理が完了したかどうか
2664 function enableReplaceHead()
2666 $this->outputHead = true;
2669 * ウィジェット検索モードの場合のページサブIDの設定
2671 * @param RequestManager $request HTTPリクエスト処理クラス
2673 function redirectToUpdatedPageSubId($request)
2675 global $gEnvManager;
2677 // 現在設定されているページIDを取得
2678 $pageId = $gEnvManager->getCurrentPageId();
2679 $pageSubId = $gEnvManager->getCurrentPageSubId();
2682 $fromWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_FROM);
2685 $targetWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
2687 // 対象のウィジェットのページサブIDを取得
2688 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2689 if ($ret){// データが存在する
2690 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2691 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2692 if ($ret){// データが存在する
2693 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2695 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2700 for ($i = 0; $i < count($rows); $i++){
2701 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2706 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2707 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2709 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2712 } else { // 対象のウィジェットが見つからない場合は、互換ウィジェットを探す
2713 $widgetId = $this->db->getCompatibleWidgetId($targetWidgetId);
2714 if (!empty($widgetId)){
2715 $targetWidgetId = $widgetId;
2717 // 対象のウィジェットのページサブIDを取得
2718 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2719 if ($ret){// データが存在する
2720 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2721 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2722 if ($ret){// データが存在する
2723 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2725 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2730 for ($i = 0; $i < count($rows); $i++){
2731 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2736 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2737 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2739 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2745 // ページサブIDが見つからないときは、既に設定されている値を使用
2746 // 既に設定されている値は、URL「sub」パラメータで指定されている値か
2747 // 設定されていない場合はデフォルトのサブページID
2748 // ********** 指定ページへリダイレクト ***********
2750 $todo = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TODO);
2751 $todo = str_replace(M3_TODO_SEPARATOR, '&', $todo); // セパレータを変換
2752 // $redirectUrl = '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2753 $redirectUrl = $gEnvManager->createPageUrl() . '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2754 if (!empty($todo)) $redirectUrl .= '&' . $todo;
2755 if ($gEnvManager->getIsMobileSite()){ // 携帯用アクセスポイントの場合
2756 $this->redirect($redirectUrl, true/*遷移時のダイアログ表示を抑止*/);
2758 $this->redirect($redirectUrl);
2764 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2765 * 追加するHTMLは主にウィンドウ制御用のスクリプト
2767 * @return string 最終HTML
2769 function getLastContents()
2771 global $gEnvManager;
2772 global $gRequestManager;
2775 $initScript = ''; // 初期化用スクリプト
2776 $pageId = $gEnvManager->getCurrentPageId();
2777 $pageSubId = $gEnvManager->getCurrentPageSubId();
2778 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2780 if (!$gEnvManager->isSystemManageUser()) return ''; // システム運用権限がない場合は終了
2783 if ($cmd == M3_REQUEST_CMD_RSS || // RSS配信のときは終了
2784 $cmd == M3_REQUEST_CMD_DO_WIDGET) return ''; // ウィジェット単体オペレーションのときは出力しない
2786 if ($gEnvManager->getIsMobileSite()) return ''; // 携帯用URLのときは終了
2788 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2790 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
2791 /* // テンプレート上のポジション名
2792 if (count($this->viewPosId) > 0){
2794 for ($i = 0; $i < count($this->viewPosId); $i++){
2795 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
2796 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
2798 $posArrayStr .= ']';
2799 $contents .= 'var M3_POSITIONS=' . $posArrayStr . ';' . M3_NL;
2802 $contents .= 'var M3_REVISION=' . $this->pageDefRev . ';' . M3_NL;*/
2805 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2806 $contents .= M3_INDENT_SPACE . 'window.m3.m3UpdateByConfig(serial);' . M3_NL;
2807 $contents .= '}' . M3_NL;
2808 } else if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定画面
2809 } else { // ダッシュボード画面、メイン管理画面
2811 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2812 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2813 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2814 $contents .= '}' . M3_NL;
2817 // ウィジェット単体実行以外のときの処理
2818 if (!$this->showWidget){
2819 if ($this->updateParentWindow){ // 管理画面からの親画面の更新
2820 $initScript .= M3_INDENT_SPACE . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
2825 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2826 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2827 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2828 $contents .= '}' . M3_NL;
2832 if (!empty($contents) || !empty($initScript)){
2833 // $destContents .= '<script type="text/javascript">' . M3_NL;
2834 // $destContents .= '//<![CDATA[' . M3_NL;
2835 $destContents .= $contents;
2836 if (!empty($initScript)){ // 初期化用スクリプト
2837 $destContents .= '$(function(){' . M3_NL;
2838 $destContents .= $initScript;
2839 $destContents .= '});' . M3_NL;
2841 // $destContents .= '//]]>' . M3_NL;
2842 // $destContents .= '</script>' . M3_NL;
2844 return $destContents;
2849 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2851 * @param RequestManager $request HTTPリクエスト処理クラス
2852 * @return string 最終HTML
2854 function getOptionContents($request)
2856 global $gEnvManager;
2861 if ($this->isAbort) return '';
2863 // AJAX用のレスポンスボディデータのときは終了
2864 if ($this->outputAjaxResponseBody) return '';
2867 // AJAXを送信する場合は空文字列では送信できないので、ダミーデータを返す
2868 if ($this->isWidgetAbort) $contents .= 'NO DATA' . M3_NL;
2871 if (!$gEnvManager->isMobile() && $this->outputByHtml){ // 携帯以外で、HTML出力のとき
2872 $contents .= '<!-- created by ' . M3_SYSTEM_NAME . ' v' . M3_SYSTEM_VERSION . ' - http://www.magic3.org -->' . M3_NL;
2873 $contents .= '<!-- convert time: ' . sprintf('%01.03f', microtime(true) - M3_MTIME) . ' -->' . M3_NL;
2878 * Widget単体起動用のHTMLのヘッダ部(headタグ)出力
2880 * startWidget(),endWidget()は、以下のコマンドを処理する
2881 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
2882 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
2883 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
2884 * Widgetの出力方法は、以下のパターンがある
2885 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
2886 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
2888 * @param string $cmd 起動コマンド
2890 function startWidget($cmd)
2892 global $gEnvManager;
2893 global $gRequestManager;
2895 // ウィジェット単体表示のときのみ出力
2896 if (!$this->showWidget) return;
2899 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
2900 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
2902 // $isHtml5 = false; // HTML5で出力するかどうか
2903 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
2904 if (intval($tempVer) >= 2) $this->isHtml5 = true; // HTML5で出力するかどうか
2907 if ($this->isHtml5){
2908 echo '<!DOCTYPE html>' . M3_NL;
2909 echo '<html dir="ltr" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2910 echo '<head>' . M3_NL;
2912 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . M3_NL;
2913 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $gEnvManager->getCurrentLanguage() . '" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2914 echo '<head>' . M3_NL;
2915 // echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' . M3_NL;
2918 // HTMLのヘッダ部(headタグ内)出力
2922 $widgetId = $gEnvManager->getCurrentWidgetId(); // カレントのウィジェットID
2925 if ($gEnvManager->getUseSslAdmin()){
2926 $rootUrl = $gEnvManager->getSslRootUrl();
2927 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
2928 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
2930 $rootUrl = $gEnvManager->getRootUrl();
2931 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
2932 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
2935 // ##### テンプレートのCSSの読み込み #####
2936 // テンプレートは管理用テンプレートに固定されている
2937 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット設定のとき
2938 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
2939 $curTemplateUrl = $templatesUrl . '/' . $gEnvManager->getCurrentTemplateId();
2940 if ($this->isHtml5){
2941 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/style.css" media="screen">' . M3_NL;
2942 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/widget.css" media="screen">' . M3_NL; // ウィジェット設定画面用CSS
2943 echo '<!--[if IE]><link rel="stylesheet" href="' . $curTemplateUrl . '/css/iestyles.css" media="screen"><![endif]-->' . M3_NL;
2944 echo '<!--[if lt IE 9]><script src="' . $curTemplateUrl . '/html5shiv.js"></script><![endif]-->' . M3_NL;
2946 echo '<link href="' . $curTemplateUrl . '/css/style.css" rel="stylesheet" type="text/css" />' . M3_NL;
2947 echo '<!--[if IE]><link rel="stylesheet" type="text/css" media="screen" href="' . $curTemplateUrl . '/css/iestyles.css" /><![endif]-->' . M3_NL;
2951 $ret = $this->db->getWidgetInfo($widgetId, $row);
2953 // ##### 共通ライブラリ読み込み設定 #####
2954 if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
2955 $scritLib = trim($row['wd_add_script_lib']);
2956 if (!empty($scritLib)) $this->addScript($task, $scritLib);
2959 // CSS読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2960 if ($row['wd_read_css']){
2961 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_CSS;
2962 if (is_dir($searchPath)){
2963 $dir = dir($searchPath);
2964 while (($file = $dir->read()) !== false){
2965 $filePath = $searchPath . '/' . $file;
2966 if ($file != '.' && $file != '..' && is_file($filePath)
2967 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
2970 $cssURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_CSS . '/' . $file;
2971 echo '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2978 // スクリプト読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2979 if ($row['wd_read_scripts']){
2980 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS;
2981 if (is_dir($searchPath)){
2982 $dir = dir($searchPath);
2983 while (($file = $dir->read()) !== false){
2984 $filePath = $searchPath . '/' . $file;
2985 if ($file != '.' && $file != '..' && is_file($filePath)
2986 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
2989 $scriptURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
2991 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
2992 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
2993 echo '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
2999 // ##### スクリプト用出力用タグを埋め込む #####
3000 // ウィジェット設定画面用メニューバーの作成
3001 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3002 echo self::MENUBAR_SCRIPT_TAGS; // メニューバー出力用タグ
3006 $title = $row['wd_name'];
3007 if (empty($title)) $title = $row['wd_id'];
3008 $gEnvManager->setCurrentWidgetTitle($title);
3009 echo '<title>' . self::WIDGET_TITLE_START . htmlspecialchars($title) . self::WIDGET_TITLE_END . '</title>' . M3_NL;
3010 echo '</head>' . M3_NL;
3011 // タブでウィンドウを開く場合は背景を透過モードにする
3012 if ($this->isTransparentMode){
3013 echo '<body style="background-color:transparent;">' . M3_NL;
3015 echo '<body>' . M3_NL;
3017 // ウィジェット設定画面用メニューバーの作成
3018 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3020 $desc = $row['wd_description']; // 説明
3021 $gEnvManager->setCurrentWidgetParams('desc', $desc);
3023 echo self::MENUBAR_TAGS; // メニューバー出力用タグ
3026 if ($this->useBootstrap) echo '<div class="container">' . M3_NL;
3028 // 別ウィンドウで表示のときは、「閉じる」ボタンを表示
3029 if ($cmd == M3_REQUEST_CMD_SHOW_WIDGET || // ウィジェットの単体表示のとき
3030 $cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット詳細設定画面のとき
3031 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット単体実行でフロント画面編集モードのとき
3033 // if ($this->isEditMode){// フロント画面編集モードのとき
3034 if (!empty($openBy)){
3035 // サーバ指定されている場合はサーバ情報を取得
3037 $server = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_SERVER);
3038 if (!empty($server)){
3040 $ret = $this->db->getServerById($server, $row);
3042 $serverName = 'サーバ名:' . $row['ts_name'];// サーバ名
3043 echo '<div align="left" style="float:left;padding-left:30px;"><label>' . convertToHtmlEntity($serverName) . '</label></div>';
3046 // タブ、インナーフレーム、ダイアログ表示以外のときは「閉じる」ボタンを表示
3047 if ($openBy != 'tabs' && $openBy != 'iframe' && $openBy != 'dialog'){ // 以外
3048 if ($openBy == 'logout'){
3049 $titleStr = 'ログアウト';
3050 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 .
3051 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
3054 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 .
3055 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
3061 echo '<div class="m3configprev" style="display:none;"><a id="m3configprev" href="#"><img src="' . $rootUrl . self::PREV_ICON_FILE .
3062 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
3064 echo '<div class="m3confignext" style="display:none;"><a id="m3confignext" href="#"><img src="' . $rootUrl . self::NEXT_ICON_FILE .
3065 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
3068 // echo '<div class="row">' . M3_NL;
3069 echo '<!-- Widget Start -->' . M3_NL;
3074 * startWidget(),endWidget()は、以下のコマンドを処理する
3075 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
3076 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
3077 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
3079 * @param string $cmd 起動コマンド
3080 * @param string $srcContent HTML出力ソース
3082 function endWidget($cmd, $srcContent)
3084 global $gDesignManager;
3086 // ウィジェット単体表示のときのみ出力
3087 if (!$this->showWidget) return;
3091 $breadcrumbHtml = '';
3092 if (!empty($this->adminSubNavbarDef)) $breadcrumbHtml .= $gDesignManager->createSubMenubar($this->adminSubNavbarDef);
3093 if (!empty($this->adminBreadcrumbDef)) $breadcrumbHtml .= $gDesignManager->createAdminBreadcrumb($this->adminBreadcrumbDef);
3094 $destContent = str_replace(self::MENUBAR_TAGS, $breadcrumbHtml, $srcContent);
3097 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3098 $replaceStr .= '//<![CDATA[' . M3_NL;
3102 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェットの設定管理
3104 $replaceStr .= 'function m3UpdateByConfig(serial){' . M3_NL;
3105 $replaceStr .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
3106 $replaceStr .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
3107 $replaceStr .= M3_INDENT_SPACE . 'm3UpdateParentWindow();' . M3_NL; // 親ウィンドウ更新
3108 $replaceStr .= '}' . M3_NL;
3111 $replaceStr .= 'function hideIEErrors(){' . M3_NL;
3112 $replaceStr .= M3_INDENT_SPACE . 'return true;' . M3_NL;
3113 $replaceStr .= '}' . M3_NL;
3114 $replaceStr .= 'window.onerror = hideIEErrors;' . M3_NL;
3118 $replaceStr .= '$(function(){' . M3_NL;
3120 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3121 if (!empty($this->adminSubNavbarDef) || !empty($this->adminBreadcrumbDef)){
3122 $menubarHeight = $gDesignManager->getSubMenubarHeight();
3123 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("nav.secondlevel").css("margin-top", "0");' . M3_NL;
3124 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("body").css("padding-top", "' . $menubarHeight . 'px");' . M3_NL;
3127 // ##### ウィジェットからの指定による処理 #####
3128 if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
3129 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
3130 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
3131 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
3132 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
3135 $replaceStr .= '});' . M3_NL;
3136 $replaceStr .= '//]]>' . M3_NL;
3137 $replaceStr .= '</script>' . M3_NL;
3138 $destContent = str_replace(self::MENUBAR_SCRIPT_TAGS, $replaceStr, $destContent);
3139 echo $destContent;// 変換したコンテンツを出力
3141 // echo '</div>' . M3_NL; // row
3142 echo '<!-- Widget End -->' . M3_NL;
3144 // ##### ウィジェットからの指定による処理 #####
3145 /* if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
3146 echo '<script type="text/javascript">' . M3_NL;
3147 echo '//<![CDATA[' . M3_NL;
3148 echo '$(function(){' . M3_NL;
3149 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
3150 echo str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
3151 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
3152 echo str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
3155 echo '//]]>' . M3_NL;
3156 echo '</script>' . M3_NL;
3160 if ($this->useBootstrap) echo '</div>' . M3_NL;
3162 echo '</body>' . M3_NL;
3163 echo '</html>' . M3_NL;
3166 * Widget単体RSS出力用のHTMLのヘッダ部(headタグ)出力
3168 * Widgetの出力方法は、以下のパターンがある
3169 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
3170 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
3172 * @param string $cmd 起動コマンド
3174 function startWidgetRss($cmd)
3178 * Widget単体RSS出力用のタグを閉じる
3180 * @param string $cmd 起動コマンド
3181 * @param string $rssContent RSS配信内容
3183 function endWidgetRss($cmd, $rssContent)
3185 global $gEnvManager;
3188 if ($this->isAbort) return;
3190 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3193 $lang = $gEnvManager->getCurrentLanguage();
3194 $date = getW3CDate(); // RSS1.0用日付
3195 $copyright = $gEnvManager->getSiteCopyRight(); // 著作権
3196 $title = $this->rssChannel['title']; // タイトル
3197 $link = $this->rssChannel['link']; // RSS取得用URL
3198 $desc = $this->rssChannel['description']; // 説明
3199 $seq = $this->rssChannel['seq']; // 項目の並び順(URL)
3201 switch ($this->rssVersion){ // RSSバージョン
3204 echo '<rdf:RDF xmlns="http://purl.org/rss/1.0/" ';
3205 echo 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
3206 echo 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
3207 echo 'xml:lang="' . $lang . '">' . M3_NL;
3208 echo '<channel rdf:about="' . convertUrlToHtmlEntity($link) . '">' . M3_NL;
3209 echo '<title>' . convertToHtmlEntity($title) . '</title>' . M3_NL;
3210 echo '<link>' . convertUrlToHtmlEntity($link) . '</link>' . M3_NL; // 「convertUrlToHtmlEntity」が必要
3211 echo '<description>' . convertToHtmlEntity($desc) . '</description>' . M3_NL;
3212 echo '<dc:language>' . $lang . '</dc:language>' . M3_NL;
3213 if (!empty($copyright)) echo '<dc:rights>' . convertToHtmlEntity($copyright) . '</dc:rights>' . M3_NL;
3214 echo '<dc:date>' . $date . '</dc:date>' . M3_NL;
3215 echo '<items>' . M3_NL;
3216 if (count($seq) > 0){
3217 echo str_repeat(M3_INDENT_SPACE, 1) . '<rdf:Seq>' . M3_NL;
3218 for ($i = 0; $i < count($seq); $i++){
3219 echo str_repeat(M3_INDENT_SPACE, 2) . '<rdf:li rdf:resource="' . convertUrlToHtmlEntity($seq[$i]) . '" />' . M3_NL;
3221 echo str_repeat(M3_INDENT_SPACE, 1) . '</rdf:Seq>' . M3_NL;
3223 echo '</items>' . M3_NL;
3224 echo '</channel>' . M3_NL;
3226 echo '</rdf:RDF>' . M3_NL;
3233 header("Content-type: text/xml; charset=utf-8");
3236 * 直サーバ接続時のXML出力用のHTMLのヘッダ部(headタグ)出力
3238 * @param string $cmd 起動コマンド
3241 function startWidgetXml($cmd)
3244 //header("Content-type: text/xml; charset=utf-8");
3249 * @param string $cmd 起動コマンド
3252 function endWidgetXml()
3258 * @return string ドキュメントタイプ出力
3260 function getMobileDocType()
3262 global $gEnvManager;
3263 global $gInstanceManager;
3264 global $gRequestManager;
3266 $docTypeStr = ''; // 出力するDocType
3267 $agent = $gInstanceManager->getMobileAgent();
3268 if ($agent->isDoCoMo()){ // ドコモ端末のとき
3269 $htmlVer = $agent->getHTMLVersion();
3272 $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">';
3275 $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">';
3278 $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">';
3281 $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">';
3284 $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">';
3287 $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">';
3290 if (preg_match("/^DoCoMo\/1\.0/i", $gRequestManager->trimServerValueOf('HTTP_USER_AGENT'))){ // mova端末のとき
3291 // mova端末のときはドキュメントタイプなしにすると画面表示可能
3296 } else if ($agent->isEZweb()){ // au端末のとき
3297 if ($agent->isWAP2()){
3298 $docTypeStr = '<!DOCTYPE html PUBLIC "-//OPENWAVE//DTD XHTML 1.0//EN" "http://www.openwave.com/DTD/xhtml-basic.dtd">';
3300 } else if ($agent->isSoftBank()){ // ソフトバンク端末のとき
3301 if ($agent->isTypeW() || $agent->isType3GC()){
3302 $docTypeStr = '<!DOCTYPE html PUBLIC "-//J-PHONE//DTD XHTML Basic 1.0 Plus//EN" "xhtml-basic10-plus.dtd">';
3305 if ($gEnvManager->getIsMobileSite()){ // 携帯用サイトへのアクセスの場合
3306 echo '<?xml version="1.0" encoding="' . $gEnvManager->getMobileCharset() . '" ?>' . M3_NL;
3308 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3310 if (empty($docTypeStr)) $docTypeStr = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
3311 echo $docTypeStr . M3_NL;
3316 * @return string XML宣言
3318 function getDefaultXmlDeclaration()
3320 return '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>';
3323 * HTMLのヘッダ部(headタグ内)出力
3325 * システムに共通な定義をHTMLのheadタグ内に出力する
3326 * mosFunc.phpからも実行されるので、このメソッドは引数なしに固定。
3327 * この関数は、以下の「形式1」または「形式2」でheadタグ内に記述する
3329 * 形式1: <!-- m3:HTMLHeader -->
3330 * 形式2(old style): <?php mosShowHead(); ?>
3332 function getHeader()
3334 global $gEnvManager;
3335 global $gRequestManager;
3337 $this->outputHead = true; // HTMLヘッダ出力を行ったかどうか
3340 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3342 // ######### 携帯用サイトの場合は別にヘッダを作成する #########
3343 if ($gEnvManager->getIsMobileSite()){
3345 echo '<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=' . $gEnvManager->getMobileCharset() . '" />' . M3_NL;
3348 echo '<meta http-equiv="Pragma" content="no-cache" />' . M3_NL;
3349 echo '<meta http-equiv="Cache-Control" content="no-cache" />' . M3_NL;
3350 echo '<meta http-equiv="Expires" content="-1" />' . M3_NL;
3353 echo '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
3354 } else { // PC用サイト、管理用サイト、スマートフォン用サイトのとき
3355 // $isHtml5 = false; // HTML5で出力するかどうか
3356 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
3357 $this->isHtml5 = true;
3359 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
3360 if (intval($tempVer) >= 2) $this->isHtml5 = true;
3363 // ********** メタタグの設定 **********
3365 //if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
3366 if ($this->isHtml5){
3367 //echo '<meta http-equiv="content-type" content="text/html; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
3368 echo '<meta charset="' . M3_HTML_CHARSET . '">' . M3_NL;
3370 echo '<meta http-equiv="content-script-type" content="text/javascript" />' . M3_NL;
3371 echo '<meta http-equiv="content-style-type" content="text/css" />' . M3_NL;
3372 echo '<meta http-equiv="content-type" content="application/xhtml+xml; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
3374 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3375 // Bootstrapで必要なMETAタグを追加
3376 echo '<meta name="viewport" content="width=device-width, initial-scale=1">' . M3_NL;
3380 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 表示位置を表示するとき
3381 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
3383 if ($gEnvManager->getUseSslAdmin()){
3384 $rootUrl = $gEnvManager->getSslRootUrl();
3386 $rootUrl = $gEnvManager->getRootUrl();
3388 echo '<base href="' . $rootUrl . '/" />' . M3_NL;
3391 echo self::HEAD_TAGS; // HTMLヘッダの埋め込みデータ
3396 * @return string HTMLヘッダ出力文字列
3398 function getHeaderOutput()
3400 global $gEnvManager;
3401 global $gRequestManager;
3402 global $gInstanceManager;
3403 global $gSystemManager;
3405 $replaceStr = ''; // 変換文字列
3408 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3409 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
3410 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
3411 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
3413 // ********************************************************
3415 // ********************************************************
3416 // ##### テンプレートの設定、フレームの設定から必要なライブラリを取得 #####
3418 // if (!$this->useBootstrap) $this->useBootstrap = $gEnvManager->getCurrentTemplateUseBootstrap();
3419 if ($this->useBootstrap){
3420 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3421 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3422 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
3423 if ($cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)以外のとき
3424 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3426 } else { // ログインしていない場合(ログイン画面等)
3427 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP);
3428 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP_ADMIN);// Bootstrap管理画面オプション
3430 } else { // フロント画面へのアクセスの場合
3431 // ### Bootstrapのjsとcssはテンプレート側で読み込む ###
3432 // $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP); // Bootstrapライブラリ
3433 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW || // ログイン、ログアウト場合
3434 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
3435 $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3439 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3440 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3441 $this->addAdminScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3443 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3445 } else if ($gEnvManager->isContentEditableUser()){ // 投稿ユーザの場合
3446 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3450 // ********************************************************
3452 // ********************************************************
3453 // ##### インストール時のヘッダ出力 #####
3454 if (defined('M3_STATE_IN_INSTALL')){
3457 if (count($this->headSubTitle) > 0) $title = htmlspecialchars(trim($this->headSubTitle[0]));
3459 // ********** メタタグの設定 **********
3460 $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3462 // ##### インストーラ用のファイルの読み込み #####
3463 $scriptsUrl = '../scripts';
3465 // 管理機能用共通ライブラリのCSSの読み込み
3466 $count = count($this->defaultAdminCssFiles);
3467 for ($i = 0; $i < $count; $i++){
3469 $cssFilename = $this->defaultAdminCssFiles[$i];
3470 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3471 $cssURL = $cssFilename;
3473 $cssURL = $scriptsUrl . '/' . $cssFilename;
3475 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3478 // 管理画面用の共通スクリプトを読み込む
3479 $count = count($this->defaultAdminScriptFiles);
3480 for ($i = 0; $i < $count; $i++){
3481 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3484 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3485 $scriptURL = $scriptFilename;
3489 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3491 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3494 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3497 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3498 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3499 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3502 // ##### ページへJavascriptの埋め込む #####
3503 // JavaScriptグローバル変数の設定
3504 $rootUrl = $gEnvManager->getRootUrl();
3505 if (empty($rootUrl)) $rootUrl = $gEnvManager->calcSystemRootUrl();
3506 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3507 $replaceStr .= '//<![CDATA[' . M3_NL;
3508 $replaceStr .= '// Magic3 Global values' . M3_NL;
3509 if (!empty($rootUrl)) $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3510 $replaceStr .= '//]]>' . M3_NL;
3511 $replaceStr .= '</script>' . M3_NL;
3516 $cleanType = $gEnvManager->getCurrentTemplateCleanType(); // テンプレートクリーンタイプ
3517 /* if ($this->db->getTemplate($gEnvManager->getCurrentTemplateId(), $templateRow)){
3518 $cleanType = $templateRow['tm_clean_type'];
3523 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3525 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
3527 $isSslPage = $this->isSslPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
3530 $rootUrl = $gEnvManager->getSslRootUrl();
3531 $scriptsUrl = $gEnvManager->getSslScriptsUrl(); // スクリプト読み込み用パス
3532 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
3533 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
3535 $rootUrl = $gEnvManager->getRootUrl();
3536 $scriptsUrl = $gEnvManager->getScriptsUrl(); // スクリプト読み込み用パス
3537 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
3538 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
3542 if (!$this->showWidget){// 単体実行以外のとき
3543 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスの場合
3545 // メイン画面は「サイト名 - 管理画面」、サブ画面は個別画面名
3546 $siteName = $gEnvManager->getSiteName();
3547 // if (empty($siteName)) $siteName = self::DEFAULT_SITE_NAME;
3548 $title = $siteName . ' - ' . self::DEFAULT_ADMIN_TITLE;
3549 $titleCount = count($this->headSubTitle);
3550 if ($titleCount > 0) $title = $this->headSubTitle[$titleCount -1]; // サブタイトルが設定されている場合は変更
3551 $replaceStr .= '<title>' . htmlspecialchars($title) . '</title>' . M3_NL;
3553 // その他HTMLヘッダに出力するタグ文字列
3554 if (!empty($this->adminHeadOthers)){
3556 $this->adminHeadOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->adminHeadOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3557 $replaceStr .= $this->adminHeadOthers . M3_NL;
3559 } else { // 管理画面以外の画面へのアクセスの場合
3561 $titleItemCount = 0; // タイトル項目数
3562 $defaultTitle = trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_TITLE));
3563 if (!empty($defaultTitle)) $titleItemCount++;
3564 if (!empty($this->headSubTitle)){ // サブタイトルが設定されているとき
3565 $titleItemCount += count($this->headSubTitle);
3569 if ($titleItemCount > 0){
3570 $format = $this->gSystem->getSystemConfig(self::CONFIG_KEY_HEAD_TITLE_FORMAT);
3571 if (empty($format)){
3572 $title = htmlspecialchars($defaultTitle);
3574 $formats = explode(';', $format);
3575 $titleItemCount = ($titleItemCount > count($formats)) ? count($formats) : $titleItemCount;
3576 $title = $formats[$titleItemCount -1];
3578 if (!empty($defaultTitle)){
3579 $title = str_replace('$1', htmlspecialchars($defaultTitle), $title);
3582 for ($i = 0; $i < count($this->headSubTitle); $i++){
3583 $key = '$' . $number;
3584 $value = htmlspecialchars(trim($this->headSubTitle[$i]));
3585 $title = str_replace($key, $value, $title);
3590 if (!empty($title)) $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3593 if (!empty($this->headDescription)) $replaceStr .= '<meta name="description" content="' . htmlspecialchars($this->headDescription) . '" />' . M3_NL;
3596 if (!empty($this->headKeywords)) $replaceStr .= '<meta name="keywords" content="' . htmlspecialchars($this->headKeywords) . '" />' . M3_NL;
3598 // その他HTMLヘッダに出力するタグ文字列
3599 if (!empty($this->headOthers)){
3601 $this->headOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->headOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3602 $replaceStr .= $this->headOthers . M3_NL;
3607 // ##### PC用URLと携帯用URLのアクセス別に処理 #####
3608 if ($gEnvManager->getIsMobileSite()){ // 携帯用URLのとき
3609 } else { // PC用URLまたはスマートフォン用URLのとき
3610 // ##### テンプレート情報に応じた処理 #####
3611 // テンプレートクリーンが必要な場合はJQueryを追加
3612 if ($cleanType != 0) $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
3615 $robots = htmlspecialchars(trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_ROBOTS)));
3616 if (!empty($robots)){
3617 $replaceStr .= '<meta name="robots" content="' . $robots . '" />' . M3_NL;
3621 $replaceStr .= '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
3624 $templateId = $gEnvManager->getCurrentTemplateId();
3625 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3626 // テンプレートのFaviconがない場合はシステムのデフォルトのFaviconを使用
3627 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3628 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3629 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3630 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3633 $faviconPath = $gEnvManager->getSystemRootPath() . self::DEFAULT_ADMIN_FAVICON_FILE;
3634 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3635 $faviconFile = $rootUrl . self::DEFAULT_ADMIN_FAVICON_FILE;
3636 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3640 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3641 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3642 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3643 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3646 // ##### 追加ライブラリの読み込み #####
3647 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用URLのとき
3648 $value = $gSystemManager->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面で常にjQuery Mobileを使用
3650 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
3651 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
3652 for ($l = 0; $l < count($this->headPreMobileScriptFiles); $l++){
3653 $this->addScriptFile($this->headPreMobileScriptFiles[$l]); // 通常機能用のスクリプト追加
3656 $this->addScriptFile($this->selectedJQueryMobileFilename);
3660 // ##### Ajaxライブラリの読み込み #####
3661 if (!$gEnvManager->isAdminDirAccess()){ // 通常画面へのアクセスのとき
3662 if ($this->db->isExistsWidgetWithAjax($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId())){// Ajaxライブラリを使用しているウィジェットがあるときは追加
3663 $this->addScriptFile($this->selectedJQueryFilename); // デフォルトAjaxライブラリ追加
3664 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
3668 // ##### 共通ライブラリの読み込み #####
3669 if (!$this->showWidget){// 単体実行以外のとき
3670 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3671 for ($i = 0; $i < count($rows); $i++){
3672 $this->addScript($task, trim($rows[$i]['wd_add_script_lib']));
3676 // ##### 共通CSS読み込み #####
3677 if (($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()) || $this->isEditMode){ // フロント画面編集モード
3678 $cssURL = $scriptsUrl . '/' . self::M3_EDIT_CSS_FILE;
3679 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3681 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3682 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
3683 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3684 // 管理機能用共通ライブラリのCSSの読み込み
3685 $count = count($this->defaultAdminCssFiles);
3686 for ($i = 0; $i < $count; $i++){
3688 //$cssURL = $scriptsUrl . '/' . $this->defaultAdminCssFiles[$i];
3689 $cssFilename = $this->defaultAdminCssFiles[$i];
3690 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3691 $cssURL = $cssFilename;
3693 $cssURL = $scriptsUrl . '/' . $cssFilename;
3695 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3698 // 管理権限なしで管理ディレクトリアクセスで必要なCSSファイルを読み込む
3699 $count = count($this->defaultAdminDirCssFiles);
3700 for ($i = 0; $i < $count; $i++){
3702 $cssURL = $scriptsUrl . '/' . $this->defaultAdminDirCssFiles[$i];
3703 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3708 $count = count($this->defaultCssFiles);
3709 for ($i = 0; $i < $count; $i++){
3711 $cssFilename = $this->defaultCssFiles[$i];
3712 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3713 $cssURL = $cssFilename;
3715 $cssURL = $scriptsUrl . '/' . $cssFilename;
3717 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3721 // ##### 表示モードによるCSS読み込み #####
3722 // ウィジェット付きポジション画面は管理画面のアクセスではない
3723 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3725 $cssURL = $scriptsUrl . self::M3_ADMIN_WIDGET_CSS_FILE;
3726 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3729 // ##### ウィジェットごとのCSS読み込み #####
3731 $this->db->getWidgetsIdWithCss($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3732 for ($i = 0; $i < count($rows); $i++){
3733 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS;
3734 // ディレクトリがあるときはディレクトリ内読み込み
3735 if (is_dir($searchPath)){
3736 $dir = dir($searchPath);
3737 while (($file = $dir->read()) !== false){
3738 $filePath = $searchPath . '/' . $file;
3739 if ($file != '.' && $file != '..' && is_file($filePath)
3740 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3743 $cssURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS . '/' . $file;
3744 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3750 // ##### 外部出力用CSS読み込み #####
3751 // ウィジェットからの追加のCSS読み込み
3752 $count = count($this->headCssFiles);
3753 for ($i = 0; $i < $count; $i++){
3754 $cssUrl = $this->headCssFiles[$i];
3755 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3756 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3759 // 外部出力用CSSデータがある場合はURLを追加
3760 if (!empty($this->exportCss)){
3761 $cssUrl = $this->createCssCmdUrl($isSslPage, date('YmdHis'));
3762 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3763 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3766 // ##### RSS配信情報の読み込み #####
3767 $count = count($this->headRssFiles);
3768 for ($i = 0; $i < $count; $i++){
3769 $rssUrl = $this->headRssFiles[$i]['href'];// リンク先URL
3770 $rssTitle = $this->headRssFiles[$i]['title'];// タイトル
3771 $replaceStr .= '<link rel="alternate" type="application/rss+xml" title="' . $rssTitle . '" href="' . convertUrlToHtmlEntity($rssUrl) . '" />' . M3_NL;
3774 // ##### 共通Javascriptの読み込み #####
3775 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3776 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3777 // 管理画面用の共通スクリプトを読み込む
3778 $count = count($this->defaultAdminScriptFiles);
3779 for ($i = 0; $i < $count; $i++){
3780 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3783 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3784 $scriptURL = $scriptFilename;
3788 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3790 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3793 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3796 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3797 //$scriptURL = $scriptsUrl . '/' . $scriptFilename;
3798 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3799 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3801 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示のときは、ウィジェット操作ライブラリを読み込む
3803 $scriptURL = $scriptsUrl . '/' . self::M3_ADMIN_WIDGET_SCRIPT_FILENAME;
3804 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();// スクリプトをキャッシュ保存しない場合は、パラメータを付加
3805 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3807 } else { // システム運用権限がない場合
3808 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3809 $count = count($this->defaultAdminDirScriptFiles);
3810 for ($i = 0; $i < $count; $i++){
3811 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3813 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3814 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3815 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3816 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3820 // Googleマップライブラリの読み込み
3821 if ($this->useGooglemaps && $this->isContentGooglemaps) $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS)); // コンテンツにGoogleマップが含むかどうか
3823 $useExternalJquery = $gSystemManager->getSystemConfig(self::CF_EXTERNAL_JQUERY); // システム外部のjQueryを使用するかどうか
3825 $count = count($this->defaultScriptFiles);
3826 for ($i = 0; $i < $count; $i++){
3827 $defaultScriptFile = $this->defaultScriptFiles[$i];
3829 // 外部のjQueryを使用する場合はSCRIPTタグを出力しない
3830 if ($defaultScriptFile == $this->selectedJQueryFilename && $useExternalJquery) continue;
3832 // ##### jQueryMobileスクリプトを追加する場合は直前に初期化スクリプトを追加 #####
3833 if ($defaultScriptFile == $this->selectedJQueryMobileFilename){
3834 if (count($this->headPreMobileScript) > 0){
3835 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3836 $replaceStr .= '//<![CDATA[' . M3_NL;
3837 for ($j = 0; $j < count($this->headPreMobileScript); $j++){
3838 $replaceStr .= $this->headPreMobileScript[$j];
3840 $replaceStr .= M3_NL;
3841 $replaceStr .= '//]]>' . M3_NL;
3842 $replaceStr .= '</script>' . M3_NL;
3847 if (strncasecmp($defaultScriptFile, 'http://', 7) == 0 || strncasecmp($defaultScriptFile, 'https://', 8) == 0){
3848 $scriptURL = $defaultScriptFile;
3852 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3854 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3857 $scriptURL = $scriptsUrl . '/' . $defaultScriptFile;
3860 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3861 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3862 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3865 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW){ // ログイン、ログアウト場合
3866 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3867 $count = count($this->defaultAdminDirScriptFiles);
3868 for ($i = 0; $i < $count; $i++){
3869 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3870 if (!in_array($scriptFilename, $this->defaultScriptFiles)){ // 既に追加されていない場合のみ追加
3871 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3872 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3873 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3874 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3879 // ***** [WordPressテンプレート] jQueryの読み込み後、ヘッダ部に出力するテンプレート用のJavascriptがあれば読み込む *****
3880 $headData = $this->gEnv->getWpHeadScriptsData();
3881 if (!empty($headData)) $replaceStr .= $headData;
3883 // ##### ウィジェットごとのJavaScript読み込み #####
3884 // スクリプトがあるウィジェットを取得
3885 $this->db->getWidgetsIdWithScript($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3886 for ($i = 0; $i < count($rows); $i++){
3887 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS;
3889 // ディレクトリがあるときはディレクトリ内読み込み
3890 if (is_dir($searchPath)){
3891 $dir = dir($searchPath);
3892 while (($file = $dir->read()) !== false){
3893 $filePath = $searchPath . '/' . $file;
3894 if ($file != '.' && $file != '..' && is_file($filePath)
3895 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3898 $scriptURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
3899 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3900 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3901 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3907 // ウィジェットからの追加のCSS読み込み
3908 $count = count($this->headScriptFiles);
3909 for ($i = 0; $i < $count; $i++){
3910 $scriptUrl = $this->headScriptFiles[$i];
3911 if ($isSslPage) $scriptUrl = str_replace('http://', 'https://', $scriptUrl); // SSL化が必要なときは変換
3913 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3914 if (!$this->hasScriptCache) $scriptUrl .= $this->getCacheParam();
3915 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptUrl) . '"></script>' . M3_NL;
3919 $openType = $this->gSystem->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE);// ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
3921 // ##### ページへJavascriptの埋め込む #####
3922 // JavaScriptグローバル変数の設定
3923 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
3924 //$replaceStr .= '<!--' . M3_NL;
3925 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3926 $replaceStr .= '//<![CDATA[' . M3_NL;
3927 $replaceStr .= '// Magic3 Global values' . M3_NL;
3928 $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3930 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()){ // 管理画面へのアクセス、システム運用権限があり
3931 $pageId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID); // ページID
3932 $pageSubId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);// ページサブID
3935 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
3936 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
3939 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
3940 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
3942 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3945 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
3946 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
3947 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
3949 // Googleマップライブラリの読み込み
3950 if ($this->useGooglemaps){
3951 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
3953 // CKEditor拡張プラグイン用の定義
3954 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
3955 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
3957 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
3960 // 管理画面の小画面デバイス最適化を行うかどうか
3961 if ($gEnvManager->isSmallDeviceAdmin()){
3962 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = true;' . M3_NL;
3964 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = false;' . M3_NL;
3967 // ウィジェット詳細設定画面専用のJavaScriptグローバル変数
3968 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){
3969 // ##### CKEditor用の設定 #####
3970 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3972 // CKEditor用のCSSファイル
3973 if (!empty($this->ckeditorCssFiles)){
3974 // 編集エリア用のCSSファイルを追加
3975 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3976 //array_unshift($this->ckeditorCssFiles, $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE);
3978 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
3979 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3981 // CKEditor用(レイアウト)のCSSファイル
3982 $cssFiles = array();
3983 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_ADMIN_CSS; // BootstrapのCSSを追加
3984 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3985 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
3986 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3988 // CKEditor用のテンプレートタイプ
3989 if (isset($this->ckeditorTemplateType)){
3990 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
3992 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3994 $positionData = $this->getRestPositionData();
3997 if (count($this->viewPosId) > 0){
3999 for ($i = 0; $i < count($this->viewPosId); $i++){
4000 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
4001 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
4003 $posArrayStr .= ']';
4004 $replaceStr .= 'var M3_POSITIONS = ' . $posArrayStr . ';' . M3_NL;
4007 $replaceStr .= 'var M3_REVISION = ' . $this->pageDefRev . ';' . M3_NL;
4010 $replaceStr .= 'var M3_REST_POSITION_DATA = \'' . $positionData . '\';' . M3_NL;
4011 } else if (!empty($pageId)){
4012 $accessPoint = $this->gEnv->getAllDefaultPageId();
4013 for ($i = 0; $i < count($accessPoint); $i++){
4014 if ($pageId == $accessPoint[$i]){
4015 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $i . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
4019 } else { // メインの管理画面の場合
4020 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = 0;' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
4023 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
4024 if (!empty($task)){ // 戻りタスクが設定されているときのみ最大化可能
4025 $replaceStr .= 'function gobackPagedef(){' . M3_NL;
4026 $replaceStr .= ' window.location.href = "' . $gEnvManager->getDefaultAdminUrl() . '?pageid=' . $pageId . '&pagesubid=' . $pageSubId . '&task=' . $task . '";' . M3_NL;
4027 $replaceStr .= '}' . M3_NL;
4028 $replaceStr .= '$(function(){' . M3_NL;
4029 $replaceStr .= ' $(document).keyup(function(e){' . M3_NL;
4030 $replaceStr .= ' if (e.which == 36) gobackPagedef();' . M3_NL;
4031 $replaceStr .= ' });' . M3_NL;
4032 $replaceStr .= '});' . M3_NL;
4035 // ##### 管理用テンプレートを使用している場合の処理 #####
4036 // Bootstrap用のスクリプト処理
4037 if ($this->useBootstrap){
4038 $replaceStr .= '$(function(){' . M3_NL;
4039 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
4040 $replaceStr .= '});' . M3_NL;
4043 } else if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4044 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
4045 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
4048 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
4049 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
4051 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4054 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4055 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4056 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4059 $templateType = $gEnvManager->getCurrentTemplateType();
4060 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4061 } else if ($this->isEditMode){ // フロント画面編集モード(コンテンツ編集可能ユーザ)
4062 if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
4064 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4067 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4068 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4069 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4071 // Googleマップライブラリの読み込み
4072 if ($this->useGooglemaps){
4073 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
4075 // CKEditor拡張プラグイン用の定義
4076 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
4077 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
4079 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
4082 // 管理画面の小画面デバイス最適化を行うかどうか
4083 if ($gEnvManager->isSmallDeviceAdmin()){
4084 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = true;' . M3_NL;
4086 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = false;' . M3_NL;
4089 // ##### CKEditor用の設定 #####
4091 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
4092 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
4094 // CKEditor用のCSSファイル
4095 if (!empty($this->ckeditorCssFiles)){
4096 // 編集エリア用のCSSファイルを追加
4097 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4098 //array_unshift($this->ckeditorCssFiles, $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE);
4100 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
4101 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4103 // CKEditor用(レイアウト)のCSSファイル
4104 $cssFiles = array();
4105 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_ADMIN_CSS; // BootstrapのCSSを追加
4106 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4107 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
4108 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4110 // CKEditor用のテンプレートタイプ
4111 if (isset($this->ckeditorTemplateType)){
4112 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
4115 // Bootstrap用のスクリプト処理
4116 if ($this->useBootstrap){
4117 $replaceStr .= '$(function(){' . M3_NL;
4118 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
4119 $replaceStr .= '});' . M3_NL;
4122 // プレビュー画面用にテンプレートタイプを出力
4123 $templateType = $gEnvManager->getCurrentTemplateType();
4124 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4126 // ##### ヘルプシステムの組み込み #####
4127 if ($this->useHelp){ // ヘルプ表示のとき
4128 $replaceStr .= '$(function(){' . M3_NL;
4129 $replaceStr .= ' if (jQuery().tooltip) $(\'[rel=m3help]\').tooltip({ placement: \'top\'});' . M3_NL;
4130 $replaceStr .= '});' . M3_NL;
4134 if (!$gEnvManager->isAdminDirAccess()){ // フロント画面のとき
4135 // テンプレートタイプを追加(ファイルローダ等で使用)
4136 $templateType = $gEnvManager->getCurrentTemplateType();
4137 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4141 // ##### パネルメニュー(フロント画面と管理画面の切り替え等)の表示 #####
4142 // PC用、携帯用、スマートフォン用画面とウィジェット付きポジションの管理画面時に表示
4143 if (($gEnvManager->isAdminDirAccess() && $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) || // 管理画面(ウィジェット付きポジション表示)のとき
4144 (!$gEnvManager->isAdminDirAccess() && // 一般用画面のとき
4145 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4146 $cmd != M3_REQUEST_CMD_RSS)){ // RSS配信でない
4147 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
4148 if ($gEnvManager->isSystemManageUser()){ // システム運用権限ありの場合
4150 $menubarTag = ''; // 管理用メニューバー
4151 $adminTag = ''; // 管理画面ボタン
4152 $editTag = ''; // 編集ボタン
4153 $logoutTag = ''; // ログアウトボタン
4155 if ($gEnvManager->isAdminDirAccess()){ // 管理画面(ウィジェット付きポジション表示)の場合
4157 /* $titleStr = '編集終了';
4158 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4159 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4160 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
4161 $editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
4164 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4165 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4166 //$editTag = '<div class="m3editend"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4167 //$editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" /></a></div>';
4168 $editTag = '<div class="m3editend m3topright"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4169 $editTag .= '<i class="glyphicon glyphicon-ok-sign"></i></a></div>';
4170 $menubarTag .= $editTag;
4172 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4173 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4174 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").prepend(\'' . $menubarTag . '\');' . M3_NL; // appendでうまく表示できないのでprependで表示
4175 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4176 } else if ($this->isAccessPointWithAdminMenu){ // 通常画面は、管理メニューを使用するアクセスポイントの場合のみ表示
4178 $titleStr = '管理画面へ遷移';
4179 $linkUrl = $gEnvManager->getDefaultAdminUrl();
4180 $adminTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4181 $adminTag .= '<img src="' . $rootUrl . self::ADMIN_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4184 $titleStr = '画面を編集';
4185 $linkUrl = $gEnvManager->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' .M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET;
4186 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_ID . '=' . $gEnvManager->getCurrentPageId();
4187 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
4188 $linkUrl .= '&' . M3_REQUEST_PARAM_BACKUP_URL . '=' . urlencode($gEnvManager->getCurrentRequestUri()); // URL退避用
4189 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4190 $editTag .= '<img src="' . $rootUrl . self::EDIT_PAGE_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4193 $titleStr = 'ログアウト';
4194 // if ($gEnvManager->isAdminDirAccess()){ // 管理画面の場合
4195 // $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4196 // if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4198 $linkUrl = $gEnvManager->getCurrentRequestUri();
4200 $linkUrl = createUrl($linkUrl, M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_LOGOUT);
4201 $logoutTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4202 $logoutTag .= '<img src="' . $rootUrl . self::LOGOUT_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4205 $widgetToolTag .= '<li><div class="m3widgettoolbutton m3-nav m3-navbar-nav" data-toggle="buttons">';
4206 $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>';
4207 $widgetToolTag .= '<input type="checkbox" class="hidden" />';
4208 $widgetToolTag .= '</div></li>';
4210 //$menubarTag .= '<div id="m3slidepanel">';
4211 $menubarTag .= '<div id="m3slidepanel" class="m3panel_top m3-navbar-default" style="top:-60px; visibility: visible;">';
4212 $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>';
4213 // $menubarTag .= '<div tabindex="0" class="m3panel_wrap">';
4214 $menubarTag .= '<div>';
4215 $menubarTag .= '<ul class="m3-nav m3-navbar-nav">';
4216 if ($gEnvManager->isSystemAdmin()){ // 管理画面、編集モードは、管理者権限がある場合のみ有効
4217 $menubarTag .= $adminTag;
4218 $menubarTag .= $editTag;
4220 $menubarTag .= $logoutTag;
4221 $menubarTag .= $widgetToolTag;
4222 $menubarTag .= '</ul>';
4223 $menubarTag .= '</div>';
4224 $menubarTag .= '</div>';
4225 // $menubarTag .= '</div>';
4227 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4228 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4229 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").append(\'' . $menubarTag . '\');' . M3_NL;
4230 //$this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("#m3slidemenubarpanel").m3SlideMenubar();' . M3_NL;
4231 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(".m3panel_top").m3slidepanel({ "position": "top", "type": "push" });' . M3_NL;
4232 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").css("position", "relative");' . M3_NL;
4233 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetHelp($(\'#m3slidepanel\'));' . M3_NL;
4234 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetupWidgetTool(\'m3widgettoolbutton\');' . M3_NL;
4235 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4239 // ##### フロント画面からのウィジェット操作用ツールバー #####
4240 if (!$gEnvManager->isAdminDirAccess() &&
4241 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4242 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
4243 if ($gEnvManager->isSystemManageUser()){ // 一般用画面で管理者権限がある場合のみ有効
4245 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').each(function(){' . M3_NL;
4246 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var attrs = m3_splitAttr($(this).attr(\'m3\'));' . M3_NL;
4247 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var widgetId = attrs[\'widgetid\'];' . M3_NL;
4248 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var serialNo = attrs[\'serial\'];' . M3_NL;
4249 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var configId = attrs[\'configid\'];' . M3_NL;
4250 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var useconfig = attrs[\'useconfig\'];' . M3_NL;
4252 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'\';' . M3_NL;
4253 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (useconfig == 1){' . M3_NL;
4254 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4255 'html += \'<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\\\'\' + widgetId + \'\\\', \' + configId + \', \' + serialNo + \');return false;" rel="m3help" data-container="body" title="ウィジェット設定">' .
4256 '<img src="' . $rootUrl . self::CONFIG_ICON32_FILE . '" alt="ウィジェット設定" width="32" height="32" /></a>\';' . M3_NL;
4257 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4258 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4259 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) .
4260 '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="タイトル・スタイル調整">' .
4261 '<img src="' . $rootUrl . self::ADJUST_ICON32_FILE . '" alt="タイトル・スタイル調整" width="32" height="32" /></a>\';' . M3_NL;
4263 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (html != \'\'){' . M3_NL;
4264 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4265 'html = \'<div class="m3tooltip" style="display:none;">\' + html + \'<a class="m3closebox" href="javascript:void(0);" rel="m3help" data-container="body" title="閉じる">' .
4266 '<img src="' . $rootUrl . self::CLOSE_BOX_ICON32_FILE . '" alt="閉じる" width="11" height="11" /></a></div>\';' . M3_NL;
4268 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).append(html);' . M3_NL;
4269 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4271 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).click(function(){' . M3_NL;
4272 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4273 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (tooltipObj.css(\'display\') == \'none\'){' . M3_NL;
4274 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (_m3ShowWidgetTool){' . M3_NL;
4275 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'tooltipObj.show();' . M3_NL;
4276 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4277 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4278 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.hide();' . M3_NL;
4279 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4280 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4281 // ウィジェットボーダーハイライト、ツールチップ表示
4282 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).hover(function(){' . M3_NL;
4283 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4284 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(this).addClass(\'m3_widget_highlight\');' . M3_NL;
4285 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4286 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var pos = $(this).position();' . M3_NL;
4287 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var width = $(this).outerWidth();' . M3_NL;
4288 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipWidth = tooltipObj.outerWidth(true);' . M3_NL;
4289 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var x = pos.left + width - tooltipWidth;' . M3_NL;
4290 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var y = pos.top;' . M3_NL;
4291 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.css({position: "absolute",top: y + "px", left: x + "px"}).show();' . M3_NL;
4292 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4293 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}, function(){' . M3_NL;
4294 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).removeClass(\'m3_widget_highlight\');' . M3_NL;
4295 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4296 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'tooltipObj.hide();' . M3_NL;
4297 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4299 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3closebox\').click(function(event){' . M3_NL;
4300 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).children(\'.m3tooltip\').hide();' . M3_NL;
4301 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4303 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4304 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var offset = $(this).offset();' . M3_NL;
4305 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).outerWidth();' . M3_NL;
4306 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3edittool\').each(function(){' . M3_NL;
4307 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).offset({left: offset.left});' . M3_NL;
4308 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).width(width);' . M3_NL;
4309 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4310 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4313 $this->initScript .= M3_INDENT_SPACE . 'var widgetWindow = \'<div class="m3_contextmenu" id="m3_widgetmenu" style="visibility:hidden;">\';' . M3_NL;
4314 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<ul>\';' . M3_NL;
4315 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<li id="m3_wconfig"><img src="\' + M3_ROOT_URL + \'/images/system/config.png" /> <span>ウィジェットの設定</span></li>\';' . M3_NL;
4316 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4317 $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;
4319 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</ul>\';' . M3_NL;
4320 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</div>\';' . M3_NL;
4321 $this->initScript .= M3_INDENT_SPACE . '$("body").append(widgetWindow);' . M3_NL;
4322 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').contextMenu(\'m3_widgetmenu\', {' . M3_NL;
4323 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'menuStyle: {' . M3_NL;
4324 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// border : "2px solid green",' . M3_NL;
4325 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'backgroundColor: \'#FFFFFF\',' . M3_NL;
4326 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'width: "150px",' . M3_NL;
4327 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'textAlign: \'left\',' . M3_NL;
4328 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'font: \'12px/1.5 Arial, sans-serif\'' . M3_NL;
4329 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4330 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'itemStyle: {' . M3_NL;
4331 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'padding: \'3px 3px\'' . M3_NL;
4332 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4333 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'bindings: {' . M3_NL;
4334 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wconfig\': function(t){' . M3_NL;
4335 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4336 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4337 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'alert("このウィジェットには設定画面がありません");' . M3_NL;
4338 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'return;' . M3_NL;
4339 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4340 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowConfigWindow(attrs[\'widgetid\'], attrs[\'configid\'], attrs[\'serial\']);' . M3_NL;
4341 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '},' . M3_NL;
4342 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wadjust\': function(t){' . M3_NL;
4343 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4344 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowAdjustWindow(attrs[\'configid\'], attrs[\'serial\'], M3_PAGE_ID, M3_PAGE_SUB_ID);' . M3_NL;
4345 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4346 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4347 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onContextMenu: function(e){' . M3_NL;
4348 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4349 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return true;' . M3_NL;
4350 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4351 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return false;' . M3_NL;
4352 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4353 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4354 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onShowMenu: function(e, menu){' . M3_NL;
4355 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// メニュー項目の変更' . M3_NL;
4356 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var attrs = m3_splitAttr($(e.target).parents(\'dl\').attr(\'m3\'));' . M3_NL;
4357 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4358 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(\'#m3_wconfig\', menu).remove();' . M3_NL;
4359 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4360 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'return menu;' . M3_NL;
4361 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4362 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4365 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3content_private\').each(function(){' . M3_NL;
4366 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4367 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var top = pos.top;' . M3_NL;
4368 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var left = pos.left;' . M3_NL;
4369 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).css(\'width\');' . M3_NL;
4370 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var height = $(this).css(\'height\');' . M3_NL;
4371 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'<div class="m3content_overlay"><div><h2>非公開</h2></div></div>\';' . M3_NL;
4372 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).prepend(html);' . M3_NL;
4373 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var overlayObj = $(this).children(\'.m3content_overlay div\');' . M3_NL;
4374 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'overlayObj.css({ position:"absolute", top:top + "px", left:left + "px" }).show();' . M3_NL;
4375 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4378 // ##### フロント画面のデフォルトのJavaスクリプト #####
4379 // if (!$gEnvManager->isAdminDirAccess()){
4380 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (jQuery().tooltip) $(\'[rel=tooltip]\').tooltip();' . M3_NL; // 標準ツールチップ作成
4382 // ポップアップメッセージがある場合は表示
4383 if (!empty($this->popupMsg)){
4384 $replaceStr .= 'alert("' . $this->popupMsg . '");' . M3_NL;
4387 if ($cleanType == 1){
4388 // HTMLのクリーン処理が必要なときはコードを埋め込む
4389 $this->initScript .= ' $(\'.PostHeaderIcons\').remove();' . M3_NL;// 不要なアイコン表示タグの削除
4390 $this->initScript .= ' $(\'.PostMetadataHeader\').each(function(i){' . M3_NL;
4391 $this->initScript .= ' if ($(this).text().trim() == \'\') $(this).remove();' . M3_NL;
4392 $this->initScript .= ' });' . M3_NL;
4396 $replaceStr .= $this->getLastContents();
4399 if (!empty($this->initScript)){
4400 $replaceStr .= '$(function(){' . M3_NL;
4401 $replaceStr .= $this->initScript;
4402 $replaceStr .= '});' . M3_NL;
4405 //$replaceStr .= '// -->' . M3_NL;
4406 //$replaceStr .= '</script>' . M3_NL;
4407 $replaceStr .= '//]]>' . M3_NL;
4408 $replaceStr .= '</script>' . M3_NL;
4410 // HEADタグに埋め込むCSS,JavaScript,任意文字列
4411 if (count($this->headCss) > 0){
4412 // CSSの場合は全体をstyleタグで囲む
4413 $replaceStr .= '<style type="text/css">' . M3_NL;
4414 $replaceStr .= '<!--' . M3_NL;
4415 for ($i = 0; $i < count($this->headCss); $i++){
4416 $replaceStr .= $this->headCss[$i];
4418 $replaceStr .= M3_NL . '//-->' . M3_NL;
4419 $replaceStr .= '</style>' . M3_NL;
4421 if (count($this->headScript) > 0){
4422 // JavaScriptの場合は全体をscriptタグで囲む
4423 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
4424 //$replaceStr .= '<!--' . M3_NL;
4425 $replaceStr .= '<script type="text/javascript">' . M3_NL;
4426 $replaceStr .= '//<![CDATA[' . M3_NL;
4427 for ($i = 0; $i < count($this->headScript); $i++){
4428 $replaceStr .= $this->headScript[$i];
4430 //$replaceStr .= M3_NL . '//-->' . M3_NL;
4431 //$replaceStr .= '</script>' . M3_NL;
4432 $replaceStr .= M3_NL;
4433 $replaceStr .= '//]]>' . M3_NL;
4434 $replaceStr .= '</script>' . M3_NL;
4436 if (count($this->headString) > 0){
4438 for ($i = 0; $i < count($this->headString); $i++){
4439 $replaceStr .= $this->headString[$i];
4448 * @param string $position HTMLテンプレート上の書き出し位置
4449 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
4450 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
4451 * @param array $attr その他属性
4452 * @return string 出力コンテンツ
4454 function getContents($position, $style = '', $templateVer = 0, $attr = array())
4456 static $render; // HTML生成オブジェクト
4457 global $gRequestManager;
4458 global $gEnvManager;
4461 $filename = $gEnvManager->getCurrentPageId();
4462 $subId = $gEnvManager->getCurrentPageSubId();
4463 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
4465 // ポジション名表示モードに応じて出力を作成
4466 $contents = ''; // 出力コンテンツ
4467 switch ($this->showPositionMode){
4469 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4470 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4471 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
4472 if ($ret){ // 1行以上データが取得できたとき
4473 $this->pageDefRows = $rows; // ページ定義レコード
4474 $this->pageDefPosition = $position;
4476 $this->pageDefRows = array();
4477 $this->pageDefPosition = '';
4481 $count = count($this->pageDefRows);
4483 if ($templateVer == 0){ // ########## Joomla!v1.0テンプレートの場合 ##########
4484 ob_start();// バッファ作成
4486 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4487 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
4488 for ($i = 0; $i < $count; $i++){
4489 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4490 $widgetId = $this->pageDefRows[$i]['wd_id'];
4492 // ### 遅延実行ウィジェットはキャッシュしない ###
4493 // キャッシュデータがあるときはキャッシュデータを使用
4494 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4496 if (empty($cacheData)){ // キャッシュデータがないとき
4498 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, $widgetHeaderType);
4500 $widgetContent = ob_get_contents();
4503 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4505 // ウィジェットの内枠(コンテンツ外枠)を設定
4506 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4509 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4510 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4513 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4514 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4515 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4516 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4517 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4518 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4519 // ウィジェット表示タイプによる表示制御
4520 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4521 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4522 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4523 if (!empty($controlType)){
4524 switch ($controlType){
4525 case 1: // ログイン時のみ表示
4526 $widgetStatusClass .= ' ' . self::WIDGET_VISIBLE_IN_LOGIN_CLASS; // ログイン時のみ表示ウィジェットクラス
4528 case 2: // 非ログイン時のみ表示
4529 $widgetStatusClass .= ' ' . self::WIDGET_VISIBLE_IN_NOT_LOGIN_CLASS; // 非ログイン時のみ表示ウィジェットクラス
4535 if (!empty($pageState)){
4536 switch ($pageState){
4538 if (!$this->isPageTopUrl) $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4545 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4546 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4547 $hasAdmin = '0'; // 管理画面があるかどうか
4548 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4549 $shared = '0'; // 共通属性があるかどうか
4550 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4551 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4552 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4553 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . '>' . $widgetContent . '</div>';
4555 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4556 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4558 } else { // キャッシュデータがあるとき
4559 $widgetContent = $cacheData;
4562 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4563 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4564 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4566 $contents .= $widgetContent;
4568 // ##### 外部出力用のCSSがある場合は追加 #####
4569 $exportCss = $this->pageDefRows[$i]['pd_css'];
4570 if (!empty($exportCss)){
4572 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4573 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4574 $this->addExportCss($exportCss);
4577 ob_end_clean(); // バッファ破棄
4579 if ($i < $count) return '';// 処理中断のときは終了
4580 } else if ($templateVer == 100){ // ########## WordPressテンプレートの場合 ##########
4581 ob_start();// バッファ作成
4583 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4584 //$widgetHeaderType = $this->getTemplateWidgetHeaderType();
4585 for ($i = 0; $i < $count; $i++){
4586 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4587 $widgetId = $this->pageDefRows[$i]['wd_id'];
4589 // ### 遅延実行ウィジェットはキャッシュしない ###
4590 // キャッシュデータがあるときはキャッシュデータを使用
4591 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4593 if (empty($cacheData)){ // キャッシュデータがないとき
4594 // WordPressウィジェット用のパラメータ設定
4595 $gEnvManager->setWpWidgetClass(''); // ウィジェットクラス名初期化
4598 // $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, $widgetHeaderType);
4599 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, 0/*タイトル出力なし*/);
4601 $widgetContent = ob_get_contents();
4603 // WordPressウィジェット用のパラメータ設定
4604 $widgetClassName = $gEnvManager->getWpWidgetClass(); // ウィジェットクラス名
4606 $trimContent = trim($widgetContent);
4607 if (!empty($trimContent)){ // 出力が空でない場合
4610 if (!isset($render)) $render = new WPRender(); // WordPress用HTML生成オブジェクト
4612 // デフォルトのウィジェットタイトル取得
4613 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4616 //$joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4618 // 遅延ウィジェットのときはタイトルタグを埋め込む
4619 if (!empty($titleTag)) $defaultTitle = $titleTag;
4621 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4622 $title = $this->pageDefRows[$i]['pd_title'];
4623 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4624 if (empty($title)) $title = $defaultTitle;
4626 $title = ''; // タイトルは非表示
4629 // WordPress用パラメータ作成
4630 $params = array(); // ウィジェットごとの属性
4631 if (!empty($widgetClassName)) $params['moduleclass'] = $widgetClassName; // ウィジェットクラス名
4634 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . ($i + 1); // ウィジェット識別用ユニークタグ
4636 if (strcmp($position, 'main') == 0){// メイン部のとき
4637 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
4639 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
4643 // $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4645 // ウィジェットの内枠(コンテンツ外枠)を設定
4646 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4650 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4651 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4654 // $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4655 // $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4656 // if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4657 // $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4658 // $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4660 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4661 // ウィジェット表示タイプによる表示制御
4662 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4663 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4664 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4665 if (!empty($controlType)){
4666 switch ($controlType){
4667 case 1: // ログイン時のみ表示
4668 $widgetStatusClass .= ' ' . self::WIDGET_VISIBLE_IN_LOGIN_CLASS; // ログイン時のみ表示ウィジェットクラス
4670 case 2: // 非ログイン時のみ表示
4671 $widgetStatusClass .= ' ' . self::WIDGET_VISIBLE_IN_NOT_LOGIN_CLASS; // 非ログイン時のみ表示ウィジェットクラス
4677 if (!empty($pageState)){
4678 switch ($pageState){
4680 if (!$this->isPageTopUrl) $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4687 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4688 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4689 $hasAdmin = '0'; // 管理画面があるかどうか
4690 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4691 $shared = '0'; // 共通属性があるかどうか
4692 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4693 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4694 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4695 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . '>' . $widgetContent . '</div>';
4697 // $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4698 // $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4700 } else { // キャッシュデータがあるとき
4701 $widgetContent = $cacheData;
4704 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4705 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4706 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4708 $contents .= $widgetContent;
4710 // ##### 外部出力用のCSSがある場合は追加 #####
4711 $exportCss = $this->pageDefRows[$i]['pd_css'];
4712 if (!empty($exportCss)){
4714 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4715 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4716 $this->addExportCss($exportCss);
4719 ob_end_clean(); // バッファ破棄
4721 if ($i < $count) return '';// 処理中断のときは終了
4722 } else { // ########## Joomla!v1.5テンプレートの場合 ##########
4723 // テンプレート側で指定されたメニューの表示属性を設定
4724 $gEnvManager->setMenuAttr($attr);
4728 if (!empty($attr['type'])) $posType = $attr['type'];
4730 for ($i = 0; $i < $count; $i++){
4731 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4732 $widgetId = $this->pageDefRows[$i]['wd_id'];
4734 // ### 遅延実行ウィジェットはキャッシュしない ###
4735 // キャッシュデータがあるときはキャッシュデータを使用
4736 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4738 if (empty($cacheData)){ // キャッシュデータがないとき
4740 $gEnvManager->setCurrentWidgetTitle('');
4742 // Joomla用のパラメータを初期化
4743 $gEnvManager->setCurrentWidgetJoomlaParam(array());
4747 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, 0/*タイトル出力なし*/);
4748 $widgetContent = ob_get_contents();
4750 $trimContent = trim($widgetContent);
4751 if (!empty($trimContent)){ // 出力が空でない場合
4752 $isRendered = false; // Joomla!の描画処理を行ったかどうか
4753 if (!empty($this->pageDefRows[$i]['pd_use_render'])){ // Joomla!の描画処理を使用する場合
4754 // Joomla!ウィジェットの出力に埋め込む
4755 if (strcasecmp($style, 'none') != 0){
4757 if (!isset($render)) $render = new JRender();
4759 // デフォルトのウィジェットタイトル取得
4760 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4763 $joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4765 // 遅延ウィジェットのときはタイトルタグを埋め込む
4766 if (!empty($titleTag)) $defaultTitle = $titleTag;
4768 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4769 $title = $this->pageDefRows[$i]['pd_title'];
4770 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4771 if (empty($title)) $title = $defaultTitle;
4773 $title = ''; // タイトルは非表示
4777 $params = array(); // ウィジェットごとの属性
4778 $widgetType = $this->pageDefRows[$i]['wd_type']; // ウィジェットタイプ
4780 // オプションのJoomlaクラス(縦型メニュー(art-vmenu)等)
4781 $joomlaClass = $this->pageDefRows[$i]['wd_joomla_class']; // 「wd_joomla_class」は使っていない?
4782 if (!empty($joomlaClass)) $params['moduleclass_sfx'] = $joomlaClass;
4783 if (isset($joomlaParam['moduleclass_sfx'])) $params['moduleclass_sfx'] = $joomlaParam['moduleclass_sfx'];// ウィジェットでjoomla用パラメータの設定があるとき
4785 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
4786 $moduleContent = '';
4788 // メニュータイプのウィジェットのみ実行
4789 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4791 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
4792 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4793 $widgetContent = $moduleContent;
4795 if (strcmp($position, 'main') == 0){// メイン部のとき
4796 // ウィジェットの内枠(コンテンツ外枠)を設定
4797 // ウィジェットの内枠はレンダーで設定
4798 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4799 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4800 } else { // その他の位置のとき
4801 // ウィジェットの内枠(コンテンツ外枠)を設定
4802 // ウィジェットの内枠はレンダーで設定
4803 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4805 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4808 /* if (strcmp($position, 'main') == 0){// メイン部のとき
4809 // ウィジェットの内枠(コンテンツ外枠)を設定
4810 // ウィジェットの内枠はレンダーで設定
4811 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4812 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4813 // } else if (strStartsWith($position, 'user') || // ナビゲーションメニュー位置の場合
4814 } else if (strcasecmp($position, 'user3') == 0 || // ナビゲーションメニュー位置の場合
4815 strcasecmp($position, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
4816 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
4818 $moduleContent = '';
4819 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
4820 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4822 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
4823 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4825 $moduleContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4827 $widgetContent = $moduleContent;
4829 // ウィジェットの内枠(コンテンツ外枠)を設定。メニュー処理後に付加。
4830 // ウィジェットの内枠はレンダーで設定
4831 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4832 } else { // その他の位置のとき
4833 // ウィジェットの内枠(コンテンツ外枠)を設定
4834 // ウィジェットの内枠はレンダーで設定
4835 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4837 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4839 $isRendered = true; // Joomla!の描画処理を行ったかどうか
4842 if (!$isRendered){ // Joomla!の描画処理を行っていない場合
4844 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4846 // ウィジェットの内枠(コンテンツ外枠)を設定
4847 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4850 if (!$ret) return ''; // 処理中断のときは終了
4853 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4854 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4857 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4858 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4859 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4860 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4861 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4862 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4863 // ウィジェット表示タイプによる表示制御
4864 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4865 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4866 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4867 if (!empty($controlType)){
4868 switch ($controlType){
4869 case 1: // ログイン時のみ表示
4870 $widgetStatusClass .= ' ' . self::WIDGET_VISIBLE_IN_LOGIN_CLASS; // ログイン時のみ表示ウィジェットクラス
4872 case 2: // 非ログイン時のみ表示
4873 $widgetStatusClass .= ' ' . self::WIDGET_VISIBLE_IN_NOT_LOGIN_CLASS; // 非ログイン時のみ表示ウィジェットクラス
4879 if (!empty($pageState)){
4880 switch ($pageState){
4882 if (!$this->isPageTopUrl) $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4889 //$editInfo = 'widgetid:' . $this->pageDefRows[$i]['wd_id'];
4890 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4891 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4892 $hasAdmin = '0'; // 管理画面があるかどうか
4893 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4894 $shared = '0'; // 共通属性があるかどうか
4895 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4896 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4897 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4898 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . '>' . $widgetContent . '</div>';
4900 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4901 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4903 } else { // キャッシュデータがあるとき
4904 $widgetContent = $cacheData;
4907 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4908 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4909 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4911 $contents .= $widgetContent;
4913 // ##### 外部出力用のCSSがある場合は追加 #####
4914 $exportCss = $this->pageDefRows[$i]['pd_css'];
4915 if (!empty($exportCss)){
4917 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4918 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4919 $this->addExportCss($exportCss);
4924 if ($position == 'main'){ // メイン部のときは、メッセージを出力
4925 /*if (strlen($this->popupMsg) > 0){
4926 echo "\n<script language=\"javascript\">alert('" . addslashes($this->popupMsg) . "');</script>";
4928 } else if ($position == 'debug'){ // デバッグ文出力
4934 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:3px solid #f00;color:#700;">ポジション名: ';
4935 $contents .= '<b>' . $position . '</b>';
4936 $contents .= '</div>';
4938 case 2: // ポジション表示(ウィジェット付き)
4939 $rev = '555'; // データのリビジョン番号
4940 // ポジションのHTMLタグIDを作成
4943 for ($i = 0; $i < 100; $i++){
4944 $posId = $position . '_' . $num;
4945 $viewPosId = self::POSITION_TAG_HEAD . $posId;
4946 if (!in_array($viewPosId, $this->viewPosId)) break;
4949 $this->viewPosId[] = $viewPosId;// IDを保存
4951 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4952 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4953 $ret = $this->db->getPageDef($filename, $subId, $position, $rows);
4954 if ($ret){ // 1行以上データが取得できたとき
4955 $this->pageDefRows = $rows; // ページ定義レコード
4956 $this->pageDefPosition = $position;
4958 $this->pageDefRows = array();
4959 $this->pageDefPosition = '';
4963 // ナビゲーション型のポジションの場合はアイコン付加
4964 //if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4965 if ($style == self::WIDGET_STYLE_NAVMENU) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4966 $contents .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
4967 $contents .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
4970 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
4971 //$contents .= $this->getWidgetList($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $widgetTagHead, $this->pageDefRows);
4972 $contents .= $this->getWidgetList($filename, $subId, $widgetTagHead, $this->pageDefRows);
4974 $contents .= '</div>' . M3_NL;
4977 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">param error</div>';
4981 $this->viewPositions[] = $position;
4986 * 各部品のHTML出力(WordPressテンプレート専用)
4988 * @param string $position HTMLテンプレート上の書き出し位置
4989 * @param bool $showTitle タイトルを表示するかどうか
4990 * @return string 出力コンテンツ
4992 function getWPContents($position, $showTitle = true)
4995 return $this->getContents($position, self::WIDGET_STYLE_WORDPRESS/*WordPressテンプレート用出力*/, 100/*WordPressテンプレート*/);
4997 return $this->getContents($position, self::WIDGET_STYLE_WORDPRESS_NOTITLE/*WordPressテンプレート(タイトルなし)用出力*/, 100/*WordPressテンプレート*/);
5001 * その他のポジションブロックデータを取得
5003 * @param string ポジション作成用タグ
5005 function getRestPositionData()
5007 global $gEnvManager;
5009 $restPositionData = '';
5011 $pageId = $gEnvManager->getCurrentPageId();
5012 $subId = $gEnvManager->getCurrentPageSubId();
5014 $restPositions = array_values(array_diff($this->defPositions/*全ポジション*/, $this->viewPositions/*表示済みポジション*/));
5015 $positionCount = count($restPositions);
5016 for ($i = 0; $i < $positionCount; $i++){
5017 $posHead = ''; // アイコン付加用
5018 $position = $restPositions[$i];
5019 $posId = $position . '_0';
5020 $viewPosId = self::POSITION_TAG_HEAD . $posId;
5023 $ret = $this->db->getPageDef($pageId, $subId, $position, $rows);
5025 //$pageDefRows = $rows; // ページ定義レコード
5027 $restPositionData .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">'; // リビジョン番号を付加
5028 $restPositionData .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>';
5031 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
5032 $contents = $this->getWidgetList($pageId, $subId, $widgetTagHead, $rows);
5033 $contents = str_replace(M3_NL, '', $contents);
5034 $contents = str_replace('\'', '\\\'', $contents);
5035 $restPositionData .= $contents;
5036 $restPositionData .= '</div>';
5038 $this->viewPosId[] = $viewPosId;// IDを保存
5041 return $restPositionData;
5044 * ウィジェット共通のコンテンツ追加処理
5046 * @param string $src ウィジェット出力
5047 * @param array $pageDefParam 画面定義レコード
5048 * @return string コンテンツを付加したウィジェット出力
5050 function _addOptionContent($src, $pageDefParam)
5053 $dest = $pageDefParam['pd_top_content'] . $src . $pageDefParam['pd_bottom_content'];
5056 if ($pageDefParam['pd_show_readmore']){
5057 $title = $pageDefParam['pd_readmore_title'];
5058 if (empty($title)) $title = self::DEFAULT_READMORE_TITLE;
5059 $dest .= '<div><a href="' . convertUrlToHtmlEntity($pageDefParam['pd_readmore_url']) . '">' . convertToHtmlEntity($title) . '</a></div>';
5064 * BODYタグに付加するスタイルを取得(管理画面用)
5066 * @param string CSS文字列
5068 function getBodyStyle()
5070 // 画面透過モードのときスタイルを追加
5072 if ($this->isTransparentMode) $transCss = ' style="background-color:transparent;"';
5078 * @param string $position HTMLテンプレート上の書き出し位置
5079 * @return int ウィジェットの数
5081 function getWidgetsCount($position)
5083 global $gRequestManager;
5084 global $gEnvManager;
5085 static $widgetCountArray = array();
5087 // 管理画面へのアクセスでログインされていないときは0を返す
5088 if ($gEnvManager->isAdminDirAccess() && !$gEnvManager->isSystemManageUser()){ // 管理画面へのアクセスのときでシステム運用権限がない場合
5093 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
5094 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
5095 return 1; // ウィジェットが設定されていないポジション名を表示するために固定で値を返す
5098 // 単一ポジション以外の設定のときは固定で返す(or等)
5099 $pos = strpos($position, ' ');
5100 if ($pos !== false) return 1;
5102 // 既にウィジェット数が取得されている場合は保存値を返す
5103 $widgetCount = $widgetCountArray[$position];
5104 if (isset($widgetCount)) return $widgetCount;
5107 $filename = $gEnvManager->getCurrentPageId();
5108 $subId = $gEnvManager->getCurrentPageSubId();
5109 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
5111 // 取得しようとするページ定義のポジションが既に取得しているポジションと異なるときはデータを取得
5112 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // 現在取得しているページ定義のポジション
5113 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
5114 if ($ret){ // 1行以上データが取得できたとき
5115 $this->pageDefRows = $rows; // ページ定義レコード
5116 $this->pageDefPosition = $position;
5118 $this->pageDefRows = array();
5119 $this->pageDefPosition = '';
5122 // ### ウィジェット数を取得 ###
5123 // テンプレートのカラム制御を行うためにウィジェット表示条件でウィジェット数を取得
5125 $rowCount = count($this->pageDefRows);
5126 for ($i = 0; $i < $rowCount; $i++){
5127 // $condition = trim($this->pageDefRows[$i]['wd_visible_condition']);
5128 $condition = trim($this->pageDefRows[$i]['pd_visible_condition']);
5129 if (empty($condition)){ // ウィジェット表示条件が設定されていない場合はウィジェットを表示
5131 } else { // ウィジェット表示条件が設定されている場合はパラメータをチェック
5132 $conds = explode(';', $condition);
5133 for ($j = 0; $j < count($conds); $j++){
5134 $pos = strpos($conds[$j], '=');
5135 if ($pos !== false){ // URLクエリーパラメータ条件がマッチした場合はウィジェットを表示
5136 list($key, $value) = explode('=', trim($conds[$j]));
5138 $value = trim($value);
5139 if (!empty($key) && !empty($value)){
5140 $requestValue = $gRequestManager->trimValueOf($key);
5141 if ($value == $requestValue) $widgetCount++;
5147 // $widgetCount = count($this->pageDefRows);
5148 $widgetCountArray[$position] = $widgetCount;
5149 return $widgetCount;
5152 * ウィジェットのページ定義シリアル番号からウィジェットCSS IDを取得
5154 * @param int $defSerial ページ定義シリアル番号
5155 * @param string $pageId ページID
5156 * @param string $subpage ページサブID
5157 * @param string $position 表示位置ID
5158 * @return string CSSエレメントID
5160 function getWidgetCssId($defSerial, $pageId, $pageSubId, $position)
5163 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
5165 $rowCount = count($rows);
5166 for ($i = 0; $i < $rowCount; $i++){
5168 if ($row['pd_serial'] == $defSerial){
5169 $elementId = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
5179 * 画面作成機能でウィジェット情報を取得するためのAjaxインターフェイス
5181 * @param RequestManager $request HTTPリクエスト処理クラス
5183 function getWidgetInfoByAjax($request)
5185 global $gEnvManager;
5186 global $gDesignManager;
5187 global $gCacheManager;
5189 // アクセスするページIDからPC用、携帯用、スマートフォン用かを判断
5190 $widgetDeviceType = 0; // 端末タイプをPC用に初期化
5191 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
5192 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
5193 $mobilePageIdPrefix = M3_DIR_NAME_MOBILE . '_';
5194 $smartphonePageIdPrefix = M3_DIR_NAME_SMARTPHONE . '_';
5195 if (strncmp($pageId, $mobilePageIdPrefix, strlen($mobilePageIdPrefix)) == 0){
5196 $widgetDeviceType = 1; // 携帯用
5197 } else if (strncmp($pageId, $smartphonePageIdPrefix, strlen($smartphonePageIdPrefix)) == 0){
5198 $widgetDeviceType = 2; // スマートフォン用
5201 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
5202 if ($task == 'list'){
5204 $ret = $this->db->getAvailableWidgetList($widgetDeviceType, $rows);
5206 $currentCategoryId = '_none'; // 現在のウィジェットカテゴリー初期化
5207 for ($i = 0; $i < count($rows); $i++){
5208 $widgetId = $rows[$i]['wd_id'];
5209 $desc = $rows[$i]['wd_description'];
5210 $widgetTag = self::WIDGET_TYPE_TAG_HEAD . $widgetId;
5211 $categoryId = $rows[$i]['wd_category_id'];
5214 if ($categoryId != $currentCategoryId){
5216 echo '</dd>' . M3_NL;
5217 echo '</dl>' . M3_NL;
5219 echo '<dl class="m3accordion">' . M3_NL;
5220 echo '<dt>' . $rows[$i]['wt_name'] . '</dt>' . M3_NL;
5221 echo '<dd>' . M3_NL;
5224 $currentCategoryId = $categoryId;
5227 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
5228 if ($gEnvManager->getUseSslAdmin()){
5229 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
5230 $image = $gEnvManager->getSslUrl($image);
5232 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
5233 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
5234 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
5239 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5240 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5244 if (!empty($rows[$i]['wd_template_type'])){ // 対応テンプレートタイプ
5245 $templateTypeArray = explode(',', $rows[$i]['wd_template_type']);
5246 if (in_array('bootstrap', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_BOOTSTRAP; // Bootstrap型テンプレート対応
5247 if (in_array('wordpress', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_WORDPRESS; // WordPress型テンプレート対応
5249 if (!empty($functionMark)) $functionMark = '<hr />' . $functionMark;
5251 echo '<dl class="m3_widgetlist_item" id="' . $widgetTag . '">' . M3_NL;
5252 echo '<dt>' . $widgetMark . $rows[$i]['wd_name'] . '</dt>' . M3_NL; // ウィジェット名
5253 echo '<dd><table style="width:100%;"><tr style="vertical-align:top;"><td style="width:35px;">' . $imageTag . '</td><td>' . $desc . '</td></tr></table>';
5254 echo $functionMark . '</dd>' . M3_NL;
5255 echo '</dl>' . M3_NL;
5258 if ($i == count($rows) - 1){
5259 echo '</dd>' . M3_NL;
5260 echo '</dl>' . M3_NL;
5264 } else if ($task == 'wget' || $task == 'wdelete' || $task == 'wtoggle' || $task == 'wadd' || $task == 'wmove'){ // ウィジェット再取得、ウィジェット削除,ウィジェット共通属性変更、ウィジェット追加、ウィジェット移動のとき
5265 $rev = $request->trimValueOf('rev'); // リビジョン
5266 $serial = $request->trimValueOf('serial');
5267 $position = $request->trimValueOf('pos');
5268 $widgetsStr = $request->trimValueOf('widgets');
5269 if (empty($widgetsStr)){
5272 $widgets = explode(',', $widgetsStr);
5274 $shared = $request->trimValueOf('shared');
5275 $updatepos = explode(',', $request->trimValueOf('updatepos'));
5276 $index = $request->trimValueOf('index');
5279 if ($task == 'wmove'){
5280 $positions = explode(',', $position);
5281 if (count($positions) >= 2){
5282 $position = $positions[0];
5283 $position2 = $positions[1];
5285 $position = $positions[0];
5289 // ##### エラーチェック #####
5292 $rev = '111'; // データのリビジョン番号
5295 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows); // 0レコードでも正常とする
5297 // 変更前のウィジェットのシリアル番号をチェック
5298 if (count($widgets) == count($rows)){
5299 if (!($task == 'wmove' && empty($position2))){ // 同一ブロック内の移動の場合はチェックなし
5300 for ($i = 0; $i < count($rows); $i++){
5301 if ($widgets[$i] != $rows[$i]['pd_serial']){// シリアル番号
5312 if (!$isErr){ // エラーなしのとき
5313 if ($task == 'wdelete'){
5314 $ret = $this->db->deleteWidget($serial);
5315 } else if ($task == 'wtoggle'){
5317 if (empty($shared)) $newShared = 1;
5318 $ret = $this->db->toggleSharedWidget($pageId, $pageSubId, $serial, $newShared);
5319 } else if ($task == 'wadd'){ // ウィジェットの追加
5320 $widget = $request->trimValueOf('widget');
5323 if (empty($widget)) $isErr = true;
5326 if (!$isErr) $this->db->addWidget($pageId, $pageSubId, $position, $widget, $index);
5327 } else if ($task == 'wmove'){
5329 if (!$isErr) $this->db->moveWidget($pageId, $pageSubId, $position, $serial, $index);
5333 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows);// 0レコードでも正常とする
5335 // 移動のときは、移動元と移動先の再表示データを取得
5336 if ($task == 'wmove' && !empty($position2)){
5337 $ret = $this->db->getPageDef($pageId, $pageSubId, $position2, $rows2);// 0レコードでも正常とする
5342 echo '<div>' . M3_NL;
5343 for ($i = 0; $i < count($updatepos); $i++){
5345 $widgetTagHead = str_replace(self::POSITION_TAG_HEAD, self::WIDGET_TAG_HEAD, $updatepos[$i]);
5348 $posName = str_replace(self::POSITION_TAG_HEAD, '', substr($updatepos[$i], 0, strlen($updatepos[$i]) - strlen(strrchr($updatepos[$i], "_"))));
5349 if ($task == 'wmove' && $posName == $position2){
5352 if (strcasecmp($position2, 'user3') == 0 || strcasecmp($position2, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5353 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position2 . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5354 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position2 . '</h2>' . M3_NL;
5357 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows2);
5361 if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5362 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5363 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
5366 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows);
5369 echo '</div>' . M3_NL;
5371 echo '</div>' . M3_NL;
5374 $gCacheManager->clearAllCache();
5378 * 画面作成用ウィジェット一覧データ出力
5380 * @param string $pageId ページID
5381 * @param string $pageSubId ページサブID
5382 * @param string $widgetTagHead HTMLウィジェットID用のヘッダ
5383 * @param array $rows ウィジェット一覧データ
5384 * @return string ウィジェット一覧出力
5386 function getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows)
5388 global $gEnvManager;
5389 global $gDesignManager;
5390 global $gSystemManager;
5392 if ($gEnvManager->getUseSslAdmin()){
5393 $rootUrl = $gEnvManager->getSslRootUrl();
5395 $rootUrl = $gEnvManager->getRootUrl();
5399 $line = $this->getPageInfo($pageId, $pageSubId);
5400 if (!empty($line)) $pageContentType = $line['pn_content_type'];
5402 $contents = ''; // ウィジェット一覧出力コンテンツ
5403 for ($i = 0; $i < count($rows); $i++){
5404 $widgetId = $rows[$i]['wd_id'];
5405 $desc = $rows[$i]['wd_description'];
5406 $widgetIndex = $rows[$i]['pd_index']; // 表示順
5407 $configId = $rows[$i]['pd_config_id']; // 定義ID
5408 $serial = $rows[$i]['pd_serial']; // シリアル番号
5409 $isShared = empty($rows[$i]['pd_sub_id']); // グローバル属性が設定されているかどうか
5410 $widgetTag = $widgetTagHead . '_' . $i; // ウィジェット識別用ユニークタグ
5411 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
5412 if ($gEnvManager->getUseSslAdmin()){
5413 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
5414 $image = $gEnvManager->getSslUrl($image);
5416 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
5417 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
5418 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
5421 if (empty($rows[$i]['pd_config_name'])){
5422 if ($rows[$i]['wd_use_instance_def'] && $configId == 0){ // インスタンス定義が必要で未定義のとき
5423 $configName = '<span style="color:red;">[未設定]</span>';
5428 $configName = '[' . $rows[$i]['pd_config_name'] . ']';
5430 $hasAdmin = '0'; // 管理画面があるかどうか
5431 $configImg = ''; // 設定アイコンの表示
5433 // ウィジェットの配置位置に問題があるかどうかを表示
5434 // メインコンテンツとページ属性が一致するかどうかチェック
5435 $widgetContentType = $rows[$i]['wd_content_type'];
5436 //if (!empty($widgetContentType) && $widgetContentType != $pageContentType &&
5437 if (!empty($widgetContentType) && $widgetContentType != $pageContentType && empty($rows[$i]['wd_content_widget_id']) && // 編集用のウィジェットが別にある場合は除く(2015/3/24))
5438 (in_array($widgetContentType, $this->_getAllContentType()) || in_array($widgetContentType, $this->_getAllFeatureType()))){
5439 //$title = 'ウィジェット配置注意';
5440 $title = 'ページ属性と不一致';
5441 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::NOTICE_ICON_FILE . '" alt="' . $title . '" /></span> ';
5443 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type']) && $isShared){ // メイン型ウィジェットがグローバル属性を持つとき
5444 $title = 'メイン型ウィジェットはグローバル属性を設定できません';
5445 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::ALERT_ICON_FILE . '" alt="' . $title . '" /></span> ';
5447 if ($rows[$i]['wd_has_admin']){
5449 $title = 'ウィジェット設定';
5450 $configImg .= '<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\'' . $widgetId . '\', \'' . $configId . '\', \'' . $serial . '\');return false;" rel="m3help" data-container="body" title="' . $title . '">' .
5451 '<img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" alt="' . $title . '"/></a> ';
5454 $configImg .= '<span rel="m3help" data-container="body" title="表示順">' . $widgetIndex . '</span>';
5456 $shared = '0'; // 共通属性があるかどうか
5457 $sharedClassName = '';
5458 //if (empty($rows[$i]['pd_sub_id'])){
5459 if ($isShared){ // グローバル属性ウィジェットのとき
5461 $sharedClassName = 'm3_widget_shared'; // 共通ウィジェットのクラス
5463 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
5467 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5468 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5471 $dropdownMenuId = $widgetTag . '_dropdown';
5472 $operationMenu = '<div class="m3widgetdropdown">';
5473 // $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#"><i class="glyphicon glyphicon-list-alt"></i> <b class="caret"></b></a>';
5474 $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#" data-horizontal-offset="4"><b class="caret"></b></a>';
5475 $operationMenu .= '<div id="' . $dropdownMenuId . '" class="m3dropdown m3dropdown-tip m3dropdown-relative m3dropdown-anchor-right">';
5476 $operationMenu .= '<ul class="m3dropdown-menu">';
5477 if ($hasAdmin) $operationMenu .= '<li class="m3_wconfig"><a href="#"><img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" /> <span>ウィジェットの設定</span></a></li>';
5478 $operationMenu .= '<li class="m3_wadjust"><a href="#"><img src="' . $rootUrl . self::ADJUST_ICON_FILE . '" /> <span>タイトル・スタイル調整</span></a></li>';
5480 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を解除</span></a></li>';
5482 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を設定</span></a></li>';
5484 $operationMenu .= '<li class="m3_wdelete"><a href="#"><img src="' . $rootUrl . self::DELETE_ICON_FILE . '" /> <span>このウィジェットを削除</span></a></li>';
5485 $operationMenu .= '</ul>';
5486 $operationMenu .= '</div>';
5487 $operationMenu .= '</div>';
5489 $contents .= '<dl class="m3_widget m3_widget_sortable" id="' . $widgetTag . '" ' . $m3Option . ' >' . M3_NL;
5490 $contents .= '<dt class="m3_widget_with_check_box ' . $sharedClassName . '"><div class="m3widgettitle">' . $widgetMark . $rows[$i]['wd_name'] . '</div>' . $operationMenu . '</dt>' . M3_NL;
5491 $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;
5492 $contents .= '<table style="width:100%;"><tr><td>' . $configName . '</td><td style="text-align:right;">' . $configImg . '</td></tr></table></dd>' . M3_NL;
5493 $contents .= '</dl>' . M3_NL;
5500 * @param string $position HTMLテンプレート上の書き出し位置
5501 * @param int $index 行番号
5502 * @param array $fetchedRow fetch取得した行
5503 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
5504 * @param string $titleTag タイトル埋め込み用タグ(遅延ウィジェットの場合のみ作成)
5505 * @param int $widgetHeaderType ウィジェットタイトルを出力方法(0=出力なし、1=Joomla!v1.0PC用出力、2=Joomla!v1.0携帯用出力)
5506 * @return bool 処理を継続するかどうか(true=続行、false=中断)
5508 function pageDefLoop($position, $index, $fetchedRow, $style, &$titleTag, $widgetHeaderType = 0)
5510 global $gEnvManager;
5511 global $gErrorManager;
5512 global $gDesignManager;
5514 // ページ作成中断またはウィジェット処理中断のときは終了
5515 if ($this->isAbort || $this->isWidgetAbort) return false;
5517 // ウィジェット実行停止中のときは空で返す
5518 // 管理者、運営者どのレベルで制限をかける?
5519 if (!$fetchedRow['wd_active']) return true;
5521 // グローバル属性ありの場合は現在のページが例外ページにないかチェック
5522 if (empty($fetchedRow['pd_sub_id'])){
5523 $exceptPageStr = $fetchedRow['pd_except_sub_id'];
5524 if (!empty($exceptPageStr)){
5525 $exceptPageArray = explode(',', $exceptPageStr);
5526 if (in_array($gEnvManager->getCurrentPageSubId(), $exceptPageArray)) return true; // 例外ページの場合は出力しない
5530 // ウィジェット表示タイプによる表示制御。システム管理者以上の場合は常時表示。
5531 if (!$gEnvManager->isSystemAdmin()){
5532 if (!empty($fetchedRow['pd_view_control_type'])){
5533 switch ($fetchedRow['pd_view_control_type']){
5534 case 1: // ログイン時のみ表示
5535 if (!$gEnvManager->isCurrentUserLogined()) return true; // ログインしていなければ終了
5537 case 2: // 非ログイン時のみ表示
5538 if ($gEnvManager->isCurrentUserLogined()) return true; // ログインしていれば終了
5544 if (!empty($fetchedRow['pd_view_page_state'])){
5545 switch ($fetchedRow['pd_view_page_state']){
5547 if (!$this->isPageTopUrl) return true; // ページトップ(サブページ内のトップ位置)でなければ終了
5559 $widgetId = $fetchedRow['wd_id'];
5560 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5563 $configId = $fetchedRow['pd_config_id']; // ウィジェット定義ID
5564 if ($configId == 0) $configId = '';
5565 $prefix = $fetchedRow['wd_suffix']; // サフィックス文字列
5566 $title = $fetchedRow['wd_name']; // デフォルトのウィジェットタイトル
5567 if (empty($title)) $title = $fetchedRow['wd_id'];
5568 $widgetHeadTitle = $fetchedRow['pd_title']; // ウィジェットのヘッドタイトル
5569 if (empty($widgetHeadTitle)) $widgetHeadTitle = $title; // ウィジェットのヘッドタイトルが空の場合はウィジェットタイトルを取得
5570 $serial = $fetchedRow['pd_serial']; // シリアル番号
5571 $cssStyle = $fetchedRow['pd_style']; // CSS
5572 $lateLaunchIndex = $fetchedRow['wd_launch_index']; // 遅延実行インデックス
5574 if (empty($fetchedRow['pd_sub_id'])) $shared = true;// 共通属性あり
5575 if ($this->nonSharedWidgetCount == -1) $this->nonSharedWidgetCount = 0; // 初期化されていない場合は初期化
5576 if (!$shared) $this->nonSharedWidgetCount++; // 非共通ウィジェットの数を更新
5578 // ウィジェットが遅延実行に指定されている場合は、ウィジェットのタグのみ埋め込む
5579 if ($lateLaunchIndex > 0){ // 遅延実行のとき
5581 if (!isset($this->lateLaunchWidgetList[$widgetId])){
5582 $this->lateLaunchWidgetList[$widgetId] = (int)$lateLaunchIndex;
5585 $maxNo = 0; // 最大シリアル番号
5586 $count = count($this->latelaunchWidgetParam);
5587 for ($i = 0; $i < $count; $i++){
5588 list($wId, $maxNo, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5, $tmp6, $tmp7, $tmp8, $tmp9, $tmp10, $tmp11) = $this->latelaunchWidgetParam[$i];
5589 if ($wId == $widgetId) $maxNo = $maxNo + 1;
5591 // Joomla!1.0テンプレートの場合はタイトルを修正
5592 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5593 if (!empty($fetchedRow['pd_title'])) $title = $fetchedRow['pd_title'];
5595 $this->latelaunchWidgetParam[] = array($widgetId, $maxNo, $configId, $prefix, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $fetchedRow);
5598 echo self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
5601 $titleTag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
5604 if (!file_exists($widgetIndexFile)) {
5605 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5608 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
5609 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
5610 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
5611 $this->lastHeadTitle = ''; // ヘッダ部titleにセットした文字列
5612 $this->lastHeadDescription = ''; // ヘッダ部descriptionにセットした文字列
5613 $this->lastHeadKeywords = ''; // ヘッダ部keywordsにセットした文字列
5616 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
5617 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
5619 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
5620 $joomlaTitleVisble = false;
5621 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5622 if ($fetchedRow['pd_title_visible']){
5623 if ($widgetHeaderType == 1){ // PC用出力のとき
5624 $joomlaTitle = $fetchedRow['pd_title'];
5625 if (empty($joomlaTitle)) $joomlaTitle = $title;
5626 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
5627 echo '<tr><th>' . $joomlaTitle . '</th></tr>' . M3_NL;
5628 echo '<tr><td>' . M3_NL;
5629 $joomlaTitleVisble = true;
5630 } else if ($widgetHeaderType == 2){ // 携帯用出力のとき
5631 $joomlaTitle = $fetchedRow['pd_title'];
5632 if (empty($joomlaTitle)) $joomlaTitle = $title;
5633 echo '<div>' . $joomlaTitle . '</div>' . M3_NL;
5634 $joomlaTitleVisble = true;
5639 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
5640 // ウィジェット親のCSS定義があるときは、タグを追加
5641 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
5644 echo $gDesignManager->getAdditionalWidgetOutput(true);
5647 $gEnvManager->setCurrentWidgetId($widgetId);
5650 $gEnvManager->setCurrentWidgetConfigId($configId);
5653 $gEnvManager->setCurrentPageDefSerial($fetchedRow['pd_serial']);
5656 $gEnvManager->setCurrentPageDefRec($fetchedRow);
5659 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5661 // ウィジェットのヘッドタイトルを設定
5662 $gEnvManager->setCurrentWidgetHeadTitle($widgetHeadTitle);
5665 $gEnvManager->setCurrentWidgetTitle($title);
5668 $gEnvManager->setCurrentWidgetStyle($style);
5670 // ウィジェットのグローバル属性状況を設定
5671 $gEnvManager->setIsCurrentWidgetShared($shared);
5674 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5677 //require_once($widgetIndexFile);
5678 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5679 $msg = 'widget-start(' . $widgetId . ')';
5680 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5681 require($widgetIndexFile);
5682 $msg = 'widget-end(' . $widgetId . ')';
5683 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5686 $gEnvManager->setCurrentWidgetId('');
5689 $gEnvManager->setCurrentWidgetConfigId('');
5692 $gEnvManager->setCurrentPageDefSerial(0);
5695 $gEnvManager->setCurrentPageDefRec();
5698 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
5701 $gEnvManager->setCurrentWidgetStyle('');
5703 // ウィジェットのグローバル属性状況を解除
5704 $gEnvManager->setIsCurrentWidgetShared(false);
5707 echo $gDesignManager->getAdditionalWidgetOutput(false);
5708 // echo "<!-- ".time()." -->";
5710 // ウィジェット親のCSS定義があるときは、タグを追加
5711 if (!empty($cssStyle)) echo '</div>' . M3_NL;
5713 //echo '</div>' . M3_NL;
5715 // Joomla!1.0テンプレートのときはタイトルを出力
5716 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用出力のとき
5717 echo '</td></tr>' . M3_NL;
5718 echo '</table>' . M3_NL;
5722 return true; // 処理継続
5725 * 定義IDを指定してウィジェットの出力を取得
5727 * @param string $widgetId ウィジェットID
5728 * @param int $configId ウィジェット定義ID
5729 * @return string ウィジェットの出力
5731 function getWidgetOutput($widgetId, $configId = 0)
5733 global $gEnvManager;
5734 global $gErrorManager;
5736 // ウィジェットのアクセス権をチェック
5737 if (!$this->db->canAccessWidget($widgetId)) return '';
5740 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
5743 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
5745 // 必要なJavascriptライブラリを追加
5746 $scritLib = trim($row['wd_add_script_lib']);
5747 if (!empty($scritLib)) $this->addScript('', $scritLib);
5753 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5756 $saveWidgetId = $gEnvManager->getCurrentWidgetId();
5757 $gEnvManager->setCurrentWidgetId($widgetId);
5760 $saveConfigId = $gEnvManager->getCurrentWidgetConfigId();
5761 $gEnvManager->setCurrentWidgetConfigId($configId);
5764 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
5767 //$gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5770 //$gEnvManager->setCurrentWidgetTitle($title);
5772 // ウィジェットのグローバル属性状況を設定
5773 //$gEnvManager->setIsCurrentWidgetShared($shared);
5776 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5779 //require_once($widgetIndexFile);
5780 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5781 $msg = 'widget-start(' . $widgetId . ')';
5782 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5783 if (file_exists($widgetIndexFile)){
5784 require($widgetIndexFile);
5786 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5788 $msg = 'widget-end(' . $widgetId . ')';
5789 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5792 $gEnvManager->setCurrentWidgetId($saveWidgetId);
5795 $gEnvManager->setCurrentWidgetConfigId($saveConfigId);
5798 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
5801 //$gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
5803 // ウィジェットのグローバル属性状況を解除
5804 //$gEnvManager->setIsCurrentWidgetShared(false);
5806 // 現在のバッファ内容を取得し、バッファを破棄
5807 $output = ob_get_contents();
5815 * @param int $cmdNo 実行コマンド(0=初期化、1=更新、2=計算、10=コンテンツ取得)
5816 * @param string $id ウィジェットID+インナーウィジェットID
5817 * @param string $configId インナーウィジェット定義ID
5818 * @param object $paramObj インナーウィジェットに渡すパラメータオブジェクト
5819 * @param object $optionParamObj インナーウィジェットに渡すパラメータオブジェクト(オプション)
5820 * @param object $resultObj インナーウィジェットから返る結果オブジェクト
5821 * @param string $content 出力内容
5822 * @param bool $isAdmin 管理者機能(adminディレクトリ以下)かどうか
5823 * @return bool true=成功、false=失敗
5825 function commandIWidget($cmdNo, $id, $configId, &$paramObj, &$optionParamObj, &$resultObj, &$content, $isAdmin = false)
5827 global $gEnvManager;
5829 // ウィジェットIDとインナーウィジェットIDを取り出す
5830 list($widgetId, $iWidgetId) = explode(M3_WIDGET_ID_SEPARATOR, $id);
5832 // インナーウィジェットに渡すパラメータを設定
5835 $cmd = self::IWIDTET_CMD_INIT; // 初期化
5836 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5839 $cmd = self::IWIDTET_CMD_UPDATE; // 更新
5840 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
5843 $cmd = self::IWIDTET_CMD_CALC; // 計算
5844 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5847 $cmd = self::IWIDTET_CMD_CONTENT; // コンテンツ取得
5848 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
5852 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5856 // インナーウィジェットのエラー出力は呼び出しウィジェット側で受けるため、出力を抑止する
5857 ob_start();// バッファ作成
5860 if (empty($widgetId)){ // ウィジェットIDが指定されていないときは共通ディレクトリ
5861 //$gEnvManager->getIWidgetsPath() . '/' . $iWidgetId . '/' . $containerClass . '.php';
5864 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/' . M3_DIR_NAME_ADMIN . '/index.php';
5866 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/index.php';
5870 // 作業中のインナーウィジェットIDを設定
5871 $gEnvManager->setCurrentIWidgetId($id); // インナーウィジェットを設定
5873 // インナーウィジェット定義IDを設定
5874 $gEnvManager->setCurrentIWidgetConfigId($configId);
5877 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5878 if (file_exists($widgetIndexFile)){
5879 require($widgetIndexFile);
5881 echo 'file not found error: ' . $widgetIndexFile;
5885 $gEnvManager->setCurrentIWidgetId('');
5887 // インナーウィジェット定義IDを解除
5888 $gEnvManager->setCurrentIWidgetConfigId('');
5890 // 現在のバッファ内容を取得し、バッファを破棄
5891 $content = ob_get_contents();
5895 if ($this->gInstance->getCmdParamManager()->getParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $obj, $option)){
5897 $optionParamObj = $option;
5901 if ($this->gInstance->getCmdParamManager()->getResult($id . M3_WIDGET_ID_SEPARATOR . $configId, $resObj)) $resultObj = $resObj;
5905 * コールバックメソッドを実行し、出力を返す
5907 * @param array $callback 実行するコールバック
5908 * @return string 出力結果
5910 function getOutputByCallbackMethod($callback)
5912 ob_start();// バッファ作成
5915 if (is_callable($callback)) call_user_func($callback);
5917 // 現在のバッファ内容を取得し、バッファを破棄
5918 $content = ob_get_contents();
5923 * ページ作成処理中断を行った場合のレスポンスヘッダ設定
5925 * @param int $responseCode レスポンスコード
5928 function setResponse($responseCode)
5930 switch ($responseCode){
5931 case 403: // アクセス禁止のとき
5932 header('HTTP/1.1 403 Forbidden');
5933 header('Status: 403 Forbidden');
5935 case 404: // 存在しないページのとき
5936 header("HTTP/1.1 404 Not Found");
5937 header("Status: 404 Not Found");
5939 case 500: // サーバ内部エラー
5940 header('HTTP/1.1 500 Internal Server Error');
5941 header('Status: 500 Internal Server Error');
5943 case 503: // サイト非公開(システムメンテナンス)
5944 header('HTTP/1.1 503 Service Temporarily Unavailable');
5945 header('Status: 503 Service Temporarily Unavailable');
5952 * @param string $filePath ダウンロードするファイルのファイルパス
5953 * @param string $downloadFilename ダウンロード時のファイル名
5954 * @param bool $deleteFile 実行後ファイルを削除するかどうか(成功失敗に関係なく)
5955 * @return bool true=成功、false=失敗
5957 function downloadFile($filePath, $downloadFilename, $deleteFile=false)
5960 if (!file_exists($filePath)) return false;
5963 $fileSize = filesize($filePath);
5965 // バッファ内容が残っているときは破棄
5966 if (ob_get_level() > 0) ob_end_clean();
5968 header('Cache-Control: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
5969 header('Pragma: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
5970 header('Content-Disposition: attachment; filename=' . $downloadFilename);
5971 header('Content-Length: ' . $fileSize);
5972 header('Content-Type: application/octet-stream; name=' . $downloadFilename);
5973 $fp = fopen($filePath, "r");
5974 echo fread($fp, $fileSize);
5980 if ($deleteFile) unlink($filePath);
5984 * システム制御ページを表示するかどうかを返す
5986 * @return bool true=システム制御ページを表示、false=システム制御ページを表示しない
5988 function isSystemPage()
5990 return $this->isSystemPage;
5995 * @param string $url 遷移先URL。未指定の場合は現在のスクリプト。URLでないときは、現在のスクリプトに付加。
5996 * @param bool $noMessage 画面を遷移させたとき、ドコモ携帯端末でダイアログ(サイトが移動しました(301))が出ないようにするオプション
5997 * @param int $responseCode レスポンスコード
5998 * @param bool $autoSsl リダイレクト先のページの状態に合わせてSSLを制御するかどうか
6001 function redirect($url = '', $noMessage = false, $responseCode = 0, $autoSsl = true)
6003 global $gEnvManager;
6005 // すでにリダイレクトが設定されている場合は終了
6006 if ($this->isRedirect) return; // リダイレクトするかどうか
6010 $toUrl = $gEnvManager->getCurrentScriptUrl();
6011 } else if (strncmp($toUrl, 'http://', 7) != 0 && strncmp($toUrl, 'https://', 8) != 0){ // URL以外のときはクエリー文字列と判断する
6012 $toUrl = $gEnvManager->getCurrentScriptUrl() . $toUrl;
6015 // SSL化が必要な場合はhttpsに変更
6018 if ($gEnvManager->isAdminUrlAccess($toUrl)){ // 管理画面へのアクセスのとき
6020 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
6021 } else { // フロント画面へのアクセスのとき
6023 $paramArray = array();
6024 //list($filename, $query) = explode('?', basename($toUrl));
6025 list($url, $query) = explode('?', $toUrl);
6026 $baseUrl = dirname($url);
6027 $filename = basename($url);
6028 if (empty($filename)) $filename = M3_FILENAME_INDEX;
6029 if (!empty($query)) parse_str($query, $paramArray); // クエリーの解析
6032 $pageId = basename($filename, '.php');
6033 $pageSubId = $paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID];
6036 $isSslPage = $this->isSslPage($pageId, $pageSubId);
6039 if ($this->gSystem->hierarchicalPage() && $filename == M3_FILENAME_INDEX){
6040 $toUrl = $baseUrl . '/' . $pageSubId . '/';
6041 unset($paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID]);
6043 $paramStr = $this->_createUrlParamStr($paramArray);
6044 if (!empty($paramStr)) $toUrl .= '?' . $paramStr;
6048 //$toUrl = str_replace('http://', 'https://', $toUrl);
6049 $toUrl = $gEnvManager->getSslUrl($toUrl); // SSL用URLに変換
6051 $toUrl = str_replace('https://', 'http://', $toUrl);
6055 // バッファ内容が残っているときは破棄
6056 if (ob_get_level() > 0) ob_end_clean();
6058 if (empty($responseCode)){
6060 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
6062 header('HTTP/1.1 301 Moved Permanently');
6064 } else { // レスポンスコードが指定されている場合
6065 switch ($responseCode){
6067 header('HTTP/1.1 301 Moved Permanently');
6070 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
6073 header('HTTP/1.1 303 See Other');
6075 case 500: // サーバ内部エラー
6076 header('HTTP/1.1 500 Internal Server Error');
6077 header('Status: 500 Internal Server Error');
6079 case 503: // サイト非公開(システムメンテナンス)
6080 header('HTTP/1.1 503 Service Temporarily Unavailable');
6081 header('Status: 503 Service Temporarily Unavailable');
6084 header('HTTP/1.1 ' . (string)$responseCode);
6088 header('Location: ' . $toUrl);
6090 $this->isRedirect = true; // リダイレクトするかどうか
6095 * @return bool true=リダイレクト、false=リダイレクトでない
6097 function isRedirect()
6099 return $this->isRedirect;
6102 * 指定URLのディレクトリへリダイレクト
6106 function redirectToDirectory()
6108 global $gEnvManager;
6111 $dirPath = dirname($gEnvManager->getCurrentScriptUrl()) . '/';
6112 //$this->redirect($dirPath);
6113 $this->redirect($dirPath, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/7/23)
6118 * @param string $url 遷移先URL
6121 function redirectInInstall($url)
6123 $this->redirect($url, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
6130 function redirectToInstall()
6132 global $gEnvManager;
6134 $sytemRootUrl = $gEnvManager->calcSystemRootUrl();
6135 //$this->redirect($sytemRootUrl . '/admin/install.php');
6136 $this->redirect($sytemRootUrl . '/admin/install.php', false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
6139 * ログイン、ログアウト処理を行った後、リダイレクト
6141 * @param RequestManager $request HTTPリクエスト処理クラス
6142 * @param bool $success ログインの成否
6143 * @param string $redirectUrl ログイン成功の場合のリダイレクト先
6144 * @return int 0=何も処理しなかった場合、1=ログイン処理、2=ログアウト処理、3=パスワード送信
6146 function standardLoginLogoutRedirect($request, &$success, $redirectUrl = '')
6148 global $gEnvManager;
6149 global $gAccessManager;
6150 global $gRequestManager;
6152 // ログイン、ログアウト処理、および、コンテナの起動
6153 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
6154 if ($cmd == M3_REQUEST_CMD_LOGIN){ // ログインの場合
6155 $act = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_ACT);
6156 if ($act == 'sendpwd'){ // パスワード送信の場合
6157 $success = $gAccessManager->sendPassword($request);
6161 $ret = $gAccessManager->userLogin($request);
6163 if (empty($redirectUrl)){
6164 // システム運用可能ユーザの場合でリダイレクト先が設定されていない場合はデフォルトの管理画面URLへ遷移
6165 $userInfo = $gEnvManager->getCurrentUserInfo();// ユーザ情報取得
6166 if ($userInfo->userType >= UserInfo::USER_TYPE_MANAGER){
6167 $ret = $this->db->getLoginUserRecordById($userInfo->userId, $userInfoRow);
6168 if ($ret && !empty($userInfoRow['lu_default_admin_url'])){
6169 $redirectUrl = $gEnvManager->getDefaultAdminUrl() . $userInfoRow['lu_default_admin_url'];
6175 $this->redirect($redirectUrl);
6176 $success = true; // ログイン成功
6177 } else { // ログイン失敗のとき
6178 $success = false; // ログイン失敗
6182 } else if ($cmd == M3_REQUEST_CMD_LOGOUT){ // ログアウト
6184 $gAccessManager->userLogout(true);
6187 $this->redirect($redirectUrl);
6196 * @param int $errStatus HTTPエラーステータスコード
6199 function showError($errStatus)
6202 $this->setResponse($errStatus);
6205 $msg = 'NOT DEFINED ERROR';
6206 switch ($errStatus){
6207 case 403: // アクセス禁止のとき
6210 case 404: // 存在しないページのとき
6213 case 500: // サーバ内部エラー
6214 $msg = 'Internal Server Error';
6216 case 503: // サイト非公開(システムメンテナンス)
6217 $msg = 'Service Temporarily Unavailable';
6221 echo '<!doctype html>';
6224 echo '<title>' . $msg . '</title>';
6227 echo '<h2>' . $msg . '</h2>';
6232 * ウィジェットがセットされているページサブIDを取得
6234 * @param string $pageId ページID
6235 * @param string $widgetId 対象ウィジェットID
6236 * @param int $configId ウィジェット定義ID
6237 * @return string ページサブID
6239 function getPageSubIdByWidget($pageId, $widgetId, $configId = 0)
6243 // 対象のウィジェットのページサブIDを取得
6244 $ret = $this->db->getSubPageId($widgetId, $pageId, $rows);
6245 if ($ret){// データが存在する
6246 for ($i = 0; $i < count($rows); $i++){
6247 if (!empty($rows[$i]['pd_sub_id']) && $rows[$i]['pd_config_id'] == $configId){
6248 $pageSubId = $rows[$i]['pd_sub_id'];
6256 * その他のGET,POSTパラメータからページサブID取得
6258 * @param RequestManager $request HTTPリクエスト処理クラス
6259 * @param string $redirectUrl リダイレクト用URL
6260 * @return string ページサブID
6262 function getPageSubIdByParam($request, &$redirectUrl)
6264 global $gEnvManager;
6268 $task = $request->trimValueOf('task');
6269 $option = $request->trimValueOf('option');
6270 if ($task == 'search' && $option == 'com_search'){ // joomla!の検索結果表示の場合
6271 $this->contentType = M3_VIEW_TYPE_SEARCH; // ページのコンテンツタイプ
6273 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_SEARCH, $gEnvManager->getCurrentPageId());// ページサブIDを取得
6274 if (!empty($subId)){
6276 $keyword = $request->trimValueOf('searchword');
6277 $redirectUrl = $gEnvManager->createPageUrl();
6278 $redirectUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subId;
6279 $redirectUrl .= '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=search&' . M3_REQUEST_PARAM_KEYWORD . '=' . urlencode($keyword);
6285 * コンテンツタイプとページIDからページサブID取得
6287 * @param string $contentType コンテンツタイプ
6288 * @param string $pageId ページID
6289 * @return string ページサブID
6291 function getPageSubIdByContentType($contentType, $pageId)
6293 $subId = $this->db->getSubPageIdWithContent($contentType, $pageId);// ページサブIDを取得
6297 * 指定のウィジェットがページ上にあるかを取得
6299 * @param string $pageId ページID
6300 * @param string $widgetId 対象ウィジェットID
6301 * @param bool $activePageOnly 公開中のページのウィジェットに制限するかどうか。falseの場合はすべてのページのウィジェットを対象とする。
6302 * @return bool true=ページ上にあり、false=ページ上になし
6304 function isWidgetOnPage($pageId, $widgetId, $activePageOnly=true)
6306 $ret = $this->db->isWidgetOnPage($pageId, $widgetId, $activePageOnly, 0/*定義セットID*/);
6310 * URLで示されるページ上のウィジェットをウィジェット種別で取得
6312 * @param string $url URL
6313 * @param string $widgetType 対象ウィジェットタイプ
6314 * @return string ウィジェットID
6316 function getWidgetIdByWidgetType($url, $widgetType)
6318 $ret = $this->getPageIdFromUrl($url, $pageId, $pageSubId, $param);
6321 if ($ret) $widgetId = $this->db->getWidgetIdByType($pageId, $pageSubId, $widgetType);
6325 * ページコンテンツタイプ、コンテンツタイプからウィジェットIDを取得
6327 * @param string $pageId ページID
6328 * @param string $contentType コンテンツタイプ
6329 * @return string ウィジェットID
6331 function getWidgetIdWithPageInfoByContentType($pageId, $contentType)
6333 $widgetId = $this->db->getWidgetIdWithPageInfoByContentType($pageId, $contentType);
6337 * ジョブタイプからウィジェットIDを取得
6339 * @param string $jobType ジョブタイプ
6340 * @return string ウィジェットID
6342 function getWidgetIdByJobType($jobType)
6344 global $gEnvManager;
6345 global $gErrorManager;
6349 $linkInfoObj = $this->gInstance->getObject(self::LINKINFO_OBJ_ID);
6350 if (isset($linkInfoObj)) $widgetId = $linkInfoObj->getJobWidget($jobType);
6352 // ウィジェットのアクセス権をチェック
6353 if (!$this->db->canAccessWidget($widgetId)) return '';
6356 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
6359 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
6364 * 現在アクティブなメイン型ウィジェットをウィジェット種別で取得
6366 * @param string $widgetType 対象ウィジェットタイプ
6367 * @return string ウィジェットID
6369 function getActiveMainWidgetIdByWidgetType($widgetType)
6372 $widgetId = $this->db->getActiveMainWidgetIdByType($widgetType);
6376 * URLを解析して、ページID,サブページIDを取得
6378 * @param string $url URL
6379 * @param string $pageId ページID
6380 * @param string $pageSubId ページサブID
6381 * @param array $urlParam URLパラメータ
6382 * @return bool true=成功、false=失敗
6384 function getPageIdFromUrl($url, &$pageId, &$pageSubId, &$urlParam)
6386 global $gEnvManager;
6388 // ページID、ページサブIDを求める
6389 list($page, $other) = explode('?', str_replace($gEnvManager->getRootUrl(), '', $url));
6390 parse_str($other, $urlParam);
6392 $pageId = str_replace('/', '_', trim($page, '/'));
6393 $pageId = basename($pageId, '.php');
6396 $pageSubId = $param[M3_REQUEST_PARAM_PAGE_SUB_ID];
6397 if (empty($pageSubId)) $pageSubId = $gEnvManager->getDefaultPageSubId();
6401 * ウィジェットが組み込まれているページのURLを生成
6403 * @param string $widgetId 送信元ウィジェットID
6404 * @param string $param 実行パラメータ
6405 * @param string $pageId ウィジェットが存在するページID
6406 * @return string 生成したURL
6408 function getDefaultPageUrlByWidget($widgetId, $param = '', $pageId = '')
6410 global $gEnvManager;
6412 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6414 // このウィジェットがマップされているページサブIDを取得
6416 $subPageId = $this->getPageSubIdByWidget($pageId, $widgetId);
6417 if (empty($subPageId)){
6418 // 見つからないときは互換ウィジェットを探す
6419 $targetWidgetId = $this->db->getCompatibleWidgetId($widgetId);
6420 if (!empty($targetWidgetId)){
6421 $subPageId = $this->getPageSubIdByWidget($pageId, $targetWidgetId);
6424 if (!empty($subPageId)) $sub = M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId;
6426 //$url = $gEnvManager->getDefaultUrl();
6427 $url = $gEnvManager->createPageUrl($pageId);
6428 if (!empty($sub)) $url .= '?' . $sub;
6429 if (!empty($param)) $url .= '&' . $param;
6433 * 現在のアクセスポイントの指定のページ属性のページURLを生成
6435 * @param string $contentType コンテンツタイプ
6436 * @param string $param 追加パラメータ
6437 * @param bool $omitPageId ページID省略形を使用するかどうか
6438 * @return string 生成したURL
6440 function createContentPageUrl($contentType, $param = '', $omitPageId = true)
6442 global $gEnvManager;
6443 static $urlArray = array();
6445 // 複数回呼ばれるのでコンテンツタイプごとにページまでのURLは保存しておく
6446 $baseUrl = $urlArray[$contentType];
6447 if (!isset($baseUrl)){
6448 // コンテンツタイプからページサブIDを取得
6449 $pageSubId = $this->getPageSubIdByContentType($contentType, $gEnvManager->getCurrentPageId()); // DBから取得
6451 if (empty($pageSubId)){ // ページサブIDが取得できない場合はデフォルトのページサブIDを取得
6452 $pageSubId = $gEnvManager->getDefaultPageSubId();
6453 } else if ($pageSubId == $gEnvManager->getDefaultPageSubId()){ // デフォルトページの場合
6454 if ($omitPageId) $pageSubId = ''; // ページID省略形を使用する場合はページサブIDを省略
6457 // 現在のアクセスポイントのURLを取得
6458 $baseUrl = $gEnvManager->createPageUrl();
6461 if (!empty($pageSubId)) $baseUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId;
6464 $urlArray[$contentType] = $baseUrl;
6469 if (!empty($param)){
6470 if (strEndsWith($url, '.php') || strEndsWith($url, '/')){
6480 * ウィジェット指定呼び出し用のURLを生成
6482 * @param string $toWidgetId 送信先ウィジェットID
6483 * @param string $fromWidgetId 送信元ウィジェットID
6484 * @param string $todo 実行パラメータ
6485 * @param string $pageId ページID(空のときは現在のURL)
6486 * @return string 生成したURL
6488 function createWidgetCmdUrl($toWidgetId, $fromWidgetId, $todo, $pageId = '')
6490 global $gEnvManager;
6492 $url = $gEnvManager->createPageUrl($pageId);
6494 $url .= '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_FIND_WIDGET;
6495 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $toWidgetId;
6496 if (!empty($fromWidgetId)) $url .= '&' . M3_REQUEST_PARAM_FROM . '=' . $fromWidgetId; // 送信元
6497 if (!empty($todo)) $url .= '&' . M3_REQUEST_PARAM_OPERATION_TODO . '=' . urlencode($todo);
6503 * @param string $widgetId 実行ウィジェットID
6504 * @param string $optionParam 追加パラメータ
6505 * @param string $pageId ページID(空のときは現在のURL)
6506 * @param string $pageSubId ページサブID
6507 * @return string 生成したURL
6509 function createRssCmdUrl($widgetId, $optionParam = '', $pageId = '', $pageSubId = '')
6511 global $gEnvManager;
6514 $url = $gEnvManager->createPageUrl() . '?';
6517 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6518 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6520 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_RSS;
6521 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6522 if (!empty($optionParam)) $url .= '&' . $optionParam;
6528 * @param bool $isSslPage SSLが必要なページかどうか
6529 * @param string $optionParam 追加パラメータ
6530 * @return string 生成したURL
6532 function createCssCmdUrl($isSslPage, $optionParam = '')
6534 global $gEnvManager;
6535 global $gRequestManager;
6538 // $url = $gEnvManager->createPageUrl() . '?';
6539 $url = $gEnvManager->createPageUrl(''/*現在のページ*/, $isSslPage) . '?';
6542 $pageSubId = $this->gEnv->getCurrentPageSubId();
6543 $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6545 // コンテンツ詳細画面の場合はコンテンツパラメータを追加
6546 if ($this->isContentDetailPage){
6547 switch ($this->contentType){
6548 case M3_VIEW_TYPE_CONTENT: // 汎用コンテンツ
6549 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID);
6550 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID_SHORT);
6551 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentsId . '&';
6553 case M3_VIEW_TYPE_PRODUCT: // 製品
6554 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID);
6555 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID_SHORT);
6556 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PRODUCT_ID . '=' . $contentsId . '&';
6558 case M3_VIEW_TYPE_BBS: // BBS
6559 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID);
6560 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT);
6561 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BBS_THREAD_ID . '=' . $contentsId . '&';
6563 case M3_VIEW_TYPE_BLOG: // ブログ
6564 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID);
6565 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT);
6566 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $contentsId . '&';
6568 case M3_VIEW_TYPE_WIKI: // Wiki
6569 $contentsId = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
6570 if (!empty($contentsId)) $url .= $contentsId . '&';
6572 case M3_VIEW_TYPE_USER: // ユーザ作成コンテンツ
6573 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_ROOM_ID);
6574 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_ROOM_ID_SHORT);
6575 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_ROOM_ID . '=' . $contentsId . '&';
6577 case M3_VIEW_TYPE_EVENT: // イベント
6578 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID);
6579 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID_SHORT);
6580 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_EVENT_ID . '=' . $contentsId . '&';
6582 case M3_VIEW_TYPE_PHOTO: // フォトギャラリー
6583 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID);
6584 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID_SHORT);
6585 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PHOTO_ID . '=' . $contentsId . '&';
6590 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_CSS;
6591 if (!empty($optionParam)) $url .= '&' . $optionParam;
6597 * @param string $widgetId 実行ウィジェットID
6598 * @param string $optionParam 追加パラメータ
6599 * @param bool $byMacro マクロ変換で返すかどうか
6600 * @param string $pageId ページID(空のときは現在のURL)
6601 * @param string $pageSubId ページサブID
6602 * @return string 生成したURL
6604 function createDirectWidgetCmdUrl($widgetId, $optionParam = '', $byMacro = false, $pageId = '', $pageSubId = '')
6606 global $gEnvManager;
6610 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . M3_FILENAME_INDEX . '?';
6612 $url = $gEnvManager->createPageUrl() . '?';
6616 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6617 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6619 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_DO_WIDGET;
6620 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6621 if (!empty($optionParam)) $url .= '&' . $optionParam;
6627 * @return array パラメータ文字列の配列
6629 function getUrlParamOrder()
6631 return $this->urlParamOrder; // URLパラメータの並び順
6634 * キャッシュ制御用の付加パラメータを取得
6636 * @return string パラメータ
6638 function getCacheParam()
6640 $addParam = '?' . date('YmdHis');
6644 * 現在のURLにアクセス可能かチェック
6646 * @param bool $isActivePage ページが有効かどうか
6647 * @param int $errCode エラーコード
6648 * @return bool true=可能、false=不可
6650 function canAccessUrl(&$isActivePage, &$errCode)
6652 global $gEnvManager;
6654 $errCode = 0; // エラーコード初期化
6656 // 現在設定されているページIDを取得
6657 $pageId = $gEnvManager->getCurrentPageId();
6658 $pageSubId = $gEnvManager->getCurrentPageSubId();
6659 $ret = $this->db->canAccessPage($pageId, $pageSubId, $pageVisible, $pageSubVisible, $isAdminMenu);
6660 if ($ret){ // アクセス可能なときは、ユーザ制限もチェックする
6661 $isActivePage = true;
6664 if (!$pageVisible || !$pageSubVisible) return false;
6666 if (!$gEnvManager->isCurrentUserLogined() && $this->isUserLimitedPage($pageId, $pageSubId)){ // ユーザがログインされていない状態でユーザ制限されていればアクセス不可
6669 $this->isAccessPointWithAdminMenu = $isAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
6672 } else { // 無効ページのとき
6673 $isActivePage = false;
6675 // ページIDの文字のチェック。ページIDは半角英小文字、数字、アンダーバー、ハイフンのみ使用可能。
6676 if (preg_match("/[^0-9a-z-_]/", $pageSubId)) $errCode = 1; // 不正文字検出
6681 * ウィジェットヘッダ(Joomla!1.0用)を出力タイプを取得
6683 * @return int 0=出力しない、1=Joomla!1.0テンプレートPC用、2=Joomla!1.0テンプレート携帯用
6685 function getTemplateWidgetHeaderType()
6687 global $gEnvManager;
6689 $templateId = $gEnvManager->getCurrentTemplateId();
6690 if ($templateId == self::ADMIN_TEMPLATE || // PC管理用テンプレート
6691 $templateId == self::M_ADMIN_TEMPLATE){ // 携帯管理用テンプレート
6693 } else if(strncmp($templateId, 'm/', 2) == 0){ // 携帯用テンプレート
6694 return 2; // 携帯テンプレート用出力
6696 return 1; // PCテンプレート用出力
6702 * @param string $pageId ページID
6703 * @param string $pageSubId ページサブID
6704 * @return bool true=必要、false=不要
6706 function isSslPage($pageId, $pageSubId)
6708 global $gEnvManager;
6711 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6714 if ($pageId == $gEnvManager->getDefaultAdminPageId()){
6715 if ($gEnvManager->getUseSslAdmin()){ // 管理用ページにSSLを使用するかどうか
6722 // ##### フロント画面の場合 #####
6723 if ($gEnvManager->isRootUrlSsl()) return true; // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
6725 // 一般用ページにSSLを使用しない場合は不要を返す
6726 if (!$gEnvManager->getUseSsl()) return false;
6728 // 一般用ページでSSLを使用する場合は、データベースの設定をチェックする
6729 $line = $this->getPageInfo($pageId, $pageSubId);
6731 if ($line['pn_use_ssl']){
6740 * ユーザ制限が必要なページかどうかを判断
6742 * @param string $pageId ページID
6743 * @param string $pageSubId ページサブID
6744 * @return bool true=必要、false=不要
6746 function isUserLimitedPage($pageId, $pageSubId)
6748 global $gEnvManager;
6751 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6753 $line = $this->getPageInfo($pageId, $pageSubId);
6755 if ($line['pn_user_limited']){
6766 * @param string $pageId ページID
6767 * @param string $pageSubId ページサブID
6768 * @return array ページ情報レコード
6770 function getPageInfo($pageId, $pageSubId)
6772 // ページ情報が空のときはデータをロード
6773 if (empty($this->pageInfo)){
6774 $records = $this->db->getPageInfoRecords();
6775 $count = count($records);
6776 $this->pageInfo = array();
6777 for ($i = 0; $i < $count; $i++){
6778 $pId = $records[$i]['pn_id'] . self::PAGE_ID_SEPARATOR . $records[$i]['pn_sub_id'];
6779 $this->pageInfo[$pId] = $records[$i];
6782 return $this->pageInfo[$pageId . self::PAGE_ID_SEPARATOR . $pageSubId];
6787 * @return array ページ情報レコード
6789 function getCurrentPageInfo()
6791 return $this->currentPageInfo;
6794 * 現在のページ情報からテンプレートIDを取得
6796 * @param string $subTemplateId テンプレートIDが取得できるときはサブページIDが返る
6797 * @return string テンプレートID
6799 function getTemplateIdFromCurrentPageInfo(&$subTemplateId)
6802 if (!empty($this->currentPageInfo)){
6803 $templateId = $this->currentPageInfo['pn_template_id'];
6804 $subTemplateId = $this->currentPageInfo['pn_sub_template_id']; // サブテンプレートID
6809 * JavascriptライブラリのIDを取得
6811 * @param int $type 種別(0=すべて、1=jQuery関係すべて、2=jQueryプラグインのみ)
6812 * @return array JavascriptライブラリのID
6814 function getScriptLibId($type = 0)
6816 // Javascriptライブラリのすべてのキーを取得
6817 $keys = array_keys($this->libFiles);
6819 $destKeys = array();
6820 for ($i = 0; $i < count($keys); $i++){
6822 case 1: // jQuery関係すべて
6823 if (strStartsWith($keys[$i], 'jquery')) $destKeys[] = $keys[$i];
6825 case 2: // jQueryプラグインのみ
6826 if (strStartsWith($keys[$i], 'jquery.')) $destKeys[] = $keys[$i];
6833 * Javascriptライブラリの情報を取得
6835 * @param string $id ライブラリID
6836 * @return array ライブラリの情報
6838 function getScriptLibInfo($id)
6840 $libInfo = $this->libFiles[$id];
6841 if (isset($libInfo)){
6848 * 管理画面用jQueryUIテーマのURLを取得
6850 * @return string テーマURL
6852 function getAdminDefaultThemeUrl()
6854 // $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
6855 $themeFile = $this->gEnv->getAdminUrl(true/*「admin」削除*/) . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
6859 * フロント画面用jQueryUIテーマのURLを取得
6861 * @return string テーマURL
6863 function getDefaultThemeUrl()
6867 if (!isset($themeFile)){
6869 $theme = $this->gSystem->defaultTheme();
6870 if (!empty($theme)){
6871 $path = $this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
6872 if (file_exists($path)) $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
6880 * @param array $paramArray URL作成用のパス
6881 * @return string 作成したURLパラメータ
6883 function _createUrlParamStr($paramArray)
6886 if (count($paramArray) == 0) return $destParam;
6888 $sortParam = array();
6889 $keys = array_keys($paramArray);
6890 $keyCount = count($keys);
6891 for ($i = 0; $i < $keyCount; $i++){
6893 $value = $paramArray[$key];
6894 $orderNo = $this->urlParamOrder[$key];
6895 if (!isset($orderNo)) $orderNo = 100;
6896 $sortParam[] = array('key' => $key, 'value' => $value, 'no' => $orderNo);
6898 // usort($sortParam, create_function('$a,$b', 'return $a["no"] - $b["no"];'));
6899 usort($sortParam, function($a, $b)
6901 return $a['no'] - $b['no'];
6905 $sortCount = count($sortParam);
6906 for ($i = 0; $i < $sortCount; $i++){
6907 if ($i > 0) $destParam .= '&';
6908 $destParam .= rawurlencode($sortParam[$i]['key']) . '=' . rawurlencode($sortParam[$i]['value']);
6913 * URLで指定した画面のCSSファイルを取得
6915 * @param string $url 取得画面のURL
6918 function loadCssFilesByUrl($url)
6921 curl_setopt($ch, CURLOPT_URL, $url);
6922 curl_setopt($ch, CURLOPT_USERAGENT, M3_SYSTEM_NAME . '/' . M3_SYSTEM_VERSION); // ユーザエージェント
6923 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 画面に出力しない
6924 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
6925 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
6926 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); // セッションを維持
6927 $content = curl_exec($ch);
6931 $urlArray = array();
6933 $pattern = '/<head\b[^>]*?>(.*?)<\/head\b[^>]*?>/si';
6934 if (preg_match($pattern, $content, $matches)) $headContent = $matches[0];
6937 $pattern = '/<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>/si';
6938 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
6939 foreach ($matches as $match){
6940 if (strEndsWith($match[1], '.css')){ // ファイル名の拡張子が「css」の場合
6941 $urlArray[] = $match[1];
6943 // typeが「text/css」の場合も取得
6944 $attrPattern = '/type\s*=\s*[\'"]+(.+?)[\'"]/si';
6945 if (preg_match($attrPattern, $match[0], $attrMatch)){
6946 if (strcasecmp($attrMatch[1], 'text/css') == 0) $urlArray[] = $match[1];
6952 // ifで制御されているCSSファイルを除く
6953 $delUrlArray = array();
6954 $pattern = '/<!--\[if\b.*?\]>[\b]*<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>[\b]*<!\[endif\]-->/si';
6955 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
6956 foreach ($matches as $match) $delUrlArray[] = $match[1];
6959 // テンプレート独自のCSSまたは外部のCSSを取得する
6960 $this->ckeditorCssFiles = array();
6961 $cssFiles = array_merge(array_diff($urlArray, $delUrlArray)); // CKEditor用のCSSファイル
6962 for ($i = 0; $i < count($cssFiles); $i++){
6963 $cssFileUrl = $cssFiles[$i];
6964 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
6965 $baseUrl = $this->gEnv->getRootUrl();
6966 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
6967 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
6970 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
6972 if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){ // テンプレートディレクトリの場合
6973 $this->ckeditorCssFiles[] = $cssFileUrl;
6974 } else if (strStartsWith($relativePath, '/')){ // テンプレートディレクトリ以外のディレクトリの場合
6975 } else { // 外部URLの場合
6976 $this->ckeditorCssFiles[] = $cssFileUrl;
6981 $pattern = '/var\s*M3_TEMPLATE_TYPE\s*=\s*(\d+?)\s*;/si';
6982 if (preg_match($pattern, $headContent, $matches)) $this->ckeditorTemplateType = $matches[1]; // CKEditor用のテンプレートタイプ
6985 * CKEditor用のテンプレートタイプを取得
6987 * @return int テンプレートタイプ
6989 function getCkeditorTemplateType()
6991 return $this->ckeditorTemplateType;
6996 * @return bool true=正常、false=不正
6998 /* function _checkReferer()
7000 global $gEnvManager;
7001 global $gRequestManager;
7004 $referer = $gRequestManager->trimServerValueOf('HTTP_REFERER');
7005 $uri = $gEnvManager->getCurrentRequestUri();
7006 if (empty($referer) || $referer != $uri){