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-2016 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 $lastHeadTitle; // 最後にヘッダ部titleにセットした文字列
65 private $lastHeadDescription; // 最後にヘッダ部descriptionにセットした文字列
66 private $lastHeadKeywords; // 最後にヘッダ部keywordsにセットした文字列
67 private $headCss = array(); // HTMLヘッダにCSS出力する文字列
68 private $headScript = array(); // HTMLヘッダにJavascript出力する文字列
69 private $headPreMobileScript = array(); // HTMLヘッダにJavascript出力する文字列(jQueryMobile用挿入スクリプト)
70 private $headString = array(); // HTMLヘッダに出力する任意文字列
71 private $exportCss = array(); // 外部出力でCSS出力する文字列
72 private $lastHeadCss; // 最後に設定したHTMLヘッダにCSS出力する文字列
73 private $lastHeadScript; // 最後に設定したHTMLヘッダにJavascript出力する文字列
74 private $lastHeadString; // 最後に設定したHTMLヘッダに出力する任意文字列
75 private $initScript = ''; // ウィンドウ初期化時に実行されるスクリプト
76 private $outputByHtml = true; // HTMLフォーマットで出力するかどうか
77 private $outputHead; // HTMLヘッダ出力を行ったかどうか
78 private $outputTheme; // jQueryUIテーマ出力を行ったかどうか
79 private $outputAjaxResponseBody; // AJAX用のレスポンスボディデータかどうか
80 private $isAbort; // ページ作成処理を中断するかどうか
81 private $isWidgetAbort; // 各ウィジェット処理を中断するかどうか
82 private $isRedirect; // リダイレクトするかどうか
83 private $libFiles; // javascript追加用ライブラリ
84 private $pageDefRev = 234; // 画面定義のリビジョン番号
85 private $headSubTitle = array(); // ヘッダタグサブタイトル
86 private $headSubTitleUrl = array(); // ヘッダサブタイトルのリンク先
87 private $pageInfo; // すべてのページ情報
88 private $currentPageInfo; // 現在のページのページ情報
89 private $configWidgetInfo; // ウィジェット設定画面のウィジェットの情報
90 private $contentType = ''; // ページのコンテンツタイプ
91 private $mainContentTypeInfo; // フロント画面で使用する主要コンテンツタイプ
92 private $subContentTypeInfo; // フロント画面で使用する補助コンテンツタイプ
93 private $mainFeatureTypeInfo; // フロント画面で使用する主要機能タイプ
94 private $adminFeatureTypeInfo; // 管理画面専用で使用する主要機能タイプ
95 private $rssVersion; // RSSバージョン
96 private $rssChannel; // RSSチャンネルデータ
97 private $selectedJQueryFilename; // 使用対象のjQueryファイル
98 private $selectedJQueryUiFilename; // 使用対象のjQuery UIファイル
99 private $selectedJQueryMobileFilename; // 使用対象のjQueryMobileファイル
100 private $urlParamOrder; // URLパラメータの並び順
101 private $wysiwygEditor; // 管理画面用WYSIWYGエディター
102 private $optionTemplateId; // 追加設定するテンプレートID
103 private $isContentGooglemaps; // コンテンツにGoogleマップが含むかどうか
104 private $useGooglemaps; // Googleマップを使用するかどうか
105 private $useBootstrap; // Bootstrapを使用するかどうか
106 private $isHtml5; // HTML5で出力するかどうか
107 private $ckeditorCssFiles = array(); // CKEditor用のCSSファイル
108 private $ckeditorTemplateType; // CKEditor用のテンプレートタイプ
109 private $adminSubNavbarDef = array(); // 管理画面用のサブメニューバーの定義
110 private $adminBreadcrumbDef = array(); // 管理画面用パンくずリスト定義
111 private $adminBreadcrumbDefHelp = array(); // 管理画面用パンくずリストヘルプ定義
112 const CONFIG_KEY_HEAD_TITLE_FORMAT = 'head_title_format'; // ヘッダ作成用フォーマット
113 const ADMIN_WIDGET_ID = 'admin_main'; // 管理用ウィジェットのウィジェットID
114 //const CONTENT_TYPE_WIKI = 'wiki'; // ページのコンテンツタイプ(Wiki)
115 const WIDGET_ID_TAG_START = '{{WIDGETID:'; // 遅延実行用タグ
116 const WIDGET_ID_TAG_END = '}}'; // 遅延実行用タグ
117 const WIDGET_ID_TITLE_TAG_START = '{{WIDGETID_TITLE:'; // 遅延実行用タグ(タイトル埋め込み用)
118 const WIDGET_ID_TITLE_TAG_END = '}}'; // 遅延実行用タグ(タイトル埋め込み用)
119 const WIDGET_ID_SEPARATOR = ',';
120 const HEAD_TAGS = '{{HEAD_TAGS}}'; // HTMLヘッダ出力用タグ
121 const MENUBAR_TAGS = '{{MENUBAR_TAGS}}'; // メニューバー出力用タグ
122 const MENUBAR_SCRIPT_TAGS = '{{MENUBAR_SCRIPT_TAGS}}'; // メニューバー出力用スクリプトタグ
123 const WIDGET_ICON_IMG_SIZE = 32; // ウィジェットアイコンサイズ
124 const WIDGET_OUTER_CLASS = 'm3_widget_outer'; // ウィジェット外枠クラスクラス
125 const WIDGET_OUTER_CLASS_HEAD_POSITION = 'm3_pos_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
126 const WIDGET_OUTER_CLASS_WIDGET_TAG = 'm3_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
127 const WIDGET_INNER_CLASS = 'm3_widget_inner'; // ウィジェットの内側クラス
128 const POSITION_TAG_HEAD = 'm3pos_'; // ポジションの識別用タグIDヘッダ
129 const WIDGET_TAG_HEAD = 'm3widget_'; // ウィジェットの識別用タグIDヘッダ
130 // const WIDGET_TAG_HEAD_SHORT = 'm3_'; // ウィジェットの識別用タグIDヘッダ
131 const WIDGET_TYPE_TAG_HEAD = 'm3widgettype_'; // ウィジェット種別の識別用タグIDヘッダ
132 const WIDTET_CLASS_NAME = 'm3widget'; // ウィジェットオブジェクトのタグクラス名
133 const WIDTET_CLASS_TYPE_0 = 'm3widget_type0'; // ウィジェットオブジェクトのタグクラス(グローバル属性でない)
134 const WIDTET_CLASS_TYPE_1 = 'm3widget_type1'; // ウィジェットオブジェクトのタグクラス(グローバル属性)
135 const POSITION_CLASS_NAME = 'm3position'; // ポジションオブジェクトのタグクラス名
136 const JOOMLA10_DEFAULT_WIDGET_MENU_PARAM = 'class="moduletable"'; // Joomla!1.0用デフォルトメニューパラメータ値
137 const ADMIN_TEMPLATE = '_admin'; // PC管理用テンプレートID
138 const M_ADMIN_TEMPLATE = 'm/_admin'; // 携帯用管理画面テンプレートID
139 const SCRIPT_LIB_SEPARATOR = ';'; // JavaScriptライブラリ読み込み設定のライブラリの区切り
140 const PAGE_ID_SEPARATOR = ','; // ページIDとページサブID連結用
141 const DEFAULT_ADMIN_FAVICON_FILE = '/images/system/favicon.ico'; // デフォルトの管理画面用faviconファイル
142 const DEFAULT_FAVICON_FILE = '/favicon.ico'; // デフォルトのfaviconファイル
143 // const DEFAULT_SITE_NAME = 'サイト名未設定'; // 管理画面用のデフォルトサイト名
144 const DEFAULT_ADMIN_TITLE = '管理画面'; // デフォルトの管理画面名
145 const WIDGET_TITLE_START = '['; // ウィジェットのタイトルの括弧
146 const WIDGET_TITLE_END = ']'; // ウィジェットのタイトルの括弧
147 const DEFAULT_RSS_VERSION = '1.0'; // デフォルトのRSSのバージョン
148 const CF_ACCESS_IN_INTRANET = 'access_in_intranet'; // イントラネット運用かどうか
149 const CF_USE_LATEST_SCRIPT_LIB = 'dev_use_latest_script_lib'; // 最新のJavaScriptライブラリを使用するかどうか
150 const CF_GOOGLE_MAPS_KEY = 'google_maps_key'; // Googleマップ利用キー
151 const CF_CONFIG_WINDOW_OPEN_TYPE = 'config_window_open_type'; // ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
152 const CF_JQUERY_VERSION = 'jquery_version'; // jQueryバージョン
153 const CF_WYSIWYG_EDITOR = 'wysiwyg_editor'; // 管理画面用WYSIWYGエディター
154 const CF_ADMIN_JQUERY_VERSION = 'admin_jquery_version'; // 管理画面用jQueryバージョン
155 const CF_USE_JQUERY = 'use_jquery'; // jQueryを常に使用するかどうか
156 const CF_SMARTPHONE_USE_JQUERY_MOBILE = 'smartphone_use_jquery_mobile'; // スマートフォン画面でjQuery Mobileを使用
157 const SD_HEAD_OTHERS = 'head_others'; // ヘッダその他タグ
158 const DEFAULT_THEME_DIR = '/ui/themes/'; // jQueryUIテーマ格納ディレクトリ
159 const THEME_CSS_FILE = 'jquery-ui.custom.css'; // テーマファイル
160 const CONFIG_ICON_FILE = '/images/system/config.png'; // ウィジェット定義画面アイコン
161 const ADJUST_ICON_FILE = '/images/system/adjust_widget.png'; // 位置調整アイコン
162 const SHARED_ICON_FILE = '/images/system/shared.png'; // グローバル属性
163 const DELETE_ICON_FILE = '/images/system/delete.png'; // ウィジェット削除
164 const CONFIG_ICON32_FILE = '/images/system/config32.png'; // ウィジェット定義画面アイコン(ツールチップ用)
165 const ADJUST_ICON32_FILE = '/images/system/adjust_widget32.png'; // 位置調整アイコン(ツールチップ用)
166 const CLOSE_BOX_ICON32_FILE = '/images/system/close_box.png'; // ウィンドウ閉じるアイコン(ツールチップ用)
167 const NOTICE_ICON_FILE = '/images/system/notice16.png'; // ウィジェット配置注意アイコン
168 const ALERT_ICON_FILE = '/images/system/alert16.png'; // ウィジェット配置警告アイコン
169 // const ADMIN_ICON_FILE = '/images/system/admin64.png'; // パネルメニュー管理画面遷移用アイコン
170 // const LOGOUT_ICON_FILE = '/images/system/logout64.png'; // パネルメニューログアウト用アイコン
171 // const EDIT_PAGE_ICON_FILE = '/images/system/create_page64.png'; // パネルメニュー編集用アイコン
172 const ADMIN_ICON_FILE = '/images/system/home32.png'; // パネルメニュー管理画面遷移用アイコン
173 const LOGOUT_ICON_FILE = '/images/system/logout32.png'; // パネルメニューログアウト用アイコン
174 const EDIT_PAGE_ICON_FILE = '/images/system/create_page32.png'; // パネルメニュー編集用アイコン
175 // const EDIT_END_ICON_FILE = '/images/system/close32.png'; // パネルメニュー編集終了用アイコン
176 const EDIT_END_ICON_FILE = '/images/system/back32.png'; // パネルメニュー編集終了用アイコン
177 const CLOSE_ICON_FILE = '/images/system/close32.png'; // ウィンドウ閉じるアイコン
178 const PREV_ICON_FILE = '/images/system/prev48.png'; // ウィンドウ「前へ」アイコン
179 const NEXT_ICON_FILE = '/images/system/next48.png'; // ウィンドウ「次へ」アイコン
180 const DEFAULT_READMORE_TITLE = 'もっと読む'; // もっと読むボタンのデフォルトタイトル
181 const POS_HEAD_NAV_MENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // 特殊ポジションブロック(ナビゲーションメニュー)
182 const WIDGET_MARK_MAIN = '<i class="glyphicon glyphicon-tower" rel="m3help" title="メイン型" data-placement="auto"></i> '; // ウィジェットの機能マーク(メイン型ウィジェット)
183 const WIDGET_MARK_NAVMENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // ウィジェットの機能マーク(ナビゲーションメニュー)
184 const WIDGET_FUNCTION_MARK_BOOTSTRAP = ' <span class="label label-warning" rel="m3help" title="Bootstrap型テンプレート対応" data-placement="auto">B</span>'; // ウィジェット機能マーク(Boostrap型テンプレート
185 const WIDGET_STYLE_NAVMENU = '_navmenu'; // ウィジェットの表示スタイル(ナビゲーションメニュー)
188 const CONTENT_OBJ_ID = 'contentlib'; // 汎用コンテンツオブジェクトID
189 const BLOG_OBJ_ID = 'bloglib'; // ブログオブジェクトID
190 const LINKINFO_OBJ_ID = 'linkinfo'; // リンク情報オブジェクトID
193 const IWIDTET_CMD_CONTENT = 'content'; // コンテンツ取得
194 const IWIDTET_CMD_INIT = 'init'; // 初期化
195 const IWIDTET_CMD_UPDATE = 'update'; // 更新
196 const IWIDTET_CMD_CALC = 'calc'; // 計算
199 const M3_ADMIN_SCRIPT_FILENAME = 'm3admin1.8.7.js'; // 管理機能用スクリプト(FCKEditor2.6.6、CKEditor4.0.1対応)
200 const M3_ADMIN_WIDGET_SCRIPT_FILENAME = 'm3admin_widget2.0.10.js'; // 管理機能(ウィジェット操作)用スクリプト(Magic3 v1.15.0以降)
201 const M3_ADMIN_WIDGET_CSS_FILE = '/m3/widget.css'; // 管理機能(ウィジェット操作)用CSSファイル
202 const M3_STD_SCRIPT_FILENAME = 'm3std1.5.2.js'; // 一般、管理機能共通スクリプト
203 // const M3_PLUS_SCRIPT_FILENAME = 'm3plus1.6.2.js'; // フロント画面追加用スクリプト(FCKEditor2.6.6対応、CKEditor4.0.1対応)
204 const M3_OPTION_SCRIPT_FILENAME = 'm3opt1.2.0.js'; // AJAXを含んだオプションライブラリファイル(jQuery必須)
205 const M3_ADMIN_CSS_FILE = 'm3/admin.css'; // 管理機能用のCSS
206 const M3_EDIT_CSS_FILE = 'm3/edit.css'; // フロント画面編集用のCSS
207 const M3_DEFAULT_CSS_FILE = 'm3/default.css'; // フロント画面共通のデフォルトCSS
208 const M3_CKEDITOR_CSS_FILE = 'm3/ckeditor.css'; // CKEditorの編集エリア用CSS
211 const USE_BOOTSTRAP_ADMIN = false; // 管理画面でBootstrapを使用するかどうか(デフォルト値)
212 const BOOTSTRAP_BUTTON_CLASS = 'btn btn-default';
215 const FILEBROWSER_WIDTH_RATIO = '0.8'; // ファイルブラウザ幅比率
216 const FILEBROWSER_HEIGHT_RATIO = '0.8'; // ファイルブラウザ高さ比率
221 function __construct()
223 global $gInstanceManager;
225 global $gSystemManager;
226 global $gRequestManager;
229 parent::__construct();
231 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
232 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
235 $this->db = $gInstanceManager->getSytemDbObject();
238 $value = $gSystemManager->getSystemConfig(self::CF_ACCESS_IN_INTRANET); // イントラネット運用かどうか
239 if (empty($value)){ // インターネット運用
240 $this->useGooglemaps = true; // Googleマップを使用するかどうか
242 $this->useHelp = true; // ヘルプ機能
244 // デフォルトのWYSIWYGエディターを取得
245 $this->wysiwygEditor = $gSystemManager->getSystemConfig(self::CF_WYSIWYG_EDITOR); // 管理画面用WYSIWYGエディター
247 // ##### jQueryバージョン設定 #####
248 // アクセスする画面に応じてjQueryのバージョンを設定
249 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
250 $value = $gSystemManager->getSystemConfig(self::CF_ADMIN_JQUERY_VERSION);// 管理画面用jQueryバージョン
252 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET && strStartsWith($widgetId, 'm/')){// 携帯用アクセスポイント用の管理画面の場合はWYSIWYGエディターはFCKEditorに固定
253 $this->wysiwygEditor = ScriptLibInfo::LIB_FCKEDITOR; // FCKEditorに固定
256 // 管理画面にBOOTSTRAPを使用するかどうか(初期値)
257 $this->useBootstrap = self::USE_BOOTSTRAP_ADMIN;
259 $value = $gSystemManager->getSystemConfig(self::CF_JQUERY_VERSION);// jQueryバージョン
261 ScriptLibInfo::setJQueryVer($value);
263 // WYSISIGエディターのタイプを設定。ScriptLibInfo::getLib()を実行する前に設定。
264 ScriptLibInfo::setWysiwygEditorType($this->wysiwygEditor);
267 $this->libFiles = ScriptLibInfo::getLib(); // ライブラリ取得
270 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(0); // 使用対象のjQueryファイル
271 $this->selectedJQueryUiFilename = ScriptLibInfo::getJQueryFilename(1); // 使用対象のjQuery UIファイル
273 // ##### フロント画面用のデフォルトのJavascript、CSSを取得 #####
274 $this->defaultScriptFiles = array(
275 $this->selectedJQueryFilename, // jQuery
276 self::M3_STD_SCRIPT_FILENAME
278 $this->defaultCssFiles = array(
279 self::M3_DEFAULT_CSS_FILE // フロント画面共通のデフォルトCSS
282 // ##### 管理機能用のデフォルトのJavascript、CSSを取得 #####
283 if (defined('M3_STATE_IN_INSTALL')){ // インストーラの場合のスクリプト
284 $this->defaultAdminScriptFiles = array(
285 $this->selectedJQueryFilename, // jQuery
286 // self::M3_STD_SCRIPT_FILENAME,
287 self::M3_ADMIN_SCRIPT_FILENAME
289 $this->defaultAdminCssFiles = array(); // 管理機能用のCSS
291 $this->defaultAdminScriptFiles = array(
292 $this->selectedJQueryFilename, // jQuery
293 $this->selectedJQueryUiFilename, // jQuery UI Core
294 ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME, // jQuery Contextmenu Lib
295 self::M3_STD_SCRIPT_FILENAME,
296 self::M3_ADMIN_SCRIPT_FILENAME,
297 self::M3_OPTION_SCRIPT_FILENAME
299 $this->defaultAdminCssFiles = array(
300 self::M3_ADMIN_CSS_FILE // 管理機能用のCSS
304 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用
305 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用
306 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_NUMERIC); // 入力制限プラグイン
307 // $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
310 // 管理権限なしで管理ディレクトリアクセスで読み込むスクリプトファイル
311 $this->defaultAdminDirScriptFiles = array($this->selectedJQueryFilename); // jQuery
314 $this->lateLaunchWidgetList = array();
315 $this->latelaunchWidgetParam = array();
318 if ($gEnvManager->canUseDb()){
319 $value = $this->gSystem->getSystemConfig('script_cache_in_browser'); // ブラウザにJavaScriptファイルのキャッシュを保持するかどうか
320 if ($value != '') $this->hasScriptCache = $value;
323 $this->rssVersion = self::DEFAULT_RSS_VERSION; // RSSバージョン
325 // フロント画面で使用する主要コンテンツタイプ
326 $this->mainContentTypeInfo = array(
327 array( 'name' => '会員情報', 'value' => M3_VIEW_TYPE_MEMBER),
328 array( 'name' => '汎用コンテンツ', 'value' => M3_VIEW_TYPE_CONTENT),
329 array( 'name' => '製品', 'value' => M3_VIEW_TYPE_PRODUCT),
330 array( 'name' => 'BBS', 'value' => M3_VIEW_TYPE_BBS),
331 array( 'name' => 'ブログ', 'value' => M3_VIEW_TYPE_BLOG),
332 array( 'name' => 'Wiki', 'value' => M3_VIEW_TYPE_WIKI),
333 array( 'name' => 'ユーザ作成コンテンツ', 'value' => M3_VIEW_TYPE_USER),
334 array( 'name' => 'イベント情報', 'value' => M3_VIEW_TYPE_EVENT),
335 array( 'name' => 'フォトギャラリー', 'value' => M3_VIEW_TYPE_PHOTO)
337 // フロント画面で使用する補助コンテンツタイプ(ページ属性に対応しない)
338 $this->subContentTypeInfo = array( array( 'name' => '新着情報', 'value' => M3_VIEW_TYPE_NEWS),
339 array( 'name' => 'コメント', 'value' => M3_VIEW_TYPE_COMMENT),
340 array( 'name' => 'イベント予約', 'value' => M3_VIEW_TYPE_EVENTENTRY),
341 array( 'name' => 'バナー', 'value' => M3_VIEW_TYPE_BANNER)
343 // フロント画面で使用する主要機能タイプ(「ダッシュボード」は含まない)
344 $this->mainFeatureTypeInfo = array( array( 'name' => '検索', 'value' => M3_VIEW_TYPE_SEARCH),
345 array( 'name' => 'Eコマース', 'value' => M3_VIEW_TYPE_COMMERCE),
346 array( 'name' => 'カレンダー', 'value' => M3_VIEW_TYPE_CALENDAR)
349 $this->adminFeatureTypeInfo = array( array( 'name' => 'ダッシュボード', 'value' => M3_VIEW_TYPE_DASHBOARD)
353 $this->urlParamOrder = array(
355 M3_REQUEST_PARAM_CONTENT_ID => -20, // 汎用コンテンツID
356 M3_REQUEST_PARAM_CONTENT_ID_SHORT => -19, // 汎用コンテンツID(略式)
357 M3_REQUEST_PARAM_PRODUCT_ID => -18, // 製品ID
358 M3_REQUEST_PARAM_PRODUCT_ID_SHORT => -17, // 製品ID(略式)
359 M3_REQUEST_PARAM_BLOG_ID => -16, // ブログID
360 M3_REQUEST_PARAM_BLOG_ID_SHORT => -15, // ブログID(略式)
361 M3_REQUEST_PARAM_BLOG_ENTRY_ID => -14, // ブログ記事ID
362 M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT => -13, // ブログ記事ID(略式)
363 M3_REQUEST_PARAM_BBS_ID => -12, // 掲示板投稿記事ID
364 M3_REQUEST_PARAM_BBS_ID_SHORT => -11, // 掲示板投稿記事ID(略式)
365 M3_REQUEST_PARAM_BBS_THREAD_ID => -10, // 掲示板投稿スレッドID
366 M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT => -9, // 掲示板投稿スレッドID(略式)
367 M3_REQUEST_PARAM_USER_ID => -8, // ユーザ作成コンテンツID
368 M3_REQUEST_PARAM_USER_ID_SHORT => -7, // ユーザ作成コンテンツID(略式)
369 M3_REQUEST_PARAM_ROOM_ID => -6, // ユーザ作成コンテンツ区画ID
370 M3_REQUEST_PARAM_ROOM_ID_SHORT => -5, // ユーザ作成コンテンツ区画ID(略式)
371 M3_REQUEST_PARAM_EVENT_ID => -4, // イベントID
372 M3_REQUEST_PARAM_EVENT_ID_SHORT => -3, // イベントID(略式)
373 M3_REQUEST_PARAM_PHOTO_ID => -2, // 画像ID
374 M3_REQUEST_PARAM_PHOTO_ID_SHORT => -1, // 画像ID(略式)
376 M3_REQUEST_PARAM_PAGE_SUB_ID => 1, // ページサブID
377 M3_REQUEST_PARAM_PAGE_CONTENT_ID => 2, // ページコンテンツID
378 M3_REQUEST_PARAM_WIDGET_ID => 3, // ウィジェットID
379 M3_REQUEST_PARAM_TEMPLATE_ID => 4, // テンプレートID
380 M3_REQUEST_PARAM_URL => 5, // リンク先等のURL
381 M3_REQUEST_PARAM_STAMP => 6, // 公開発行ID
382 M3_REQUEST_PARAM_OPTION => 7, // 通信オプション
383 M3_REQUEST_PARAM_OPERATION_COMMAND => 8, // 実行処理
384 M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND => 9, // Wikiコマンド実行
385 M3_REQUEST_PARAM_OPERATION_TASK => 10, // ウィジェット間共通処理
386 M3_REQUEST_PARAM_OPERATION_ACT => 11, // クライアントからの実行処理
387 M3_REQUEST_PARAM_OPERATION_LANG => 12, // 言語指定表示
388 M3_REQUEST_PARAM_SERIAL_NO => 13, // シリアル番号
389 M3_REQUEST_PARAM_PAGE_NO => 14, // ページ番号
390 M3_REQUEST_PARAM_LIST_NO => 15, // 一覧番号
391 M3_REQUEST_PARAM_ITEM_NO => 16, // 項目番号
392 M3_REQUEST_PARAM_OPERATION_TODO => 17, // 指定ウィジェットに実行させる処理
393 M3_REQUEST_PARAM_FROM => 18, // メッセージの送信元ウィジェットID
394 M3_REQUEST_PARAM_VIEW_STYLE => 19, // 表示スタイル
395 M3_REQUEST_PARAM_FORWARD => 20, // 画面遷移用パラメータ
396 M3_REQUEST_PARAM_ADMIN_KEY => 21, // 管理者一時キー
397 M3_REQUEST_PARAM_OPEN_BY => 22, // ウィンドウの開き方
398 M3_REQUEST_PARAM_SHOW_HEADER => 23, // ヘッダ部表示制御
399 M3_REQUEST_PARAM_SHOW_FOOTER => 24, // フッタ部表示制御
400 M3_REQUEST_PARAM_SHOW_MENU => 25, // メニュー部表示制御
401 M3_REQUEST_PARAM_KEYWORD => 26, // 検索キーワード
402 M3_REQUEST_PARAM_HISTORY => 27, // 履歴インデックスNo
403 M3_REQUEST_PARAM_DEF_PAGE_ID => 28, // ページID(画面編集用)
404 M3_REQUEST_PARAM_DEF_PAGE_SUB_ID => 29, // ページサブID(画面編集用)
405 M3_REQUEST_PARAM_PAGE_DEF_SERIAL => 30, // ページ定義のレコードシリアル番号(設定画面起動時)
406 M3_REQUEST_PARAM_PAGE_DEF_CONFIG_ID => 31, // ページ定義のウィジェット定義ID(設定画面起動時)
407 M3_REQUEST_PARAM_BACK_URL => 32, // 戻り先URL
408 M3_REQUEST_PARAM_BACKUP_URL => 33, // URL退避用(画面編集時)
409 M3_REQUEST_PARAM_SERVER => 34, // サーバ指定
410 M3_REQUEST_PARAM_CATEGORY_ID => 35, // カテゴリID(共通)
411 M3_REQUEST_PARAM_WIDTH => 36, // 幅
412 M3_REQUEST_PARAM_HEIGHT => 37); // 高さ
417 * @return array コンテンツタイプ
419 public function _getAllContentType()
421 global $M3_ALL_CONTENT_TYPE;
423 /* $contentType = array( M3_VIEW_TYPE_CONTENT, // 汎用コンテンツ
424 M3_VIEW_TYPE_PRODUCT, // 製品
425 M3_VIEW_TYPE_BBS, // BBS
426 M3_VIEW_TYPE_BLOG, // ブログ
427 M3_VIEW_TYPE_WIKI, // wiki
428 M3_VIEW_TYPE_USER, // ユーザ作成コンテンツ
429 M3_VIEW_TYPE_EVENT, // イベント
430 M3_VIEW_TYPE_PHOTO); // フォトギャラリー
431 return $contentType;*/
432 return $M3_ALL_CONTENT_TYPE;
437 * @return array 機能タイプ
439 public function _getAllFeatureType()
441 global $M3_ALL_FEATURE_TYPE;
443 /* $featureType = array( M3_VIEW_TYPE_DASHBOARD, // ダッシュボード
444 M3_VIEW_TYPE_SEARCH, // 検索結果
445 M3_VIEW_TYPE_COMMERCE); // Eコマース
446 return $featureType;*/
447 return $M3_ALL_FEATURE_TYPE;
454 function setNoTimeout()
456 if (ini_get('safe_mode') == '0') set_time_limit(0);
461 * @param string $msg メッセージ
463 function setPopupMsg($msg)
465 $this->popupMsg = $msg;
468 * HTMLヘッダ「description」に出力する文字列を設定
470 * @param string $str 出力文字列
472 function setHeadDescription($str)
474 if (is_string($str) && !empty($str)){
475 $this->headDescription = $str;
476 $this->lastHeadDescription = $str; // 最後に設定した値を退避
480 * HTMLヘッダ「description」に出力する文字列を取得
482 * @return string $str 出力文字列
484 function getHeadDescription()
486 return $this->headDescription;
489 * HTMLヘッダ「keywords」に出力する文字列を設定
491 * @param string $str 出力文字列
493 function setHeadKeywords($str)
495 if (is_string($str) && !empty($str)){
496 $this->headKeywords = $str;
497 $this->lastHeadKeywords = $str; // 最後に設定した値を退避
501 * HTMLヘッダ「keywords」に出力する文字列を取得
503 * @return string $str 出力文字列
505 function getHeadKeywords()
507 return $this->headKeywords;
510 * HTMLヘッダに出力するタグ文字列を設定
512 * @param string $str 出力文字列
515 function setHeadOthers($str)
517 if (is_string($str) && !empty($str)){
518 $this->headOthers = $str;
522 * HTMLヘッダに出力するタグ文字列を追加
524 * @param string $str 出力文字列
527 function addHeadOthers($str)
529 if (is_string($str) && !empty($str)){
531 $pos = strpos($this->headOthers, $str);
532 if ($pos === false) $this->headOthers .= $str;
536 * HTMLヘッダに出力するタグ文字列を取得
538 * @return string $str 出力文字列
540 /* function getHeadOthers()
542 return $this->headOthers;
545 * HTMLヘッダ「title」のサブタイトル出力する文字列を設定
547 * @param string $str 出力文字列
548 * @param string $url リンク先
550 function setHeadSubTitle($str, $url='')
552 if (is_string($str) && !empty($str)){
553 $this->headSubTitle[] = $str;
554 $this->headSubTitleUrl[] = $url;
555 $this->lastHeadTitle = $str; // 最後に設定した値を退避
559 * HTMLヘッダ「title」のサブタイトル出力する文字列を取得
561 * @return $array サブタイトルに設定されている文字列を連想配列(title=タイトル、url=リンク先URL)の配列で返す
563 function getHeadSubTitle()
565 $titleArray = array();
566 $titleCount = count($this->headSubTitle);
567 for ($i = 0; $i < $titleCount; $i++){
568 $line = array('title' => $this->headSubTitle[$i], 'url' => $this->headSubTitleUrl[$i]);
569 $titleArray[] = $line;
574 * HTMLヘッダに出力するCSSの文字列を設定
576 * @param string $css 追加するCSS内容
579 function addHeadCss($css)
581 $destCss = trim($css);
582 if (!empty($destCss)){
583 //if (!in_array($css, $this->headCss)) $this->headCss[] = $css;
584 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css; // CSS動的外部出力
586 $this->lastHeadCss = $css; // 最後に設定したHTMLヘッダにCSS出力する文字列
590 * 外部出力で出力するCSSの文字列を設定
592 * @param string $css 追加するCSS内容
595 function addExportCss($css)
597 $destCss = trim($css);
598 if (!empty($destCss)){
599 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css;
603 * HTMLヘッダに出力するJavascriptの文字列を設定
605 * @param string $script 追加するJavascript内容
608 function addHeadScript($script)
610 $destScript = trim($script);
611 if (!empty($destScript)){
612 if (!in_array($script, $this->headScript)) $this->headScript[] = $script;
614 $this->lastHeadScript = $script; // 最後に設定したHTMLヘッダにJavascript出力する文字列
618 * HTMLヘッダに出力するJavascriptの文字列(jQueryMobile用挿入スクリプト)を設定
620 * @param string $script 追加するJavascript内容
623 function addHeadPreMobileScript($script)
625 $destScript = trim($script);
626 if (!empty($destScript)){
627 if (!in_array($script, $this->headPreMobileScript)) $this->headPreMobileScript[] = $script;
631 * HTMLヘッダに出力する任意文字列を設定
633 * @param string $str 追加する任意文字列
636 function addHeadString($str)
638 $destScript = trim($str);
639 if (!empty($destScript)){
640 if (!in_array($str, $this->headString)) $this->headString[] = $str;
642 $this->lastHeadString = $str; // 最後に設定したHTMLヘッダに出力する任意文字列
646 * HTMLヘッダに出力するCSSファイルを追加
648 * @param string,array $cssFile CSSファイルURLパス
651 function addHeadCssFile($cssFile)
653 if (is_array($cssFile)){ // 配列の場合
654 for ($i = 0; $i < count($cssFile); $i++){
655 $destCss = trim($cssFile[$i]);
656 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
659 $destCss = trim($cssFile);
660 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
664 * HTMLヘッダに出力するJavascriptライブラリを追加
666 * @param string,array $scriptLib JavascriptライブラリID
669 function addHeadAdminScriptLib($scriptLib)
671 if (is_array($scriptLib)){ // 配列の場合
672 for ($i = 0; $i < count($scriptLib); $i++){
673 $destScript = trim($scriptLib[$i]);
674 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
677 $destScript = trim($scriptLib);
678 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
682 * HTMLヘッダに出力するJavascriptライブラリを追加
684 * @param string,array $scriptLib JavascriptライブラリID
687 function addHeadScriptLib($scriptLib)
689 if (is_array($scriptLib)){ // 配列の場合
690 for ($i = 0; $i < count($scriptLib); $i++){
691 $destScript = trim($scriptLib[$i]);
692 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
695 $destScript = trim($scriptLib);
696 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
700 * HTMLヘッダに出力するJavascriptファイルを追加
702 * @param string,array $scriptFile JavascriptファイルURLパス
705 function addHeadScriptFile($scriptFile)
707 if (is_array($scriptFile)){ // 配列の場合
708 for ($i = 0; $i < count($scriptFile); $i++){
709 $destScript = trim($scriptFile[$i]);
710 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
713 $destScript = trim($scriptFile);
714 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
718 * HTMLヘッダに出力するJavascriptファイル(jQueryMobile用挿入ファイル)を追加
720 * @param string,array $scriptFile JavascriptファイルURLパス
723 function addHeadPreMobileScriptFile($scriptFile)
725 if (is_array($scriptFile)){ // 配列の場合
726 for ($i = 0; $i < count($scriptFile); $i++){
727 $destScript = trim($scriptFile[$i]);
728 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
731 $destScript = trim($scriptFile);
732 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
736 * HTMLヘッダに出力するRSSファイルを追加
738 * @param array $rssFile タイトル(title)、配信用URL(href)の連想配列。複数の場合は連想配列の配列。
741 function addHeadRssFile($rssFile)
744 if (!is_array($rssFile)) return;
747 if (is_array($line)){ // 複数追加の場合
748 for ($i = 0; $i < count($line); $i++){
750 $url = trim($line[$i]['href']);
752 for ($j = 0; $j < count($this->headRssFiles); $j++){
753 $storedUrl = $this->headRssFiles[$j]['href'];
754 if ($url == $storedUrl) break;
756 if ($j == count($this->headRssFiles)){ // 見つからないときは追加
757 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
758 'title' => $line[$i]['title']); // タイトル
764 $url = trim($rssFile['href']);
766 for ($i = 0; $i < count($this->headRssFiles); $i++){
767 $storedUrl = $this->headRssFiles[$i]['href'];
768 if ($url == $storedUrl) break;
770 if ($i == count($this->headRssFiles)){ // 見つからないときは追加
771 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
772 'title' => $rssFile['title']); // タイトル
778 * RSSチャンネル部に出力するデータを設定
780 * @param array $rssData RSSチャンネル部データ
783 function setRssChannel($rssData)
785 if (!empty($rssData)) $this->rssChannel = $rssData; // RSSチャンネルデータ
790 * @param int $mode 0=ポジション表示しない(通常画面)、1=ポジション表示、2=ウィジェット込みポジション表示
792 function showPosition($mode)
794 $this->showPositionMode = $mode;
799 * @return bool true=レイアウト中、false=レイアウト中でない
803 return $this->isLayout; // 画面レイアウト中かどうか
808 function showWidget()
810 $this->showWidget = true;
815 * @param bool true=単体表示、false=単体表示でない
817 function getShowWidget()
819 return $this->showWidget;
824 * @param int $mode 0=設定なし、1=ログイン画面、10=サイト非公開、11=アクセス不可、12=存在しないページ
826 function setSystemHandleMode($mode)
828 $this->systemHandleMode = $mode;
833 function getSystemHandleMode()
835 return $this->systemHandleMode;
842 function setEditMode()
844 $this->isEditMode = true;
849 * @return bool true=編集モードオン、false=編集モードオフ
851 function idEditMode()
853 return $this->isEditMode;
856 * 出力フォーマットがHTMLであるかを設定
858 * @param bool $isHtml HTMLフォーマットかどうか
861 function setOutputByHtml($isHtml)
863 $this->outputByHtml = $isHtml;
867 * AJAX用のレスポンスボディデータかどうかを設定
869 * @param bool $isResponseBody レスポンスボディデータかどうか
872 function setOutputAjaxResponseBody($isResponseBody)
874 $this->outputAjaxResponseBody = $isResponseBody;
879 * @param bool $status ヘルプ機能を使用するかどうか
882 function setUseHelp($status)
884 $this->useHelp = $status;
889 * @return bool ヘルプ機能を使用するかどうか
891 function getUseHelp()
893 return $this->useHelp;
896 * 表示するコンテンツにGoogleマップが含まれているかを設定
898 * @param bool $status Googleマップを含むかどうか
901 function setIsContentGooglemaps($status)
903 $this->isContentGooglemaps = $status; // コンテンツにGoogleマップが含むかどうか
906 * 表示するコンテンツにGoogleマップが含まれているかを取得
908 * @return bool ヘルプ機能を使用するかどうか
910 function isContentGooglemaps()
912 return $this->isContentGooglemaps;
915 * JavaScriptのブラウザキャッシュの使用可否を設定
917 * @param bool $status ブラウザキャッシュを使用するかどうか
920 function setHasScriptCache($status)
922 $this->hasScriptCache = $status;
929 function useBootstrap()
931 $this->useBootstrap = true; // Bootstrapを使用するかどうか
934 * Bootstrapを強制的に未使用に設定
938 function cancelBootstrap()
940 $this->useBootstrap = false; // Bootstrapを使用するかどうか
945 * @return bool true=使用、false=使用しない
947 function getUseBootstrap()
949 return $this->useBootstrap; // Bootstrapを使用するかどうか
958 $this->isHtml5 = true; // HTML5で出力するかどうか
961 * ページ作成処理を中断するかどうかを取得
963 * @return bool true=中断、false=継続
965 function isPageAbort()
967 return $this->isAbort;
972 * @param string $pos ポジション
973 * @param int $index インデックス番号
976 function getCurrentWidgetPosition(&$pos, &$index)
978 $pos = $this->currentWidgetPosition; // 現在のウィジェットのポジション
979 $index = $this->currentWidgetIndex; // 現在のウィジェットのポジション番号
984 * @param int $defSerial ページ定義シリアル番号
987 function updateParentWindow($defSerial = 0)
989 $this->updateParentWindow = true;
990 $this->updateDefSerial = $defSerial; // 更新する項目のページ定義シリアル番号
995 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
998 function addCssFile($path)
1000 $destPath = trim($path, '/');
1001 if (!in_array($destPath, $this->defaultCssFiles)) $this->defaultCssFiles[] = $destPath;
1006 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1009 function addAdminCssFile($path)
1011 $destPath = trim($path, '/');
1012 if (!in_array($destPath, $this->defaultAdminCssFiles)) $this->defaultAdminCssFiles[] = $destPath;
1017 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1020 function addCkeditorCssFile($path)
1022 $destPath = trim($path, '/');
1023 if (!in_array($destPath, $this->ckeditorCssFiles)) $this->ckeditorCssFiles[] = $destPath;
1028 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1031 function addScriptFile($path)
1033 $destPath = trim($path, '/');
1034 if (!empty($destPath) && !in_array($destPath, $this->defaultScriptFiles)) $this->defaultScriptFiles[] = $destPath;
1039 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1042 function addAdminScriptFile($path)
1044 $destPath = trim($path, '/');
1045 if (!in_array($destPath, $this->defaultAdminScriptFiles)) $this->defaultAdminScriptFiles[] = $destPath;
1050 * @return string テンプレートID
1052 function getOptionTemplateId()
1054 global $gEnvManager;
1057 $pageId = $gEnvManager->getCurrentPageId();
1059 switch ($this->contentType){
1060 case M3_VIEW_TYPE_CONTENT: // ページのコンテンツタイプ
1062 $contentLibObj = $this->gInstance->getObject(self::CONTENT_OBJ_ID);
1063 if (isset($contentLibObj)) $this->optionTemplateId = $contentLibObj->getTemplate();
1065 case M3_VIEW_TYPE_BLOG: // ページがブログタイプのとき
1066 if ($pageId == $this->gEnv->getDefaultPageId()){ // PCサイトのとき
1067 // ブログライブラリオブジェクトからテンプレートを取得
1068 $blogLibObj = $this->gInstance->getObject(self::BLOG_OBJ_ID);
1069 if (isset($blogLibObj)) $this->optionTemplateId = $blogLibObj->getOptionTemplate();
1073 return $this->optionTemplateId;
1076 * 使用した非共通ウィジェットの数を取得
1078 * @return int ウィジェット数
1080 function getNonSharedWidgetCount()
1082 return $this->nonSharedWidgetCount;
1087 * @return string コンテンツタイプ
1089 function getContentType()
1091 return $this->contentType;
1094 * フロント画面で使用する主要コンテンツタイプの情報取得
1096 * @return array コンテンツタイプの情報の連想配列
1098 function getMainContentTypeInfo()
1100 return $this->mainContentTypeInfo; // 主要コンテンツタイプ
1103 * フロント画面で使用する補助コンテンツタイプの情報取得
1105 * @return array コンテンツタイプの情報の連想配列
1107 function getSubContentTypeInfo()
1109 return $this->subContentTypeInfo; // 補助コンテンツタイプ
1112 * フロント画面で使用する主要コンテンツタイプを取得
1114 * @return array コンテンツタイプの配列
1116 function getMainContentTypes()
1119 return array_map(create_function('$a', 'return $a["value"];'), $this->mainContentTypeInfo);
1122 * フロント画面で使用するサブコンテンツタイプを取得
1124 * @return array コンテンツタイプの配列
1126 function getSubContentTypes()
1129 return array_map(create_function('$a', 'return $a["value"];'), $this->subContentTypeInfo);
1132 * フロント画面で使用する主要機能タイプ情報を取得
1134 * @return array 機能タイプの情報の連想配列
1136 function getMainFeatureTypeInfo()
1138 return $this->mainFeatureTypeInfo; // 主要機能タイプ
1141 * フロント画面で使用する主要機能タイプを取得
1143 * @return array 機能タイプの配列
1145 function getMainFeatureTypes()
1148 return array_map(create_function('$a', 'return $a["value"];'), $this->mainFeatureTypeInfo);
1154 * @return array ページ属性情報の連想配列
1156 function getAllPageAttributeTypeInfo()
1158 return array_merge($this->mainContentTypeInfo, $this->subContentTypeInfo, $this->mainFeatureTypeInfo, $this->adminFeatureTypeInfo);
1161 * 管理画面用のサブメニューバーの定義を設定
1163 * @param array $def メニューバー定義
1166 function setAdminSubNavbarDef($def)
1168 $this->adminSubNavbarDef = $def;
1171 * 管理画面用のサブメニューバーの定義を取得
1173 * @return array メニューバーの定義
1175 function getAdminSubNavbarDef()
1177 return $this->adminSubNavbarDef;
1182 * @param array $def パンくずリスト定義
1183 * @param array $help ヘルプ(title,bodyの連想配列)
1186 function setAdminBreadcrumbDef($def, $help = array())
1188 $this->adminBreadcrumbDef = $def;
1189 if (!empty($help)) $this->adminBreadcrumbDefHelp = $help; // 管理画面用パンくずリストヘルプ定義
1194 * @param array $help ヘルプ(title,bodyの連想配列)
1195 * @return array パンくずリスト定義
1197 function getAdminBreadcrumbDef(&$help)
1200 $argNum = func_num_args();
1202 // ヘルプ取得用パラメータが存在する場合は定義を設定
1203 if ($argNum > 0) $help = $this->adminBreadcrumbDefHelp;
1205 return $this->adminBreadcrumbDef;
1210 * HTTPヘッダを設定する。セッションを取得する。サブページIDを設定する。
1212 * @param RequestManager $request HTTPリクエスト処理クラス
1215 function startPage($request)
1217 global $gEnvManager;
1218 global $gRequestManager;
1219 global $gInstanceManager;
1220 global $gAccessManager;
1221 global $gSystemManager;
1222 global $gDispManager;
1225 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
1226 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
1227 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
1228 $pageId = $gEnvManager->getCurrentPageId();
1230 // ###### クライアントIDの読み込み、再設定 ######
1231 // この後、クライアントIDがアクセスログに記録される
1232 $clientId = $request->getCookieValue(M3_COOKIE_CLIENT_ID);
1233 if (empty($clientId)){ // クライアントIDが設定されていないとき(初回アクセス)
1235 $clientId = $this->gAccess->createClientId();
1237 $this->gAccess->setClientId($clientId); // クライアントIDを設定
1240 $this->gEnv->setCanUseCookie(true);
1242 $request->setCookieValue(M3_COOKIE_CLIENT_ID, $clientId, M3_COOKIE_EXPIRE_CLIENT_ID);
1244 // インストール時の管理画面用ライブラリを追加(フレームコンテナでの設定を反映)
1245 if (defined('M3_STATE_IN_INSTALL')){
1247 if ($this->useBootstrap){
1248 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
1249 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
1252 // 管理者キーがあればGETまたはPOST値のセッションIDを使用する
1253 if ($gEnvManager->isAdminDirAccess()){
1254 if ($gAccessManager->isValidAdminKey()) session_id($gRequestManager->trimValueOf(session_name()));
1258 // 最終HTML(ページ全体で使用するHTML)の出力
1259 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
1260 $gRequestManager->stopSessionUpdate(); // セッションの更新を停止
1266 // ##### インストール時はここで終了 #####
1267 if (defined('M3_STATE_IN_INSTALL')) return; // インストール時は実行しない
1269 // セッションを再生成する(セキュリティ対策)
1270 if ($gSystemManager->regenerateSessionId()){
1271 $gAccessManager->setOldSessionId(session_id()); // 古いセッションIDを保存
1272 session_regenerate_id(true);
1276 $userInfo = $gRequestManager->getSessionValueWithSerialize(M3_SESSION_USER_INFO);
1277 $gInstanceManager->setUserInfo($userInfo);
1279 // ##### 自動ログイン #####
1280 // ログイン中でない場合は自動ログインでユーザ情報を取得
1281 $gAccessManager->startAutoLogin();
1284 if (M3_SYSTEM_DEBUG) echo 'Debug mode<br />';
1286 // ##### サブページIDの設定 #####
1287 if ($gEnvManager->isAdminDirAccess() && // 管理画面へのアクセスのとき
1288 ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT)){ // ログイン、ログアウト場合は管理画面のページサブIDを指定
1289 $subId = $gEnvManager->getAdminDefaultPageSubId(); // 管理画面用のデフォルトページサブID
1291 $subId = $request->trimValueOf(M3_REQUEST_PARAM_PAGE_SUB_ID);// ページサブIDを取得
1292 if (empty($subId)){ // サブページIDが設定されていないとき
1293 // URLパラメータからコンテンツ形式を取得し、ページを選択
1294 $params = $gRequestManager->getQueryArray();
1295 $paramCount = count($params);
1297 // コマンド以外のパラメータ数が1つだけのときはパラメータからページ属性を判断する
1298 // 値が空でもキーがあれば属性を持つとする
1299 if ($paramCount == 0){
1300 $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1302 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemAdmin() && empty($task)){
1303 // ダッシュボード機能は、パラメータなし、管理者ディレクトリ、システム管理者の条件で使用可能
1304 // POST値にタスクがある場合はダッシュボードとしない
1305 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_DASHBOARD, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1307 } else if ($paramCount > 0 && !$gEnvManager->isAdminDirAccess()){ // パラメータ付きの場合(2013/3/23)
1308 // ##### ページ属性から画面を選択(管理画面は対応しない) ###
1309 // 最初のURLパラメータでコンテンツを判断
1310 // プレビュー(cmd=preview)等のパターンで複数パラメータがある
1312 $firstKey = key($params);
1313 $firstValue = $params[$firstKey];
1315 if (!empty($firstValue)){ // 「key=value」の形式であること
1317 case M3_REQUEST_PARAM_CONTENT_ID: // コンテンツIDのとき
1318 case M3_REQUEST_PARAM_CONTENT_ID_SHORT:
1319 // ローカルメニューのURLからページを特定。ページが特定できないときはページ属性で取得。
1320 $url = $gEnvManager->getMacroPath($gEnvManager->getCurrentRequestUri());
1321 $ret = $this->db->getSubPageIdByMenuItemUrl($url, $gEnvManager->getCurrentPageId(), M3_VIEW_TYPE_CONTENT, $rows);
1323 $rowCount = count($rows);
1324 for ($i = 0; $i < $rowCount; $i++){
1325 // コンテンツを表示するウィジェットがあるときはページサブIDを確定
1326 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);
1327 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);// コンテンツタイプでの取得に変更(2012/6/20)
1328 if (!empty($widgetId)){
1329 $subId = $rows[$i]['pd_sub_id'];
1334 if (empty($subId)) $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_CONTENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1335 $this->contentType = M3_VIEW_TYPE_CONTENT; // ページのコンテンツタイプ
1337 // コンテンツ詳細ページかどうかを設定
1338 if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT) $this->isContentDetailPage = true;
1340 case M3_REQUEST_PARAM_PRODUCT_ID: // 製品IDのとき
1341 case M3_REQUEST_PARAM_PRODUCT_ID_SHORT:
1342 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PRODUCT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1343 $this->contentType = M3_VIEW_TYPE_PRODUCT; // ページのコンテンツタイプ
1345 // コンテンツ詳細ページかどうかを設定
1346 $this->isContentDetailPage = true;
1348 case M3_REQUEST_PARAM_BBS_ID: // 掲示板投稿記事のとき
1349 case M3_REQUEST_PARAM_BBS_ID_SHORT:
1350 case M3_REQUEST_PARAM_BBS_THREAD_ID:
1351 case M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT:
1352 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BBS, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1353 $this->contentType = M3_VIEW_TYPE_BBS; // ページのコンテンツタイプ
1355 // コンテンツ詳細ページかどうかを設定
1356 if ($firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID || $firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT) $this->isContentDetailPage = true;
1358 case M3_REQUEST_PARAM_EVENT_ID: // イベント記事のとき
1359 case M3_REQUEST_PARAM_EVENT_ID_SHORT:
1360 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_EVENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1361 $this->contentType = M3_VIEW_TYPE_EVENT; // ページのコンテンツタイプ
1363 // コンテンツ詳細ページかどうかを設定
1364 $this->isContentDetailPage = true;
1366 case M3_REQUEST_PARAM_PHOTO_ID: // フォトギャラリー写真のとき
1367 case M3_REQUEST_PARAM_PHOTO_ID_SHORT:
1368 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PHOTO, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1369 $this->contentType = M3_VIEW_TYPE_PHOTO; // ページのコンテンツタイプ
1371 // コンテンツ詳細ページかどうかを設定
1372 $this->isContentDetailPage = true;
1374 case M3_REQUEST_PARAM_BLOG_ID: // ブログIDのとき
1375 case M3_REQUEST_PARAM_BLOG_ID_SHORT:
1376 case M3_REQUEST_PARAM_BLOG_ENTRY_ID:
1377 case M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT:
1378 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BLOG, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1379 $this->contentType = M3_VIEW_TYPE_BLOG; // ページのコンテンツタイプ
1381 // コンテンツ詳細ページかどうかを設定
1382 if ($firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT) $this->isContentDetailPage = true;
1384 case M3_REQUEST_PARAM_ROOM_ID: // ユーザ作成コンテンツのとき
1385 case M3_REQUEST_PARAM_ROOM_ID_SHORT:
1386 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_USER, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1387 $this->contentType = M3_VIEW_TYPE_USER; // ページのコンテンツタイプ
1389 // コンテンツ詳細ページかどうかを設定
1390 $this->isContentDetailPage = true;
1392 // コンテンツを表示するウィジェットを取得
1393 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);
1394 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);// コンテンツタイプでの取得に変更(2012/6/20)
1395 if (!empty($widgetId)){
1396 // ルーム用の定義ID(所属グループID)を取得
1397 $roomId = isset($params[M3_REQUEST_PARAM_ROOM_ID]) ? $params[M3_REQUEST_PARAM_ROOM_ID] : $params[M3_REQUEST_PARAM_ROOM_ID_SHORT];
1398 $configId = $this->db->getWidgetConfigIdForRoom($roomId);
1400 // グループIDを定義IDとするページのページサブIDを取得
1401 $subPageId = $this->getPageSubIdByWidget($gEnvManager->getCurrentPageId(), $widgetId, $configId);
1402 if (!empty($subPageId)) $subId = $subPageId;
1405 default: // オプションのURLコンテンツパラメータからサブページIDを取得
1406 $ret = $this->db->getSubPageIdByUrlContentParam($gEnvManager->getCurrentPageId(), $firstKey, $row);
1407 if ($ret) $subId = $row['pd_sub_id'];
1415 // 「http://www.example.com?ページ名」「wcmd」の場合はwikiコンテンツページを選択
1416 $wikiCmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND);
1417 $pageName = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
1419 if (!empty($wikiCmd) || !empty($pageName)){ // Wikiコンテンツページを指定のとき
1421 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_WIKI, $gEnvManager->getCurrentPageId());
1422 $this->contentType = M3_VIEW_TYPE_WIKI; // ページのコンテンツタイプ
1424 // コンテンツ詳細ページかどうかを設定
1425 $this->isContentDetailPage = true;
1428 // その他のGET,POSTパラメータからページサブID取得
1430 // 検索用パラメータなどでリダイレクト先のURLが取得できた場合は遷移
1431 $subId = $this->getPageSubIdByParam($request, $redirectUrl);
1432 if (!empty($subId) && !empty($redirectUrl)) $this->redirect($redirectUrl);
1435 // ページサブIDが取得できない場合はデフォルトを使用
1436 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
1437 } else { // ページサブIDが設定されているとき
1438 // URLパラメータからコンテンツ形式を取得し、ページを選択
1439 $params = $gRequestManager->getQueryArray();
1440 $paramCount = count($params);
1441 if ($paramCount == 1) $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1444 $gEnvManager->setCurrentPageSubId($subId);// サブページIDを設定
1446 // SSL通信機能がオンの場合は、アクセスされたURLのSSLをチェックし不正の場合は正しいURLにリダイレクト
1447 // 設定に間違いがある場合、管理画面にアクセスできなくなるので、フロント画面のみ制御
1448 // if ($gEnvManager->getUseSsl() || $gEnvManager->getUseSslAdmin()){
1449 if ($gEnvManager->getUseSsl()){ // フロント画面のSSL設定のみチェック(2016/7/30)
1450 if (!$gEnvManager->isAdminDirAccess()){ // 管理画面以外へのアクセスのとき
1451 // ルートURLがSSLの場合はSSLに固定
1452 if ($gEnvManager->isRootUrlSsl()){ // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
1455 $isSsl = $gEnvManager->isSslByCurrentPage();
1457 $currentUrl = $gEnvManager->getCurrentRequestUri();
1459 $correctUrl = str_replace('http://', 'https://', $currentUrl);
1461 $correctUrl = str_replace('https://', 'http://', $currentUrl);
1463 if ($currentUrl != $correctUrl) $this->redirect($correctUrl);
1467 $gEnvManager->initMultiDomain();
1470 $gDispManager->load();
1472 // ##### 画面に必要なスクリプトを追加 #####
1473 // スマートフォン用URLのときはスマートフォン用のjQueryを使用
1474 if ($gEnvManager->getIsSmartphoneSite()){
1475 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(10); // スマートフォン用jQueryファイル
1477 if (isset($this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'])){
1478 $scriptFiles = $this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'];
1479 if (count($scriptFiles) > 0) $this->selectedJQueryMobileFilename = $scriptFiles[0]; // 使用対象のjQueryMobileファイル
1483 // Magic3管理用のスクリプトを追加
1484 if (!$gEnvManager->getIsMobileSite()){ // 携帯用URL以外のとき
1485 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
1486 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
1487 // $this->isEditMode = true; // フロント画面編集モード
1488 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定(コンテキストメニュー表示)
1491 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1492 $this->addAdminScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1494 // Googleマップライブラリの読み込み
1495 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1496 $this->defaultAdminScriptFiles[] = ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS);
1498 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1499 $this->isLayout = true; // 画面レイアウト中かどうか
1500 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_IDTABS); // 管理パネル用スクリプト追加(ポジション表示追加分)
1501 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_DROPDOWN); // 管理パネル用スクリプト追加(ドロップダウンメニュー)
1502 //$this->useBootstrap = true; // Bootstrapを使用
1503 //$this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1505 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1506 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1508 // スクリプトが必要なウィジェットをすべて取得
1509 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1510 for ($i = 0; $i < count($rows); $i++){
1511 $this->addAdminScript($task, trim($rows[$i]['wd_add_script_lib']));
1513 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1515 $widgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
1516 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
1517 if ($ret) $this->addAdminScript($task, trim($this->configWidgetInfo['wd_add_script_lib_a'])); // 管理機能用スクリプト
1520 } else { // フロント画面へのアクセスのとき
1521 // フロント画面用スクリプトファイル追加
1522 $value = $gSystemManager->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
1523 if ($value) $this->addScriptFile($this->selectedJQueryFilename);
1525 if ($cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
1526 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
1527 if ($gEnvManager->isSystemManageUser()){
1528 $this->isEditMode = true; // フロント画面編集モード
1529 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定
1531 // システム運用権限がある場合は管理用スクリプトを追加
1532 // フロント画面と管理画面の切り替え用のスライドメニューバーには管理用スクリプト,CSSが必要
1533 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1534 $this->addScriptFile(ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME); // jQuery Contextmenu Lib
1535 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1536 //$this->addScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1537 $this->addScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用スクリプト追加
1538 $this->addScript('', ScriptLibInfo::LIB_JQUERY_COOKIE); // 管理パネル用スクリプト追加
1539 $this->addScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用スクリプト追加
1540 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1541 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1543 $this->addCssFile(self::M3_ADMIN_CSS_FILE); // 管理機能用CSS
1544 } else if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1545 $this->isEditMode = true; // フロント画面編集モード
1547 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
1548 if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1549 $this->isEditMode = true; // フロント画面編集モード
1551 // $this->addScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
1552 $this->addScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1553 // $this->addScriptFile(self::M3_PLUS_SCRIPT_FILENAME); // フロント画面追加用スクリプト追加(PLUSライブラリを追加する場合はFCKEditorも使用可能にする)
1554 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1555 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
1556 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1557 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1559 // Googleマップライブラリの読み込み
1560 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1561 $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS));
1569 $row = $this->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
1571 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1572 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1575 $this->currentPageInfo = $row; // 現在のページのページ情報
1579 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1580 $defPageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1581 $defPageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1582 $ret = $this->db->getPageDefOnPage($defPageId, $defPageSubId, $rows);
1584 for ($i = 0; $i < count($rows); $i++){
1585 $position = $rows[$i]['pd_position_id'];
1586 if (!in_array($position, $this->defPositions)) $this->defPositions[] = $position; // 画面定義データのポジション(すべて)
1592 if ($openBy == 'tabs') $this->isTransparentMode = true; // 画面透過モード
1601 global $gEnvManager;
1602 global $gSystemManager;
1604 $lang = $gEnvManager->getCurrentLanguage();
1606 // デフォルト言語とカレント言語が異なる場合のみ実行
1607 if ($lang != $gEnvManager->getDefaultLanguage()){
1609 $gSystemManager->roadSiteDefByLang($lang);
1613 $this->headDescription = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_DESCRIPTION); // HTMLヘッダ「description」に出力する文字列
1614 $this->headKeywords = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_KEYWORDS); // HTMLヘッダ「keywords」に出力する文字列
1615 $this->headOthers = $gSystemManager->getSiteDef(self::SD_HEAD_OTHERS); // HTMLヘッダに出力するタグ文字列
1617 // デフォルトのページ情報でヘッダを更新
1618 if (!empty($this->currentPageInfo)){
1619 $title = $this->currentPageInfo['pn_meta_title']; // 画面タイトル
1620 $desc = $this->currentPageInfo['pn_meta_description']; // ページ要約
1621 $keyword = $this->currentPageInfo['pn_meta_keywords']; // ページキーワード
1622 $headOthers = $this->currentPageInfo['pn_head_others']; // ヘッダその他タグ
1624 if (!empty($title)) $this->setHeadSubTitle($title);
1625 if (!empty($desc)) $this->setHeadDescription($desc);
1626 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1627 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1630 // 現在の言語のページ情報でヘッダを更新
1631 $ret = $this->db->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $lang, $row);
1633 $title = $row['pn_meta_title']; // 画面タイトル
1634 $desc = $row['pn_meta_description']; // ページ要約
1635 $keyword = $row['pn_meta_keywords']; // ページキーワード
1636 $headOthers = $row['pn_head_others']; // ヘッダその他タグ
1638 if (!empty($title)) $this->setHeadSubTitle($title);
1639 if (!empty($desc)) $this->setHeadDescription($desc);
1640 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1641 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1644 // $this->currentPageInfo = $row; // 現在のページのページ情報
1648 * スクリプト追加情報から、管理機能用のJavascriptファイル、CSSを追加する
1650 * @param string $task 指定タスク
1651 * @param string $scriptInfo スクリプト追加情報
1654 function addAdminScript($task, $scriptInfo)
1656 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1657 for ($i = 0; $i < count($itemArray); $i++){
1658 $pos = strpos($itemArray[$i], '=');
1659 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1660 $libs = trim($itemArray[$i]);
1661 } else { // タスク指定のとき
1662 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1663 $libTask = trim($libTask);
1664 $libs = trim($libs);
1666 if (strEndsWith($libTask, '_')){ // 「task_subtask」形式のタスクのとき
1667 if (!strStartsWith($task, $libTask)) $libs = ''; // タスクIDの先頭部が異なるときは追加しない
1669 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1672 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1673 $libsArray = explode(',', $libs);
1674 for ($j = 0; $j < count($libsArray); $j++){
1675 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1678 $setLibArray = ScriptLibInfo::getLibSet($lib);
1679 $setLibCount = count($setLibArray);
1680 if ($setLibCount > 0){ // ライブラリセットの場合
1681 for ($k = 0; $k < $setLibCount; $k++){
1682 $this->_addAdminScript($setLibArray[$k]);
1685 $this->_addAdminScript($lib);
1692 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1694 * @param string $lib ライブラリID
1697 function _addAdminScript($lib)
1700 if (!isset($this->libFiles[$lib])) return;
1703 // if (strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1704 // jQuery UIライブラリを追加
1705 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1706 if (isset($dependentLib)){
1707 for ($i = 0; $i < count($dependentLib); $i++){
1708 $addLib = $dependentLib[$i];
1711 if (isset($this->libFiles[$addLib]['script'])){
1712 $scriptFiles = $this->libFiles[$addLib]['script'];
1713 for ($m = 0; $m < count($scriptFiles); $m++){
1714 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1718 if (isset($this->libFiles[$addLib]['script_lang'])){
1719 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1720 for ($m = 0; $m < count($scriptFiles); $m++){
1721 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1725 if (isset($this->libFiles[$addLib]['css'])){
1726 $cssFiles = $this->libFiles[$addLib]['css'];
1727 for ($m = 0; $m < count($cssFiles); $m++){
1728 $this->addAdminCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1733 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1734 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1735 $this->outputTheme = true;
1740 if (isset($this->libFiles[$lib]['script'])){
1741 $scriptFiles = $this->libFiles[$lib]['script'];
1743 // ##### ライブラリ情報を作成する場合 #####
1744 if (empty($scriptFiles)){
1745 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
1746 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
1749 for ($i = 0; $i < count($scriptFiles); $i++){
1750 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1754 if (isset($this->libFiles[$lib]['script_lang'])){
1755 $scriptFiles = ScriptLibInfo::getLangScript($lib);
1756 for ($i = 0; $i < count($scriptFiles); $i++){
1757 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1761 if (isset($this->libFiles[$lib]['css'])){
1762 $cssFiles = $this->libFiles[$lib]['css'];
1763 for ($i = 0; $i < count($cssFiles); $i++){
1764 $this->addAdminCssFile($cssFiles[$i]); // 管理機能用のCSS追加
1768 if (strncmp($lib, 'jquery-ui.', 10) == 0){ // jQuery UIのwidgetsまたはeffectsのとき。jQuery UI Coreはデフォルトで読み込まれている。
1770 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1771 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1772 $this->outputTheme = true;
1777 * スクリプト追加情報から、通常機能用のJavascriptファイル、CSSを追加する
1779 * @param string $task 指定タスク
1780 * @param string $scriptInfo スクリプト追加情報
1783 function addScript($task, $scriptInfo)
1785 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1786 for ($i = 0; $i < count($itemArray); $i++){
1787 $pos = strpos($itemArray[$i], '=');
1788 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1789 $libs = trim($itemArray[$i]);
1790 } else { // タスク指定のとき
1791 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1792 $libTask = trim($libTask);
1793 $libs = trim($libs);
1794 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1796 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1797 $libsArray = explode(',', $libs);
1798 for ($j = 0; $j < count($libsArray); $j++){
1799 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1801 // jQueryライブラリ等、デフォルトでは追加されないライブラリを追加
1802 $setLibArray = ScriptLibInfo::getLibSet($lib);// ライブラリセットを展開
1803 $setLibCount = count($setLibArray);
1804 if ($setLibCount > 0){ // ライブラリセットの場合
1805 for ($k = 0; $k < $setLibCount; $k++){
1806 $this->_addScript($setLibArray[$k]);
1809 $this->_addScript($lib);
1816 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1818 * @param string $lib ライブラリID
1821 function _addScript($lib)
1824 if (!isset($this->libFiles[$lib])) return;
1826 // ライブラリの依存ライブラリファイルを追加
1827 if (strcmp($lib, 'jquery') == 0){// jQuery本体のとき
1828 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1829 } else if (strncmp($lib, 'jquery.', 7) == 0){ // jQueryプラグインのとき
1830 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1831 if (strcmp($lib, 'jquery.mobile') == 0){ // jQueryMobileファイルのとき
1832 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
1833 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
1834 for ($i = 0; $i < count($this->headPreMobileScriptFiles); $i++){
1835 $this->addScriptFile($this->headPreMobileScriptFiles[$i]); // 通常機能用のスクリプト追加
1840 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1841 if (isset($dependentLib)){
1842 for ($i = 0; $i < count($dependentLib); $i++){
1843 $addLib = $dependentLib[$i];
1846 if (isset($this->libFiles[$addLib]['script'])){
1847 $scriptFiles = $this->libFiles[$addLib]['script'];
1848 for ($m = 0; $m < count($scriptFiles); $m++){
1849 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1853 if (isset($this->libFiles[$addLib]['script_lang'])){
1854 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1855 for ($m = 0; $m < count($scriptFiles); $m++){
1856 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1860 if (isset($this->libFiles[$addLib]['css'])){
1861 $cssFiles = $this->libFiles[$addLib]['css'];
1862 for ($m = 0; $m < count($cssFiles); $m++){
1863 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1869 } else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI) == 0){ // jQuery UI
1870 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1871 //} else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI_PLUS) == 0){ // jQuery UI plus
1872 // $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1873 // $this->addScriptFile($this->selectedJQueryUiFilename); // jQuery Coreスクリプト追加
1874 } else if (strncmp($lib, 'jquery-ui.', 10) == 0 || // jQuery UIのwidgetsまたはeffectsのとき
1875 strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1878 if (strncmp($lib, 'jquery-ui.', 10) == 0){
1879 $jQueryUiInfo = ScriptLibInfo::getJQueryUiInfo();// ライブラリ情報取得
1880 $dependentLib = $jQueryUiInfo[$lib]; // 依存ライブラリ取得
1882 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1884 for ($i = 0; $i < count($dependentLib); $i++){
1885 $addLib = $dependentLib[$i];
1888 if (isset($this->libFiles[$addLib]['script'])){
1889 $scriptFiles = $this->libFiles[$addLib]['script'];
1890 for ($m = 0; $m < count($scriptFiles); $m++){
1891 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1895 if (isset($this->libFiles[$addLib]['script_lang'])){
1896 $scriptFiles = ScriptLibInfo::getLangScript($addLib);;
1897 for ($m = 0; $m < count($scriptFiles); $m++){
1898 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1902 if (isset($this->libFiles[$addLib]['css'])){
1903 $cssFiles = $this->libFiles[$addLib]['css'];
1904 for ($m = 0; $m < count($cssFiles); $m++){
1905 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1910 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1911 $this->addCssFile($this->getDefaultThemeUrl()); // 通常機能用のCSS追加
1912 $this->outputTheme = true;
1917 if (isset($this->libFiles[$lib]['script'])){
1918 $scriptFiles = $this->libFiles[$lib]['script'];
1920 // ##### ライブラリ情報を作成する場合 #####
1921 if (empty($scriptFiles)){
1922 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
1923 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
1926 for ($i = 0; $i < count($scriptFiles); $i++){
1927 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
1931 if (isset($this->libFiles[$lib]['script_lang'])){
1932 $scriptFiles = ScriptLibInfo::getLangScript($lib);
1933 for ($i = 0; $i < count($scriptFiles); $i++){
1934 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
1938 if (isset($this->libFiles[$lib]['css'])){
1939 $cssFiles = $this->libFiles[$lib]['css'];
1940 for ($i = 0; $i < count($cssFiles); $i++){
1941 $this->addCssFile($cssFiles[$i]); // 通常機能用のCSS追加
1946 * 非ログイン時の管理機能用のJavascriptファイル、CSSを追加する
1948 * @param array, string $lib 追加ライブラリID
1951 function addPermittedAdminScript($lib)
1953 if (is_array($lib)){
1954 for ($j = 0; $j < count($lib); $j++){
1958 if (isset($this->libFiles[$libId]['script'])){
1959 $scriptFiles = $this->libFiles[$libId]['script'];
1961 // ##### ライブラリ情報を作成する場合 #####
1962 if (empty($scriptFiles)){
1963 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
1964 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
1967 for ($i = 0; $i < count($scriptFiles); $i++){
1968 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
1972 if (isset($this->libFiles[$libId]['script_lang'])){
1973 $scriptFiles = ScriptLibInfo::getLangScript($libId);
1974 for ($i = 0; $i < count($scriptFiles); $i++){
1975 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
1979 if (isset($this->libFiles[$libId]['css'])){
1980 $cssFiles = $this->libFiles[$libId]['css'];
1981 for ($i = 0; $i < count($cssFiles); $i++){
1982 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
1990 if (isset($this->libFiles[$libId]['script'])){
1991 $scriptFiles = $this->libFiles[$libId]['script'];
1993 // ##### ライブラリ情報を作成する場合 #####
1994 if (empty($scriptFiles)){
1995 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
1996 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
1999 for ($i = 0; $i < count($scriptFiles); $i++){
2000 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2004 if (isset($this->libFiles[$libId]['script_lang'])){
2005 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2006 for ($i = 0; $i < count($scriptFiles); $i++){
2007 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2011 if (isset($this->libFiles[$libId]['css'])){
2012 $cssFiles = $this->libFiles[$libId]['css'];
2013 for ($i = 0; $i < count($cssFiles); $i++){
2014 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2024 * ・ウィジェットで生成されたHTTPヘッダを設定する
2026 * @param RequestManager $request HTTPリクエスト処理クラス
2027 * @param bool $getOutput 出力を取得するかどうか
2028 * @return string 最終出力HTML
2030 function endPage($request, $getOutput = false)
2032 global $gRequestManager;
2033 global $gInstanceManager;
2034 global $gEnvManager;
2035 global $gDispManager;
2036 global $gAccessManager;
2039 if ($this->isAbort) return '';
2044 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2046 // 最終HTML(ページ全体で使用するHTML)の出力
2047 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
2049 if (count($this->exportCss) > 0){
2050 for ($i = 0; $i < count($this->exportCss); $i++){
2051 $contents .= $this->exportCss[$i] . M3_NL;
2056 header('Content-type: text/css');
2058 // 画面情報、ユーザ情報の保存は行わない
2060 } else if ($cmd != M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体オペレーションのときは出力しない
2062 $contents = $this->getLastContents($request);
2064 echo $this->getLastContents($request);
2069 $userInfo = $gInstanceManager->getUserInfo();
2070 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2073 $gDispManager->save();
2075 // キャッシュリミッタは、各リクエスト毎に(アウトプットバッファー が無効な場合は、
2076 // session_start()がコールされる 前に) session_cache_limiter()をコールする必要がある。
2078 // session_cache_limiter('private');
2079 // session_cache_expire(5);
2080 if ($this->isRedirect) return ''; // リダイレクトの場合は終了
2082 // ########## HTTPヘッダ出力処理 ########
2083 if (headers_sent($filename, $linenum)){ // HTTPヘッダが既に送信されているとき
2084 echo "$filename の $linenum 行目でヘッダがすでに送信されています。";
2086 if ($gEnvManager->isMobile()){ // 携帯の場合
2087 // ドコモ端末の場合はリクエストヘッダにXHTMLを指定しないとXHTMLを処理しない
2088 $agent = $gInstanceManager->getMobileAgent();
2089 if ($agent->isDoCoMo()){ // ドコモ端末のとき
2090 header('Content-Type: application/xhtml+xml;');
2094 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// 過去の日付
2095 header('Cache-Control: no-store, no-cache, must-revalidate');// HTTP/1.1
2096 header('Cache-Control: post-check=0, pre-check=0', false);
2097 header('Pragma: no-cache');
2100 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
2102 // Ajax用JSON型データをHTTPヘッダに格納
2103 $gInstanceManager->getAjaxManager()->header();
2105 // システム制御画面が設定されている場合はステータスコードを変更
2106 //if ($this->gEnv->getIsMaintenance()){
2107 if (!$this->isRedirect){ // リダイレクトがセットされていない場合
2108 switch ($this->systemHandleMode){
2109 case 10: // サイト非公開(システムメンテナンス)
2110 header('HTTP/1.1 503 Service Temporarily Unavailable');
2111 header('Status: 503 Service Temporarily Unavailable');
2113 case 11: // アクセス禁止のとき
2114 header('HTTP/1.1 403 Forbidden');
2115 header('Status: 403 Forbidden');
2117 case 12: // 存在しないページのとき
2118 header("HTTP/1.1 404 Not Found");
2119 header("Status: 404 Not Found");
2124 // ##### 自動ログイン #####
2125 $gAccessManager->endAutoLogin();
2132 * 注意)exitSystem()でシステムを終了させる必要あり
2136 function abortPage()
2138 global $gInstanceManager;
2139 global $gRequestManager;
2141 // HTTPヘッダを削除(PHP 5.3以上で有効)
2142 if (version_compare(PHP_VERSION, '5.3.0') >= 0) header_remove();
2144 // exit()等でabortPage()が最後の処理になってしまう可能性があるのでなるべく必要な処理を行う
2145 //if (ob_get_level() > 0) ob_end_clean();// バッファ内容が残っているときは破棄
2146 while (ob_get_level()) ob_end_clean(); // バッファ削除方法変更(2009/12/2)
2149 $userInfo = $gInstanceManager->getUserInfo();
2150 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2152 $this->isAbort = true; // ページ作成処理を中断するかどうか
2159 function abortWidget()
2161 $this->isWidgetAbort = true; // 各ウィジェット処理を中断するかどうか
2168 function exitSystem()
2170 global $gEnvManager;
2171 global $gAccessManager;
2173 // DBが使用可能であれば、アクセスログのユーザを登録
2174 if ($gEnvManager->canUseDb()) $gAccessManager->accessLogUser();
2179 * Joomla!v1.5タグを読み込んでウィジェット実行
2181 * @param string $srcBuf バッファデータ
2182 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
2183 * @return string 変換後文字列
2185 function launchWidgetByJoomlaTag($srcBuf, $templateVer)
2191 if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\s*\/>#iU', $srcBuf, $matches)){
2192 $count = count($matches[1]);
2193 for ($i = 0; $i < $count; $i++)
2196 $type = $matches[1][$i];
2198 if (strcasecmp($type, 'head') == 0){ // ヘッダ埋め込みタグの場合
2201 $contents = ob_get_contents();
2202 } else if (strcasecmp($type, 'modules') == 0 ||
2203 strcasecmp($type, 'module') == 0){ // ポジションタグの場合
2204 $name = ''; // ポジション名
2205 $posType = ''; // ポジションのタイプ
2206 $style = ''; // 表示スタイル
2207 $params = explode(' ', $matches[2][$i]);
2208 $paramArray = array();
2209 for ($j = 0; $j < count($params); $j++){
2210 list($key, $value) = explode('=', $params[$j]);
2212 $value = trim($value, "\"'");
2213 if (!empty($key)) $paramArray[$key] = $value;
2215 $value = $paramArray['name'];
2218 $attr['name'] = $value;
2220 $value = $paramArray['type']; // ポジションのタイプ
2223 $attr['type'] = $value;
2225 $value = $paramArray['id'];
2226 if (isset($value)) $attr['id'] = $value;
2228 // スタイルが設定されている場合はオプションスタイルを取得
2229 $value = $paramArray['style'];
2232 $attr['style'] = $value;
2234 $optionStyle = $paramArray[$value]; // オプションのスタイル
2235 if (isset($optionStyle)) $attr[$value] = $optionStyle;
2237 /* for ($j = 0; $j < count($params); $j++){
2238 list($key, $value) = explode('=', $params[$j]);
2239 if (strcasecmp($key, 'name') == 0){
2240 $name = strtolower(trim($value, "\"'"));
2241 $attr['name'] = $name;
2242 } else if (strcasecmp($key, 'style') == 0){
2244 $style = trim($value, "\"'");
2245 } else if (strcasecmp($key, 'artstyle') == 0){ // テンプレート側指定の表示スタイル(Artisteer用)
2246 $attr['artstyle'] = trim($value, "\"'");
2247 } else if (strcasecmp($key, 'bootstyle') == 0){ // テンプレート側指定の表示スタイル(Bootstrap用)
2248 $attr['bootstyle'] = trim($value, "\"'");
2249 } else if (strcasecmp($key, 'drstyle') == 0){ // テンプレート側指定の表示スタイル(Themer用)
2250 $attr['drstyle'] = trim($value, "\"'");
2254 if (!empty($name)){ // ポジション名が取得できたとき
2255 // Joomla!では、テンプレートの「jdoc:include」タグの属性styleが空のときは「none」で処理される
2256 // Joomla!デフォルトで設定可能なのは「none,table,horz,xhtml,rounded,outline」
2257 /* if (empty($style)){
2258 if (strStartsWith($name, 'user') || // ナビゲーションメニュー位置の場合
2259 strcasecmp($name, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
2260 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2265 // if (strStartsWith($name, 'user') || // ナビゲーションメニュー位置の場合
2266 if (strcasecmp($name, 'user3') == 0 || // ナビゲーションメニュー位置の場合
2267 strcasecmp($name, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
2268 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
2269 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2270 } else if (empty($style)){
2274 $contents = $this->getContents($name, $style, $templateVer, $attr);
2276 } else if (strcasecmp($type, 'component') == 0){ // メインポジションタグの場合
2278 $style = ''; // 表示スタイル
2279 $params = explode(' ', $matches[2][$i]);
2280 for ($j = 0; $j < count($params); $j++){
2281 list($key, $value) = explode('=', $params[$j]);
2282 if (strcasecmp($key, 'style') == 0){
2284 $style = trim($value, "\"'");
2288 if ($style != 'none') $style = 'xhtml';
2289 $contents = $this->getContents('main', $style, $templateVer, $attr);
2290 } else if (strcasecmp($type, 'message') == 0){ // メッセージタグの場合
2292 $replace[$i] = $contents;
2295 $destBuf = str_replace($matches[0], $replace, $srcBuf);
2302 * 遅延実行インデックスのついているウィジェットをインデックス順に実行し、出力バッファデータ内のタグの位置に出力を埋め込む
2304 * @param RequestManager $request HTTPリクエスト処理クラス
2305 * @param string $srcBuf バッファデータ
2306 * @return string 変換後文字列
2308 function lateLaunchWidget($request, $srcBuf)
2310 global $gEnvManager;
2311 global $gErrorManager;
2312 global $gDesignManager;
2314 // ページ作成中断またはウィジェット処理中断のときは終了
2315 if ($this->isAbort || $this->isWidgetAbort) return '';
2317 // ウィジェットヘッダ(Joomla!1.0用)を出力のタイプを取得
2318 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
2320 // 遅延実行ウィジェットをインデックス順にソート
2321 asort($this->lateLaunchWidgetList, SORT_NUMERIC);
2325 foreach ($this->lateLaunchWidgetList as $widgetId => $value){
2327 $count = count($this->latelaunchWidgetParam);
2328 for ($i = 0; $i < $count; $i++){
2329 list($wId, $maxNo, $confId, $preId, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $pageDefRec) = $this->latelaunchWidgetParam[$i];
2330 if ($wId == $widgetId){
2332 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
2333 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
2334 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
2337 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
2338 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
2344 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
2347 $configId = $confId; // ウィジェット定義ID
2348 if ($configId == 0) $configId = '';
2349 $prefix = $preId; // サフィックス文字列
2351 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
2352 $joomlaTitleVisble = false;
2353 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
2354 if (!empty($title)){
2355 if ($widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2356 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
2357 echo '<tr><th>' . $title . '</th></tr>' . M3_NL;
2358 echo '<tr><td>' . M3_NL;
2359 $joomlaTitleVisble = true;
2360 } else if ($widgetHeaderType == 2){ // 携帯用ウィジェットヘッダ出力
2361 echo '<div>' . $title . '</div>' . M3_NL;
2362 $joomlaTitleVisble = true;
2367 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
2368 // ウィジェット親のCSS定義があるときは、タグを追加
2369 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
2372 echo $gDesignManager->getAdditionalWidgetOutput(true);
2375 $gEnvManager->setCurrentWidgetId($widgetId);
2378 $gEnvManager->setCurrentWidgetConfigId($configId);
2381 $gEnvManager->setCurrentPageDefSerial($serial);
2384 $gEnvManager->setCurrentPageDefRec($pageDefRec);
2387 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
2390 $gEnvManager->setCurrentWidgetTitle('');
2393 $gEnvManager->setCurrentWidgetStyle($style);
2395 // ウィジェットのグローバル属性状況を設定
2396 $gEnvManager->setIsCurrentWidgetShared($shared);
2399 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
2402 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
2403 $msg = 'widget-start(' . $widgetId . ')';
2404 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2405 require($widgetIndexFile);
2406 $msg = 'widget-end(' . $widgetId . ')';
2407 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2410 $gEnvManager->setCurrentWidgetId('');
2413 $gEnvManager->setCurrentWidgetConfigId('');
2416 $gEnvManager->setCurrentPageDefSerial(0);
2419 $gEnvManager->setCurrentPageDefRec();
2422 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
2425 $gEnvManager->setCurrentWidgetStyle('');
2427 // ウィジェットのグローバル属性状況を解除
2428 $gEnvManager->setIsCurrentWidgetShared(false);
2431 $newTitle = $gEnvManager->getCurrentWidgetTitle();
2434 echo $gDesignManager->getAdditionalWidgetOutput(false);
2436 // ウィジェット親のCSS定義があるときは、タグを追加
2437 if (!empty($cssStyle)) echo '</div>' . M3_NL;
2439 //echo '</div>' . M3_NL;
2441 // Joomla!1.0テンプレートのときはタイトルを出力
2442 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2443 echo '</td></tr>' . M3_NL;
2444 echo '</table>' . M3_NL;
2447 // 現在のバッファ内容を取得し、バッファを破棄
2448 $srcContents = ob_get_contents();
2452 $tag = self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
2453 $destBuf = str_replace($tag, $srcContents, $destBuf);
2456 if (!empty($newTitle)) $title = $newTitle;
2457 $tag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
2458 $destBuf = str_replace($tag, $title, $destBuf);
2460 // ##### 外部出力用のCSSがある場合は追加 #####
2461 if (!empty($exportCss)){
2463 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $index; // ウィジェット識別用ユニークタグ
2464 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
2465 $this->addExportCss($exportCss);
2471 // ##### HTMLヘッダ出力処理 #####
2472 $destBuf = $this->replaceHead($destBuf);
2479 * @param string $jobType ジョブタイプ
2482 function launchJob($jobType)
2484 global $gEnvManager;
2486 // ジョブタイプから実行するウィジェットIDを取得
2487 $widgetId = $this->getWidgetIdByJobType($jobType);
2488 if (empty($widgetId)) return;
2491 $gEnvManager->setCurrentWidgetId($widgetId);
2494 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/admin/job.php';
2496 if (file_exists($widgetIndexFile)){
2498 // $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd);
2500 require_once($widgetIndexFile);
2502 echo 'file not found: ' . $widgetIndexFile;
2506 $gEnvManager->setCurrentWidgetId();
2511 * @param string $srcBuf 変換元
2512 * @return string 変換後文字列
2514 function replaceHead($srcBuf)
2518 // ##### ヘッダ部分の置換 #####
2519 if ($this->outputHead){ // HTMLヘッダ出力を行っているとき
2521 $replaceStr = $this->getHeaderOutput();
2524 $destBuf = str_replace(self::HEAD_TAGS, $replaceStr, $destBuf);
2526 $this->replaceHeadDone = true; // ヘッダマクロ変換処理が完了したかどうか
2530 * ウィジェット検索モードの場合のページサブIDの設定
2532 * @param RequestManager $request HTTPリクエスト処理クラス
2534 function redirectToUpdatedPageSubId($request)
2536 global $gEnvManager;
2538 // 現在設定されているページIDを取得
2539 $pageId = $gEnvManager->getCurrentPageId();
2540 $pageSubId = $gEnvManager->getCurrentPageSubId();
2543 $fromWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_FROM);
2546 $targetWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
2548 // 対象のウィジェットのページサブIDを取得
2549 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2550 if ($ret){// データが存在する
2551 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2552 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2553 if ($ret){// データが存在する
2554 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2556 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2561 for ($i = 0; $i < count($rows); $i++){
2562 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2567 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2568 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2570 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2573 } else { // 対象のウィジェットが見つからない場合は、互換ウィジェットを探す
2574 $widgetId = $this->db->getCompatibleWidgetId($targetWidgetId);
2575 if (!empty($widgetId)){
2576 $targetWidgetId = $widgetId;
2578 // 対象のウィジェットのページサブIDを取得
2579 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2580 if ($ret){// データが存在する
2581 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2582 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2583 if ($ret){// データが存在する
2584 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2586 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2591 for ($i = 0; $i < count($rows); $i++){
2592 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2597 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2598 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2600 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2606 // ページサブIDが見つからないときは、既に設定されている値を使用
2607 // 既に設定されている値は、URL「sub」パラメータで指定されている値か
2608 // 設定されていない場合はデフォルトのサブページID
2609 // ********** 指定ページへリダイレクト ***********
2611 $todo = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TODO);
2612 $todo = str_replace(M3_TODO_SEPARATOR, '&', $todo); // セパレータを変換
2613 // $redirectUrl = '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2614 $redirectUrl = $gEnvManager->createPageUrl() . '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2615 if (!empty($todo)) $redirectUrl .= '&' . $todo;
2616 if ($gEnvManager->getIsMobileSite()){ // 携帯用アクセスポイントの場合
2617 $this->redirect($redirectUrl, true/*遷移時のダイアログ表示を抑止*/);
2619 $this->redirect($redirectUrl);
2625 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2626 * 追加するHTMLは主にウィンドウ制御用のスクリプト
2628 * @return string 最終HTML
2630 function getLastContents()
2632 global $gEnvManager;
2633 global $gRequestManager;
2636 $initScript = ''; // 初期化用スクリプト
2637 $pageId = $gEnvManager->getCurrentPageId();
2638 $pageSubId = $gEnvManager->getCurrentPageSubId();
2639 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2641 if (!$gEnvManager->isSystemManageUser()) return ''; // システム運用権限がない場合は終了
2644 if ($cmd == M3_REQUEST_CMD_RSS || // RSS配信のときは終了
2645 $cmd == M3_REQUEST_CMD_DO_WIDGET) return ''; // ウィジェット単体オペレーションのときは出力しない
2647 if ($gEnvManager->getIsMobileSite()) return ''; // 携帯用URLのときは終了
2649 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2651 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
2652 /* // テンプレート上のポジション名
2653 if (count($this->viewPosId) > 0){
2655 for ($i = 0; $i < count($this->viewPosId); $i++){
2656 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
2657 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
2659 $posArrayStr .= ']';
2660 $contents .= 'var M3_POSITIONS=' . $posArrayStr . ';' . M3_NL;
2663 $contents .= 'var M3_REVISION=' . $this->pageDefRev . ';' . M3_NL;*/
2666 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2667 $contents .= M3_INDENT_SPACE . 'window.m3.m3UpdateByConfig(serial);' . M3_NL;
2668 $contents .= '}' . M3_NL;
2669 } else if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定画面
2670 } else { // ダッシュボード画面、メイン管理画面
2672 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2673 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2674 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2675 $contents .= '}' . M3_NL;
2678 // ウィジェット単体実行以外のときの処理
2679 if (!$this->showWidget){
2680 if ($this->updateParentWindow){ // 管理画面からの親画面の更新
2681 $initScript .= M3_INDENT_SPACE . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
2686 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2687 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2688 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2689 $contents .= '}' . M3_NL;
2693 if (!empty($contents) || !empty($initScript)){
2694 // $destContents .= '<script type="text/javascript">' . M3_NL;
2695 // $destContents .= '//<![CDATA[' . M3_NL;
2696 $destContents .= $contents;
2697 if (!empty($initScript)){ // 初期化用スクリプト
2698 $destContents .= '$(function(){' . M3_NL;
2699 $destContents .= $initScript;
2700 $destContents .= '});' . M3_NL;
2702 // $destContents .= '//]]>' . M3_NL;
2703 // $destContents .= '</script>' . M3_NL;
2705 return $destContents;
2710 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2712 * @param RequestManager $request HTTPリクエスト処理クラス
2713 * @return string 最終HTML
2715 function getOptionContents($request)
2717 global $gEnvManager;
2722 if ($this->isAbort) return '';
2724 // AJAX用のレスポンスボディデータのときは終了
2725 if ($this->outputAjaxResponseBody) return '';
2728 // AJAXを送信する場合は空文字列では送信できないので、ダミーデータを返す
2729 if ($this->isWidgetAbort) $contents .= 'NO DATA' . M3_NL;
2732 if (!$gEnvManager->isMobile() && $this->outputByHtml){ // 携帯以外で、HTML出力のとき
2733 $contents .= '<!-- created by ' . M3_SYSTEM_NAME . ' v' . M3_SYSTEM_VERSION . ' - http://www.magic3.org -->' . M3_NL;
2734 $contents .= '<!-- convert time: ' . sprintf('%01.03f', microtime(true) - M3_MTIME) . ' -->' . M3_NL;
2739 * Widget単体起動用のHTMLのヘッダ部(headタグ)出力
2741 * startWidget(),endWidget()は、以下のコマンドを処理する
2742 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
2743 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
2744 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
2745 * Widgetの出力方法は、以下のパターンがある
2746 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
2747 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
2749 * @param string $cmd 起動コマンド
2751 function startWidget($cmd)
2753 global $gEnvManager;
2754 global $gRequestManager;
2756 // ウィジェット単体表示のときのみ出力
2757 if (!$this->showWidget) return;
2760 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
2761 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
2763 // $isHtml5 = false; // HTML5で出力するかどうか
2764 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
2765 if (intval($tempVer) >= 2) $this->isHtml5 = true; // HTML5で出力するかどうか
2768 if ($this->isHtml5){
2769 echo '<!DOCTYPE html>' . M3_NL;
2770 echo '<html dir="ltr" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2771 echo '<head>' . M3_NL;
2773 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . M3_NL;
2774 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $gEnvManager->getCurrentLanguage() . '" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2775 echo '<head>' . M3_NL;
2776 // echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' . M3_NL;
2779 // HTMLのヘッダ部(headタグ内)出力
2783 $widgetId = $gEnvManager->getCurrentWidgetId(); // カレントのウィジェットID
2786 if ($gEnvManager->getUseSslAdmin()){
2787 $rootUrl = $gEnvManager->getSslRootUrl();
2788 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
2789 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
2791 $rootUrl = $gEnvManager->getRootUrl();
2792 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
2793 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
2796 // ##### テンプレートのCSSの読み込み #####
2797 // テンプレートは管理用テンプレートに固定されている
2798 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット設定のとき
2799 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
2800 $curTemplateUrl = $templatesUrl . '/' . $gEnvManager->getCurrentTemplateId();
2801 if ($this->isHtml5){
2802 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/style.css" media="screen">' . M3_NL;
2803 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/widget.css" media="screen">' . M3_NL; // ウィジェット設定画面用CSS
2804 echo '<!--[if IE]><link rel="stylesheet" href="' . $curTemplateUrl . '/css/iestyles.css" media="screen"><![endif]-->' . M3_NL;
2805 echo '<!--[if lt IE 9]><script src="' . $curTemplateUrl . '/html5shiv.js"></script><![endif]-->' . M3_NL;
2807 echo '<link href="' . $curTemplateUrl . '/css/style.css" rel="stylesheet" type="text/css" />' . M3_NL;
2808 echo '<!--[if IE]><link rel="stylesheet" type="text/css" media="screen" href="' . $curTemplateUrl . '/css/iestyles.css" /><![endif]-->' . M3_NL;
2812 $ret = $this->db->getWidgetInfo($widgetId, $row);
2814 // ##### 共通ライブラリ読み込み設定 #####
2815 if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
2816 $scritLib = trim($row['wd_add_script_lib']);
2817 if (!empty($scritLib)) $this->addScript($task, $scritLib);
2820 // CSS読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2821 if ($row['wd_read_css']){
2822 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_CSS;
2823 if (is_dir($searchPath)){
2824 $dir = dir($searchPath);
2825 while (($file = $dir->read()) !== false){
2826 $filePath = $searchPath . '/' . $file;
2827 if ($file != '.' && $file != '..' && is_file($filePath)
2828 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
2831 $cssURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_CSS . '/' . $file;
2832 echo '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2839 // スクリプト読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2840 if ($row['wd_read_scripts']){
2841 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS;
2842 if (is_dir($searchPath)){
2843 $dir = dir($searchPath);
2844 while (($file = $dir->read()) !== false){
2845 $filePath = $searchPath . '/' . $file;
2846 if ($file != '.' && $file != '..' && is_file($filePath)
2847 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
2850 $scriptURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
2852 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
2853 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
2854 echo '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
2860 // ##### スクリプト用出力用タグを埋め込む #####
2861 // ウィジェット設定画面用メニューバーの作成
2862 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
2863 echo self::MENUBAR_SCRIPT_TAGS; // メニューバー出力用タグ
2867 $title = $row['wd_name'];
2868 if (empty($title)) $title = $row['wd_id'];
2869 $gEnvManager->setCurrentWidgetTitle($title);
2870 echo '<title>' . self::WIDGET_TITLE_START . htmlspecialchars($title) . self::WIDGET_TITLE_END . '</title>' . M3_NL;
2871 echo '</head>' . M3_NL;
2872 // タブでウィンドウを開く場合は背景を透過モードにする
2873 if ($this->isTransparentMode){
2874 echo '<body style="background-color:transparent;">' . M3_NL;
2876 echo '<body>' . M3_NL;
2878 // ウィジェット設定画面用メニューバーの作成
2879 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
2881 $desc = $row['wd_description']; // 説明
2882 $gEnvManager->setCurrentWidgetParams('desc', $desc);
2884 echo self::MENUBAR_TAGS; // メニューバー出力用タグ
2887 if ($this->useBootstrap) echo '<div class="container">' . M3_NL;
2889 // 別ウィンドウで表示のときは、「閉じる」ボタンを表示
2890 if ($cmd == M3_REQUEST_CMD_SHOW_WIDGET || // ウィジェットの単体表示のとき
2891 $cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット詳細設定画面のとき
2892 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット単体実行でフロント画面編集モードのとき
2894 // if ($this->isEditMode){// フロント画面編集モードのとき
2895 if (!empty($openBy)){
2896 // サーバ指定されている場合はサーバ情報を取得
2898 $server = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_SERVER);
2899 if (!empty($server)){
2901 $ret = $this->db->getServerById($server, $row);
2903 $serverName = 'サーバ名:' . $row['ts_name'];// サーバ名
2904 echo '<div align="left" style="float:left;padding-left:30px;"><label>' . convertToHtmlEntity($serverName) . '</label></div>';
2907 // タブ、インナーフレーム、ダイアログ表示以外のときは「閉じる」ボタンを表示
2908 if ($openBy != 'tabs' && $openBy != 'iframe' && $openBy != 'dialog'){ // 以外
2909 if ($openBy == 'logout'){
2910 $titleStr = 'ログアウト';
2911 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 .
2912 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
2915 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 .
2916 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
2922 echo '<div class="m3configprev" style="display:none;"><a id="m3configprev" href="#"><img src="' . $rootUrl . self::PREV_ICON_FILE .
2923 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
2925 echo '<div class="m3confignext" style="display:none;"><a id="m3confignext" href="#"><img src="' . $rootUrl . self::NEXT_ICON_FILE .
2926 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
2929 // echo '<div class="row">' . M3_NL;
2930 echo '<!-- Widget Start -->' . M3_NL;
2935 * startWidget(),endWidget()は、以下のコマンドを処理する
2936 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
2937 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
2938 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
2940 * @param string $cmd 起動コマンド
2941 * @param string $srcContent HTML出力ソース
2943 function endWidget($cmd, $srcContent)
2945 global $gDesignManager;
2947 // ウィジェット単体表示のときのみ出力
2948 if (!$this->showWidget) return;
2952 $breadcrumbHtml = '';
2953 if (!empty($this->adminSubNavbarDef)) $breadcrumbHtml .= $gDesignManager->createSubMenubar($this->adminSubNavbarDef);
2954 if (!empty($this->adminBreadcrumbDef)) $breadcrumbHtml .= $gDesignManager->createAdminBreadcrumb($this->adminBreadcrumbDef);
2955 $destContent = str_replace(self::MENUBAR_TAGS, $breadcrumbHtml, $srcContent);
2958 $replaceStr .= '<script type="text/javascript">' . M3_NL;
2959 $replaceStr .= '//<![CDATA[' . M3_NL;
2963 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェットの設定管理
2965 $replaceStr .= 'function m3UpdateByConfig(serial){' . M3_NL;
2966 $replaceStr .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2967 $replaceStr .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2968 $replaceStr .= M3_INDENT_SPACE . 'm3UpdateParentWindow();' . M3_NL; // 親ウィンドウ更新
2969 $replaceStr .= '}' . M3_NL;
2972 $replaceStr .= 'function hideIEErrors(){' . M3_NL;
2973 $replaceStr .= M3_INDENT_SPACE . 'return true;' . M3_NL;
2974 $replaceStr .= '}' . M3_NL;
2975 $replaceStr .= 'window.onerror = hideIEErrors;' . M3_NL;
2979 $replaceStr .= '$(function(){' . M3_NL;
2981 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
2982 if (!empty($this->adminSubNavbarDef) || !empty($this->adminBreadcrumbDef)){
2983 $menubarHeight = $gDesignManager->getSubMenubarHeight();
2984 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("nav.secondlevel").css("margin-top", "0");' . M3_NL;
2985 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("body").css("padding-top", "' . $menubarHeight . 'px");' . M3_NL;
2988 // ##### ウィジェットからの指定による処理 #####
2989 if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
2990 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
2991 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
2992 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
2993 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
2996 $replaceStr .= '});' . M3_NL;
2997 $replaceStr .= '//]]>' . M3_NL;
2998 $replaceStr .= '</script>' . M3_NL;
2999 $destContent = str_replace(self::MENUBAR_SCRIPT_TAGS, $replaceStr, $destContent);
3000 echo $destContent;// 変換したコンテンツを出力
3002 // echo '</div>' . M3_NL; // row
3003 echo '<!-- Widget End -->' . M3_NL;
3005 // ##### ウィジェットからの指定による処理 #####
3006 /* if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
3007 echo '<script type="text/javascript">' . M3_NL;
3008 echo '//<![CDATA[' . M3_NL;
3009 echo '$(function(){' . M3_NL;
3010 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
3011 echo str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
3012 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
3013 echo str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
3016 echo '//]]>' . M3_NL;
3017 echo '</script>' . M3_NL;
3021 if ($this->useBootstrap) echo '</div>' . M3_NL;
3023 echo '</body>' . M3_NL;
3024 echo '</html>' . M3_NL;
3027 * Widget単体RSS出力用のHTMLのヘッダ部(headタグ)出力
3029 * Widgetの出力方法は、以下のパターンがある
3030 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
3031 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
3033 * @param string $cmd 起動コマンド
3035 function startWidgetRss($cmd)
3039 * Widget単体RSS出力用のタグを閉じる
3041 * @param string $cmd 起動コマンド
3042 * @param string $rssContent RSS配信内容
3044 function endWidgetRss($cmd, $rssContent)
3046 global $gEnvManager;
3049 if ($this->isAbort) return;
3051 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3054 $lang = $gEnvManager->getCurrentLanguage();
3055 $date = getW3CDate(); // RSS1.0用日付
3056 $copyright = $gEnvManager->getSiteCopyRight(); // 著作権
3057 $title = $this->rssChannel['title']; // タイトル
3058 $link = $this->rssChannel['link']; // RSS取得用URL
3059 $desc = $this->rssChannel['description']; // 説明
3060 $seq = $this->rssChannel['seq']; // 項目の並び順(URL)
3062 switch ($this->rssVersion){ // RSSバージョン
3065 echo '<rdf:RDF xmlns="http://purl.org/rss/1.0/" ';
3066 echo 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
3067 echo 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
3068 echo 'xml:lang="' . $lang . '">' . M3_NL;
3069 echo '<channel rdf:about="' . convertUrlToHtmlEntity($link) . '">' . M3_NL;
3070 echo '<title>' . convertToHtmlEntity($title) . '</title>' . M3_NL;
3071 echo '<link>' . convertUrlToHtmlEntity($link) . '</link>' . M3_NL; // 「convertUrlToHtmlEntity」が必要
3072 echo '<description>' . convertToHtmlEntity($desc) . '</description>' . M3_NL;
3073 echo '<dc:language>' . $lang . '</dc:language>' . M3_NL;
3074 if (!empty($copyright)) echo '<dc:rights>' . convertToHtmlEntity($copyright) . '</dc:rights>' . M3_NL;
3075 echo '<dc:date>' . $date . '</dc:date>' . M3_NL;
3076 echo '<items>' . M3_NL;
3077 if (count($seq) > 0){
3078 echo str_repeat(M3_INDENT_SPACE, 1) . '<rdf:Seq>' . M3_NL;
3079 for ($i = 0; $i < count($seq); $i++){
3080 echo str_repeat(M3_INDENT_SPACE, 2) . '<rdf:li rdf:resource="' . convertUrlToHtmlEntity($seq[$i]) . '" />' . M3_NL;
3082 echo str_repeat(M3_INDENT_SPACE, 1) . '</rdf:Seq>' . M3_NL;
3084 echo '</items>' . M3_NL;
3085 echo '</channel>' . M3_NL;
3087 echo '</rdf:RDF>' . M3_NL;
3094 header("Content-type: text/xml; charset=utf-8");
3097 * 直サーバ接続時のXML出力用のHTMLのヘッダ部(headタグ)出力
3099 * @param string $cmd 起動コマンド
3102 function startWidgetXml($cmd)
3105 //header("Content-type: text/xml; charset=utf-8");
3110 * @param string $cmd 起動コマンド
3113 function endWidgetXml()
3119 * @return string ドキュメントタイプ出力
3121 function getMobileDocType()
3123 global $gEnvManager;
3124 global $gInstanceManager;
3125 global $gRequestManager;
3127 $docTypeStr = ''; // 出力するDocType
3128 $agent = $gInstanceManager->getMobileAgent();
3129 if ($agent->isDoCoMo()){ // ドコモ端末のとき
3130 $htmlVer = $agent->getHTMLVersion();
3133 $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">';
3136 $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">';
3139 $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">';
3142 $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">';
3145 $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">';
3148 $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">';
3151 if (preg_match("/^DoCoMo\/1\.0/i", $gRequestManager->trimServerValueOf('HTTP_USER_AGENT'))){ // mova端末のとき
3152 // mova端末のときはドキュメントタイプなしにすると画面表示可能
3157 } else if ($agent->isEZweb()){ // au端末のとき
3158 if ($agent->isWAP2()){
3159 $docTypeStr = '<!DOCTYPE html PUBLIC "-//OPENWAVE//DTD XHTML 1.0//EN" "http://www.openwave.com/DTD/xhtml-basic.dtd">';
3161 } else if ($agent->isSoftBank()){ // ソフトバンク端末のとき
3162 if ($agent->isTypeW() || $agent->isType3GC()){
3163 $docTypeStr = '<!DOCTYPE html PUBLIC "-//J-PHONE//DTD XHTML Basic 1.0 Plus//EN" "xhtml-basic10-plus.dtd">';
3166 if ($gEnvManager->getIsMobileSite()){ // 携帯用サイトへのアクセスの場合
3167 echo '<?xml version="1.0" encoding="' . $gEnvManager->getMobileCharset() . '" ?>' . M3_NL;
3169 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3171 if (empty($docTypeStr)) $docTypeStr = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
3172 echo $docTypeStr . M3_NL;
3177 * @return string XML宣言
3179 function getDefaultXmlDeclaration()
3181 return '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>';
3184 * HTMLのヘッダ部(headタグ内)出力
3186 * システムに共通な定義をHTMLのheadタグ内に出力する
3187 * mosFunc.phpからも実行されるので、このメソッドは引数なしに固定。
3188 * この関数は、以下の「形式1」または「形式2」でheadタグ内に記述する
3190 * 形式1: <!-- m3:HTMLHeader -->
3191 * 形式2(old style): <?php mosShowHead(); ?>
3193 function getHeader()
3195 global $gEnvManager;
3196 global $gRequestManager;
3198 $this->outputHead = true; // HTMLヘッダ出力を行ったかどうか
3201 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3203 // ######### 携帯用サイトの場合は別にヘッダを作成する #########
3204 if ($gEnvManager->getIsMobileSite()){
3206 echo '<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=' . $gEnvManager->getMobileCharset() . '" />' . M3_NL;
3209 echo '<meta http-equiv="Pragma" content="no-cache" />' . M3_NL;
3210 echo '<meta http-equiv="Cache-Control" content="no-cache" />' . M3_NL;
3211 echo '<meta http-equiv="Expires" content="-1" />' . M3_NL;
3214 echo '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
3215 } else { // PC用サイト、管理用サイト、スマートフォン用サイトのとき
3216 // $isHtml5 = false; // HTML5で出力するかどうか
3217 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
3218 $this->isHtml5 = true;
3220 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
3221 if (intval($tempVer) >= 2) $this->isHtml5 = true;
3224 // ********** メタタグの設定 **********
3227 //if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
3228 if ($this->isHtml5){
3229 //echo '<meta http-equiv="content-type" content="text/html; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
3230 echo '<meta charset="' . M3_HTML_CHARSET . '">' . M3_NL;
3232 echo '<meta http-equiv="content-script-type" content="text/javascript" />' . M3_NL;
3233 echo '<meta http-equiv="content-style-type" content="text/css" />' . M3_NL;
3234 echo '<meta http-equiv="content-type" content="application/xhtml+xml; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
3238 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 表示位置を表示するとき
3239 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
3241 if ($gEnvManager->getUseSslAdmin()){
3242 $rootUrl = $gEnvManager->getSslRootUrl();
3244 $rootUrl = $gEnvManager->getRootUrl();
3246 echo '<base href="' . $rootUrl . '/" />' . M3_NL;
3249 echo self::HEAD_TAGS; // HTMLヘッダの埋め込みデータ
3254 * @return string HTMLヘッダ出力文字列
3256 function getHeaderOutput()
3258 global $gEnvManager;
3259 global $gRequestManager;
3260 global $gInstanceManager;
3261 global $gSystemManager;
3263 $replaceStr = ''; // 変換文字列
3266 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3267 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
3268 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
3269 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
3271 // ********************************************************
3273 // ********************************************************
3274 // ##### テンプレートの設定、フレームの設定から必要なライブラリを取得 #####
3276 // if (!$this->useBootstrap) $this->useBootstrap = $gEnvManager->getCurrentTemplateUseBootstrap();
3277 if ($this->useBootstrap){
3278 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3279 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3280 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
3281 if ($cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)以外のとき
3282 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3284 } else { // ログインしていない場合(ログイン画面等)
3285 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP);
3286 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP_ADMIN);// Bootstrap管理画面オプション
3288 } else { // フロント画面へのアクセスの場合
3289 // ### Bootstrapのjsとcssはテンプレート側で読み込む ###
3290 // $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP); // Bootstrapライブラリ
3291 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW || // ログイン、ログアウト場合
3292 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
3293 $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3297 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3298 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3299 $this->addAdminScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3301 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3303 } else if ($gEnvManager->isContentEditableUser()){ // 投稿ユーザの場合
3304 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3308 // ********************************************************
3310 // ********************************************************
3311 // ##### インストール時のヘッダ出力 #####
3312 if (defined('M3_STATE_IN_INSTALL')){
3315 if (count($this->headSubTitle) > 0) $title = htmlspecialchars(trim($this->headSubTitle[0]));
3317 // ********** メタタグの設定 **********
3318 $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3320 // ##### インストーラ用のファイルの読み込み #####
3321 $scriptsUrl = '../scripts';
3323 // 管理機能用共通ライブラリのCSSの読み込み
3324 $count = count($this->defaultAdminCssFiles);
3325 for ($i = 0; $i < $count; $i++){
3327 $cssFilename = $this->defaultAdminCssFiles[$i];
3328 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3329 $cssURL = $cssFilename;
3331 $cssURL = $scriptsUrl . '/' . $cssFilename;
3333 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3336 // 管理画面用の共通スクリプトを読み込む
3337 $count = count($this->defaultAdminScriptFiles);
3338 for ($i = 0; $i < $count; $i++){
3339 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3342 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3343 $scriptURL = $scriptFilename;
3347 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3349 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3352 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3355 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3356 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3357 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3360 // ##### ページへJavascriptの埋め込む #####
3361 // JavaScriptグローバル変数の設定
3362 $rootUrl = $gEnvManager->getRootUrl();
3363 if (empty($rootUrl)) $rootUrl = $gEnvManager->calcSystemRootUrl();
3364 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3365 $replaceStr .= '//<![CDATA[' . M3_NL;
3366 $replaceStr .= '// Magic3 Global values' . M3_NL;
3367 if (!empty($rootUrl)) $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3368 $replaceStr .= '//]]>' . M3_NL;
3369 $replaceStr .= '</script>' . M3_NL;
3374 $cleanType = $gEnvManager->getCurrentTemplateCleanType(); // テンプレートクリーンタイプ
3375 /* if ($this->db->getTemplate($gEnvManager->getCurrentTemplateId(), $templateRow)){
3376 $cleanType = $templateRow['tm_clean_type'];
3381 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3383 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
3385 $isSslPage = $this->isSslPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
3388 $rootUrl = $gEnvManager->getSslRootUrl();
3389 $scriptsUrl = $gEnvManager->getSslScriptsUrl(); // スクリプト読み込み用パス
3390 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
3391 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
3393 $rootUrl = $gEnvManager->getRootUrl();
3394 $scriptsUrl = $gEnvManager->getScriptsUrl(); // スクリプト読み込み用パス
3395 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
3396 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
3400 if (!$this->showWidget){// 単体実行以外のとき
3401 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスの場合
3403 // メイン画面は「サイト名 - 管理画面」、サブ画面は個別画面名
3404 $siteName = $gEnvManager->getSiteName();
3405 // if (empty($siteName)) $siteName = self::DEFAULT_SITE_NAME;
3406 $title = $siteName . ' - ' . self::DEFAULT_ADMIN_TITLE;
3407 $titleCount = count($this->headSubTitle);
3408 if ($titleCount > 0) $title = $this->headSubTitle[$titleCount -1]; // サブタイトルが設定されている場合は変更
3409 $replaceStr .= '<title>' . htmlspecialchars($title) . '</title>' . M3_NL;
3410 } else { // 管理画面以外の画面へのアクセスの場合
3412 $titleItemCount = 0; // タイトル項目数
3413 $defaultTitle = trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_TITLE));
3414 if (!empty($defaultTitle)) $titleItemCount++;
3415 if (!empty($this->headSubTitle)){ // サブタイトルが設定されているとき
3416 $titleItemCount += count($this->headSubTitle);
3420 if ($titleItemCount > 0){
3421 $format = $this->gSystem->getSystemConfig(self::CONFIG_KEY_HEAD_TITLE_FORMAT);
3422 if (empty($format)){
3423 $title = htmlspecialchars($defaultTitle);
3425 $formats = explode(';', $format);
3426 $titleItemCount = ($titleItemCount > count($formats)) ? count($formats) : $titleItemCount;
3427 $title = $formats[$titleItemCount -1];
3429 if (!empty($defaultTitle)){
3430 $title = str_replace('$1', htmlspecialchars($defaultTitle), $title);
3433 for ($i = 0; $i < count($this->headSubTitle); $i++){
3434 $key = '$' . $number;
3435 $value = htmlspecialchars(trim($this->headSubTitle[$i]));
3436 $title = str_replace($key, $value, $title);
3441 if (!empty($title)) $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3444 if (!empty($this->headDescription)) $replaceStr .= '<meta name="description" content="' . htmlspecialchars($this->headDescription) . '" />' . M3_NL;
3447 if (!empty($this->headKeywords)) $replaceStr .= '<meta name="keywords" content="' . htmlspecialchars($this->headKeywords) . '" />' . M3_NL;
3449 // その他HTMLヘッダに出力するタグ文字列
3450 if (!empty($this->headOthers)){
3452 $this->headOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->headOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3453 $replaceStr .= $this->headOthers . M3_NL;
3458 // ##### PC用URLと携帯用URLのアクセス別に処理 #####
3459 if ($gEnvManager->getIsMobileSite()){ // 携帯用URLのとき
3460 } else { // PC用URLまたはスマートフォン用URLのとき
3461 // ##### テンプレート情報に応じた処理 #####
3462 // テンプレートクリーンが必要な場合はJQueryを追加
3463 if ($cleanType != 0) $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
3466 $robots = htmlspecialchars(trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_ROBOTS)));
3467 if (!empty($robots)){
3468 $replaceStr .= '<meta name="robots" content="' . $robots . '" />' . M3_NL;
3472 $replaceStr .= '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
3475 $templateId = $gEnvManager->getCurrentTemplateId();
3476 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3477 // テンプレートのFaviconがない場合はシステムのデフォルトのFaviconを使用
3478 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3479 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3480 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3481 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3484 $faviconPath = $gEnvManager->getSystemRootPath() . self::DEFAULT_ADMIN_FAVICON_FILE;
3485 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3486 $faviconFile = $rootUrl . self::DEFAULT_ADMIN_FAVICON_FILE;
3487 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3491 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3492 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3493 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3494 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3497 // ##### 追加ライブラリの読み込み #####
3498 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用URLのとき
3499 $value = $gSystemManager->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面で常にjQuery Mobileを使用
3501 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
3502 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
3503 for ($l = 0; $l < count($this->headPreMobileScriptFiles); $l++){
3504 $this->addScriptFile($this->headPreMobileScriptFiles[$l]); // 通常機能用のスクリプト追加
3507 $this->addScriptFile($this->selectedJQueryMobileFilename);
3511 // ##### Ajaxライブラリの読み込み #####
3512 if (!$gEnvManager->isAdminDirAccess()){ // 通常画面へのアクセスのとき
3513 if ($this->db->isExistsWidgetWithAjax($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId())){// Ajaxライブラリを使用しているウィジェットがあるときは追加
3514 $this->addScriptFile($this->selectedJQueryFilename); // デフォルトAjaxライブラリ追加
3515 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
3519 // ##### 共通ライブラリの読み込み #####
3520 if (!$this->showWidget){// 単体実行以外のとき
3521 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3522 for ($i = 0; $i < count($rows); $i++){
3523 $this->addScript($task, trim($rows[$i]['wd_add_script_lib']));
3527 // ##### 共通CSS読み込み #####
3528 if (($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()) || $this->isEditMode){ // フロント画面編集モード
3529 $cssURL = $scriptsUrl . '/' . self::M3_EDIT_CSS_FILE;
3530 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3532 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3533 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
3534 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3535 // 管理機能用共通ライブラリのCSSの読み込み
3536 $count = count($this->defaultAdminCssFiles);
3537 for ($i = 0; $i < $count; $i++){
3539 //$cssURL = $scriptsUrl . '/' . $this->defaultAdminCssFiles[$i];
3540 $cssFilename = $this->defaultAdminCssFiles[$i];
3541 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3542 $cssURL = $cssFilename;
3544 $cssURL = $scriptsUrl . '/' . $cssFilename;
3546 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3549 // 管理権限なしで管理ディレクトリアクセスで必要なCSSファイルを読み込む
3550 $count = count($this->defaultAdminDirCssFiles);
3551 for ($i = 0; $i < $count; $i++){
3553 $cssURL = $scriptsUrl . '/' . $this->defaultAdminDirCssFiles[$i];
3554 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3559 $count = count($this->defaultCssFiles);
3560 for ($i = 0; $i < $count; $i++){
3562 $cssFilename = $this->defaultCssFiles[$i];
3563 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3564 $cssURL = $cssFilename;
3566 $cssURL = $scriptsUrl . '/' . $cssFilename;
3568 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3572 // ##### 表示モードによるCSS読み込み #####
3573 // ウィジェット付きポジション画面は管理画面のアクセスではない
3574 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3576 $cssURL = $scriptsUrl . self::M3_ADMIN_WIDGET_CSS_FILE;
3577 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3580 // ##### ウィジェットごとのCSS読み込み #####
3582 $this->db->getWidgetsIdWithCss($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3583 for ($i = 0; $i < count($rows); $i++){
3584 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS;
3585 // ディレクトリがあるときはディレクトリ内読み込み
3586 if (is_dir($searchPath)){
3587 $dir = dir($searchPath);
3588 while (($file = $dir->read()) !== false){
3589 $filePath = $searchPath . '/' . $file;
3590 if ($file != '.' && $file != '..' && is_file($filePath)
3591 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3594 $cssURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS . '/' . $file;
3595 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3601 // ##### 外部出力用CSS読み込み #####
3602 // ウィジェットからの追加のCSS読み込み
3603 $count = count($this->headCssFiles);
3604 for ($i = 0; $i < $count; $i++){
3605 $cssUrl = $this->headCssFiles[$i];
3606 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3607 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3610 // 外部出力用CSSデータがある場合はURLを追加
3611 if (!empty($this->exportCss)){
3612 $cssUrl = $this->createCssCmdUrl($isSslPage, date('YmdHis'));
3613 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3614 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3617 // ##### RSS配信情報の読み込み #####
3618 $count = count($this->headRssFiles);
3619 for ($i = 0; $i < $count; $i++){
3620 $rssUrl = $this->headRssFiles[$i]['href'];// リンク先URL
3621 $rssTitle = $this->headRssFiles[$i]['title'];// タイトル
3622 $replaceStr .= '<link rel="alternate" type="application/rss+xml" title="' . $rssTitle . '" href="' . convertUrlToHtmlEntity($rssUrl) . '" />' . M3_NL;
3625 // ##### 共通Javascriptの読み込み #####
3626 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3627 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3628 // 管理画面用の共通スクリプトを読み込む
3629 $count = count($this->defaultAdminScriptFiles);
3630 for ($i = 0; $i < $count; $i++){
3631 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3634 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3635 $scriptURL = $scriptFilename;
3639 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3641 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3644 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3647 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3648 //$scriptURL = $scriptsUrl . '/' . $scriptFilename;
3649 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3650 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3652 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示のときは、ウィジェット操作ライブラリを読み込む
3654 $scriptURL = $scriptsUrl . '/' . self::M3_ADMIN_WIDGET_SCRIPT_FILENAME;
3655 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();// スクリプトをキャッシュ保存しない場合は、パラメータを付加
3656 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3658 } else { // システム運用権限がない場合
3659 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3660 $count = count($this->defaultAdminDirScriptFiles);
3661 for ($i = 0; $i < $count; $i++){
3662 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3664 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3665 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3666 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3667 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3671 // Googleマップライブラリの読み込み
3672 if ($this->useGooglemaps && $this->isContentGooglemaps) $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS)); // コンテンツにGoogleマップが含むかどうか
3674 $count = count($this->defaultScriptFiles);
3675 for ($i = 0; $i < $count; $i++){
3676 $defaultScriptFile = $this->defaultScriptFiles[$i];
3678 // ##### jQueryMobileスクリプトを追加する場合は直前に初期化スクリプトを追加 #####
3679 if ($defaultScriptFile == $this->selectedJQueryMobileFilename){
3680 if (count($this->headPreMobileScript) > 0){
3681 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3682 $replaceStr .= '//<![CDATA[' . M3_NL;
3683 for ($j = 0; $j < count($this->headPreMobileScript); $j++){
3684 $replaceStr .= $this->headPreMobileScript[$j];
3686 $replaceStr .= M3_NL;
3687 $replaceStr .= '//]]>' . M3_NL;
3688 $replaceStr .= '</script>' . M3_NL;
3693 if (strncasecmp($defaultScriptFile, 'http://', 7) == 0 || strncasecmp($defaultScriptFile, 'https://', 8) == 0){
3694 $scriptURL = $defaultScriptFile;
3698 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3700 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3703 $scriptURL = $scriptsUrl . '/' . $defaultScriptFile;
3706 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3707 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3708 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3711 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW){ // ログイン、ログアウト場合
3712 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3713 $count = count($this->defaultAdminDirScriptFiles);
3714 for ($i = 0; $i < $count; $i++){
3715 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3716 if (!in_array($scriptFilename, $this->defaultScriptFiles)){ // 既に追加されていない場合のみ追加
3717 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3718 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3719 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3720 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3725 // ##### ウィジェットごとのJavaScript読み込み #####
3726 // スクリプトがあるウィジェットを取得
3727 $this->db->getWidgetsIdWithScript($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3728 for ($i = 0; $i < count($rows); $i++){
3729 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS;
3731 // ディレクトリがあるときはディレクトリ内読み込み
3732 if (is_dir($searchPath)){
3733 $dir = dir($searchPath);
3734 while (($file = $dir->read()) !== false){
3735 $filePath = $searchPath . '/' . $file;
3736 if ($file != '.' && $file != '..' && is_file($filePath)
3737 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3740 $scriptURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
3741 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3742 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3743 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3749 // ウィジェットからの追加のCSS読み込み
3750 $count = count($this->headScriptFiles);
3751 for ($i = 0; $i < $count; $i++){
3752 $scriptUrl = $this->headScriptFiles[$i];
3753 if ($isSslPage) $scriptUrl = str_replace('http://', 'https://', $scriptUrl); // SSL化が必要なときは変換
3755 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3756 if (!$this->hasScriptCache) $scriptUrl .= $this->getCacheParam();
3757 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptUrl) . '"></script>' . M3_NL;
3761 $openType = $this->gSystem->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE);// ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
3763 // ##### ページへJavascriptの埋め込む #####
3764 // JavaScriptグローバル変数の設定
3765 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
3766 //$replaceStr .= '<!--' . M3_NL;
3767 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3768 $replaceStr .= '//<![CDATA[' . M3_NL;
3769 $replaceStr .= '// Magic3 Global values' . M3_NL;
3770 $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3772 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()){ // 管理画面へのアクセス、システム運用権限があり
3773 $pageId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID); // ページID
3774 $pageSubId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);// ページサブID
3777 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
3778 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
3781 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
3782 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
3784 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3787 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
3788 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
3789 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
3791 // Googleマップライブラリの読み込み
3792 if ($this->useGooglemaps){
3793 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
3795 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
3798 // ウィジェット詳細設定画面専用のJavaScriptグローバル変数
3799 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){
3800 // ##### CKEditor用の設定 #####
3801 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3803 // CKEditor用のCSSファイル
3804 if (!empty($this->ckeditorCssFiles)){
3805 // 編集エリア用のCSSファイルを追加
3806 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3808 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
3809 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3811 // CKEditor用(レイアウト)のCSSファイル
3812 $cssFiles = array();
3813 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_CSS; // BootstrapのCSSを追加
3814 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3815 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
3816 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3818 // CKEditor用のテンプレートタイプ
3819 if (isset($this->ckeditorTemplateType)){
3820 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
3822 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3824 $positionData = $this->getRestPositionData();
3827 if (count($this->viewPosId) > 0){
3829 for ($i = 0; $i < count($this->viewPosId); $i++){
3830 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
3831 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
3833 $posArrayStr .= ']';
3834 $replaceStr .= 'var M3_POSITIONS = ' . $posArrayStr . ';' . M3_NL;
3837 $replaceStr .= 'var M3_REVISION = ' . $this->pageDefRev . ';' . M3_NL;
3840 $replaceStr .= 'var M3_REST_POSITION_DATA = \'' . $positionData . '\';' . M3_NL;
3841 } else if (!empty($pageId)){
3842 $accessPoint = $this->gEnv->getAllDefaultPageId();
3843 for ($i = 0; $i < count($accessPoint); $i++){
3844 if ($pageId == $accessPoint[$i]){
3845 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $i . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3849 } else { // メインの管理画面の場合
3850 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = 0;' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
3853 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3854 if (!empty($task)){ // 戻りタスクが設定されているときのみ最大化可能
3855 $replaceStr .= 'function gobackPagedef(){' . M3_NL;
3856 $replaceStr .= ' window.location.href = "' . $gEnvManager->getDefaultAdminUrl() . '?pageid=' . $pageId . '&pagesubid=' . $pageSubId . '&task=' . $task . '";' . M3_NL;
3857 $replaceStr .= '}' . M3_NL;
3858 $replaceStr .= '$(function(){' . M3_NL;
3859 $replaceStr .= ' $(document).keyup(function(e){' . M3_NL;
3860 $replaceStr .= ' if (e.which == 36) gobackPagedef();' . M3_NL;
3861 $replaceStr .= ' });' . M3_NL;
3862 $replaceStr .= '});' . M3_NL;
3865 // ##### 管理用テンプレートを使用している場合の処理 #####
3866 // Bootstrap用のスクリプト処理
3867 if ($this->useBootstrap){
3868 $replaceStr .= '$(function(){' . M3_NL;
3869 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
3870 $replaceStr .= '});' . M3_NL;
3873 } else if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
3874 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
3875 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
3878 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
3879 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
3881 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3884 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
3885 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
3886 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
3889 $templateType = $gEnvManager->getCurrentTemplateType();
3890 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
3891 } else if ($this->isEditMode){ // フロント画面編集モード(コンテンツ編集可能ユーザ)
3892 if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
3894 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3897 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
3898 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
3899 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
3901 // Googleマップライブラリの読み込み
3902 if ($this->useGooglemaps){
3903 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
3905 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
3908 // ##### CKEditor用の設定 #####
3910 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
3911 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3913 // CKEditor用のCSSファイル
3914 if (!empty($this->ckeditorCssFiles)){
3915 // 編集エリア用のCSSファイルを追加
3916 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3918 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
3919 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3921 // CKEditor用(レイアウト)のCSSファイル
3922 $cssFiles = array();
3923 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_CSS; // BootstrapのCSSを追加
3924 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3925 $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
3926 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3928 // CKEditor用のテンプレートタイプ
3929 if (isset($this->ckeditorTemplateType)){
3930 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
3933 // Bootstrap用のスクリプト処理
3934 if ($this->useBootstrap){
3935 $replaceStr .= '$(function(){' . M3_NL;
3936 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
3937 $replaceStr .= '});' . M3_NL;
3940 // プレビュー画面用にテンプレートタイプを出力
3941 $templateType = $gEnvManager->getCurrentTemplateType();
3942 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
3944 // ##### ヘルプシステムの組み込み #####
3945 if ($this->useHelp){ // ヘルプ表示のとき
3946 $replaceStr .= '$(function(){' . M3_NL;
3947 $replaceStr .= ' if (jQuery().tooltip) $(\'[rel=m3help]\').tooltip({ placement: \'top\'});' . M3_NL;
3948 $replaceStr .= '});' . M3_NL;
3953 // ##### パネルメニュー(フロント画面と管理画面の切り替え等)の表示 #####
3954 // PC用、携帯用、スマートフォン用画面とウィジェット付きポジションの管理画面時に表示
3955 if (($gEnvManager->isAdminDirAccess() && $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) || // 管理画面(ウィジェット付きポジション表示)のとき
3956 (!$gEnvManager->isAdminDirAccess() && // 一般用画面のとき
3957 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
3958 $cmd != M3_REQUEST_CMD_RSS)){ // RSS配信でない
3959 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
3960 if ($gEnvManager->isSystemManageUser()){ // システム運用権限ありの場合
3962 $menubarTag = ''; // 管理用メニューバー
3963 $adminTag = ''; // 管理画面ボタン
3964 $editTag = ''; // 編集ボタン
3965 $logoutTag = ''; // ログアウトボタン
3967 if ($gEnvManager->isAdminDirAccess()){ // 管理画面(ウィジェット付きポジション表示)の場合
3969 /* $titleStr = '編集終了';
3970 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
3971 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
3972 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
3973 $editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
3976 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
3977 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
3978 //$editTag = '<div class="m3editend"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
3979 //$editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" /></a></div>';
3980 $editTag = '<div class="m3editend m3topright"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
3981 $editTag .= '<i class="glyphicon glyphicon-ok-sign"></i></a></div>';
3982 $menubarTag .= $editTag;
3984 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
3985 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
3986 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").prepend(\'' . $menubarTag . '\');' . M3_NL; // appendでうまく表示できないのでprependで表示
3987 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
3988 } else if ($this->isAccessPointWithAdminMenu){ // 通常画面は、管理メニューを使用するアクセスポイントの場合のみ表示
3990 $titleStr = '管理画面へ遷移';
3991 $linkUrl = $gEnvManager->getDefaultAdminUrl();
3992 $adminTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
3993 $adminTag .= '<img src="' . $rootUrl . self::ADMIN_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
3996 $titleStr = '画面を編集';
3997 $linkUrl = $gEnvManager->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' .M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET;
3998 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_ID . '=' . $gEnvManager->getCurrentPageId();
3999 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
4000 $linkUrl .= '&' . M3_REQUEST_PARAM_BACKUP_URL . '=' . urlencode($gEnvManager->getCurrentRequestUri()); // URL退避用
4001 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4002 $editTag .= '<img src="' . $rootUrl . self::EDIT_PAGE_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4005 $titleStr = 'ログアウト';
4006 // if ($gEnvManager->isAdminDirAccess()){ // 管理画面の場合
4007 // $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4008 // if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4010 $linkUrl = $gEnvManager->getCurrentRequestUri();
4012 $linkUrl = createUrl($linkUrl, M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_LOGOUT);
4013 $logoutTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4014 $logoutTag .= '<img src="' . $rootUrl . self::LOGOUT_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4017 $widgetToolTag .= '<li><div class="m3widgettoolbutton m3-nav m3-navbar-nav" data-toggle="buttons">';
4018 $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>';
4019 $widgetToolTag .= '<input type="checkbox" class="hidden" />';
4020 $widgetToolTag .= '</div></li>';
4022 //$menubarTag .= '<div id="m3slidepanel">';
4023 $menubarTag .= '<div id="m3slidepanel" class="m3panel_top m3-navbar-default" style="top:-60px; visibility: visible;">';
4024 $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>';
4025 // $menubarTag .= '<div tabindex="0" class="m3panel_wrap">';
4026 $menubarTag .= '<div>';
4027 $menubarTag .= '<ul class="m3-nav m3-navbar-nav">';
4028 if ($gEnvManager->isSystemAdmin()){ // 管理画面、編集モードは、管理者権限がある場合のみ有効
4029 $menubarTag .= $adminTag;
4030 $menubarTag .= $editTag;
4032 $menubarTag .= $logoutTag;
4033 $menubarTag .= $widgetToolTag;
4034 $menubarTag .= '</ul>';
4035 $menubarTag .= '</div>';
4036 $menubarTag .= '</div>';
4037 // $menubarTag .= '</div>';
4039 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4040 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4041 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").append(\'' . $menubarTag . '\');' . M3_NL;
4042 //$this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("#m3slidemenubarpanel").m3SlideMenubar();' . M3_NL;
4043 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(".m3panel_top").m3slidepanel({ "position": "top", "type": "push" });' . M3_NL;
4044 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").css("position", "relative");' . M3_NL;
4045 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetHelp($(\'#m3slidepanel\'));' . M3_NL;
4046 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetupWidgetTool(\'m3widgettoolbutton\');' . M3_NL;
4047 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4051 // ##### フロント画面からのウィジェット操作用ツールバー #####
4052 if (!$gEnvManager->isAdminDirAccess() &&
4053 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4054 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
4055 if ($gEnvManager->isSystemManageUser()){ // 一般用画面で管理者権限がある場合のみ有効
4057 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').each(function(){' . M3_NL;
4058 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var attrs = m3_splitAttr($(this).attr(\'m3\'));' . M3_NL;
4059 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var widgetId = attrs[\'widgetid\'];' . M3_NL;
4060 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var serialNo = attrs[\'serial\'];' . M3_NL;
4061 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var configId = attrs[\'configid\'];' . M3_NL;
4062 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var useconfig = attrs[\'useconfig\'];' . M3_NL;
4064 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'\';' . M3_NL;
4065 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (useconfig == 1){' . M3_NL;
4066 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4067 'html += \'<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\\\'\' + widgetId + \'\\\', \' + configId + \', \' + serialNo + \');return false;" rel="m3help" data-container="body" title="ウィジェット設定">' .
4068 '<img src="' . $rootUrl . self::CONFIG_ICON32_FILE . '" alt="ウィジェット設定" width="32" height="32" /></a>\';' . M3_NL;
4069 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4070 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4071 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) .
4072 '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="タイトル・スタイル調整">' .
4073 '<img src="' . $rootUrl . self::ADJUST_ICON32_FILE . '" alt="タイトル・スタイル調整" width="32" height="32" /></a>\';' . M3_NL;
4075 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (html != \'\'){' . M3_NL;
4076 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4077 'html = \'<div class="m3tooltip" style="display:none;">\' + html + \'<a class="m3closebox" href="javascript:void(0);" rel="m3help" data-container="body" title="閉じる">' .
4078 '<img src="' . $rootUrl . self::CLOSE_BOX_ICON32_FILE . '" alt="閉じる" width="11" height="11" /></a></div>\';' . M3_NL;
4080 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).append(html);' . M3_NL;
4081 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4083 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).click(function(){' . M3_NL;
4084 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4085 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (tooltipObj.css(\'display\') == \'none\'){' . M3_NL;
4086 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (_m3ShowWidgetTool){' . M3_NL;
4087 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'tooltipObj.show();' . M3_NL;
4088 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4089 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4090 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.hide();' . M3_NL;
4091 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4092 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4093 // ウィジェットボーダーハイライト、ツールチップ表示
4094 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).hover(function(){' . M3_NL;
4095 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4096 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(this).addClass(\'m3_widget_highlight\');' . M3_NL;
4097 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4098 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var pos = $(this).position();' . M3_NL;
4099 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var width = $(this).outerWidth();' . M3_NL;
4100 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipWidth = tooltipObj.outerWidth(true);' . M3_NL;
4101 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var x = pos.left + width - tooltipWidth;' . M3_NL;
4102 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var y = pos.top;' . M3_NL;
4103 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.css({position: "absolute",top: y + "px", left: x + "px"}).show();' . M3_NL;
4104 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4105 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}, function(){' . M3_NL;
4106 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).removeClass(\'m3_widget_highlight\');' . M3_NL;
4107 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4108 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'tooltipObj.hide();' . M3_NL;
4109 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4111 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3closebox\').click(function(event){' . M3_NL;
4112 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).children(\'.m3tooltip\').hide();' . M3_NL;
4113 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4115 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4116 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var offset = $(this).offset();' . M3_NL;
4117 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).outerWidth();' . M3_NL;
4118 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3edittool\').each(function(){' . M3_NL;
4119 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).offset({left: offset.left});' . M3_NL;
4120 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).width(width);' . M3_NL;
4121 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4122 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4125 $this->initScript .= M3_INDENT_SPACE . 'var widgetWindow = \'<div class="m3_contextmenu" id="m3_widgetmenu" style="visibility:hidden;">\';' . M3_NL;
4126 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<ul>\';' . M3_NL;
4127 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<li id="m3_wconfig"><img src="\' + M3_ROOT_URL + \'/images/system/config.png" /> <span>ウィジェットの設定</span></li>\';' . M3_NL;
4128 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4129 $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;
4131 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</ul>\';' . M3_NL;
4132 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</div>\';' . M3_NL;
4133 $this->initScript .= M3_INDENT_SPACE . '$("body").append(widgetWindow);' . M3_NL;
4134 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').contextMenu(\'m3_widgetmenu\', {' . M3_NL;
4135 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'menuStyle: {' . M3_NL;
4136 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// border : "2px solid green",' . M3_NL;
4137 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'backgroundColor: \'#FFFFFF\',' . M3_NL;
4138 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'width: "150px",' . M3_NL;
4139 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'textAlign: \'left\',' . M3_NL;
4140 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'font: \'12px/1.5 Arial, sans-serif\'' . M3_NL;
4141 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4142 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'itemStyle: {' . M3_NL;
4143 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'padding: \'3px 3px\'' . M3_NL;
4144 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4145 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'bindings: {' . M3_NL;
4146 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wconfig\': function(t){' . M3_NL;
4147 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4148 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4149 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'alert("このウィジェットには設定画面がありません");' . M3_NL;
4150 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'return;' . M3_NL;
4151 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4152 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowConfigWindow(attrs[\'widgetid\'], attrs[\'configid\'], attrs[\'serial\']);' . M3_NL;
4153 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '},' . M3_NL;
4154 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wadjust\': function(t){' . M3_NL;
4155 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4156 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowAdjustWindow(attrs[\'configid\'], attrs[\'serial\'], M3_PAGE_ID, M3_PAGE_SUB_ID);' . M3_NL;
4157 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4158 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4159 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onContextMenu: function(e){' . M3_NL;
4160 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4161 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return true;' . M3_NL;
4162 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4163 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return false;' . M3_NL;
4164 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4165 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4166 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onShowMenu: function(e, menu){' . M3_NL;
4167 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// メニュー項目の変更' . M3_NL;
4168 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var attrs = m3_splitAttr($(e.target).parents(\'dl\').attr(\'m3\'));' . M3_NL;
4169 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4170 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(\'#m3_wconfig\', menu).remove();' . M3_NL;
4171 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4172 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'return menu;' . M3_NL;
4173 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4174 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4177 // ##### フロント画面のデフォルトのJavaスクリプト #####
4178 // if (!$gEnvManager->isAdminDirAccess()){
4179 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (jQuery().tooltip) $(\'[rel=tooltip]\').tooltip();' . M3_NL; // 標準ツールチップ作成
4181 // ポップアップメッセージがある場合は表示
4182 if (!empty($this->popupMsg)){
4183 $replaceStr .= 'alert("' . $this->popupMsg . '");' . M3_NL;
4186 if ($cleanType == 1){
4187 // HTMLのクリーン処理が必要なときはコードを埋め込む
4188 $this->initScript .= ' $(\'.PostHeaderIcons\').remove();' . M3_NL;// 不要なアイコン表示タグの削除
4189 $this->initScript .= ' $(\'.PostMetadataHeader\').each(function(i){' . M3_NL;
4190 $this->initScript .= ' if ($(this).text().trim() == \'\') $(this).remove();' . M3_NL;
4191 $this->initScript .= ' });' . M3_NL;
4195 $replaceStr .= $this->getLastContents();
4198 if (!empty($this->initScript)){
4199 $replaceStr .= '$(function(){' . M3_NL;
4200 $replaceStr .= $this->initScript;
4201 $replaceStr .= '});' . M3_NL;
4204 //$replaceStr .= '// -->' . M3_NL;
4205 //$replaceStr .= '</script>' . M3_NL;
4206 $replaceStr .= '//]]>' . M3_NL;
4207 $replaceStr .= '</script>' . M3_NL;
4209 // HEADタグに埋め込むCSS,JavaScript,任意文字列
4210 if (count($this->headCss) > 0){
4211 // CSSの場合は全体をstyleタグで囲む
4212 $replaceStr .= '<style type="text/css">' . M3_NL;
4213 $replaceStr .= '<!--' . M3_NL;
4214 for ($i = 0; $i < count($this->headCss); $i++){
4215 $replaceStr .= $this->headCss[$i];
4217 $replaceStr .= M3_NL . '//-->' . M3_NL;
4218 $replaceStr .= '</style>' . M3_NL;
4220 if (count($this->headScript) > 0){
4221 // JavaScriptの場合は全体をscriptタグで囲む
4222 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
4223 //$replaceStr .= '<!--' . M3_NL;
4224 $replaceStr .= '<script type="text/javascript">' . M3_NL;
4225 $replaceStr .= '//<![CDATA[' . M3_NL;
4226 for ($i = 0; $i < count($this->headScript); $i++){
4227 $replaceStr .= $this->headScript[$i];
4229 //$replaceStr .= M3_NL . '//-->' . M3_NL;
4230 //$replaceStr .= '</script>' . M3_NL;
4231 $replaceStr .= M3_NL;
4232 $replaceStr .= '//]]>' . M3_NL;
4233 $replaceStr .= '</script>' . M3_NL;
4235 if (count($this->headString) > 0){
4237 for ($i = 0; $i < count($this->headString); $i++){
4238 $replaceStr .= $this->headString[$i];
4247 * @param string $position HTMLテンプレート上の書き出し位置
4248 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
4249 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
4250 * @param array $attr その他属性
4251 * @return string 出力コンテンツ
4253 function getContents($position, $style = '', $templateVer = 0, $attr = array())
4255 static $render; // Joomla!v1.5テンプレート用
4256 global $gRequestManager;
4257 global $gEnvManager;
4260 $filename = $gEnvManager->getCurrentPageId();
4261 $subId = $gEnvManager->getCurrentPageSubId();
4262 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
4264 // ポジション名表示モードに応じて出力を作成
4265 $contents = ''; // 出力コンテンツ
4266 switch ($this->showPositionMode){
4268 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4269 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4270 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
4271 if ($ret){ // 1行以上データが取得できたとき
4272 $this->pageDefRows = $rows; // ページ定義レコード
4273 $this->pageDefPosition = $position;
4275 $this->pageDefRows = array();
4276 $this->pageDefPosition = '';
4280 $count = count($this->pageDefRows);
4282 if ($templateVer == 0){ // echo出力のとき(Joomla!v1.0テンプレートの場合)
4283 ob_start();// バッファ作成
4285 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4286 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
4287 for ($i = 0; $i < $count; $i++){
4288 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4289 $widgetId = $this->pageDefRows[$i]['wd_id'];
4291 // ### 遅延実行ウィジェットはキャッシュしない ###
4292 // キャッシュデータがあるときはキャッシュデータを使用
4293 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4295 if (empty($cacheData)){ // キャッシュデータがないとき
4297 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, $widgetHeaderType);
4299 $widgetContent = ob_get_contents();
4302 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4304 // ウィジェットの内枠(コンテンツ外枠)を設定
4305 $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4308 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4309 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4312 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4313 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4314 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4315 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4316 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4317 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4318 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4319 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4320 $hasAdmin = '0'; // 管理画面があるかどうか
4321 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4322 $shared = '0'; // 共通属性があるかどうか
4323 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4324 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4325 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4326 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget" rel="#m3editwidget" ' . $m3Option . '>' . $widgetContent . '</div>';
4328 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4329 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4331 } else { // キャッシュデータがあるとき
4332 $widgetContent = $cacheData;
4335 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4336 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4337 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4339 $contents .= $widgetContent;
4341 // ##### 外部出力用のCSSがある場合は追加 #####
4342 $exportCss = $this->pageDefRows[$i]['pd_css'];
4343 if (!empty($exportCss)){
4345 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4346 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4347 $this->addExportCss($exportCss);
4350 ob_end_clean(); // バッファ破棄
4352 if ($i < $count) return '';// 処理中断のときは終了
4353 } else { // Joomla!v1.5テンプレートの場合
4354 // テンプレート側で指定されたメニューの表示属性を設定
4355 $gEnvManager->setMenuAttr($attr);
4359 if (!empty($attr['type'])) $posType = $attr['type'];
4361 for ($i = 0; $i < $count; $i++){
4362 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4363 $widgetId = $this->pageDefRows[$i]['wd_id'];
4365 // ### 遅延実行ウィジェットはキャッシュしない ###
4366 // キャッシュデータがあるときはキャッシュデータを使用
4367 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4369 if (empty($cacheData)){ // キャッシュデータがないとき
4371 $gEnvManager->setCurrentWidgetTitle('');
4373 // Joomla用のパラメータを初期化
4374 $gEnvManager->setCurrentWidgetJoomlaParam(array());
4378 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $titleTag, 0/*タイトル出力なし*/);
4379 $widgetContent = ob_get_contents();
4381 $trimContent = trim($widgetContent);
4382 if (!empty($trimContent)){ // 出力が空でない場合
4383 $isRendered = false; // Joomla!の描画処理を行ったかどうか
4384 if (!empty($this->pageDefRows[$i]['pd_use_render'])){ // Joomla!の描画処理を使用する場合
4385 // Joomla!ウィジェットの出力に埋め込む
4386 if (strcasecmp($style, 'none') != 0){
4388 if (!isset($render)) $render = new JRender();
4390 // デフォルトのウィジェットタイトル取得
4391 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4394 $joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4396 // 遅延ウィジェットのときはタイトルタグを埋め込む
4397 if (!empty($titleTag)) $defaultTitle = $titleTag;
4399 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4400 $title = $this->pageDefRows[$i]['pd_title'];
4401 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4402 if (empty($title)) $title = $defaultTitle;
4404 $title = ''; // タイトルは非表示
4408 $params = array(); // ウィジェットごとの属性
4409 $widgetType = $this->pageDefRows[$i]['wd_type']; // ウィジェットタイプ
4411 // オプションのJoomlaクラス(縦型メニュー(art-vmenu)等)
4412 $joomlaClass = $this->pageDefRows[$i]['wd_joomla_class']; // 「wd_joomla_class」は使っていない?
4413 if (!empty($joomlaClass)) $params['moduleclass_sfx'] = $joomlaClass;
4414 if (isset($joomlaParam['moduleclass_sfx'])) $params['moduleclass_sfx'] = $joomlaParam['moduleclass_sfx'];// ウィジェットでjoomla用パラメータの設定があるとき
4416 if (strcmp($position, 'main') == 0){// メイン部のとき
4417 // ウィジェットの内枠(コンテンツ外枠)を設定
4418 // ウィジェットの内枠はレンダーで設定
4419 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4420 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4421 // } else if (strStartsWith($position, 'user') || // ナビゲーションメニュー位置の場合
4422 } else if (strcasecmp($position, 'user3') == 0 || // ナビゲーションメニュー位置の場合
4423 strcasecmp($position, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
4424 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
4426 $moduleContent = '';
4427 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
4428 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4430 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
4431 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4433 $moduleContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4435 $widgetContent = $moduleContent;
4437 // ウィジェットの内枠(コンテンツ外枠)を設定。メニュー処理後に付加。
4438 // ウィジェットの内枠はレンダーで設定
4439 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4440 } else { // その他の位置のとき
4441 // ウィジェットの内枠(コンテンツ外枠)を設定
4442 // ウィジェットの内枠はレンダーで設定
4443 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4445 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4447 $isRendered = true; // Joomla!の描画処理を行ったかどうか
4450 if (!$isRendered){ // Joomla!の描画処理を行っていない場合
4452 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4454 // ウィジェットの内枠(コンテンツ外枠)を設定
4455 $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4458 if (!$ret) return ''; // 処理中断のときは終了
4461 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4462 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4465 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4466 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4467 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4468 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4469 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4470 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4471 //$editInfo = 'widgetid:' . $this->pageDefRows[$i]['wd_id'];
4472 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4473 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4474 $hasAdmin = '0'; // 管理画面があるかどうか
4475 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4476 $shared = '0'; // 共通属性があるかどうか
4477 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4478 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4479 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4480 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget" rel="#m3editwidget" ' . $m3Option . '>' . $widgetContent . '</div>';
4482 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4483 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4485 } else { // キャッシュデータがあるとき
4486 $widgetContent = $cacheData;
4489 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4490 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4491 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4493 $contents .= $widgetContent;
4495 // ##### 外部出力用のCSSがある場合は追加 #####
4496 $exportCss = $this->pageDefRows[$i]['pd_css'];
4497 if (!empty($exportCss)){
4499 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4500 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4501 $this->addExportCss($exportCss);
4506 if ($position == 'main'){ // メイン部のときは、メッセージを出力
4507 /*if (strlen($this->popupMsg) > 0){
4508 echo "\n<script language=\"javascript\">alert('" . addslashes($this->popupMsg) . "');</script>";
4510 } else if ($position == 'debug'){ // デバッグ文出力
4516 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:3px solid #f00;color:#700;">ポジション名: ';
4517 $contents .= '<b>' . $position . '</b>';
4518 $contents .= '</div>';
4520 case 2: // ポジション表示(ウィジェット付き)
4521 $rev = '555'; // データのリビジョン番号
4522 // ポジションのHTMLタグIDを作成
4525 for ($i = 0; $i < 100; $i++){
4526 $posId = $position . '_' . $num;
4527 $viewPosId = self::POSITION_TAG_HEAD . $posId;
4528 if (!in_array($viewPosId, $this->viewPosId)) break;
4531 $this->viewPosId[] = $viewPosId;// IDを保存
4533 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4534 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4535 $ret = $this->db->getPageDef($filename, $subId, $position, $rows);
4536 if ($ret){ // 1行以上データが取得できたとき
4537 $this->pageDefRows = $rows; // ページ定義レコード
4538 $this->pageDefPosition = $position;
4540 $this->pageDefRows = array();
4541 $this->pageDefPosition = '';
4545 // ナビゲーション型のポジションの場合はアイコン付加
4546 //if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4547 if ($style == self::WIDGET_STYLE_NAVMENU) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4548 $contents .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
4549 $contents .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
4552 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
4553 //$contents .= $this->getWidgetList($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $widgetTagHead, $this->pageDefRows);
4554 $contents .= $this->getWidgetList($filename, $subId, $widgetTagHead, $this->pageDefRows);
4556 $contents .= '</div>' . M3_NL;
4559 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">param error</div>';
4563 $this->viewPositions[] = $position;
4568 * その他のポジションブロックデータを取得
4570 * @param string ポジション作成用タグ
4572 function getRestPositionData()
4574 global $gEnvManager;
4576 $restPositionData = '';
4578 $pageId = $gEnvManager->getCurrentPageId();
4579 $subId = $gEnvManager->getCurrentPageSubId();
4581 $restPositions = array_values(array_diff($this->defPositions/*全ポジション*/, $this->viewPositions/*表示済みポジション*/));
4582 $positionCount = count($restPositions);
4583 for ($i = 0; $i < $positionCount; $i++){
4584 $posHead = ''; // アイコン付加用
4585 $position = $restPositions[$i];
4586 $posId = $position . '_0';
4587 $viewPosId = self::POSITION_TAG_HEAD . $posId;
4590 $ret = $this->db->getPageDef($pageId, $subId, $position, $rows);
4592 //$pageDefRows = $rows; // ページ定義レコード
4594 $restPositionData .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">'; // リビジョン番号を付加
4595 $restPositionData .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>';
4598 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
4599 $contents = $this->getWidgetList($pageId, $subId, $widgetTagHead, $rows);
4600 $contents = str_replace(M3_NL, '', $contents);
4601 $contents = str_replace('\'', '\\\'', $contents);
4602 $restPositionData .= $contents;
4603 $restPositionData .= '</div>';
4605 $this->viewPosId[] = $viewPosId;// IDを保存
4608 return $restPositionData;
4611 * ウィジェット共通のコンテンツ追加処理
4613 * @param string $src ウィジェット出力
4614 * @param array $pageDefParam 画面定義レコード
4615 * @return string コンテンツを付加したウィジェット出力
4617 function _addOptionContent($src, $pageDefParam)
4620 $dest = $pageDefParam['pd_top_content'] . $src . $pageDefParam['pd_bottom_content'];
4623 if ($pageDefParam['pd_show_readmore']){
4624 $title = $pageDefParam['pd_readmore_title'];
4625 if (empty($title)) $title = self::DEFAULT_READMORE_TITLE;
4626 $dest .= '<div><a href="' . convertUrlToHtmlEntity($pageDefParam['pd_readmore_url']) . '">' . convertToHtmlEntity($title) . '</a></div>';
4631 * BODYタグに付加するスタイルを取得(管理画面用)
4633 * @param string CSS文字列
4635 function getBodyStyle()
4637 // 画面透過モードのときスタイルを追加
4639 if ($this->isTransparentMode) $transCss = ' style="background-color:transparent;"';
4645 * @param string $position HTMLテンプレート上の書き出し位置
4646 * @return int ウィジェットの数
4648 function getWidgetsCount($position)
4650 global $gRequestManager;
4651 global $gEnvManager;
4652 static $widgetCountArray = array();
4654 // 管理画面へのアクセスでログインされていないときは0を返す
4655 if ($gEnvManager->isAdminDirAccess() && !$gEnvManager->isSystemManageUser()){ // 管理画面へのアクセスのときでシステム運用権限がない場合
4660 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
4661 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
4662 return 1; // ウィジェットが設定されていないポジション名を表示するために固定で値を返す
4665 // 単一ポジション以外の設定のときは固定で返す(or等)
4666 $pos = strpos($position, ' ');
4667 if ($pos !== false) return 1;
4669 // 既にウィジェット数が取得されている場合は保存値を返す
4670 $widgetCount = $widgetCountArray[$position];
4671 if (isset($widgetCount)) return $widgetCount;
4674 $filename = $gEnvManager->getCurrentPageId();
4675 $subId = $gEnvManager->getCurrentPageSubId();
4676 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
4678 // 取得しようとするページ定義のポジションが既に取得しているポジションと異なるときはデータを取得
4679 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // 現在取得しているページ定義のポジション
4680 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
4681 if ($ret){ // 1行以上データが取得できたとき
4682 $this->pageDefRows = $rows; // ページ定義レコード
4683 $this->pageDefPosition = $position;
4685 $this->pageDefRows = array();
4686 $this->pageDefPosition = '';
4689 // ### ウィジェット数を取得 ###
4690 // テンプレートのカラム制御を行うためにウィジェット表示条件でウィジェット数を取得
4692 $rowCount = count($this->pageDefRows);
4693 for ($i = 0; $i < $rowCount; $i++){
4694 // $condition = trim($this->pageDefRows[$i]['wd_visible_condition']);
4695 $condition = trim($this->pageDefRows[$i]['pd_visible_condition']);
4696 if (empty($condition)){ // ウィジェット表示条件が設定されていない場合はウィジェットを表示
4698 } else { // ウィジェット表示条件が設定されている場合はパラメータをチェック
4699 $conds = explode(';', $condition);
4700 for ($j = 0; $j < count($conds); $j++){
4701 $pos = strpos($conds[$j], '=');
4702 if ($pos !== false){ // URLクエリーパラメータ条件がマッチした場合はウィジェットを表示
4703 list($key, $value) = explode('=', trim($conds[$j]));
4705 $value = trim($value);
4706 if (!empty($key) && !empty($value)){
4707 $requestValue = $gRequestManager->trimValueOf($key);
4708 if ($value == $requestValue) $widgetCount++;
4714 // $widgetCount = count($this->pageDefRows);
4715 $widgetCountArray[$position] = $widgetCount;
4716 return $widgetCount;
4719 * ウィジェットのページ定義シリアル番号からウィジェットCSS IDを取得
4721 * @param int $defSerial ページ定義シリアル番号
4722 * @param string $pageId ページID
4723 * @param string $subpage ページサブID
4724 * @param string $position 表示位置ID
4725 * @return string CSSエレメントID
4727 function getWidgetCssId($defSerial, $pageId, $pageSubId, $position)
4730 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
4732 $rowCount = count($rows);
4733 for ($i = 0; $i < $rowCount; $i++){
4735 if ($row['pd_serial'] == $defSerial){
4736 $elementId = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4746 * 画面作成機能でウィジェット情報を取得するためのAjaxインターフェイス
4748 * @param RequestManager $request HTTPリクエスト処理クラス
4750 function getWidgetInfoByAjax($request)
4752 global $gEnvManager;
4753 global $gDesignManager;
4754 global $gCacheManager;
4756 // アクセスするページIDからPC用、携帯用、スマートフォン用かを判断
4757 $widgetDeviceType = 0; // 端末タイプをPC用に初期化
4758 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
4759 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
4760 $mobilePageIdPrefix = M3_DIR_NAME_MOBILE . '_';
4761 $smartphonePageIdPrefix = M3_DIR_NAME_SMARTPHONE . '_';
4762 if (strncmp($pageId, $mobilePageIdPrefix, strlen($mobilePageIdPrefix)) == 0){
4763 $widgetDeviceType = 1; // 携帯用
4764 } else if (strncmp($pageId, $smartphonePageIdPrefix, strlen($smartphonePageIdPrefix)) == 0){
4765 $widgetDeviceType = 2; // スマートフォン用
4768 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
4769 if ($task == 'list'){
4771 $ret = $this->db->getAvailableWidgetList($widgetDeviceType, $rows);
4773 $currentCategoryId = '_none'; // 現在のウィジェットカテゴリー初期化
4774 for ($i = 0; $i < count($rows); $i++){
4775 $widgetId = $rows[$i]['wd_id'];
4776 $desc = $rows[$i]['wd_description'];
4777 $widgetTag = self::WIDGET_TYPE_TAG_HEAD . $widgetId;
4778 $categoryId = $rows[$i]['wd_category_id'];
4781 if ($categoryId != $currentCategoryId){
4783 echo '</dd>' . M3_NL;
4784 echo '</dl>' . M3_NL;
4786 echo '<dl class="m3accordion">' . M3_NL;
4787 echo '<dt>' . $rows[$i]['wt_name'] . '</dt>' . M3_NL;
4788 echo '<dd>' . M3_NL;
4791 $currentCategoryId = $categoryId;
4794 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
4795 if ($gEnvManager->getUseSslAdmin()){
4796 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
4797 $image = $gEnvManager->getSslUrl($image);
4799 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
4800 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
4801 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
4806 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
4807 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
4811 if (!empty($rows[$i]['wd_template_type'])){ // 対応テンプレートタイプ
4812 $templateTypeArray = explode(',', $rows[$i]['wd_template_type']);
4813 if (in_array('bootstrap', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_BOOTSTRAP; // Bootstrap型テンプレート対応
4816 echo '<dl class="m3_widgetlist_item" id="' . $widgetTag . '">' . M3_NL;
4817 echo '<dt>' . $widgetMark . $rows[$i]['wd_name'] . '</dt>' . M3_NL; // ウィジェット名
4818 echo '<dd><table width="100%"><tr valign="top"><td width="35">' . $imageTag . '</td><td>' . $desc . '</td></tr></table>';
4819 echo $functionMark . '</dd>' . M3_NL;
4820 echo '</dl>' . M3_NL;
4823 if ($i == count($rows) - 1){
4824 echo '</dd>' . M3_NL;
4825 echo '</dl>' . M3_NL;
4829 } else if ($task == 'wget' || $task == 'wdelete' || $task == 'wtoggle' || $task == 'wadd' || $task == 'wmove'){ // ウィジェット再取得、ウィジェット削除,ウィジェット共通属性変更、ウィジェット追加、ウィジェット移動のとき
4830 $rev = $request->trimValueOf('rev'); // リビジョン
4831 $serial = $request->trimValueOf('serial');
4832 $position = $request->trimValueOf('pos');
4833 $widgetsStr = $request->trimValueOf('widgets');
4834 if (empty($widgetsStr)){
4837 $widgets = explode(',', $widgetsStr);
4839 $shared = $request->trimValueOf('shared');
4840 $updatepos = explode(',', $request->trimValueOf('updatepos'));
4841 $index = $request->trimValueOf('index');
4844 if ($task == 'wmove'){
4845 $positions = explode(',', $position);
4846 if (count($positions) >= 2){
4847 $position = $positions[0];
4848 $position2 = $positions[1];
4850 $position = $positions[0];
4854 // ##### エラーチェック #####
4857 $rev = '111'; // データのリビジョン番号
4860 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows); // 0レコードでも正常とする
4862 // 変更前のウィジェットのシリアル番号をチェック
4863 if (count($widgets) == count($rows)){
4864 if (!($task == 'wmove' && empty($position2))){ // 同一ブロック内の移動の場合はチェックなし
4865 for ($i = 0; $i < count($rows); $i++){
4866 if ($widgets[$i] != $rows[$i]['pd_serial']){// シリアル番号
4877 if (!$isErr){ // エラーなしのとき
4878 if ($task == 'wdelete'){
4879 $ret = $this->db->deleteWidget($serial);
4880 } else if ($task == 'wtoggle'){
4882 if (empty($shared)) $newShared = 1;
4883 $ret = $this->db->toggleSharedWidget($pageId, $pageSubId, $serial, $newShared);
4884 } else if ($task == 'wadd'){ // ウィジェットの追加
4885 $widget = $request->trimValueOf('widget');
4888 if (empty($widget)) $isErr = true;
4891 if (!$isErr) $this->db->addWidget($pageId, $pageSubId, $position, $widget, $index);
4892 } else if ($task == 'wmove'){
4894 if (!$isErr) $this->db->moveWidget($pageId, $pageSubId, $position, $serial, $index);
4898 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows);// 0レコードでも正常とする
4900 // 移動のときは、移動元と移動先の再表示データを取得
4901 if ($task == 'wmove' && !empty($position2)){
4902 $ret = $this->db->getPageDef($pageId, $pageSubId, $position2, $rows2);// 0レコードでも正常とする
4907 echo '<div>' . M3_NL;
4908 for ($i = 0; $i < count($updatepos); $i++){
4910 $widgetTagHead = str_replace(self::POSITION_TAG_HEAD, self::WIDGET_TAG_HEAD, $updatepos[$i]);
4913 $posName = str_replace(self::POSITION_TAG_HEAD, '', substr($updatepos[$i], 0, strlen($updatepos[$i]) - strlen(strrchr($updatepos[$i], "_"))));
4914 if ($task == 'wmove' && $posName == $position2){
4917 if (strcasecmp($position2, 'user3') == 0 || strcasecmp($position2, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4918 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position2 . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
4919 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position2 . '</h2>' . M3_NL;
4922 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows2);
4926 if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4927 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
4928 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
4931 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows);
4934 echo '</div>' . M3_NL;
4936 echo '</div>' . M3_NL;
4939 $gCacheManager->clearAllCache();
4943 * 画面作成用ウィジェット一覧データ出力
4945 * @param string $pageId ページID
4946 * @param string $pageSubId ページサブID
4947 * @param string $widgetTagHead HTMLウィジェットID用のヘッダ
4948 * @param array $rows ウィジェット一覧データ
4949 * @return string ウィジェット一覧出力
4951 function getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows)
4953 global $gEnvManager;
4954 global $gDesignManager;
4955 global $gSystemManager;
4957 if ($gEnvManager->getUseSslAdmin()){
4958 $rootUrl = $gEnvManager->getSslRootUrl();
4960 $rootUrl = $gEnvManager->getRootUrl();
4964 $line = $this->getPageInfo($pageId, $pageSubId);
4965 if (!empty($line)) $pageContentType = $line['pn_content_type'];
4967 $contents = ''; // ウィジェット一覧出力コンテンツ
4968 for ($i = 0; $i < count($rows); $i++){
4969 $widgetId = $rows[$i]['wd_id'];
4970 $desc = $rows[$i]['wd_description'];
4971 $widgetIndex = $rows[$i]['pd_index']; // 表示順
4972 $configId = $rows[$i]['pd_config_id']; // 定義ID
4973 $serial = $rows[$i]['pd_serial']; // シリアル番号
4974 $isShared = empty($rows[$i]['pd_sub_id']); // グローバル属性が設定されているかどうか
4975 $widgetTag = $widgetTagHead . '_' . $i; // ウィジェット識別用ユニークタグ
4976 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
4977 if ($gEnvManager->getUseSslAdmin()){
4978 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
4979 $image = $gEnvManager->getSslUrl($image);
4981 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
4982 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
4983 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
4986 if (empty($rows[$i]['pd_config_name'])){
4987 if ($rows[$i]['wd_use_instance_def'] && $configId == 0){ // インスタンス定義が必要で未定義のとき
4988 $configName = '<span style="color:red;">[未設定]</span>';
4993 $configName = '[' . $rows[$i]['pd_config_name'] . ']';
4995 $hasAdmin = '0'; // 管理画面があるかどうか
4996 $configImg = ''; // 設定アイコンの表示
4998 // ウィジェットの配置位置に問題があるかどうかを表示
4999 // メインコンテンツとページ属性が一致するかどうかチェック
5000 $widgetContentType = $rows[$i]['wd_content_type'];
5001 //if (!empty($widgetContentType) && $widgetContentType != $pageContentType &&
5002 if (!empty($widgetContentType) && $widgetContentType != $pageContentType && empty($rows[$i]['wd_content_widget_id']) && // 編集用のウィジェットが別にある場合は除く(2015/3/24))
5003 (in_array($widgetContentType, $this->_getAllContentType()) || in_array($widgetContentType, $this->_getAllFeatureType()))){
5004 //$title = 'ウィジェット配置注意';
5005 $title = 'ページ属性と不一致';
5006 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::NOTICE_ICON_FILE . '" alt="' . $title . '" /></span> ';
5008 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type']) && $isShared){ // メイン型ウィジェットがグローバル属性を持つとき
5009 $title = 'メイン型ウィジェットはグローバル属性を設定できません';
5010 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::ALERT_ICON_FILE . '" alt="' . $title . '" /></span> ';
5012 if ($rows[$i]['wd_has_admin']){
5014 $title = 'ウィジェット設定';
5015 $configImg .= '<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\'' . $widgetId . '\', \'' . $configId . '\', \'' . $serial . '\');return false;" rel="m3help" data-container="body" title="' . $title . '">' .
5016 '<img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" alt="' . $title . '"/></a> ';
5019 $configImg .= '<span rel="m3help" data-container="body" title="表示順">' . $widgetIndex . '</span>';
5021 $shared = '0'; // 共通属性があるかどうか
5022 $sharedClassName = '';
5023 //if (empty($rows[$i]['pd_sub_id'])){
5024 if ($isShared){ // グローバル属性ウィジェットのとき
5026 $sharedClassName = 'm3_widget_shared'; // 共通ウィジェットのクラス
5028 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
5032 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5033 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5036 $dropdownMenuId = $widgetTag . '_dropdown';
5037 $operationMenu = '<div class="m3widgetdropdown">';
5038 // $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#"><i class="glyphicon glyphicon-list-alt"></i> <b class="caret"></b></a>';
5039 $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#" data-horizontal-offset="4"><b class="caret"></b></a>';
5040 $operationMenu .= '<div id="' . $dropdownMenuId . '" class="m3dropdown m3dropdown-tip m3dropdown-relative m3dropdown-anchor-right">';
5041 $operationMenu .= '<ul class="m3dropdown-menu">';
5042 if ($hasAdmin) $operationMenu .= '<li class="m3_wconfig"><a href="#"><img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" /> <span>ウィジェットの設定</span></a></li>';
5043 $operationMenu .= '<li class="m3_wadjust"><a href="#"><img src="' . $rootUrl . self::ADJUST_ICON_FILE . '" /> <span>タイトル・スタイル調整</span></a></li>';
5045 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を解除</span></a></li>';
5047 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を設定</span></a></li>';
5049 $operationMenu .= '<li class="m3_wdelete"><a href="#"><img src="' . $rootUrl . self::DELETE_ICON_FILE . '" /> <span>このウィジェットを削除</span></a></li>';
5050 $operationMenu .= '</ul>';
5051 $operationMenu .= '</div>';
5052 $operationMenu .= '</div>';
5054 $contents .= '<dl class="m3_widget m3_widget_sortable" id="' . $widgetTag . '" ' . $m3Option . ' >' . M3_NL;
5055 $contents .= '<dt class="m3_widget_with_check_box ' . $sharedClassName . '"><div class="m3widgettitle">' . $widgetMark . $rows[$i]['wd_name'] . '</div>' . $operationMenu . '</dt>' . M3_NL;
5056 $contents .= '<dd><table width="100%"><tr valign="top"><td width="35">' . $imageTag . '</td><td>' . $desc . '</td></tr></table>' . M3_NL;
5057 $contents .= '<table width="100%"><tr><td>' . $configName . '</td><td align="right">' . $configImg . '</td></tr></table></dd>' . M3_NL;
5058 $contents .= '</dl>' . M3_NL;
5065 * @param string $position HTMLテンプレート上の書き出し位置
5066 * @param int $index 行番号
5067 * @param array $fetchedRow fetch取得した行
5068 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
5069 * @param string $titleTag タイトル埋め込み用タグ(遅延ウィジェットの場合のみ作成)
5070 * @param int $widgetHeaderType ウィジェットタイトルを出力方法(0=出力なし、1=Joomla!v1.0PC用出力、2=Joomla!v1.0携帯用出力)
5071 * @return bool 処理を継続するかどうか(true=続行、false=中断)
5073 function pageDefLoop($position, $index, $fetchedRow, $style, &$titleTag, $widgetHeaderType = 0)
5075 global $gEnvManager;
5076 global $gErrorManager;
5077 global $gDesignManager;
5079 // ページ作成中断またはウィジェット処理中断のときは終了
5080 if ($this->isAbort || $this->isWidgetAbort) return false;
5082 // ウィジェット実行停止中のときは空で返す
5083 // 管理者、運営者どのレベルで制限をかける?
5084 if (!$fetchedRow['wd_active']) return true;
5086 // グローバル属性ありの場合は現在のページが例外ページにないかチェック
5087 if (empty($fetchedRow['pd_sub_id'])){
5088 $exceptPageStr = $fetchedRow['pd_except_sub_id'];
5089 if (!empty($exceptPageStr)){
5090 $exceptPageArray = explode(',', $exceptPageStr);
5091 if (in_array($gEnvManager->getCurrentPageSubId(), $exceptPageArray)) return true; // 例外ページの場合は出力しない
5095 // ウィジェット表示タイプによる表示制御。システム管理者以上の場合は常時表示。
5096 if (!$gEnvManager->isSystemAdmin()){
5097 if (!empty($fetchedRow['pd_view_control_type'])){
5098 switch ($fetchedRow['pd_view_control_type']){
5099 case 1: // ログイン時のみ表示
5100 if (!$gEnvManager->isCurrentUserLogined()) return true; // ログインしていなければ終了
5102 case 2: // 非ログイン時のみ表示
5103 if ($gEnvManager->isCurrentUserLogined()) return true; // ログインしていれば終了
5109 if (!empty($fetchedRow['pd_view_page_state'])){
5110 switch ($fetchedRow['pd_view_page_state']){
5112 if (!$this->isPageTopUrl) return true; // ページトップ(サブページ内のトップ位置)でなければ終了
5124 $widgetId = $fetchedRow['wd_id'];
5125 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5128 $configId = $fetchedRow['pd_config_id']; // ウィジェット定義ID
5129 if ($configId == 0) $configId = '';
5130 $prefix = $fetchedRow['wd_suffix']; // サフィックス文字列
5131 $title = $fetchedRow['wd_name']; // デフォルトのウィジェットタイトル
5132 if (empty($title)) $title = $fetchedRow['wd_id'];
5133 $serial = $fetchedRow['pd_serial']; // シリアル番号
5134 $cssStyle = $fetchedRow['pd_style']; // CSS
5135 $lateLaunchIndex = $fetchedRow['wd_launch_index']; // 遅延実行インデックス
5137 if (empty($fetchedRow['pd_sub_id'])) $shared = true;// 共通属性あり
5138 if ($this->nonSharedWidgetCount == -1) $this->nonSharedWidgetCount = 0; // 初期化されていない場合は初期化
5139 if (!$shared) $this->nonSharedWidgetCount++; // 非共通ウィジェットの数を更新
5141 // ウィジェットが遅延実行に指定されている場合は、ウィジェットのタグのみ埋め込む
5142 if ($lateLaunchIndex > 0){ // 遅延実行のとき
5144 if (!isset($this->lateLaunchWidgetList[$widgetId])){
5145 $this->lateLaunchWidgetList[$widgetId] = (int)$lateLaunchIndex;
5148 $maxNo = 0; // 最大シリアル番号
5149 $count = count($this->latelaunchWidgetParam);
5150 for ($i = 0; $i < $count; $i++){
5151 list($wId, $maxNo, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5, $tmp6, $tmp7, $tmp8, $tmp9, $tmp10, $tmp11) = $this->latelaunchWidgetParam[$i];
5152 if ($wId == $widgetId) $maxNo = $maxNo + 1;
5154 // Joomla!1.0テンプレートの場合はタイトルを修正
5155 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5156 if (!empty($fetchedRow['pd_title'])) $title = $fetchedRow['pd_title'];
5158 $this->latelaunchWidgetParam[] = array($widgetId, $maxNo, $configId, $prefix, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $fetchedRow);
5161 echo self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
5164 $titleTag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
5167 if (!file_exists($widgetIndexFile)) {
5168 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5171 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
5172 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
5173 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
5174 $this->lastHeadTitle = ''; // ヘッダ部titleにセットした文字列
5175 $this->lastHeadDescription = ''; // ヘッダ部descriptionにセットした文字列
5176 $this->lastHeadKeywords = ''; // ヘッダ部keywordsにセットした文字列
5179 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
5180 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
5182 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
5183 $joomlaTitleVisble = false;
5184 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5185 if ($fetchedRow['pd_title_visible']){
5186 if ($widgetHeaderType == 1){ // PC用出力のとき
5187 $joomlaTitle = $fetchedRow['pd_title'];
5188 if (empty($joomlaTitle)) $joomlaTitle = $title;
5189 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
5190 echo '<tr><th>' . $joomlaTitle . '</th></tr>' . M3_NL;
5191 echo '<tr><td>' . M3_NL;
5192 $joomlaTitleVisble = true;
5193 } else if ($widgetHeaderType == 2){ // 携帯用出力のとき
5194 $joomlaTitle = $fetchedRow['pd_title'];
5195 if (empty($joomlaTitle)) $joomlaTitle = $title;
5196 echo '<div>' . $joomlaTitle . '</div>' . M3_NL;
5197 $joomlaTitleVisble = true;
5202 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
5203 // ウィジェット親のCSS定義があるときは、タグを追加
5204 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
5207 echo $gDesignManager->getAdditionalWidgetOutput(true);
5210 $gEnvManager->setCurrentWidgetId($widgetId);
5213 $gEnvManager->setCurrentWidgetConfigId($configId);
5216 $gEnvManager->setCurrentPageDefSerial($fetchedRow['pd_serial']);
5219 $gEnvManager->setCurrentPageDefRec($fetchedRow);
5222 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5225 $gEnvManager->setCurrentWidgetTitle($title);
5228 $gEnvManager->setCurrentWidgetStyle($style);
5230 // ウィジェットのグローバル属性状況を設定
5231 $gEnvManager->setIsCurrentWidgetShared($shared);
5234 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5237 //require_once($widgetIndexFile);
5238 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5239 $msg = 'widget-start(' . $widgetId . ')';
5240 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5241 require($widgetIndexFile);
5242 $msg = 'widget-end(' . $widgetId . ')';
5243 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5246 $gEnvManager->setCurrentWidgetId('');
5249 $gEnvManager->setCurrentWidgetConfigId('');
5252 $gEnvManager->setCurrentPageDefSerial(0);
5255 $gEnvManager->setCurrentPageDefRec();
5258 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
5261 $gEnvManager->setCurrentWidgetStyle('');
5263 // ウィジェットのグローバル属性状況を解除
5264 $gEnvManager->setIsCurrentWidgetShared(false);
5267 echo $gDesignManager->getAdditionalWidgetOutput(false);
5268 // echo "<!-- ".time()." -->";
5270 // ウィジェット親のCSS定義があるときは、タグを追加
5271 if (!empty($cssStyle)) echo '</div>' . M3_NL;
5273 //echo '</div>' . M3_NL;
5275 // Joomla!1.0テンプレートのときはタイトルを出力
5276 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用出力のとき
5277 echo '</td></tr>' . M3_NL;
5278 echo '</table>' . M3_NL;
5282 return true; // 処理継続
5285 * 定義IDを指定してウィジェットの出力を取得
5287 * @param string $widgetId ウィジェットID
5288 * @param int $configId ウィジェット定義ID
5289 * @return string ウィジェットの出力
5291 function getWidgetOutput($widgetId, $configId = 0)
5293 global $gEnvManager;
5294 global $gErrorManager;
5296 // ウィジェットのアクセス権をチェック
5297 if (!$this->db->canAccessWidget($widgetId)) return '';
5300 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
5303 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
5305 // 必要なJavascriptライブラリを追加
5306 $scritLib = trim($row['wd_add_script_lib']);
5307 if (!empty($scritLib)) $this->addScript('', $scritLib);
5313 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5316 $saveWidgetId = $gEnvManager->getCurrentWidgetId();
5317 $gEnvManager->setCurrentWidgetId($widgetId);
5320 $saveConfigId = $gEnvManager->getCurrentWidgetConfigId();
5321 $gEnvManager->setCurrentWidgetConfigId($configId);
5324 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
5327 //$gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5330 //$gEnvManager->setCurrentWidgetTitle($title);
5332 // ウィジェットのグローバル属性状況を設定
5333 //$gEnvManager->setIsCurrentWidgetShared($shared);
5336 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5339 //require_once($widgetIndexFile);
5340 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5341 $msg = 'widget-start(' . $widgetId . ')';
5342 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5343 if (file_exists($widgetIndexFile)){
5344 require($widgetIndexFile);
5346 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5348 $msg = 'widget-end(' . $widgetId . ')';
5349 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5352 $gEnvManager->setCurrentWidgetId($saveWidgetId);
5355 $gEnvManager->setCurrentWidgetConfigId($saveConfigId);
5358 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
5361 //$gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
5363 // ウィジェットのグローバル属性状況を解除
5364 //$gEnvManager->setIsCurrentWidgetShared(false);
5366 // 現在のバッファ内容を取得し、バッファを破棄
5367 $output = ob_get_contents();
5375 * @param int $cmdNo 実行コマンド(0=初期化、1=更新、2=計算、10=コンテンツ取得)
5376 * @param string $id ウィジェットID+インナーウィジェットID
5377 * @param string $configId インナーウィジェット定義ID
5378 * @param object $paramObj インナーウィジェットに渡すパラメータオブジェクト
5379 * @param object $optionParamObj インナーウィジェットに渡すパラメータオブジェクト(オプション)
5380 * @param object $resultObj インナーウィジェットから返る結果オブジェクト
5381 * @param string $content 出力内容
5382 * @param bool $isAdmin 管理者機能(adminディレクトリ以下)かどうか
5383 * @return bool true=成功、false=失敗
5385 function commandIWidget($cmdNo, $id, $configId, &$paramObj, &$optionParamObj, &$resultObj, &$content, $isAdmin = false)
5387 global $gEnvManager;
5389 // ウィジェットIDとインナーウィジェットIDを取り出す
5390 list($widgetId, $iWidgetId) = explode(M3_WIDGET_ID_SEPARATOR, $id);
5392 // インナーウィジェットに渡すパラメータを設定
5395 $cmd = self::IWIDTET_CMD_INIT; // 初期化
5396 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5399 $cmd = self::IWIDTET_CMD_UPDATE; // 更新
5400 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
5403 $cmd = self::IWIDTET_CMD_CALC; // 計算
5404 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5407 $cmd = self::IWIDTET_CMD_CONTENT; // コンテンツ取得
5408 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
5412 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5416 // インナーウィジェットのエラー出力は呼び出しウィジェット側で受けるため、出力を抑止する
5417 ob_start();// バッファ作成
5420 if (empty($widgetId)){ // ウィジェットIDが指定されていないときは共通ディレクトリ
5421 //$gEnvManager->getIWidgetsPath() . '/' . $iWidgetId . '/' . $containerClass . '.php';
5424 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/' . M3_DIR_NAME_ADMIN . '/index.php';
5426 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/index.php';
5430 // 作業中のインナーウィジェットIDを設定
5431 $gEnvManager->setCurrentIWidgetId($id); // インナーウィジェットを設定
5433 // インナーウィジェット定義IDを設定
5434 $gEnvManager->setCurrentIWidgetConfigId($configId);
5437 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5438 if (file_exists($widgetIndexFile)){
5439 require($widgetIndexFile);
5441 echo 'file not found error: ' . $widgetIndexFile;
5445 $gEnvManager->setCurrentIWidgetId('');
5447 // インナーウィジェット定義IDを解除
5448 $gEnvManager->setCurrentIWidgetConfigId('');
5450 // 現在のバッファ内容を取得し、バッファを破棄
5451 $content = ob_get_contents();
5455 if ($this->gInstance->getCmdParamManager()->getParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $obj, $option)){
5457 $optionParamObj = $option;
5461 if ($this->gInstance->getCmdParamManager()->getResult($id . M3_WIDGET_ID_SEPARATOR . $configId, $resObj)) $resultObj = $resObj;
5465 * コールバックメソッドを実行し、出力を返す
5467 * @param array $callback 実行するコールバック
5468 * @return string 出力結果
5470 function getOutputByCallbackMethod($callback)
5472 ob_start();// バッファ作成
5475 if (is_callable($callback)) call_user_func($callback);
5477 // 現在のバッファ内容を取得し、バッファを破棄
5478 $content = ob_get_contents();
5483 * ページ作成処理中断を行った場合のレスポンスヘッダ設定
5485 * @param int $responseCode レスポンスコード
5488 function setResponse($responseCode)
5490 switch ($responseCode){
5491 case 403: // アクセス禁止のとき
5492 header('HTTP/1.1 403 Forbidden');
5493 header('Status: 403 Forbidden');
5495 case 404: // 存在しないページのとき
5496 header("HTTP/1.1 404 Not Found");
5497 header("Status: 404 Not Found");
5499 case 500: // サーバ内部エラー
5500 header('HTTP/1.1 500 Internal Server Error');
5501 header('Status: 500 Internal Server Error');
5503 case 503: // サイト非公開(システムメンテナンス)
5504 header('HTTP/1.1 503 Service Temporarily Unavailable');
5505 header('Status: 503 Service Temporarily Unavailable');
5512 * @param string $filePath ダウンロードするファイルのファイルパス
5513 * @param string $downloadFilename ダウンロード時のファイル名
5514 * @param bool $deleteFile 実行後ファイルを削除するかどうか(成功失敗に関係なく)
5515 * @return bool true=成功、false=失敗
5517 function downloadFile($filePath, $downloadFilename, $deleteFile=false)
5520 if (!file_exists($filePath)) return false;
5523 $fileSize = filesize($filePath);
5525 // バッファ内容が残っているときは破棄
5526 if (ob_get_level() > 0) ob_end_clean();
5528 header('Cache-Control: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
5529 header('Pragma: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
5530 header('Content-Disposition: attachment; filename=' . $downloadFilename);
5531 header('Content-Length: ' . $fileSize);
5532 header('Content-Type: application/octet-stream; name=' . $downloadFilename);
5533 $fp = fopen($filePath, "r");
5534 echo fread($fp, $fileSize);
5540 if ($deleteFile) unlink($filePath);
5546 * @param string $url 遷移先URL。未指定の場合は現在のスクリプト。URLでないときは、現在のスクリプトに付加。
5547 * @param bool $noMessage 画面を遷移させたとき、ドコモ携帯端末でダイアログ(サイトが移動しました(301))が出ないようにするオプション
5548 * @param int $responseCode レスポンスコード
5549 * @param bool $autoSsl リダイレクト先のページの状態に合わせてSSLを制御するかどうか
5552 function redirect($url = '', $noMessage = false, $responseCode = 0, $autoSsl = true)
5554 global $gEnvManager;
5556 // すでにリダイレクトが設定されている場合は終了
5557 if ($this->isRedirect) return; // リダイレクトするかどうか
5561 $toUrl = $gEnvManager->getCurrentScriptUrl();
5562 } else if (strncmp($toUrl, 'http://', 7) != 0 && strncmp($toUrl, 'https://', 8) != 0){ // URL以外のときはクエリー文字列と判断する
5563 $toUrl = $gEnvManager->getCurrentScriptUrl() . $toUrl;
5566 // SSL化が必要な場合はhttpsに変更
5569 if ($gEnvManager->isAdminUrlAccess($toUrl)){ // 管理画面へのアクセスのとき
5571 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
5572 } else { // フロント画面へのアクセスのとき
5574 $paramArray = array();
5575 //list($filename, $query) = explode('?', basename($toUrl));
5576 list($url, $query) = explode('?', $toUrl);
5577 $baseUrl = dirname($url);
5578 $filename = basename($url);
5579 if (empty($filename)) $filename = M3_FILENAME_INDEX;
5580 if (!empty($query)) parse_str($query, $paramArray); // クエリーの解析
5583 $pageId = basename($filename, '.php');
5584 $pageSubId = $paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID];
5587 $isSslPage = $this->isSslPage($pageId, $pageSubId);
5590 if ($this->gSystem->hierarchicalPage() && $filename == M3_FILENAME_INDEX){
5591 $toUrl = $baseUrl . '/' . $pageSubId . '/';
5592 unset($paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID]);
5594 $paramStr = $this->_createUrlParamStr($paramArray);
5595 if (!empty($paramStr)) $toUrl .= '?' . $paramStr;
5599 //$toUrl = str_replace('http://', 'https://', $toUrl);
5600 $toUrl = $gEnvManager->getSslUrl($toUrl); // SSL用URLに変換
5602 $toUrl = str_replace('https://', 'http://', $toUrl);
5606 // バッファ内容が残っているときは破棄
5607 if (ob_get_level() > 0) ob_end_clean();
5609 if (empty($responseCode)){
5611 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
5613 header('HTTP/1.1 301 Moved Permanently');
5615 } else { // レスポンスコードが指定されている場合
5616 switch ($responseCode){
5618 header('HTTP/1.1 301 Moved Permanently');
5621 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
5624 header('HTTP/1.1 303 See Other');
5626 case 500: // サーバ内部エラー
5627 header('HTTP/1.1 500 Internal Server Error');
5628 header('Status: 500 Internal Server Error');
5630 case 503: // サイト非公開(システムメンテナンス)
5631 header('HTTP/1.1 503 Service Temporarily Unavailable');
5632 header('Status: 503 Service Temporarily Unavailable');
5635 header('HTTP/1.1 ' . (string)$responseCode);
5639 header('Location: ' . $toUrl);
5641 $this->isRedirect = true; // リダイレクトするかどうか
5646 * @return bool true=リダイレクト、false=リダイレクトでない
5648 function isRedirect()
5650 return $this->isRedirect;
5653 * 指定URLのディレクトリへリダイレクト
5657 function redirectToDirectory()
5659 global $gEnvManager;
5662 $dirPath = dirname($gEnvManager->getCurrentScriptUrl()) . '/';
5663 //$this->redirect($dirPath);
5664 $this->redirect($dirPath, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/7/23)
5669 * @param string $url 遷移先URL
5672 function redirectInInstall($url)
5674 $this->redirect($url, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
5681 function redirectToInstall()
5683 global $gEnvManager;
5685 $sytemRootUrl = $gEnvManager->calcSystemRootUrl();
5686 //$this->redirect($sytemRootUrl . '/admin/install.php');
5687 $this->redirect($sytemRootUrl . '/admin/install.php', false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
5690 * ログイン、ログアウト処理を行った後、リダイレクト
5692 * @param RequestManager $request HTTPリクエスト処理クラス
5693 * @param bool $success ログインの成否
5694 * @param string $redirectUrl ログイン成功の場合のリダイレクト先
5695 * @return int 0=何も処理しなかった場合、1=ログイン処理、2=ログアウト処理、3=パスワード送信
5697 function standardLoginLogoutRedirect($request, &$success, $redirectUrl = '')
5699 global $gEnvManager;
5700 global $gAccessManager;
5701 global $gRequestManager;
5703 // ログイン、ログアウト処理、および、コンテナの起動
5704 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
5705 if ($cmd == M3_REQUEST_CMD_LOGIN){ // ログインの場合
5706 $act = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_ACT);
5707 if ($act == 'sendpwd'){ // パスワード送信の場合
5708 $success = $gAccessManager->sendPassword($request);
5712 $ret = $gAccessManager->userLogin($request);
5714 if (empty($redirectUrl)){
5715 // システム運用可能ユーザの場合でリダイレクト先が設定されていない場合はデフォルトの管理画面URLへ遷移
5716 $userInfo = $gEnvManager->getCurrentUserInfo();// ユーザ情報取得
5717 if ($userInfo->userType >= UserInfo::USER_TYPE_MANAGER){
5718 $ret = $this->db->getLoginUserRecordById($userInfo->userId, $userInfoRow);
5719 if ($ret && !empty($userInfoRow['lu_default_admin_url'])){
5720 $redirectUrl = $gEnvManager->getDefaultAdminUrl() . $userInfoRow['lu_default_admin_url'];
5726 $this->redirect($redirectUrl);
5727 $success = true; // ログイン成功
5728 } else { // ログイン失敗のとき
5729 $success = false; // ログイン失敗
5733 } else if ($cmd == M3_REQUEST_CMD_LOGOUT){ // ログアウト
5735 $gAccessManager->userLogout(true);
5738 $this->redirect($redirectUrl);
5747 * @param int $errStatus HTTPエラーステータスコード
5750 function showError($errStatus)
5753 $this->setResponse($errStatus);
5756 $msg = 'NOT DEFINED ERROR';
5757 switch ($errStatus){
5758 case 403: // アクセス禁止のとき
5761 case 404: // 存在しないページのとき
5764 case 500: // サーバ内部エラー
5765 $msg = 'Internal Server Error';
5767 case 503: // サイト非公開(システムメンテナンス)
5768 $msg = 'Service Temporarily Unavailable';
5772 echo '<!doctype html>';
5775 echo '<title>' . $msg . '</title>';
5778 echo '<h2>' . $msg . '</h2>';
5783 * ウィジェットがセットされているページサブIDを取得
5785 * @param string $pageId ページID
5786 * @param string $widgetId 対象ウィジェットID
5787 * @param int $configId ウィジェット定義ID
5788 * @return string ページサブID
5790 function getPageSubIdByWidget($pageId, $widgetId, $configId = 0)
5794 // 対象のウィジェットのページサブIDを取得
5795 $ret = $this->db->getSubPageId($widgetId, $pageId, $rows);
5796 if ($ret){// データが存在する
5797 for ($i = 0; $i < count($rows); $i++){
5798 if (!empty($rows[$i]['pd_sub_id']) && $rows[$i]['pd_config_id'] == $configId){
5799 $pageSubId = $rows[$i]['pd_sub_id'];
5807 * その他のGET,POSTパラメータからページサブID取得
5809 * @param RequestManager $request HTTPリクエスト処理クラス
5810 * @param string $redirectUrl リダイレクト用URL
5811 * @return string ページサブID
5813 function getPageSubIdByParam($request, &$redirectUrl)
5815 global $gEnvManager;
5819 $task = $request->trimValueOf('task');
5820 $option = $request->trimValueOf('option');
5821 if ($task == 'search' && $option == 'com_search'){ // joomla!の検索結果表示の場合
5822 $this->contentType = M3_VIEW_TYPE_SEARCH; // ページのコンテンツタイプ
5824 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_SEARCH, $gEnvManager->getCurrentPageId());// ページサブIDを取得
5825 if (!empty($subId)){
5827 $keyword = $request->trimValueOf('searchword');
5828 $redirectUrl = $gEnvManager->createPageUrl();
5829 $redirectUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subId;
5830 $redirectUrl .= '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=search&' . M3_REQUEST_PARAM_KEYWORD . '=' . urlencode($keyword);
5836 * コンテンツタイプとページIDからページサブID取得
5838 * @param string $contentType コンテンツタイプ
5839 * @param string $pageId ページID
5840 * @return string ページサブID
5842 function getPageSubIdByContentType($contentType, $pageId)
5844 $subId = $this->db->getSubPageIdWithContent($contentType, $pageId);// ページサブIDを取得
5848 * 指定のウィジェットがページ上にあるかを取得
5850 * @param string $pageId ページID
5851 * @param string $widgetId 対象ウィジェットID
5852 * @param bool $activePageOnly 公開中のページのウィジェットに制限するかどうか。falseの場合はすべてのページのウィジェットを対象とする。
5853 * @return bool true=ページ上にあり、false=ページ上になし
5855 function isWidgetOnPage($pageId, $widgetId, $activePageOnly=true)
5857 $ret = $this->db->isWidgetOnPage($pageId, $widgetId, $activePageOnly, 0/*定義セットID*/);
5861 * URLで示されるページ上のウィジェットをウィジェット種別で取得
5863 * @param string $url URL
5864 * @param string $widgetType 対象ウィジェットタイプ
5865 * @return string ウィジェットID
5867 function getWidgetIdByWidgetType($url, $widgetType)
5869 $ret = $this->getPageIdFromUrl($url, $pageId, $pageSubId, $param);
5872 if ($ret) $widgetId = $this->db->getWidgetIdByType($pageId, $pageSubId, $widgetType);
5876 * ページコンテンツタイプ、コンテンツタイプからウィジェットIDを取得
5878 * @param string $pageId ページID
5879 * @param string $contentType コンテンツタイプ
5880 * @return string ウィジェットID
5882 function getWidgetIdWithPageInfoByContentType($pageId, $contentType)
5884 $widgetId = $this->db->getWidgetIdWithPageInfoByContentType($pageId, $contentType);
5888 * ジョブタイプからウィジェットIDを取得
5890 * @param string $jobType ジョブタイプ
5891 * @return string ウィジェットID
5893 function getWidgetIdByJobType($jobType)
5895 global $gEnvManager;
5896 global $gErrorManager;
5900 $linkInfoObj = $this->gInstance->getObject(self::LINKINFO_OBJ_ID);
5901 if (isset($linkInfoObj)) $widgetId = $linkInfoObj->getJobWidget($jobType);
5903 // ウィジェットのアクセス権をチェック
5904 if (!$this->db->canAccessWidget($widgetId)) return '';
5907 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
5910 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
5915 * 現在アクティブなメイン型ウィジェットをウィジェット種別で取得
5917 * @param string $widgetType 対象ウィジェットタイプ
5918 * @return string ウィジェットID
5920 function getActiveMainWidgetIdByWidgetType($widgetType)
5923 $widgetId = $this->db->getActiveMainWidgetIdByType($widgetType);
5927 * URLを解析して、ページID,サブページIDを取得
5929 * @param string $url URL
5930 * @param string $pageId ページID
5931 * @param string $pageSubId ページサブID
5932 * @param array $urlParam URLパラメータ
5933 * @return bool true=成功、false=失敗
5935 function getPageIdFromUrl($url, &$pageId, &$pageSubId, &$urlParam)
5937 global $gEnvManager;
5939 // ページID、ページサブIDを求める
5940 list($page, $other) = explode('?', str_replace($gEnvManager->getRootUrl(), '', $url));
5941 parse_str($other, $urlParam);
5943 $pageId = str_replace('/', '_', trim($page, '/'));
5944 $pageId = basename($pageId, '.php');
5947 $pageSubId = $param[M3_REQUEST_PARAM_PAGE_SUB_ID];
5948 if (empty($pageSubId)) $pageSubId = $gEnvManager->getDefaultPageSubId();
5952 * ウィジェットが組み込まれているページのURLを生成
5954 * @param string $widgetId 送信元ウィジェットID
5955 * @param string $param 実行パラメータ
5956 * @param string $pageId ウィジェットが存在するページID
5957 * @return string 生成したURL
5959 function getDefaultPageUrlByWidget($widgetId, $param = '', $pageId = '')
5961 global $gEnvManager;
5963 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
5965 // このウィジェットがマップされているページサブIDを取得
5967 $subPageId = $this->getPageSubIdByWidget($pageId, $widgetId);
5968 if (empty($subPageId)){
5969 // 見つからないときは互換ウィジェットを探す
5970 $targetWidgetId = $this->db->getCompatibleWidgetId($widgetId);
5971 if (!empty($targetWidgetId)){
5972 $subPageId = $this->getPageSubIdByWidget($pageId, $targetWidgetId);
5975 if (!empty($subPageId)) $sub = M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId;
5977 //$url = $gEnvManager->getDefaultUrl();
5978 $url = $gEnvManager->createPageUrl($pageId);
5979 if (!empty($sub)) $url .= '?' . $sub;
5980 if (!empty($param)) $url .= '&' . $param;
5984 * 指定のページ属性のページURLを生成
5986 * @param string $contentType コンテンツタイプ
5987 * @param string $param 実行パラメータ
5988 * @return string 生成したURL
5990 function createContentPageUrl($contentType, $param = '')
5992 global $gEnvManager;
5994 $pageSubId = $this->getPageSubIdByContentType($contentType, $gEnvManager->getCurrentPageId());
5995 if (empty($pageSubId)) $pageSubId = $gEnvManager->getDefaultPageSubId();
5997 $url = $gEnvManager->createPageUrl();
5998 $url .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId;
5999 if (!empty($param)) $url .= '&' . $param;
6003 * ウィジェット指定呼び出し用のURLを生成
6005 * @param string $toWidgetId 送信先ウィジェットID
6006 * @param string $fromWidgetId 送信元ウィジェットID
6007 * @param string $todo 実行パラメータ
6008 * @param string $pageId ページID(空のときは現在のURL)
6009 * @return string 生成したURL
6011 function createWidgetCmdUrl($toWidgetId, $fromWidgetId, $todo, $pageId = '')
6013 global $gEnvManager;
6015 $url = $gEnvManager->createPageUrl($pageId);
6017 $url .= '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_FIND_WIDGET;
6018 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $toWidgetId;
6019 if (!empty($fromWidgetId)) $url .= '&' . M3_REQUEST_PARAM_FROM . '=' . $fromWidgetId; // 送信元
6020 if (!empty($todo)) $url .= '&' . M3_REQUEST_PARAM_OPERATION_TODO . '=' . urlencode($todo);
6026 * @param string $widgetId 実行ウィジェットID
6027 * @param string $optionParam 追加パラメータ
6028 * @param string $pageId ページID(空のときは現在のURL)
6029 * @param string $pageSubId ページサブID
6030 * @return string 生成したURL
6032 function createRssCmdUrl($widgetId, $optionParam = '', $pageId = '', $pageSubId = '')
6034 global $gEnvManager;
6037 $url = $gEnvManager->createPageUrl() . '?';
6040 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6041 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6043 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_RSS;
6044 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6045 if (!empty($optionParam)) $url .= '&' . $optionParam;
6051 * @param bool $isSslPage SSLが必要なページかどうか
6052 * @param string $optionParam 追加パラメータ
6053 * @return string 生成したURL
6055 function createCssCmdUrl($isSslPage, $optionParam = '')
6057 global $gEnvManager;
6058 global $gRequestManager;
6061 // $url = $gEnvManager->createPageUrl() . '?';
6062 $url = $gEnvManager->createPageUrl(''/*現在のページ*/, $isSslPage) . '?';
6065 $pageSubId = $this->gEnv->getCurrentPageSubId();
6066 $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6068 // コンテンツ詳細画面の場合はコンテンツパラメータを追加
6069 if ($this->isContentDetailPage){
6070 switch ($this->contentType){
6071 case M3_VIEW_TYPE_CONTENT: // 汎用コンテンツ
6072 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID);
6073 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID_SHORT);
6074 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentsId . '&';
6076 case M3_VIEW_TYPE_PRODUCT: // 製品
6077 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID);
6078 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID_SHORT);
6079 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PRODUCT_ID . '=' . $contentsId . '&';
6081 case M3_VIEW_TYPE_BBS: // BBS
6082 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID);
6083 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT);
6084 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BBS_THREAD_ID . '=' . $contentsId . '&';
6086 case M3_VIEW_TYPE_BLOG: // ブログ
6087 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID);
6088 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT);
6089 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $contentsId . '&';
6091 case M3_VIEW_TYPE_WIKI: // Wiki
6092 $contentsId = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
6093 if (!empty($contentsId)) $url .= $contentsId . '&';
6095 case M3_VIEW_TYPE_USER: // ユーザ作成コンテンツ
6096 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_ROOM_ID);
6097 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_ROOM_ID_SHORT);
6098 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_ROOM_ID . '=' . $contentsId . '&';
6100 case M3_VIEW_TYPE_EVENT: // イベント
6101 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID);
6102 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID_SHORT);
6103 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_EVENT_ID . '=' . $contentsId . '&';
6105 case M3_VIEW_TYPE_PHOTO: // フォトギャラリー
6106 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID);
6107 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID_SHORT);
6108 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PHOTO_ID . '=' . $contentsId . '&';
6113 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_CSS;
6114 if (!empty($optionParam)) $url .= '&' . $optionParam;
6120 * @param string $widgetId 実行ウィジェットID
6121 * @param string $optionParam 追加パラメータ
6122 * @param bool $byMacro マクロ変換で返すかどうか
6123 * @param string $pageId ページID(空のときは現在のURL)
6124 * @param string $pageSubId ページサブID
6125 * @return string 生成したURL
6127 function createDirectWidgetCmdUrl($widgetId, $optionParam = '', $byMacro = false, $pageId = '', $pageSubId = '')
6129 global $gEnvManager;
6133 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . M3_FILENAME_INDEX . '?';
6135 $url = $gEnvManager->createPageUrl() . '?';
6139 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6140 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6142 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_DO_WIDGET;
6143 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6144 if (!empty($optionParam)) $url .= '&' . $optionParam;
6150 * @return array パラメータ文字列の配列
6152 function getUrlParamOrder()
6154 return $this->urlParamOrder; // URLパラメータの並び順
6157 * キャッシュ制御用の付加パラメータを取得
6159 * @return string パラメータ
6161 function getCacheParam()
6163 $addParam = '?' . date('YmdHis');
6167 * 現在のURLにアクセス可能かチェック
6169 * @param bool $isActivePage ページが有効かどうか
6170 * @return bool true=可能、false=不可
6172 function canAccessUrl(&$isActivePage)
6174 global $gEnvManager;
6176 // 現在設定されているページIDを取得
6177 $pageId = $gEnvManager->getCurrentPageId();
6178 $pageSubId = $gEnvManager->getCurrentPageSubId();
6179 $ret = $this->db->canAccessPage($pageId, $pageSubId, $pageVisible, $pageSubVisible, $isAdminMenu);
6180 if ($ret){ // アクセス可能なときは、ユーザ制限もチェックする
6181 $isActivePage = true;
6184 if (!$pageVisible || !$pageSubVisible) return false;
6186 if (!$gEnvManager->isCurrentUserLogined() && $this->isUserLimitedPage($pageId, $pageSubId)){ // ユーザがログインされていない状態でユーザ制限されていればアクセス不可
6189 $this->isAccessPointWithAdminMenu = $isAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
6192 } else { // 無効ページのとき
6193 $isActivePage = false;
6198 * ウィジェットヘッダ(Joomla!1.0用)を出力タイプを取得
6200 * @return int 0=出力しない、1=Joomla!1.0テンプレートPC用、2=Joomla!1.0テンプレート携帯用
6202 function getTemplateWidgetHeaderType()
6204 global $gEnvManager;
6206 $templateId = $gEnvManager->getCurrentTemplateId();
6207 if ($templateId == self::ADMIN_TEMPLATE || // PC管理用テンプレート
6208 $templateId == self::M_ADMIN_TEMPLATE){ // 携帯管理用テンプレート
6210 } else if(strncmp($templateId, 'm/', 2) == 0){ // 携帯用テンプレート
6211 return 2; // 携帯テンプレート用出力
6213 return 1; // PCテンプレート用出力
6219 * @param string $pageId ページID
6220 * @param string $pageSubId ページサブID
6221 * @return bool true=必要、false=不要
6223 function isSslPage($pageId, $pageSubId)
6225 global $gEnvManager;
6228 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6231 if ($pageId == $gEnvManager->getDefaultAdminPageId()){
6232 if ($gEnvManager->getUseSslAdmin()){ // 管理用ページにSSLを使用するかどうか
6239 // ##### フロント画面の場合 #####
6240 if ($gEnvManager->isRootUrlSsl()) return true; // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
6242 // 一般用ページにSSLを使用しない場合は不要を返す
6243 if (!$gEnvManager->getUseSsl()) return false;
6245 // 一般用ページでSSLを使用する場合は、データベースの設定をチェックする
6246 $line = $this->getPageInfo($pageId, $pageSubId);
6248 if ($line['pn_use_ssl']){
6257 * ユーザ制限が必要なページかどうかを判断
6259 * @param string $pageId ページID
6260 * @param string $pageSubId ページサブID
6261 * @return bool true=必要、false=不要
6263 function isUserLimitedPage($pageId, $pageSubId)
6265 global $gEnvManager;
6268 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6270 $line = $this->getPageInfo($pageId, $pageSubId);
6272 if ($line['pn_user_limited']){
6283 * @param string $pageId ページID
6284 * @param string $pageSubId ページサブID
6285 * @return array ページ情報レコード
6287 function getPageInfo($pageId, $pageSubId)
6289 // ページ情報が空のときはデータをロード
6290 if (empty($this->pageInfo)){
6291 $records = $this->db->getPageInfoRecords();
6292 $count = count($records);
6293 $this->pageInfo = array();
6294 for ($i = 0; $i < $count; $i++){
6295 $pId = $records[$i]['pn_id'] . self::PAGE_ID_SEPARATOR . $records[$i]['pn_sub_id'];
6296 $this->pageInfo[$pId] = $records[$i];
6299 return $this->pageInfo[$pageId . self::PAGE_ID_SEPARATOR . $pageSubId];
6302 * 現在のページ情報からテンプレートIDを取得
6304 * @param string $subTemplateId テンプレートIDが取得できるときはサブページIDが返る
6305 * @return string テンプレートID
6307 function getTemplateIdFromCurrentPageInfo(&$subTemplateId)
6310 if (!empty($this->currentPageInfo)){
6311 $templateId = $this->currentPageInfo['pn_template_id'];
6312 $subTemplateId = $this->currentPageInfo['pn_sub_template_id']; // サブテンプレートID
6317 * JavascriptライブラリのIDを取得
6319 * @param int $type 種別(0=すべて、1=jQuery関係すべて、2=jQueryプラグインのみ)
6320 * @return array JavascriptライブラリのID
6322 function getScriptLibId($type = 0)
6324 // Javascriptライブラリのすべてのキーを取得
6325 $keys = array_keys($this->libFiles);
6327 $destKeys = array();
6328 for ($i = 0; $i < count($keys); $i++){
6330 case 1: // jQuery関係すべて
6331 if (strStartsWith($keys[$i], 'jquery')) $destKeys[] = $keys[$i];
6333 case 2: // jQueryプラグインのみ
6334 if (strStartsWith($keys[$i], 'jquery.')) $destKeys[] = $keys[$i];
6341 * Javascriptライブラリの情報を取得
6343 * @param string $id ライブラリID
6344 * @return array ライブラリの情報
6346 function getScriptLibInfo($id)
6348 $libInfo = $this->libFiles[$id];
6349 if (isset($libInfo)){
6356 * 管理画面用jQueryUIテーマのURLを取得
6358 * @return string テーマURL
6360 function getAdminDefaultThemeUrl()
6362 // $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
6363 $themeFile = $this->gEnv->getAdminUrl(true/*「admin」削除*/) . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
6367 * フロント画面用jQueryUIテーマのURLを取得
6369 * @return string テーマURL
6371 function getDefaultThemeUrl()
6375 if (!isset($themeFile)){
6377 $theme = $this->gSystem->defaultTheme();
6378 if (!empty($theme)){
6379 $path = $this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
6380 if (file_exists($path)) $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
6388 * @param array $paramArray URL作成用のパス
6389 * @return string 作成したURLパラメータ
6391 function _createUrlParamStr($paramArray)
6394 if (count($paramArray) == 0) return $destParam;
6396 $sortParam = array();
6397 $keys = array_keys($paramArray);
6398 $keyCount = count($keys);
6399 for ($i = 0; $i < $keyCount; $i++){
6401 $value = $paramArray[$key];
6402 $orderNo = $this->urlParamOrder[$key];
6403 if (!isset($orderNo)) $orderNo = 100;
6404 $sortParam[] = array('key' => $key, 'value' => $value, 'no' => $orderNo);
6406 usort($sortParam, create_function('$a,$b', 'return $a["no"] - $b["no"];'));
6409 $sortCount = count($sortParam);
6410 for ($i = 0; $i < $sortCount; $i++){
6411 if ($i > 0) $destParam .= '&';
6412 $destParam .= rawurlencode($sortParam[$i]['key']) . '=' . rawurlencode($sortParam[$i]['value']);
6417 * 画面で使用しているCSSファイルを取得
6419 * @param string $url 取得画面のURL
6420 * @return array CSSファイルのURL
6422 function getCssFilesByHttp($url)
6425 curl_setopt($ch, CURLOPT_URL, $url);
6426 curl_setopt($ch, CURLOPT_USERAGENT, M3_SYSTEM_NAME . '/' . M3_SYSTEM_VERSION); // ユーザエージェント
6427 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 画面に出力しない
6428 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
6429 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
6430 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); // セッションを維持
6431 $content = curl_exec($ch);
6435 $urlArray = array();
6437 $pattern = '/<head\b[^>]*?>(.*?)<\/head\b[^>]*?>/si';
6438 if (preg_match($pattern, $content, $matches)) $headContent = $matches[0];
6441 $pattern = '/<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>/si';
6442 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
6443 foreach ($matches as $match){
6444 if (strEndsWith($match[1], '.css')) $urlArray[] = $match[1];
6448 // ifで制御されているCSSファイルを除く
6449 $delUrlArray = array();
6450 $pattern = '/<!--\[if\b.*?\]>[\b]*<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>[\b]*<!\[endif\]-->/si';
6451 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
6452 foreach ($matches as $match) $delUrlArray[] = $match[1];
6456 $this->ckeditorCssFiles = array_diff($urlArray, $delUrlArray); // CKEditor用のCSSファイル
6459 $pattern = '/var\s*M3_TEMPLATE_TYPE\s*=\s*(\d+?)\s*;/si';
6460 if (preg_match($pattern, $headContent, $matches)) $this->ckeditorTemplateType = $matches[1]; // CKEditor用のテンプレートタイプ
6463 * CKEditor用のテンプレートタイプを取得
6465 * @return int テンプレートタイプ
6467 function getCkeditorTemplateType()
6469 return $this->ckeditorTemplateType;