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-2014 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 $tmpData; // データ作成用
32 private $db; // DBオブジェクト
33 private $defaultScriptFiles; // デフォルトで読み込むスクリプトファイル
34 private $defaultCssFiles; // デフォルトで読み込むCSSファイル
35 private $defaultAdminScriptFiles; // デフォルトで読み込むスクリプトファイル(管理用)
36 private $defaultAdminCssFiles; // デフォルトで読み込むCSSファイル(管理用)
37 private $defaultAdminDirScriptFiles; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
38 private $defaultAdminDirCssFiles; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
39 private $headScriptFiles = array(); // ウィジェットからの追加で読み込むスクリプトファイル
40 private $headPreMobileScriptFiles = array();// ウィジェットからの追加で読み込むスクリプトファイル(jQueryMobile用挿入ファイル)
41 private $headCssFiles = array(); // ウィジェットからの追加で読み込むCSSファイル
42 private $headRssFiles = array(); // HTMLヘッダに出力するRSS配信情報
43 private $pageDefPosition; // 現在取得しているページ定義のポジション
44 private $pageDefRows; // ページ定義レコード
45 private $nonSharedWidgetCount = -1; // 非共通ウィジェットの数(-1=ページ作成でないとき)
46 private $replaceHeadDone; // ヘッダマクロ変換処理が完了したかどうか
47 private $useHelp = false; // 標準ヘルプ機能を使用するかどうか
48 private $hasScriptCache = false; // JavaScriptファイルをブラウザにキャッシュさせるかどうか
49 private $isAccessPointWithAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
50 private $lateLaunchWidgetList; // 遅延実行ウィジェットのリスト
51 private $latelaunchWidgetParam; // 遅延実行ウィジェットのパラメータ
52 private $viewPositions = array(); // テンプレート上のポジション
53 private $viewPosId = array(); // テンプレート上のポジションのタグID
54 private $updateParentWindow; // 親ウィンドウを再描画するかどうか
55 private $updateDefSerial; // 更新する項目のページ定義シリアル番号
56 private $headDescription; // HTMLヘッダ「description」に出力する文字列
57 private $headKeywords; // HTMLヘッダ「keywords」に出力する文字列
58 private $headOthers; // HTMLヘッダに出力するタグ文字列
59 private $lastHeadTitle; // 最後にヘッダ部titleにセットした文字列
60 private $lastHeadDescription; // 最後にヘッダ部descriptionにセットした文字列
61 private $lastHeadKeywords; // 最後にヘッダ部keywordsにセットした文字列
62 private $headCss = array(); // HTMLヘッダにCSS出力する文字列
63 private $headScript = array(); // HTMLヘッダにJavascript出力する文字列
64 private $headPreMobileScript = array(); // HTMLヘッダにJavascript出力する文字列(jQueryMobile用挿入スクリプト)
65 private $headString = array(); // HTMLヘッダに出力する任意文字列
66 private $lastHeadCss; // 最後に設定したHTMLヘッダにCSS出力する文字列
67 private $lastHeadScript; // 最後に設定したHTMLヘッダにJavascript出力する文字列
68 private $lastHeadString; // 最後に設定したHTMLヘッダに出力する任意文字列
69 private $initScript = ''; // ウィンドウ初期化時に実行されるスクリプト
70 private $outputByHtml = true; // HTMLフォーマットで出力するかどうか
71 private $outputHead; // HTMLヘッダ出力を行ったかどうか
72 private $outputTheme; // jQueryUIテーマ出力を行ったかどうか
73 private $isAbort; // ページ作成処理を中断するかどうか
74 private $isRedirect; // リダイレクトするかどうか
75 private $libFiles; // javascript追加用ライブラリ
76 private $pageDefRev = 234; // 画面定義のリビジョン番号
77 private $headSubTitle = array(); // ヘッダタグサブタイトル
78 private $headSubTitleUrl = array(); // ヘッダサブタイトルのリンク先
79 private $pageInfo; // すべてのページ情報
80 private $currentPageInfo; // 現在のページのページ情報
81 private $configWidgetInfo; // ウィジェット設定画面のウィジェットの情報
82 private $contentType = ''; // ページのコンテンツタイプ
83 private $mainContentType; // 一般画面で使用する主要コンテンツタイプ
84 private $mainFeatureType; // 一般画面で使用する主要機能タイプ
85 private $rssVersion; // RSSバージョン
86 private $rssChannel; // RSSチャンネルデータ
87 private $selectedJQueryFilename; // 使用対象のjQueryファイル
88 private $selectedJQueryUiFilename; // 使用対象のjQuery UIファイル
89 private $selectedJQueryMobileFilename; // 使用対象のjQueryMobileファイル
90 private $urlParamOrder; // URLパラメータの並び順
91 private $wysiwygEditor; // 管理画面用WYSIWYGエディター
92 private $optionTemplateId; // 追加設定するテンプレートID
93 private $isContentGooglemaps; // コンテンツにGoogleマップが含むかどうか
94 private $useGooglemaps; // Googleマップを使用するかどうか
95 private $useBootstrap; // Bootstrapを使用するかどうか
96 private $isHtml5; // HTML5で出力するかどうか
97 const CONFIG_KEY_HEAD_TITLE_FORMAT = 'head_title_format'; // ヘッダ作成用フォーマット
98 const ADMIN_WIDGET_ID = 'admin_main'; // 管理用ウィジェットのウィジェットID
99 //const CONTENT_TYPE_WIKI = 'wiki'; // ページのコンテンツタイプ(Wiki)
100 const WIDGET_ID_TAG_START = '{{WIDGETID:'; // 遅延実行用タグ
101 const WIDGET_ID_TAG_END = '}}'; // 遅延実行用タグ
102 const WIDGET_ID_TITLE_TAG_START = '{{WIDGETID_TITLE:'; // 遅延実行用タグ(タイトル埋め込み用)
103 const WIDGET_ID_TITLE_TAG_END = '}}'; // 遅延実行用タグ(タイトル埋め込み用)
104 const WIDGET_ID_SEPARATOR = ',';
105 const HEAD_TAGS = '{{HEAD_TAGS}}'; // HTMLヘッダ出力用タグ
106 const WIDGET_ICON_IMG_SIZE = 32; // ウィジェットアイコンサイズ
107 const WIDGET_OUTER_CLASS = 'm3_widget_outer'; // ウィジェット外枠クラスクラス
108 const WIDGET_OUTER_CLASS_HEAD_POSITION = 'm3_pos_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
109 const WIDGET_OUTER_CLASS_WIDGET_TAG = 'm3_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
110 const WIDGET_INNER_CLASS = 'm3_widget_inner'; // ウィジェットの内側クラス
111 const POSITION_TAG_HEAD = 'm3pos_'; // ポジションの識別用タグIDヘッダ
112 const WIDGET_TAG_HEAD = 'm3widget_'; // ウィジェットの識別用タグIDヘッダ
113 // const WIDGET_TAG_HEAD_SHORT = 'm3_'; // ウィジェットの識別用タグIDヘッダ
114 const WIDGET_TYPE_TAG_HEAD = 'm3widgettype_'; // ウィジェット種別の識別用タグIDヘッダ
115 const WIDTET_CLASS_NAME = 'm3widget'; // ウィジェットオブジェクトのタグクラス名
116 const WIDTET_CLASS_TYPE_0 = 'm3widget_type0'; // ウィジェットオブジェクトのタグクラス(ページ共通でない)
117 const WIDTET_CLASS_TYPE_1 = 'm3widget_type1'; // ウィジェットオブジェクトのタグクラス(ページ共通)
118 const POSITION_CLASS_NAME = 'm3position'; // ポジションオブジェクトのタグクラス名
119 const JOOMLA10_DEFAULT_WIDGET_MENU_PARAM = 'class="moduletable"'; // Joomla!1.0用デフォルトメニューパラメータ値
120 const ADMIN_TEMPLATE = '_admin'; // PC管理用テンプレートID
121 const M_ADMIN_TEMPLATE = 'm/_admin'; // 携帯用管理画面テンプレートID
122 const SCRIPT_LIB_SEPARATOR = ';'; // JavaScriptライブラリ読み込み設定のライブラリの区切り
123 const PAGE_ID_SEPARATOR = ','; // ページIDとページサブID連結用
124 const DEFAULT_ADMIN_FAVICON_FILE = '/images/system/favicon.ico'; // デフォルトの管理画面用faviconファイル
125 const DEFAULT_FAVICON_FILE = '/favicon.ico'; // デフォルトのfaviconファイル
126 // const DEFAULT_SITE_NAME = 'サイト名未設定'; // 管理画面用のデフォルトサイト名
127 const DEFAULT_ADMIN_TITLE = '管理画面'; // デフォルトの管理画面名
128 const WIDGET_TITLE_START = '['; // ウィジェットのタイトルの括弧
129 const WIDGET_TITLE_END = ']'; // ウィジェットのタイトルの括弧
130 const DEFAULT_RSS_VERSION = '1.0'; // デフォルトのRSSのバージョン
131 const CF_ACCESS_IN_INTRANET = 'access_in_intranet'; // イントラネット運用かどうか
132 const CF_USE_LATEST_SCRIPT_LIB = 'dev_use_latest_script_lib'; // 最新のJavaScriptライブラリを使用するかどうか
133 const CF_GOOGLE_MAPS_KEY = 'google_maps_key'; // Googleマップ利用キー
134 const CF_CONFIG_WINDOW_OPEN_TYPE = 'config_window_open_type'; // ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
135 const CF_JQUERY_VERSION = 'jquery_version'; // jQueryバージョン
136 const CF_WYSIWYG_EDITOR = 'wysiwyg_editor'; // 管理画面用WYSIWYGエディター
137 const CF_ADMIN_JQUERY_VERSION = 'admin_jquery_version'; // 管理画面用jQueryバージョン
138 const CF_USE_JQUERY = 'use_jquery'; // jQueryを常に使用するかどうか
139 const CF_SMARTPHONE_USE_JQUERY_MOBILE = 'smartphone_use_jquery_mobile'; // スマートフォン画面でjQuery Mobileを使用
140 const SD_HEAD_OTHERS = 'head_others'; // ヘッダその他タグ
141 const DEFAULT_THEME_DIR = '/ui/themes/'; // jQueryUIテーマ格納ディレクトリ
142 const THEME_CSS_FILE = 'jquery-ui.custom.css'; // テーマファイル
143 const CONFIG_ICON_FILE = '/images/system/config.png'; // ウィジェット定義画面アイコン
144 const ADJUST_ICON_FILE = '/images/system/adjust_widget.png'; // 位置調整アイコン
145 const SHARED_ICON_FILE = '/images/system/shared.png'; // ページ共通属性
146 const DELETE_ICON_FILE = '/images/system/delete.png'; // ウィジェット削除
147 const CONFIG_ICON32_FILE = '/images/system/config32.png'; // ウィジェット定義画面アイコン(ツールチップ用)
148 const ADJUST_ICON32_FILE = '/images/system/adjust_widget32.png'; // 位置調整アイコン(ツールチップ用)
149 const CLOSE_BOX_ICON32_FILE = '/images/system/close_box.png'; // ウィンドウ閉じるアイコン(ツールチップ用)
150 const NOTICE_ICON_FILE = '/images/system/notice16.png'; // ウィジェット配置注意アイコン
151 // const ADMIN_ICON_FILE = '/images/system/admin64.png'; // パネルメニュー管理画面遷移用アイコン
152 // const LOGOUT_ICON_FILE = '/images/system/logout64.png'; // パネルメニューログアウト用アイコン
153 // const EDIT_PAGE_ICON_FILE = '/images/system/create_page64.png'; // パネルメニュー編集用アイコン
154 const ADMIN_ICON_FILE = '/images/system/home32.png'; // パネルメニュー管理画面遷移用アイコン
155 const LOGOUT_ICON_FILE = '/images/system/logout32.png'; // パネルメニューログアウト用アイコン
156 const EDIT_PAGE_ICON_FILE = '/images/system/create_page32.png'; // パネルメニュー編集用アイコン
157 // const EDIT_END_ICON_FILE = '/images/system/close32.png'; // パネルメニュー編集終了用アイコン
158 const EDIT_END_ICON_FILE = '/images/system/back32.png'; // パネルメニュー編集終了用アイコン
159 const CLOSE_ICON_FILE = '/images/system/close32.png'; // ウィンドウ閉じるアイコン
160 const PREV_ICON_FILE = '/images/system/prev48.png'; // ウィンドウ「前へ」アイコン
161 const NEXT_ICON_FILE = '/images/system/next48.png'; // ウィンドウ「次へ」アイコン
162 const DEFAULT_READMORE_TITLE = 'もっと読む'; // もっと読むボタンのデフォルトタイトル
163 const POS_HEAD_NAV_MENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー"></i> '; // 特殊ポジションブロック(ナビゲーションメニュー)
164 const WIDGET_MARK_MAIN = '<i class="glyphicon glyphicon-tower" rel="m3help" title="メインウィジェット"></i> '; // ウィジェットの機能マーク(メインウィジェット)
165 const WIDGET_MARK_NAVMENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー"></i> '; // ウィジェットの機能マーク(ナビゲーションメニュー)
166 const WIDGET_FUNCTION_MARK_BOOTSTRAP = ' <span class="label label-warning" rel="m3help" title="Bootstrap型">B</span>'; // ウィジェット機能マーク(Boostrap型テンプレート
167 const WIDGET_STYLE_NAVMENU = '_navmenu'; // ウィジェットの表示スタイル(ナビゲーションメニュー)
170 const CONTENT_OBJ_ID = 'contentlib'; // 汎用コンテンツオブジェクトID
171 const BLOG_OBJ_ID = 'bloglib'; // ブログオブジェクトID
174 const IWIDTET_CMD_CONTENT = 'content'; // コンテンツ取得
175 const IWIDTET_CMD_INIT = 'init'; // 初期化
176 const IWIDTET_CMD_UPDATE = 'update'; // 更新
177 const IWIDTET_CMD_CALC = 'calc'; // 計算
180 const M3_ADMIN_SCRIPT_FILENAME = 'm3admin1.7.4.js'; // 管理機能用スクリプト(FCKEditor2.6.6、CKEditor4.0.1対応)
181 const M3_ADMIN_WIDGET_SCRIPT_FILENAME = 'm3admin_widget2.0.3.js'; // 管理機能(ウィジェット操作)用スクリプト(Magic3 v1.15.0以降)
182 const M3_ADMIN_WIDGET_CSS_FILE = '/m3/widget.css'; // 管理機能(ウィジェット操作)用CSSファイル
183 const M3_STD_SCRIPT_FILENAME = 'm3std1.4.5.js'; // 一般、管理機能共通スクリプト
184 const M3_PLUS_SCRIPT_FILENAME = 'm3plus1.6.1.js'; // 一般画面追加用スクリプト(FCKEditor2.6.6対応、CKEditor4.0.1対応)
185 const M3_OPTION_SCRIPT_FILENAME = 'm3opt1.1.0.js'; // AJAXを含んだオプションライブラリファイル(jQuery必須)
186 const M3_ADMIN_CSS_FILE = 'm3/admin.css'; // 管理機能用のCSS
187 const M3_EDIT_CSS_FILE = 'm3/edit.css'; // 一般画面編集用のCSS
188 const M3_DEFAULT_CSS_FILE = 'm3/default.css'; // 一般画面共通のデフォルトCSS
189 // const M3_NO_BOOTSTRAP_CSS_FILE = 'm3/nobootstrap/style.css'; // 管理画面でBootstrapの読み込みなしの場合のCSS
192 const USE_BOOTSTRAP_ADMIN = false; // 管理画面でBootstrapを使用するかどうか(デフォルト値)
193 const BOOTSTRAP_BUTTON_CLASS = 'btn btn-default';
198 function __construct()
200 global $gInstanceManager;
202 global $gSystemManager;
203 global $gRequestManager;
206 parent::__construct();
208 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
209 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
212 $this->db = $gInstanceManager->getSytemDbObject();
215 $value = $gSystemManager->getSystemConfig(self::CF_ACCESS_IN_INTRANET); // イントラネット運用かどうか
216 if (empty($value)){ // インターネット運用
217 $this->useGooglemaps = true; // Googleマップを使用するかどうか
221 // 「ルート/scripts」ディレクトリからの相対パスで指定する
222 $this->defaultScriptFiles = array(self::M3_STD_SCRIPT_FILENAME);
223 $this->defaultCssFiles = array(self::M3_DEFAULT_CSS_FILE); // 一般画面共通のデフォルトCSS
225 $this->wysiwygEditor = $gSystemManager->getSystemConfig(self::CF_WYSIWYG_EDITOR); // 管理画面用WYSIWYGエディター
227 // アクセスする画面に応じてjQueryのバージョンを設定
228 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
229 $value = $gSystemManager->getSystemConfig(self::CF_ADMIN_JQUERY_VERSION);// 管理画面用jQueryバージョン
231 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET && strStartsWith($widgetId, 'm/')){// 携帯用アクセスポイント用の管理画面の場合はWYSIWYGエディターはFCKEditorに固定
232 $this->wysiwygEditor = ScriptLibInfo::LIB_FCKEDITOR; // FCKEditorに固定
235 // 管理画面にBOOTSTRAPを使用するかどうか(初期値)
236 $this->useBootstrap = self::USE_BOOTSTRAP_ADMIN;
238 $value = $gSystemManager->getSystemConfig(self::CF_JQUERY_VERSION);// jQueryバージョン
240 ScriptLibInfo::setJQueryVer($value);
242 // WYSISIGエディターのタイプを設定。ScriptLibInfo::getLib()を実行する前に設定。
243 ScriptLibInfo::setWysiwygEditorType($this->wysiwygEditor);
246 $this->libFiles = ScriptLibInfo::getLib(); // ライブラリ取得
249 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(0); // 使用対象のjQueryファイル
250 $this->selectedJQueryUiFilename = ScriptLibInfo::getJQueryFilename(1); // 使用対象のjQuery UIファイル
253 if (defined('M3_STATE_IN_INSTALL')){ // インストーラの場合のスクリプト
254 $this->defaultAdminScriptFiles = array($this->selectedJQueryFilename); // jQuery
255 // self::M3_STD_SCRIPT_FILENAME,
256 // self::M3_ADMIN_SCRIPT_FILENAME,
257 // self::M3_OPTION_SCRIPT_FILENAME);
259 $this->defaultAdminCssFiles = array(); // 管理機能用のCSS
261 $this->defaultAdminScriptFiles = array($this->selectedJQueryFilename, // jQuery
262 $this->selectedJQueryUiFilename, // jQuery UI Core
263 ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME, // jQuery Contextmenu Lib
264 self::M3_STD_SCRIPT_FILENAME,
265 self::M3_ADMIN_SCRIPT_FILENAME,
266 self::M3_OPTION_SCRIPT_FILENAME);
268 $this->defaultAdminCssFiles = array(self::M3_ADMIN_CSS_FILE);// 管理機能用のCSS
269 // if (!$this->useBootstrap) $this->defaultAdminCssFiles[] = self::M3_NO_BOOTSTRAP_CSS_FILE; // Bootstrapを読み込まない場合は代替CSSを読み込む
272 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用スクリプト追加
273 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用スクリプト追加
276 // 管理権限なしで管理ディレクトリアクセスで読み込むスクリプトファイル
277 $this->defaultAdminDirScriptFiles = array($this->selectedJQueryFilename); // jQuery
280 $this->lateLaunchWidgetList = array();
281 $this->latelaunchWidgetParam = array();
284 if ($gEnvManager->canUseDb()){
285 $value = $this->gSystem->getSystemConfig('script_cache_in_browser'); // ブラウザにJavaScriptファイルのキャッシュを保持するかどうか
286 if ($value != '') $this->hasScriptCache = $value;
289 $this->rssVersion = self::DEFAULT_RSS_VERSION; // RSSバージョン
291 // 一般画面で使用する主要コンテンツタイプ
292 $this->mainContentType = array( array( 'name' => '汎用コンテンツ', 'value' => M3_VIEW_TYPE_CONTENT),
293 array( 'name' => '製品', 'value' => M3_VIEW_TYPE_PRODUCT),
294 array( 'name' => 'BBS', 'value' => M3_VIEW_TYPE_BBS),
295 array( 'name' => 'ブログ', 'value' => M3_VIEW_TYPE_BLOG),
296 array( 'name' => 'Wiki', 'value' => M3_VIEW_TYPE_WIKI),
297 array( 'name' => 'ユーザ作成コンテンツ', 'value' => M3_VIEW_TYPE_USER),
298 array( 'name' => 'イベント', 'value' => M3_VIEW_TYPE_EVENT),
299 array( 'name' => 'フォトギャラリー', 'value' => M3_VIEW_TYPE_PHOTO));
301 $this->mainFeatureType = array( array( 'name' => '検索', 'value' => M3_VIEW_TYPE_SEARCH),
302 array( 'name' => 'Eコマース', 'value' => M3_VIEW_TYPE_COMMERCE));
305 $this->urlParamOrder = array(
307 M3_REQUEST_PARAM_CONTENT_ID => -20, // 汎用コンテンツID
308 M3_REQUEST_PARAM_CONTENT_ID_SHORT => -19, // 汎用コンテンツID(略式)
309 M3_REQUEST_PARAM_PRODUCT_ID => -18, // 製品ID
310 M3_REQUEST_PARAM_PRODUCT_ID_SHORT => -17, // 製品ID(略式)
311 M3_REQUEST_PARAM_BLOG_ID => -16, // ブログID
312 M3_REQUEST_PARAM_BLOG_ID_SHORT => -15, // ブログID(略式)
313 M3_REQUEST_PARAM_BLOG_ENTRY_ID => -14, // ブログ記事ID
314 M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT => -13, // ブログ記事ID(略式)
315 M3_REQUEST_PARAM_BBS_ID => -12, // 掲示板投稿記事ID
316 M3_REQUEST_PARAM_BBS_ID_SHORT => -11, // 掲示板投稿記事ID(略式)
317 M3_REQUEST_PARAM_BBS_THREAD_ID => -10, // 掲示板投稿スレッドID
318 M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT => -9, // 掲示板投稿スレッドID(略式)
319 M3_REQUEST_PARAM_USER_ID => -8, // ユーザ作成コンテンツID
320 M3_REQUEST_PARAM_USER_ID_SHORT => -7, // ユーザ作成コンテンツID(略式)
321 M3_REQUEST_PARAM_ROOM_ID => -6, // ユーザ作成コンテンツ区画ID
322 M3_REQUEST_PARAM_ROOM_ID_SHORT => -5, // ユーザ作成コンテンツ区画ID(略式)
323 M3_REQUEST_PARAM_EVENT_ID => -4, // イベントID
324 M3_REQUEST_PARAM_EVENT_ID_SHORT => -3, // イベントID(略式)
325 M3_REQUEST_PARAM_PHOTO_ID => -2, // 画像ID
326 M3_REQUEST_PARAM_PHOTO_ID_SHORT => -1, // 画像ID(略式)
328 M3_REQUEST_PARAM_PAGE_SUB_ID => 1, // ページサブID
329 M3_REQUEST_PARAM_PAGE_CONTENT_ID => 2, // ページコンテンツID
330 M3_REQUEST_PARAM_WIDGET_ID => 3, // ウィジェットID
331 M3_REQUEST_PARAM_TEMPLATE_ID => 4, // テンプレートID
332 M3_REQUEST_PARAM_URL => 5, // リンク先等のURL
333 M3_REQUEST_PARAM_STAMP => 6, // 公開発行ID
334 M3_REQUEST_PARAM_OPTION => 7, // 通信オプション
335 M3_REQUEST_PARAM_OPERATION_COMMAND => 8, // 実行処理
336 M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND => 9, // Wikiコマンド実行
337 M3_REQUEST_PARAM_OPERATION_TASK => 10, // ウィジェット間共通処理
338 M3_REQUEST_PARAM_OPERATION_ACT => 11, // クライアントからの実行処理
339 M3_REQUEST_PARAM_OPERATION_LANG => 12, // 言語指定表示
340 M3_REQUEST_PARAM_SERIAL_NO => 13, // シリアル番号
341 M3_REQUEST_PARAM_PAGE_NO => 14, // ページ番号
342 M3_REQUEST_PARAM_LIST_NO => 15, // 一覧番号
343 M3_REQUEST_PARAM_ITEM_NO => 16, // 項目番号
344 M3_REQUEST_PARAM_OPERATION_TODO => 17, // 指定ウィジェットに実行させる処理
345 M3_REQUEST_PARAM_FROM => 18, // メッセージの送信元ウィジェットID
346 M3_REQUEST_PARAM_VIEW_STYLE => 19, // 表示スタイル
347 M3_REQUEST_PARAM_FORWARD => 20, // 画面遷移用パラメータ
348 M3_REQUEST_PARAM_ADMIN_KEY => 21, // 管理者一時キー
349 M3_REQUEST_PARAM_OPEN_BY => 22, // ウィンドウの開き方
350 M3_REQUEST_PARAM_SHOW_HEADER => 23, // ヘッダ部表示制御
351 M3_REQUEST_PARAM_SHOW_FOOTER => 24, // フッタ部表示制御
352 M3_REQUEST_PARAM_SHOW_MENU => 25, // メニュー部表示制御
353 M3_REQUEST_PARAM_KEYWORD => 26, // 検索キーワード
354 M3_REQUEST_PARAM_HISTORY => 27, // 履歴インデックスNo
355 M3_REQUEST_PARAM_DEF_PAGE_ID => 28, // ページID(画面編集用)
356 M3_REQUEST_PARAM_DEF_PAGE_SUB_ID => 29, // ページサブID(画面編集用)
357 M3_REQUEST_PARAM_PAGE_DEF_SERIAL => 30, // ページ定義のレコードシリアル番号(設定画面起動時)
358 M3_REQUEST_PARAM_PAGE_DEF_CONFIG_ID => 31, // ページ定義のウィジェット定義ID(設定画面起動時)
359 M3_REQUEST_PARAM_BACK_URL => 32, // 戻り先URL
360 M3_REQUEST_PARAM_BACKUP_URL => 33, // URL退避用(画面編集時)
361 M3_REQUEST_PARAM_SERVER => 34, // サーバ指定
362 M3_REQUEST_PARAM_CATEGORY_ID => 35); // カテゴリID(共通)
367 * @return array コンテンツタイプ
369 public function _getAllContentType()
371 $contentType = array( M3_VIEW_TYPE_CONTENT, // 汎用コンテンツ
372 M3_VIEW_TYPE_PRODUCT, // 製品
373 M3_VIEW_TYPE_BBS, // BBS
374 M3_VIEW_TYPE_BLOG, // ブログ
375 M3_VIEW_TYPE_WIKI, // wiki
376 M3_VIEW_TYPE_USER, // ユーザ作成コンテンツ
377 M3_VIEW_TYPE_EVENT, // イベント
378 M3_VIEW_TYPE_PHOTO); // フォトギャラリー
384 * @return array 機能タイプ
386 public function _getAllFeatureType()
388 $featureType = array( M3_VIEW_TYPE_DASHBOARD, // ダッシュボード
389 M3_VIEW_TYPE_SEARCH, // 検索結果
390 M3_VIEW_TYPE_COMMERCE); // Eコマース
398 function setNoTimeout()
400 if (ini_get('safe_mode') == '0') set_time_limit(0);
405 * @param string $msg メッセージ
407 function setPopupMsg($msg)
409 $this->popupMsg = $msg;
412 * HTMLヘッダ「description」に出力する文字列を設定
414 * @param string $str 出力文字列
416 function setHeadDescription($str)
418 if (is_string($str) && !empty($str)){
419 $this->headDescription = $str;
420 $this->lastHeadDescription = $str; // 最後に設定した値を退避
424 * HTMLヘッダ「description」に出力する文字列を取得
426 * @return string $str 出力文字列
428 function getHeadDescription()
430 return $this->headDescription;
433 * HTMLヘッダ「keywords」に出力する文字列を設定
435 * @param string $str 出力文字列
437 function setHeadKeywords($str)
439 if (is_string($str) && !empty($str)){
440 $this->headKeywords = $str;
441 $this->lastHeadKeywords = $str; // 最後に設定した値を退避
445 * HTMLヘッダ「keywords」に出力する文字列を取得
447 * @return string $str 出力文字列
449 function getHeadKeywords()
451 return $this->headKeywords;
454 * HTMLヘッダに出力するタグ文字列を設定
456 * @param string $str 出力文字列
459 function setHeadOthers($str)
461 if (is_string($str) && !empty($str)){
462 $this->headOthers = $str;
466 * HTMLヘッダに出力するタグ文字列を取得
468 * @return string $str 出力文字列
470 /* function getHeadOthers()
472 return $this->headOthers;
475 * HTMLヘッダ「title」のサブタイトル出力する文字列を設定
477 * @param string $str 出力文字列
478 * @param string $url リンク先
480 function setHeadSubTitle($str, $url='')
482 if (is_string($str) && !empty($str)){
483 $this->headSubTitle[] = $str;
484 $this->headSubTitleUrl[] = $url;
485 $this->lastHeadTitle = $str; // 最後に設定した値を退避
489 * HTMLヘッダ「title」のサブタイトル出力する文字列を取得
491 * @return $array サブタイトルに設定されている文字列を連想配列(title=タイトル、url=リンク先URL)の配列で返す
493 function getHeadSubTitle()
495 $titleArray = array();
496 $titleCount = count($this->headSubTitle);
497 for ($i = 0; $i < $titleCount; $i++){
498 $line = array('title' => $this->headSubTitle[$i], 'url' => $this->headSubTitleUrl[$i]);
499 $titleArray[] = $line;
504 * HTMLヘッダに出力するCSSの文字列を設定
506 * @param string $css 追加するCSS内容
509 function addHeadCss($css)
511 $destCss = trim($css);
512 if (!empty($destCss)){
513 if (!in_array($css, $this->headCss)) $this->headCss[] = $css;
515 $this->lastHeadCss = $css; // 最後に設定したHTMLヘッダにCSS出力する文字列
519 * HTMLヘッダに出力するJavascriptの文字列を設定
521 * @param string $script 追加するJavascript内容
524 function addHeadScript($script)
526 $destScript = trim($script);
527 if (!empty($destScript)){
528 if (!in_array($script, $this->headScript)) $this->headScript[] = $script;
530 $this->lastHeadScript = $script; // 最後に設定したHTMLヘッダにJavascript出力する文字列
534 * HTMLヘッダに出力するJavascriptの文字列(jQueryMobile用挿入スクリプト)を設定
536 * @param string $script 追加するJavascript内容
539 function addHeadPreMobileScript($script)
541 $destScript = trim($script);
542 if (!empty($destScript)){
543 if (!in_array($script, $this->headPreMobileScript)) $this->headPreMobileScript[] = $script;
547 * HTMLヘッダに出力する任意文字列を設定
549 * @param string $str 追加する任意文字列
552 function addHeadString($str)
554 $destScript = trim($str);
555 if (!empty($destScript)){
556 if (!in_array($str, $this->headString)) $this->headString[] = $str;
558 $this->lastHeadString = $str; // 最後に設定したHTMLヘッダに出力する任意文字列
562 * HTMLヘッダに出力するCSSファイルを追加
564 * @param string,array $cssFile CSSファイルURLパス
567 function addHeadCssFile($cssFile)
569 if (is_array($cssFile)){ // 配列の場合
570 for ($i = 0; $i < count($cssFile); $i++){
571 $destCss = trim($cssFile[$i]);
572 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
575 $destCss = trim($cssFile);
576 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
580 * HTMLヘッダに出力するJavascriptライブラリを追加
582 * @param string,array $scriptLib JavascriptライブラリID
585 function addHeadAdminScriptLib($scriptLib)
587 if (is_array($scriptLib)){ // 配列の場合
588 for ($i = 0; $i < count($scriptLib); $i++){
589 $destScript = trim($scriptLib[$i]);
590 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
593 $destScript = trim($scriptLib);
594 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
598 * HTMLヘッダに出力するJavascriptライブラリを追加
600 * @param string,array $scriptLib JavascriptライブラリID
603 function addHeadScriptLib($scriptLib)
605 if (is_array($scriptLib)){ // 配列の場合
606 for ($i = 0; $i < count($scriptLib); $i++){
607 $destScript = trim($scriptLib[$i]);
608 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
611 $destScript = trim($scriptLib);
612 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
616 * HTMLヘッダに出力するJavascriptファイルを追加
618 * @param string,array $scriptFile JavascriptファイルURLパス
621 function addHeadScriptFile($scriptFile)
623 if (is_array($scriptFile)){ // 配列の場合
624 for ($i = 0; $i < count($scriptFile); $i++){
625 $destScript = trim($scriptFile[$i]);
626 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
629 $destScript = trim($scriptFile);
630 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
634 * HTMLヘッダに出力するJavascriptファイル(jQueryMobile用挿入ファイル)を追加
636 * @param string,array $scriptFile JavascriptファイルURLパス
639 function addHeadPreMobileScriptFile($scriptFile)
641 if (is_array($scriptFile)){ // 配列の場合
642 for ($i = 0; $i < count($scriptFile); $i++){
643 $destScript = trim($scriptFile[$i]);
644 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
647 $destScript = trim($scriptFile);
648 if (!empty($destScript) && !in_array($destScript, $this->headPreMobileScriptFiles)) $this->headPreMobileScriptFiles[] = $destScript;
652 * HTMLヘッダに出力するRSSファイルを追加
654 * @param array $rssFile タイトル(title)、配信用URL(href)の連想配列。複数の場合は連想配列の配列。
657 function addHeadRssFile($rssFile)
660 if (!is_array($rssFile)) return;
663 if (is_array($line)){ // 複数追加の場合
664 for ($i = 0; $i < count($line); $i++){
666 $url = trim($line[$i]['href']);
668 for ($j = 0; $j < count($this->headRssFiles); $j++){
669 $storedUrl = $this->headRssFiles[$j]['href'];
670 if ($url == $storedUrl) break;
672 if ($j == count($this->headRssFiles)){ // 見つからないときは追加
673 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
674 'title' => $line[$i]['title']); // タイトル
680 $url = trim($rssFile['href']);
682 for ($i = 0; $i < count($this->headRssFiles); $i++){
683 $storedUrl = $this->headRssFiles[$i]['href'];
684 if ($url == $storedUrl) break;
686 if ($i == count($this->headRssFiles)){ // 見つからないときは追加
687 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
688 'title' => $rssFile['title']); // タイトル
694 * RSSチャンネル部に出力するデータを設定
696 * @param array $rssData RSSチャンネル部データ
699 function setRssChannel($rssData)
701 if (!empty($rssData)) $this->rssChannel = $rssData; // RSSチャンネルデータ
706 * @param int $mode 0=ポジション表示しない(通常画面)、1=ポジション表示、2=ウィジェット込みポジション表示
708 function showPosition($mode)
710 $this->showPositionMode = $mode;
715 * @return bool true=レイアウト中、false=レイアウト中でない
719 return $this->isLayout; // 画面レイアウト中かどうか
724 function showWidget()
726 $this->showWidget = true;
731 * @param bool true=単体表示、false=単体表示でない
733 function getShowWidget()
735 return $this->showWidget;
740 * @param int $mode 0=設定なし、1=ログイン画面、10=サイト非公開、11=アクセス不可、12=存在しないページ
742 function setSystemHandleMode($mode)
744 $this->systemHandleMode = $mode;
749 function getSystemHandleMode()
751 return $this->systemHandleMode;
758 function setEditMode()
760 $this->isEditMode = true;
763 * 出力フォーマットがHTMLであるかを設定
765 * @param bool $isHtml HTMLフォーマットかどうか
768 function setOutputByHtml($isHtml)
770 $this->outputByHtml = $isHtml;
775 * @param bool $status ヘルプ機能を使用するかどうか
778 function setUseHelp($status)
780 $this->useHelp = $status;
785 * @return bool ヘルプ機能を使用するかどうか
787 function getUseHelp()
789 return $this->useHelp;
792 * 表示するコンテンツにGoogleマップが含まれているかを設定
794 * @param bool $status Googleマップを含むかどうか
797 function setIsContentGooglemaps($status)
799 $this->isContentGooglemaps = $status; // コンテンツにGoogleマップが含むかどうか
802 * 表示するコンテンツにGoogleマップが含まれているかを取得
804 * @return bool ヘルプ機能を使用するかどうか
806 function isContentGooglemaps()
808 return $this->isContentGooglemaps;
811 * JavaScriptのブラウザキャッシュの使用可否を設定
813 * @param bool $status ブラウザキャッシュを使用するかどうか
816 function setHasScriptCache($status)
818 $this->hasScriptCache = $status;
825 function useBootstrap()
827 $this->useBootstrap = true; // Bootstrapを使用するかどうか
830 * Bootstrapを強制的に未使用に設定
834 function cancelBootstrap()
836 $this->useBootstrap = false; // Bootstrapを使用するかどうか
841 * @return bool true=使用、false=使用しない
843 function getUseBootstrap()
845 return $this->useBootstrap; // Bootstrapを使用するかどうか
854 $this->isHtml5 = true; // HTML5で出力するかどうか
857 * ページ作成処理を中断するかどうかを取得
859 * @return bool true=中断、false=継続
861 function isPageAbort()
863 return $this->isAbort;
868 * @param int $defSerial ページ定義シリアル番号
871 function updateParentWindow($defSerial = 0)
873 $this->updateParentWindow = true;
874 $this->updateDefSerial = $defSerial; // 更新する項目のページ定義シリアル番号
879 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
882 function addCssFile($path)
884 $destPath = trim($path, '/');
885 if (!in_array($destPath, $this->defaultCssFiles)) $this->defaultCssFiles[] = $destPath;
890 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
893 function addAdminCssFile($path)
895 $destPath = trim($path, '/');
896 if (!in_array($destPath, $this->defaultAdminCssFiles)) $this->defaultAdminCssFiles[] = $destPath;
901 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
904 function addScriptFile($path)
906 $destPath = trim($path, '/');
907 if (!empty($destPath) && !in_array($destPath, $this->defaultScriptFiles)) $this->defaultScriptFiles[] = $destPath;
912 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
915 function addAdminScriptFile($path)
917 $destPath = trim($path, '/');
918 if (!in_array($destPath, $this->defaultAdminScriptFiles)) $this->defaultAdminScriptFiles[] = $destPath;
923 * @return string テンプレートID
925 function getOptionTemplateId()
930 $pageId = $gEnvManager->getCurrentPageId();
932 switch ($this->contentType){
933 case M3_VIEW_TYPE_CONTENT: // ページのコンテンツタイプ
935 $contentLibObj = $this->gInstance->getObject(self::CONTENT_OBJ_ID);
936 if (isset($contentLibObj)) $this->optionTemplateId = $contentLibObj->getTemplate();
938 case M3_VIEW_TYPE_BLOG: // ページがブログタイプのとき
939 if ($pageId == $this->gEnv->getDefaultPageId()){ // PCサイトのとき
940 // ブログライブラリオブジェクトからテンプレートを取得
941 $blogLibObj = $this->gInstance->getObject(self::BLOG_OBJ_ID);
942 if (isset($blogLibObj)) $this->optionTemplateId = $blogLibObj->getOptionTemplate();
946 return $this->optionTemplateId;
951 * @return int ウィジェット数
953 function getNonSharedWidgetCount()
955 return $this->nonSharedWidgetCount;
960 * @return string コンテンツタイプ
962 function getContentType()
964 return $this->contentType;
967 * 一般画面で使用する主要コンテンツタイプを取得
969 * @return array コンテンツタイプの配列
971 function getMainContentType()
973 return $this->mainContentType; // 主要コンテンツタイプ
976 * 一般画面で使用する主要機能タイプを取得
978 * @return array 機能タイプの配列
980 function getMainFeatureType()
982 return $this->mainFeatureType; // 主要機能タイプ
987 * HTTPヘッダを設定する。セッションを取得する。サブページIDを設定する。
989 * @param RequestManager $request HTTPリクエスト処理クラス
992 function startPage($request)
995 global $gRequestManager;
996 global $gInstanceManager;
997 global $gAccessManager;
998 global $gSystemManager;
999 global $gDispManager;
1002 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
1003 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
1004 $pageId = $gEnvManager->getCurrentPageId();
1005 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
1007 // クライアントIDの読み込み、再設定
1008 $clientId = $request->getCookieValue(M3_COOKIE_CLIENT_ID);
1009 if (empty($clientId)){ // クライアントIDが設定されていないとき
1011 $clientId = $this->gAccess->createClientId();
1013 $this->gAccess->setClientId($clientId); // クライアントIDを設定
1016 $this->gEnv->setCanUseCookie(true);
1018 $request->setCookieValue(M3_COOKIE_CLIENT_ID, $clientId, M3_COOKIE_EXPIRE_CLIENT_ID);
1020 // 管理者キーがあればGETまたはPOST値のセッションIDを使用する
1021 if ($gEnvManager->isAdminDirAccess()){
1022 if ($gAccessManager->isValidAdminKey()) session_id($gRequestManager->trimValueOf(session_name()));
1025 // インストール時の管理画面用ライブラリを追加(フレームコンテナでの設定を反映)
1026 if (defined('M3_STATE_IN_INSTALL')){
1028 if ($this->useBootstrap){
1029 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
1030 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
1037 // ##### インストール時はここで終了 #####
1038 if (defined('M3_STATE_IN_INSTALL')) return; // インストール時は実行しない
1040 // セッションを再生成する(セキュリティ対策)
1041 if ($gSystemManager->regenerateSessionId()){
1042 $gAccessManager->setOldSessionId(session_id()); // 古いセッションIDを保存
1043 session_regenerate_id(true);
1047 $userInfo = $gRequestManager->getSessionValueWithSerialize(M3_SESSION_USER_INFO);
1048 $gInstanceManager->setUserInfo($userInfo);
1050 // ##### 自動ログイン #####
1051 // ログイン中でない場合は自動ログインでユーザ情報を取得
1052 $gAccessManager->startAutoLogin();
1055 if (M3_SYSTEM_DEBUG) echo 'Debug mode<br />';
1057 // ##### サブページIDの設定 #####
1058 if ($gEnvManager->isAdminDirAccess() && // 管理画面へのアクセスのとき
1059 ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT)){ // ログイン、ログアウト場合は管理画面のページサブIDを指定
1060 $subId = $gEnvManager->getAdminDefaultPageSubId(); // 管理画面用のデフォルトページサブID
1062 $subId = $request->trimValueOf(M3_REQUEST_PARAM_PAGE_SUB_ID);// ページサブIDを取得
1063 if (empty($subId)){ // サブページIDが設定されていないとき
1064 // URLパラメータからコンテンツ形式を取得し、ページを選択
1065 $params = $gRequestManager->getQueryArray();
1066 $paramCount = count($params);
1068 // コマンド以外のパラメータ数が1つだけのときはパラメータからページ属性を判断する
1069 // 値が空でもキーがあれば属性を持つとする
1070 if ($paramCount == 0 && $gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemAdmin() && empty($task)){
1071 // ダッシュボード機能は、パラメータなし、管理者ディレクトリ、システム管理者の条件で使用可能
1072 // POST値にタスクがある場合はダッシュボードとしない
1073 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_DASHBOARD, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1075 // ##### ダッシュボードはページの位置を示すので、ページのコンテンツ属性としない #####
1076 //$this->contentType = M3_VIEW_TYPE_DASHBOARD; // ページのコンテンツタイプ
1077 //if ($paramCount == 1 || !empty($params[M3_REQUEST_PARAM_OPERATION_COMMAND])){
1078 //} else if ($paramCount > 0 || !empty($params[M3_REQUEST_PARAM_OPERATION_COMMAND])){ // コマンド(プレビュー等)のとき、または複数パラメータでも可(2011/9/20)
1079 } else if ($paramCount > 0 && !$gEnvManager->isAdminDirAccess()){ // パラメータ付きの場合(2013/3/23)
1080 // ##### ページ属性から画面を選択(管理画面は対応しない) ###
1081 // 最初のURLパラメータでコンテンツを判断
1082 // プレビュー(cmd=preview)等のパターンで複数パラメータがある
1084 $firstKey = key($params);
1085 $firstValue = $params[$firstKey];
1087 if (!empty($firstValue)){ // 「key=value」の形式であること
1089 case M3_REQUEST_PARAM_CONTENT_ID: // コンテンツIDのとき
1090 case M3_REQUEST_PARAM_CONTENT_ID_SHORT:
1091 // ローカルメニューのURLからページを特定。ページが特定できないときはページ属性で取得。
1092 $url = $gEnvManager->getMacroPath($gEnvManager->getCurrentRequestUri());
1093 $ret = $this->db->getSubPageIdByMenuItemUrl($url, $gEnvManager->getCurrentPageId(), M3_VIEW_TYPE_CONTENT, $rows);
1095 $rowCount = count($rows);
1096 for ($i = 0; $i < $rowCount; $i++){
1097 // コンテンツを表示するウィジェットがあるときはページサブIDを確定
1098 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);
1099 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);// コンテンツタイプでの取得に変更(2012/6/20)
1100 if (!empty($widgetId)){
1101 $subId = $rows[$i]['pd_sub_id'];
1106 if (empty($subId)) $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_CONTENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1107 $this->contentType = M3_VIEW_TYPE_CONTENT; // ページのコンテンツタイプ
1109 case M3_REQUEST_PARAM_PRODUCT_ID: // 製品IDのとき
1110 case M3_REQUEST_PARAM_PRODUCT_ID_SHORT:
1111 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PRODUCT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1112 $this->contentType = M3_VIEW_TYPE_PRODUCT; // ページのコンテンツタイプ
1114 case M3_REQUEST_PARAM_BBS_ID: // 掲示板投稿記事のとき
1115 case M3_REQUEST_PARAM_BBS_ID_SHORT:
1116 case M3_REQUEST_PARAM_BBS_THREAD_ID:
1117 case M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT:
1118 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BBS, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1119 $this->contentType = M3_VIEW_TYPE_BBS; // ページのコンテンツタイプ
1121 case M3_REQUEST_PARAM_EVENT_ID: // イベント記事のとき
1122 case M3_REQUEST_PARAM_EVENT_ID_SHORT:
1123 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_EVENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1124 $this->contentType = M3_VIEW_TYPE_EVENT; // ページのコンテンツタイプ
1126 case M3_REQUEST_PARAM_PHOTO_ID: // フォトギャラリー写真のとき
1127 case M3_REQUEST_PARAM_PHOTO_ID_SHORT:
1128 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PHOTO, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1129 $this->contentType = M3_VIEW_TYPE_PHOTO; // ページのコンテンツタイプ
1131 case M3_REQUEST_PARAM_BLOG_ID: // ブログIDのとき
1132 case M3_REQUEST_PARAM_BLOG_ID_SHORT:
1133 case M3_REQUEST_PARAM_BLOG_ENTRY_ID:
1134 case M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT:
1135 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BLOG, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1136 $this->contentType = M3_VIEW_TYPE_BLOG; // ページのコンテンツタイプ
1138 case M3_REQUEST_PARAM_ROOM_ID: // ユーザ作成コンテンツのとき
1139 case M3_REQUEST_PARAM_ROOM_ID_SHORT:
1140 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_USER, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1141 $this->contentType = M3_VIEW_TYPE_USER; // ページのコンテンツタイプ
1143 // コンテンツを表示するウィジェットを取得
1144 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);
1145 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);// コンテンツタイプでの取得に変更(2012/6/20)
1146 if (!empty($widgetId)){
1147 // ルーム用の定義ID(所属グループID)を取得
1148 $roomId = isset($params[M3_REQUEST_PARAM_ROOM_ID]) ? $params[M3_REQUEST_PARAM_ROOM_ID] : $params[M3_REQUEST_PARAM_ROOM_ID_SHORT];
1149 $configId = $this->db->getWidgetConfigIdForRoom($roomId);
1151 // グループIDを定義IDとするページのページサブIDを取得
1152 $subPageId = $this->getPageSubIdByWidget($gEnvManager->getCurrentPageId(), $widgetId, $configId);
1153 if (!empty($subPageId)) $subId = $subPageId;
1156 default: // オプションのURLコンテンツパラメータからサブページIDを取得
1157 $ret = $this->db->getSubPageIdByUrlContentParam($gEnvManager->getCurrentPageId(), $firstKey, $row);
1158 if ($ret) $subId = $row['pd_sub_id'];
1163 if (isset($params[M3_REQUEST_PARAM_CONTENT_ID]) || isset($params[M3_REQUEST_PARAM_CONTENT_ID_SHORT])){ // コンテンツIDのとき
1164 // ローカルメニューのURLからページを特定。ページが特定できないときはページ属性で取得。
1165 $url = $gEnvManager->getMacroPath($gEnvManager->getCurrentRequestUri());
1166 $ret = $this->db->getSubPageIdByMenuItemUrl($url, $gEnvManager->getCurrentPageId(), $rows);
1168 $rowCount = count($rows);
1169 for ($i = 0; $i < $rowCount; $i++){
1170 // コンテンツを表示するウィジェットがあるときはページサブIDを確定
1171 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);
1172 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);// コンテンツタイプでの取得に変更(2012/6/20)
1173 if (!empty($widgetId)){
1174 $subId = $rows[$i]['pd_sub_id'];
1179 if (empty($subId)) $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_CONTENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1180 $this->contentType = M3_VIEW_TYPE_CONTENT; // ページのコンテンツタイプ
1181 } else if (isset($params[M3_REQUEST_PARAM_PRODUCT_ID]) || isset($params[M3_REQUEST_PARAM_PRODUCT_ID_SHORT])){ // 製品IDのとき
1182 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PRODUCT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1183 $this->contentType = M3_VIEW_TYPE_PRODUCT; // ページのコンテンツタイプ
1184 } else if ((isset($params[M3_REQUEST_PARAM_BBS_ID]) || isset($params[M3_REQUEST_PARAM_BBS_ID_SHORT])) ||
1185 (isset($params[M3_REQUEST_PARAM_BBS_THREAD_ID]) || isset($params[M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT]))){ // 掲示板投稿記事のとき
1186 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BBS, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1187 $this->contentType = M3_VIEW_TYPE_BBS; // ページのコンテンツタイプ
1188 } else if (isset($params[M3_REQUEST_PARAM_EVENT_ID]) || isset($params[M3_REQUEST_PARAM_EVENT_ID_SHORT])){ // イベント記事のとき
1189 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_EVENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1190 $this->contentType = M3_VIEW_TYPE_EVENT; // ページのコンテンツタイプ
1191 } else if (isset($params[M3_REQUEST_PARAM_PHOTO_ID]) || isset($params[M3_REQUEST_PARAM_PHOTO_ID_SHORT])){ // フォトギャラリー写真のとき
1192 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PHOTO, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1193 $this->contentType = M3_VIEW_TYPE_PHOTO; // ページのコンテンツタイプ
1194 } else if ((isset($params[M3_REQUEST_PARAM_BLOG_ID]) || isset($params[M3_REQUEST_PARAM_BLOG_ID_SHORT])) || // ブログIDのとき
1195 (isset($params[M3_REQUEST_PARAM_BLOG_ENTRY_ID]) || isset($params[M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT]))){ // ブログ記事のとき
1196 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BLOG, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1197 $this->contentType = M3_VIEW_TYPE_BLOG; // ページのコンテンツタイプ
1198 } else if (isset($params[M3_REQUEST_PARAM_ROOM_ID]) || isset($params[M3_REQUEST_PARAM_ROOM_ID_SHORT])){ // ユーザ作成コンテンツのとき
1199 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_USER, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1200 $this->contentType = M3_VIEW_TYPE_USER; // ページのコンテンツタイプ
1202 // コンテンツを表示するウィジェットを取得
1203 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);
1204 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $subId, M3_VIEW_TYPE_USER);// コンテンツタイプでの取得に変更(2012/6/20)
1205 if (!empty($widgetId)){
1206 // ルーム用の定義ID(所属グループID)を取得
1207 $roomId = isset($params[M3_REQUEST_PARAM_ROOM_ID]) ? $params[M3_REQUEST_PARAM_ROOM_ID] : $params[M3_REQUEST_PARAM_ROOM_ID_SHORT];
1208 $configId = $this->db->getWidgetConfigIdForRoom($roomId);
1210 // グループIDを定義IDとするページのページサブIDを取得
1211 $subPageId = $this->getPageSubIdByWidget($gEnvManager->getCurrentPageId(), $widgetId, $configId);
1212 if (!empty($subPageId)) $subId = $subPageId;
1219 // 「http://www.example.com?ページ名」「wcmd」の場合はwikiコンテンツページを選択
1220 $wikiCmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND);
1221 $pageName = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
1223 if (!empty($wikiCmd) || !empty($pageName)){ // Wikiコンテンツページを指定のとき
1225 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_WIKI, $gEnvManager->getCurrentPageId());
1226 $this->contentType = M3_VIEW_TYPE_WIKI; // ページのコンテンツタイプ
1229 // その他のGET,POSTパラメータからページサブID取得
1230 if (empty($subId)) $subId = $this->getPageSubIdByParam($request, $gEnvManager->getCurrentPageId());
1232 // ページサブIDが取得できない場合はデフォルトを使用
1233 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
1236 $gEnvManager->setCurrentPageSubId($subId);// サブページIDを設定
1238 // SSL通信機能がオンの場合は、アクセスされたURLのSSLをチェックし不正の場合は正しいURLにリダイレクト
1239 // 設定に間違いがある場合、管理画面にアクセスできなくなるので、一般画面のみ制御
1240 if ($gEnvManager->getUseSsl() || $gEnvManager->getUseSslAdmin()){
1241 if (!$gEnvManager->isAdminDirAccess()){ // 管理画面以外へのアクセスのとき
1242 $isSsl = $gEnvManager->isSslByCurrentPage();
1243 $currentUrl = $gEnvManager->getCurrentRequestUri();
1245 $correctUrl = str_replace('http://', 'https://', $currentUrl);
1247 $correctUrl = str_replace('https://', 'http://', $currentUrl);
1249 if ($currentUrl != $correctUrl) $this->redirect($correctUrl);
1253 $gEnvManager->initMultiDomain();
1256 $gDispManager->load();
1258 // ##### 画面に必要なスクリプトを追加 #####
1259 // スマートフォン用URLのときはスマートフォン用のjQueryを使用
1260 if ($gEnvManager->getIsSmartphoneSite()){
1261 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(10); // スマートフォン用jQueryファイル
1263 if (isset($this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'])){
1264 $scriptFiles = $this->libFiles[ScriptLibInfo::LIB_JQUERYS_MOBILE]['script'];
1265 if (count($scriptFiles) > 0) $this->selectedJQueryMobileFilename = $scriptFiles[0]; // 使用対象のjQueryMobileファイル
1269 // Magic3管理用のスクリプトを追加
1270 if (!$gEnvManager->getIsMobileSite()){ // 携帯用URL以外のとき
1271 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
1272 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
1273 $this->isEditMode = true; // 一般画面編集モード
1274 $this->isPageEditable = true; // 一般画面ページ編集可能モードに設定(コンテキストメニュー表示)
1277 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1278 $this->addAdminScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1280 // Googleマップライブラリの読み込み
1281 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1282 $this->defaultAdminScriptFiles[] = ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS);
1284 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1285 $this->isLayout = true; // 画面レイアウト中かどうか
1286 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_IDTABS); // 管理パネル用スクリプト追加(ポジション表示追加分)
1287 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_DROPDOWN); // 管理パネル用スクリプト追加(ドロップダウンメニュー)
1288 //$this->useBootstrap = true; // Bootstrapを使用
1289 //$this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(一般画面と管理画面の切り替え等)用
1291 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1293 // スクリプトが必要なウィジェットをすべて取得
1294 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1295 for ($i = 0; $i < count($rows); $i++){
1296 $this->addAdminScript($task, trim($rows[$i]['wd_add_script_lib']));
1298 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1300 $widgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
1301 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
1302 if ($ret) $this->addAdminScript($task, trim($this->configWidgetInfo['wd_add_script_lib_a'])); // 管理機能用スクリプト
1305 } else { // 一般画面へのアクセスのとき
1307 $value = $gSystemManager->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
1308 if ($value) $this->addScriptFile($this->selectedJQueryFilename);
1310 if ($cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
1311 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
1312 if ($gEnvManager->isSystemManageUser()){
1313 $this->isEditMode = true; // 一般画面編集モード
1314 $this->isPageEditable = true; // 一般画面ページ編集可能モードに設定
1316 // システム運用権限がある場合は管理用スクリプトを追加
1317 // 一般画面と管理画面の切り替え用のスライドメニューバーには管理用スクリプト,CSSが必要
1318 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1319 $this->addScriptFile(ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME); // jQuery Contextmenu Lib
1320 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1321 //$this->addScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(一般画面と管理画面の切り替え等)用
1322 $this->addScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用スクリプト追加
1323 $this->addScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用スクリプト追加
1324 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1326 $this->addCssFile(self::M3_ADMIN_CSS_FILE); // 管理機能用CSS
1327 // if (!$this->useBootstrap) $this->addCssFile(self::M3_NO_BOOTSTRAP_CSS_FILE); // Bootstrapを読み込まない場合は代替CSSを読み込む
1329 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
1330 if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1331 $this->isEditMode = true; // 一般画面編集モード
1333 //$this->addScript('', ScriptLibInfo::LIB_FCKEDITOR);// FCKEditorスクリプト追加
1334 $this->addScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1335 $this->addScriptFile(self::M3_PLUS_SCRIPT_FILENAME); // 一般画面追加用スクリプト追加(PLUSライブラリを追加する場合はFCKEditorも使用可能にする)
1336 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
1337 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1339 // Googleマップライブラリの読み込み
1340 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1341 $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS));
1349 $row = $this->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
1351 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1352 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1355 $this->currentPageInfo = $row; // 現在のページのページ情報
1359 if ($openBy == 'tabs') $this->isTransparentMode = true; // 画面透過モード
1368 global $gEnvManager;
1369 global $gSystemManager;
1371 $lang = $gEnvManager->getCurrentLanguage();
1373 // デフォルト言語とカレント言語が異なる場合のみ実行
1374 if ($lang != $gEnvManager->getDefaultLanguage()){
1376 $gSystemManager->roadSiteDefByLang($lang);
1380 $this->headDescription = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_DESCRIPTION); // HTMLヘッダ「description」に出力する文字列
1381 $this->headKeywords = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_KEYWORDS); // HTMLヘッダ「keywords」に出力する文字列
1382 $this->headOthers = $gSystemManager->getSiteDef(self::SD_HEAD_OTHERS); // HTMLヘッダに出力するタグ文字列
1384 // デフォルトのページ情報でヘッダを更新
1385 if (!empty($this->currentPageInfo)){
1386 $title = $this->currentPageInfo['pn_meta_title']; // 画面タイトル
1387 $desc = $this->currentPageInfo['pn_meta_description']; // ページ要約
1388 $keyword = $this->currentPageInfo['pn_meta_keywords']; // ページキーワード
1389 $headOthers = $this->currentPageInfo['pn_head_others']; // ヘッダその他タグ
1391 if (!empty($title)) $this->setHeadSubTitle($title);
1392 if (!empty($desc)) $this->setHeadDescription($desc);
1393 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1394 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1397 // 現在の言語のページ情報でヘッダを更新
1398 $ret = $this->db->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $lang, $row);
1400 $title = $row['pn_meta_title']; // 画面タイトル
1401 $desc = $row['pn_meta_description']; // ページ要約
1402 $keyword = $row['pn_meta_keywords']; // ページキーワード
1403 $headOthers = $row['pn_head_others']; // ヘッダその他タグ
1405 if (!empty($title)) $this->setHeadSubTitle($title);
1406 if (!empty($desc)) $this->setHeadDescription($desc);
1407 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1408 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1411 // $this->currentPageInfo = $row; // 現在のページのページ情報
1415 * スクリプト追加情報から、管理機能用のJavascriptファイル、CSSを追加する
1417 * @param string $task 指定タスク
1418 * @param string $scriptInfo スクリプト追加情報
1421 function addAdminScript($task, $scriptInfo)
1423 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1424 for ($i = 0; $i < count($itemArray); $i++){
1425 $pos = strpos($itemArray[$i], '=');
1426 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1427 $libs = trim($itemArray[$i]);
1428 } else { // タスク指定のとき
1429 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1430 $libTask = trim($libTask);
1431 $libs = trim($libs);
1433 if (strEndsWith($libTask, '_')){ // 「task_subtask」形式のタスクのとき
1434 if (!strStartsWith($task, $libTask)) $libs = ''; // タスクIDの先頭部が異なるときは追加しない
1436 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1439 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1440 $libsArray = explode(',', $libs);
1441 for ($j = 0; $j < count($libsArray); $j++){
1442 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1445 $setLibArray = ScriptLibInfo::getLibSet($lib);
1446 $setLibCount = count($setLibArray);
1447 if ($setLibCount > 0){ // ライブラリセットの場合
1448 for ($k = 0; $k < $setLibCount; $k++){
1449 $this->_addAdminScript($setLibArray[$k]);
1452 $this->_addAdminScript($lib);
1459 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1461 * @param string $lib ライブラリID
1464 function _addAdminScript($lib)
1467 if (!isset($this->libFiles[$lib])) return;
1470 if (strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1471 // jQuery UIライブラリを追加
1472 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1473 for ($i = 0; $i < count($dependentLib); $i++){
1474 $addLib = $dependentLib[$i];
1477 if (isset($this->libFiles[$addLib]['script'])){
1478 $scriptFiles = $this->libFiles[$addLib]['script'];
1479 for ($m = 0; $m < count($scriptFiles); $m++){
1480 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1483 if (isset($this->libFiles[$addLib]['css'])){
1484 $cssFiles = $this->libFiles[$addLib]['css'];
1485 for ($m = 0; $m < count($cssFiles); $m++){
1486 $this->addAdminCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1491 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1492 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1493 $this->outputTheme = true;
1497 if (isset($this->libFiles[$lib]['script'])){
1498 $scriptFiles = $this->libFiles[$lib]['script'];
1499 for ($i = 0; $i < count($scriptFiles); $i++){
1500 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1504 if (isset($this->libFiles[$lib]['css'])){
1505 $cssFiles = $this->libFiles[$lib]['css'];
1506 for ($i = 0; $i < count($cssFiles); $i++){
1507 $this->addAdminCssFile($cssFiles[$i]); // 管理機能用のCSS追加
1511 if (strncmp($lib, 'jquery-ui.', 10) == 0){ // jQuery UIのwidgetsまたはeffectsのとき。jQuery UI Coreはデフォルトで読み込まれている。
1513 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1514 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1515 $this->outputTheme = true;
1520 * スクリプト追加情報から、通常機能用のJavascriptファイル、CSSを追加する
1522 * @param string $task 指定タスク
1523 * @param string $scriptInfo スクリプト追加情報
1526 function addScript($task, $scriptInfo)
1529 $jQueryUiInfo = ScriptLibInfo::getJQueryUiInfo();
1531 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1532 for ($i = 0; $i < count($itemArray); $i++){
1533 $pos = strpos($itemArray[$i], '=');
1534 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1535 $libs = trim($itemArray[$i]);
1536 } else { // タスク指定のとき
1537 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1538 $libTask = trim($libTask);
1539 $libs = trim($libs);
1540 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1542 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1543 $libsArray = explode(',', $libs);
1544 for ($j = 0; $j < count($libsArray); $j++){
1545 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1547 // jQueryライブラリ等、デフォルトでは追加されないライブラリを追加
1548 if (strcmp($lib, 'jquery') == 0){// jQuery本体のとき
1549 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1550 } else if (isset($this->libFiles[$lib])){ // ライブラリが存在するとき
1551 // ライブラリの依存ライブラリファイルを追加
1552 if (strncmp($lib, 'jquery.', 7) == 0){ // jQueryプラグインのとき
1553 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1554 if (strcmp($lib, 'jquery.mobile') == 0){ // jQueryMobileファイルのとき
1555 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
1556 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
1557 for ($l = 0; $l < count($this->headPreMobileScriptFiles); $l++){
1558 $this->addScriptFile($this->headPreMobileScriptFiles[$l]); // 通常機能用のスクリプト追加
1562 } else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI) == 0){ // jQuery UI
1563 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1564 //} else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI_PLUS) == 0){ // jQuery UI plus
1565 // $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1566 // $this->addScriptFile($this->selectedJQueryUiFilename); // jQuery Coreスクリプト追加
1567 } else if (strncmp($lib, 'jquery-ui.', 10) == 0){ // jQuery UIのwidgetsまたはeffectsのとき
1569 $parentLib = $jQueryUiInfo[$lib]; // 依存ライブラリ取得
1570 for ($l = 0; $l < count($parentLib); $l++){
1571 $addLib = $parentLib[$l];
1574 if (isset($this->libFiles[$addLib]['script'])){
1575 $scriptFiles = $this->libFiles[$addLib]['script'];
1576 for ($m = 0; $m < count($scriptFiles); $m++){
1577 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1580 if (isset($this->libFiles[$addLib]['css'])){
1581 $cssFiles = $this->libFiles[$addLib]['css'];
1582 for ($m = 0; $m < count($cssFiles); $m++){
1583 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1588 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1589 //$this->addHeadCssFile($this->getAdminDefaultThemeUrl()); // CSS追加
1590 $this->addHeadCssFile($this->getDefaultThemeUrl()); // CSS追加
1591 $this->outputTheme = true;
1596 if (isset($this->libFiles[$lib]['script'])){
1597 $scriptFiles = $this->libFiles[$lib]['script'];
1598 for ($l = 0; $l < count($scriptFiles); $l++){
1599 $this->addScriptFile($scriptFiles[$l]); // 通常機能用のスクリプト追加
1602 if (isset($this->libFiles[$lib]['css'])){
1603 $cssFiles = $this->libFiles[$lib]['css'];
1604 for ($l = 0; $l < count($cssFiles); $l++){
1605 $this->addCssFile($cssFiles[$l]); // 通常機能用のCSS追加
1614 * 非ログイン時の管理機能用のJavascriptファイル、CSSを追加する
1616 * @param string $libId 追加ライブラリID
1619 function addDefaultAdminScript($libId)
1622 if (isset($this->libFiles[$libId]['script'])){
1623 $scriptFiles = $this->libFiles[$libId]['script'];
1624 for ($i = 0; $i < count($scriptFiles); $i++){
1625 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
1629 if (isset($this->libFiles[$libId]['css'])){
1630 $cssFiles = $this->libFiles[$libId]['css'];
1631 for ($i = 0; $i < count($cssFiles); $i++){
1632 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
1641 * ・ウィジェットで生成されたHTTPヘッダを設定する
1643 * @param RequestManager $request HTTPリクエスト処理クラス
1644 * @param bool $getOutput 出力を取得するかどうか
1645 * @return string 最終出力HTML
1647 function endPage($request, $getOutput = false)
1649 global $gRequestManager;
1650 global $gInstanceManager;
1651 global $gEnvManager;
1652 global $gDispManager;
1653 global $gAccessManager;
1656 if ($this->isAbort) return '';
1661 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
1663 // 最終HTML(ページ全体で使用するHTML)の出力
1664 if ($cmd != M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体オペレーションのときは出力しない
1666 $contents = $this->getLastContents($request);
1668 echo $this->getLastContents($request);
1673 $userInfo = $gInstanceManager->getUserInfo();
1674 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
1677 $gDispManager->save();
1679 // キャッシュリミッタは、各リクエスト毎に(アウトプットバッファー が無効な場合は、
1680 // session_start()がコールされる 前に) session_cache_limiter()をコールする必要がある。
1682 // session_cache_limiter('private');
1683 // session_cache_expire(5);
1684 if ($this->isRedirect) return ''; // リダイレクトの場合は終了
1686 // ########## HTTPヘッダ出力処理 ########
1687 if (headers_sent($filename, $linenum)){ // HTTPヘッダが既に送信されているとき
1688 echo "$filename の $linenum 行目でヘッダがすでに送信されています。";
1690 if ($gEnvManager->isMobile()){ // 携帯の場合
1691 // ドコモ端末の場合はリクエストヘッダにXHTMLを指定しないとXHTMLを処理しない
1692 $agent = $gInstanceManager->getMobileAgent();
1693 if ($agent->isDoCoMo()){ // ドコモ端末のとき
1694 header('Content-Type: application/xhtml+xml;');
1698 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// 過去の日付
1699 header('Cache-Control: no-store, no-cache, must-revalidate');// HTTP/1.1
1700 header('Cache-Control: post-check=0, pre-check=0', false);
1701 header('Pragma: no-cache');
1704 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
1706 // Ajax用JSON型データをHTTPヘッダに格納
1707 $gInstanceManager->getAjaxManager()->header();
1709 // システム制御画面が設定されている場合はステータスコードを変更
1710 //if ($this->gEnv->getIsMaintenance()){
1711 if (!$this->isRedirect){ // リダイレクトがセットされていない場合
1712 switch ($this->systemHandleMode){
1713 case 10: // サイト非公開(システムメンテナンス)
1714 header('HTTP/1.1 503 Service Temporarily Unavailable');
1715 header('Status: 503 Service Temporarily Unavailable');
1717 case 11: // アクセス禁止のとき
1718 header('HTTP/1.1 403 Forbidden');
1719 header('Status: 403 Forbidden');
1721 case 12: // 存在しないページのとき
1722 header("HTTP/1.1 404 Not Found");
1723 header("Status: 404 Not Found");
1728 // ##### 自動ログイン #####
1729 $gAccessManager->endAutoLogin();
1738 function abortPage()
1740 global $gInstanceManager;
1741 global $gRequestManager;
1743 // HTTPヘッダを削除(PHP 5.3以上で有効)
1744 if (version_compare(PHP_VERSION, '5.3.0') >= 0) header_remove();
1746 // exit()等でabortPage()が最後の処理になってしまう可能性があるのでなるべく必要な処理を行う
1747 //if (ob_get_level() > 0) ob_end_clean();// バッファ内容が残っているときは破棄
1748 while (ob_get_level()) ob_end_clean(); // バッファ削除方法変更(2009/12/2)
1751 $userInfo = $gInstanceManager->getUserInfo();
1752 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
1754 $this->isAbort = true; // ページ作成処理を中断するかどうか
1761 function exitSystem()
1763 global $gEnvManager;
1764 global $gAccessManager;
1766 // DBが使用可能であれば、アクセスログのユーザを登録
1767 if ($gEnvManager->canUseDb()) $gAccessManager->accessLogUser();
1772 * Joomla!v1.5タグを読み込んでウィジェット実行
1774 * @param string $srcBuf バッファデータ
1775 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
1776 * @return string 変換後文字列
1778 function launchWidgetByJoomlaTag($srcBuf, $templateVer)
1784 if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\/>#iU', $srcBuf, $matches)){
1785 $count = count($matches[1]);
1786 for ($i = 0; $i < $count; $i++)
1789 $type = $matches[1][$i];
1791 if (strcasecmp($type, 'head') == 0){ // ヘッダ埋め込みタグの場合
1794 $contents = ob_get_contents();
1795 } else if (strcasecmp($type, 'modules') == 0 ||
1796 strcasecmp($type, 'module') == 0){ // ポジションタグの場合
1797 $name = ''; // ポジション名
1798 $style = ''; // 表示スタイル
1799 $params = explode(' ', $matches[2][$i]);
1800 for ($j = 0; $j < count($params); $j++){
1801 list($key, $value) = explode('=', $params[$j]);
1802 if (strcasecmp($key, 'name') == 0){
1803 $name = strtolower(trim($value, "\"'"));
1804 $attr['name'] = $name;
1805 } else if (strcasecmp($key, 'style') == 0){
1807 $style = trim($value, "\"'");
1808 } else if (strcasecmp($key, 'artstyle') == 0){ // 表示スタイル
1809 $attr['artstyle'] = trim($value, "\"'");
1812 if (!empty($name)){ // ポジション名が取得できたとき
1813 // Joomla!では、テンプレートの「jdoc:include」タグの属性styleが空のときは「none」で処理される
1814 // Joomla!デフォルトで設定可能なのは「none,table,horz,xhtml,rounded,outline」
1816 if (strStartsWith($name, 'user') || // ナビゲーションメニュー位置の場合
1817 strcasecmp($name, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
1818 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
1824 $contents = $this->getContents($name, $style, $templateVer, $attr);
1826 } else if (strcasecmp($type, 'component') == 0){ // メインポジションタグの場合
1828 $style = ''; // 表示スタイル
1829 $params = explode(' ', $matches[2][$i]);
1830 for ($j = 0; $j < count($params); $j++){
1831 list($key, $value) = explode('=', $params[$j]);
1832 if (strcasecmp($key, 'style') == 0){
1834 $style = trim($value, "\"'");
1838 if ($style != 'none') $style = 'xhtml';
1839 $contents = $this->getContents('main', $style, $templateVer, $attr);
1840 } else if (strcasecmp($type, 'message') == 0){ // メッセージタグの場合
1842 $replace[$i] = $contents;
1845 $destBuf = str_replace($matches[0], $replace, $srcBuf);
1852 * 遅延実行インデックスのついているウィジェットをインデックス順に実行し、出力バッファデータ内のタグの位置に出力を埋め込む
1854 * @param RequestManager $request HTTPリクエスト処理クラス
1855 * @param string $srcBuf バッファデータ
1856 * @return string 変換後文字列
1858 function lateLaunchWidget($request, $srcBuf)
1860 global $gEnvManager;
1861 global $gErrorManager;
1862 global $gDesignManager;
1864 // ウィジェットヘッダ(Joomla!1.0用)を出力のタイプを取得
1865 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
1867 // 遅延実行ウィジェットをインデックス順にソート
1868 asort($this->lateLaunchWidgetList, SORT_NUMERIC);
1872 foreach ($this->lateLaunchWidgetList as $widgetId => $value){
1874 $count = count($this->latelaunchWidgetParam);
1875 for ($i = 0; $i < $count; $i++){
1876 list($wId, $index, $confId, $preId, $serial, $style, $cssStyle, $title, $shared) = $this->latelaunchWidgetParam[$i];
1877 if ($wId == $widgetId){
1879 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
1880 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
1881 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
1887 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
1890 $configId = $confId; // ウィジェット定義ID
1891 if ($configId == 0) $configId = '';
1892 $prefix = $preId; // サフィックス文字列
1894 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
1895 $joomlaTitleVisble = false;
1896 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
1897 if (!empty($title)){
1898 if ($widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
1899 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
1900 echo '<tr><th>' . $title . '</th></tr>' . M3_NL;
1901 echo '<tr><td>' . M3_NL;
1902 $joomlaTitleVisble = true;
1903 } else if ($widgetHeaderType == 2){ // 携帯用ウィジェットヘッダ出力
1904 echo '<div>' . $title . '</div>' . M3_NL;
1905 $joomlaTitleVisble = true;
1910 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
1911 // ウィジェット親のCSS定義があるときは、タグを追加
1912 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
1915 echo $gDesignManager->getAdditionalWidgetOutput(true);
1918 $gEnvManager->setCurrentWidgetId($widgetId);
1921 $gEnvManager->setCurrentWidgetConfigId($configId);
1924 $gEnvManager->setCurrentPageDefSerial($serial);
1927 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
1930 $gEnvManager->setCurrentWidgetTitle('');
1933 $gEnvManager->setCurrentWidgetStyle($style);
1935 // ウィジェットのページ共通状況を設定
1936 $gEnvManager->setIsCurrentWidgetShared($shared);
1939 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
1942 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
1943 $msg = 'widget-start(' . $widgetId . ')';
1944 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
1945 require($widgetIndexFile);
1946 $msg = 'widget-end(' . $widgetId . ')';
1947 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
1950 $gEnvManager->setCurrentWidgetId('');
1953 $gEnvManager->setCurrentWidgetConfigId('');
1956 $gEnvManager->setCurrentPageDefSerial(0);
1959 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
1962 $gEnvManager->setCurrentWidgetStyle('');
1964 // ウィジェットのページ共通状況を解除
1965 $gEnvManager->setIsCurrentWidgetShared(false);
1968 $newTitle = $gEnvManager->getCurrentWidgetTitle();
1971 echo $gDesignManager->getAdditionalWidgetOutput(false);
1973 // ウィジェット親のCSS定義があるときは、タグを追加
1974 if (!empty($cssStyle)) echo '</div>' . M3_NL;
1976 //echo '</div>' . M3_NL;
1978 // Joomla!1.0テンプレートのときはタイトルを出力
1979 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
1980 echo '</td></tr>' . M3_NL;
1981 echo '</table>' . M3_NL;
1984 // 現在のバッファ内容を取得し、バッファを破棄
1985 $srcContents = ob_get_contents();
1989 $tag = self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $index . self::WIDGET_ID_TAG_END;
1990 $destBuf = str_replace($tag, $srcContents, $destBuf);
1993 if (!empty($newTitle)) $title = $newTitle;
1994 $tag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $index . self::WIDGET_ID_TITLE_TAG_END;
1995 $destBuf = str_replace($tag, $title, $destBuf);
1999 $destBuf = $this->replaceHead($destBuf);
2005 * @param string $srcBuf 変換元
2006 * @return string 変換後文字列
2008 function replaceHead($srcBuf)
2012 // ##### ヘッダ部分の置換 #####
2013 if ($this->outputHead){ // HTMLヘッダ出力を行っているとき
2015 $replaceStr = $this->getHeaderOutput();
2018 $destBuf = str_replace(self::HEAD_TAGS, $replaceStr, $destBuf);
2020 $this->replaceHeadDone = true; // ヘッダマクロ変換処理が完了したかどうか
2024 * ウィジェット検索モードの場合のページサブIDの設定
2026 * @param RequestManager $request HTTPリクエスト処理クラス
2028 function redirectToUpdatedPageSubId($request)
2030 global $gEnvManager;
2032 // 現在設定されているページIDを取得
2033 $pageId = $gEnvManager->getCurrentPageId();
2034 $pageSubId = $gEnvManager->getCurrentPageSubId();
2037 $fromWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_FROM);
2040 $targetWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
2042 // 対象のウィジェットのページサブIDを取得
2043 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2044 if ($ret){// データが存在する
2045 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2046 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2047 if ($ret){// データが存在する
2048 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2050 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2055 for ($i = 0; $i < count($rows); $i++){
2056 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2061 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2062 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2064 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2067 } else { // 対象のウィジェットが見つからない場合は、互換ウィジェットを探す
2068 $widgetId = $this->db->getCompatibleWidgetId($targetWidgetId);
2069 if (!empty($widgetId)){
2070 $targetWidgetId = $widgetId;
2072 // 対象のウィジェットのページサブIDを取得
2073 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2074 if ($ret){// データが存在する
2075 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2076 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2077 if ($ret){// データが存在する
2078 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2080 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2085 for ($i = 0; $i < count($rows); $i++){
2086 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2091 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2092 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2094 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2100 // ページサブIDが見つからないときは、既に設定されている値を使用
2101 // 既に設定されている値は、URL「sub」パラメータで指定されている値か
2102 // 設定されていない場合はデフォルトのサブページID
2103 // ********** 指定ページへリダイレクト ***********
2105 $todo = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TODO);
2106 $todo = str_replace(M3_TODO_SEPARATOR, '&', $todo); // セパレータを変換
2107 $redirectUrl = '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2108 if (!empty($todo)) $redirectUrl .= '&' . $todo;
2109 if ($gEnvManager->getIsMobileSite()){ // 携帯用アクセスポイントの場合
2110 $this->redirect($redirectUrl, true/*遷移時のダイアログ表示を抑止*/);
2112 $this->redirect($redirectUrl);
2118 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2119 * 追加するHTMLは主にウィンドウ管理用のスクリプト
2121 * @param RequestManager $request HTTPリクエスト処理クラス
2122 * @return string 最終HTML
2124 function getLastContents($request)
2126 global $gEnvManager;
2129 $initScript = ''; // 初期化用スクリプト
2130 $pageId = $gEnvManager->getCurrentPageId();
2131 $pageSubId = $gEnvManager->getCurrentPageSubId();
2132 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2135 if ($cmd == M3_REQUEST_CMD_RSS) return '';
2137 if ($gEnvManager->getIsMobileSite()){ // 携帯用URLのとき
2138 } else { // PC用URLのとき
2139 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2140 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
2141 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
2143 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
2144 //$contents .= '<div class="clear"></div>' . M3_NL;
2146 $contents .= '<div id="m3_overlay">' . M3_NL; // ロード中表示
2147 $contents .= '<div id="preloader"><img src="' . $gEnvManager->getImagesUrl() . '/system/loader.gif" alt="" /></div>' . M3_NL;
2148 $contents .= '</div>' . M3_NL;*/
2151 if (count($this->viewPosId) > 0){
2153 for ($i = 0; $i < count($this->viewPosId); $i++){
2154 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
2155 //$posArrayStr .= '\'' . $this->viewPosId[$i] . '\'';
2156 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
2158 $posArrayStr .= ']';
2159 $contents .= 'var M3_POSITIONS=' . $posArrayStr . ';' . M3_NL;
2162 $contents .= 'var M3_REVISION=' . $this->pageDefRev . ';' . M3_NL;
2165 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2166 $contents .= M3_INDENT_SPACE . 'window.m3.m3UpdateByConfig(serial);' . M3_NL;
2167 $contents .= '}' . M3_NL;
2169 // 携帯用テンプレートのときは、プレビューウィンドウの更新を通知する
2170 /*if ($gEnvManager->getCurrentTemplateType() == 1){
2171 $contents .= 'if (window.parent.m3UpdateByChildWindow) window.parent.m3UpdateByChildWindow();' . M3_NL;
2173 } else if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定画面
2175 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2176 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2177 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2178 $contents .= M3_INDENT_SPACE . 'm3UpdateParentWindow();' . M3_NL; // 親ウィンドウ更新
2179 $contents .= '}' . M3_NL;
2182 $contents .= 'function hideIEErrors(){' . M3_NL;
2183 $contents .= M3_INDENT_SPACE . 'return true;' . M3_NL;
2184 $contents .= '}' . M3_NL;
2185 $contents .= 'window.onerror = hideIEErrors;' . M3_NL;
2186 } else { // ダッシュボード画面、メイン管理画面
2188 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2189 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2190 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2191 $contents .= '}' . M3_NL;
2194 // ウィジェット単体実行以外のときの処理
2195 if (!$this->showWidget){
2196 if ($this->updateParentWindow){ // 管理画面からの親画面の更新
2197 $initScript .= M3_INDENT_SPACE . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
2201 // ##### ヘルプシステムの組み込み #####
2202 // ヘルプシステムはすべての初期処理完了後に実行する
2203 // ヘルプシステムは、「span」タグで埋め込み、「title」属性を使用する
2204 if ($this->useHelp){ // ヘルプ表示のとき
2205 $initScript .= M3_INDENT_SPACE . '$(\'span.m3help\').cluetip({splitTitle: \'|\', cluezIndex: 2000});' . M3_NL;
2206 //if ($cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示以外のとき
2207 $initScript .= M3_INDENT_SPACE . 'if (jQuery().tooltip) $(\'[rel=m3help]\').tooltip({ placement: \'top\'});' . M3_NL; // Bootstrapツールチップ。タイトルのみ表示。
2209 } else { // ヘルプ非表示のときは、title属性をクリアする
2210 $initScript .= M3_INDENT_SPACE . '$(\'span.m3help\').attr(\'title\', \'\');' . M3_NL;
2214 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
2216 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2217 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2218 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2219 $contents .= '}' . M3_NL;
2224 if (!empty($contents) || !empty($initScript)){
2225 $destContents .= '<script type="text/javascript">' . M3_NL;
2226 $destContents .= '//<![CDATA[' . M3_NL;
2227 $destContents .= $contents;
2228 if (!empty($initScript)){ // 初期化用スクリプト
2229 $destContents .= '$(function(){' . M3_NL;
2230 $destContents .= $initScript;
2231 $destContents .= '});' . M3_NL;
2233 $destContents .= '//]]>' . M3_NL;
2234 $destContents .= '</script>' . M3_NL;
2236 return $destContents;
2241 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2243 * @param RequestManager $request HTTPリクエスト処理クラス
2244 * @return string 最終HTML
2246 function getOptionContents($request)
2248 global $gEnvManager;
2253 if (!$gEnvManager->isMobile() && $this->outputByHtml){ // 携帯以外で、HTML出力のとき
2254 $contents .= '<!-- created by ' . M3_SYSTEM_NAME . ' v' . M3_SYSTEM_VERSION . ' - http://www.magic3.org -->' . M3_NL;
2255 $contents .= '<!-- convert time: ' . sprintf('%01.03f', microtime(true) - M3_MTIME) . ' -->' . M3_NL;
2260 * Widget単体起動用のHTMLのヘッダ部(headタグ)出力
2262 * Widgetの出力方法は、以下のパターンがある
2263 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
2264 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
2266 * @param string $cmd 起動コマンド
2268 function startWidget($cmd)
2270 global $gEnvManager;
2271 global $gRequestManager;
2273 // ウィジェット単体表示のときのみ出力
2274 if (!$this->showWidget) return;
2277 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
2278 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
2280 // $isHtml5 = false; // HTML5で出力するかどうか
2281 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
2282 if (intval($tempVer) >= 2) $this->isHtml5 = true; // HTML5で出力するかどうか
2285 if ($this->isHtml5){
2286 echo '<!DOCTYPE html>' . M3_NL;
2287 echo '<html dir="ltr" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2288 echo '<head>' . M3_NL;
2290 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . M3_NL;
2291 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $gEnvManager->getCurrentLanguage() . '" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2292 echo '<head>' . M3_NL;
2293 // echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' . M3_NL;
2296 // HTMLのヘッダ部(headタグ内)出力
2300 $widgetId = $gEnvManager->getCurrentWidgetId(); // カレントのウィジェットID
2303 if ($gEnvManager->getUseSslAdmin()){
2304 $rootUrl = $gEnvManager->getSslRootUrl();
2305 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
2306 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
2308 $rootUrl = $gEnvManager->getRootUrl();
2309 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
2310 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
2313 // ##### テンプレートのCSSの読み込み #####
2314 // テンプレートは管理用テンプレートに固定されている
2315 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定のとき
2316 $curTemplateUrl = $templatesUrl . '/' . $gEnvManager->getCurrentTemplateId();
2317 if ($this->isHtml5){
2318 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/style.css" media="screen">' . M3_NL;
2319 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/widget.css" media="screen">' . M3_NL; // ウィジェット設定画面用CSS
2320 echo '<!--[if IE]><link rel="stylesheet" href="' . $curTemplateUrl . '/css/iestyles.css" media="screen"><![endif]-->' . M3_NL;
2321 echo '<!--[if lt IE 9]><script src="' . $curTemplateUrl . '/html5shiv.js"></script><![endif]-->' . M3_NL;
2323 echo '<link href="' . $curTemplateUrl . '/css/style.css" rel="stylesheet" type="text/css" />' . M3_NL;
2324 echo '<!--[if IE]><link rel="stylesheet" type="text/css" media="screen" href="' . $curTemplateUrl . '/css/iestyles.css" /><![endif]-->' . M3_NL;
2328 $ret = $this->db->getWidgetInfo($widgetId, $row);
2330 // ##### 共通ライブラリ読み込み設定 #####
2331 if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
2332 $scritLib = trim($row['wd_add_script_lib']);
2333 if (!empty($scritLib)) $this->addScript($task, $scritLib);
2336 // CSS読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2337 if ($row['wd_read_css']){
2338 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_CSS;
2339 if (is_dir($searchPath)){
2340 $dir = dir($searchPath);
2341 while (($file = $dir->read()) !== false){
2342 $filePath = $searchPath . '/' . $file;
2343 if ($file != '.' && $file != '..' && is_file($filePath)
2344 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
2347 $cssURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_CSS . '/' . $file;
2348 echo '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2355 // スクリプト読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2356 if ($row['wd_read_scripts']){
2357 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS;
2358 if (is_dir($searchPath)){
2359 $dir = dir($searchPath);
2360 while (($file = $dir->read()) !== false){
2361 $filePath = $searchPath . '/' . $file;
2362 if ($file != '.' && $file != '..' && is_file($filePath)
2363 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
2366 $scriptURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
2368 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
2369 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
2370 echo '<script type="text/javascript" src="' . $scriptURL . '"></script>' . M3_NL;
2378 $title = $row['wd_name'];
2379 if (empty($title)) $title = $row['wd_id'];
2380 echo '<title>' . self::WIDGET_TITLE_START . htmlspecialchars($title) . self::WIDGET_TITLE_END . '</title>' . M3_NL;
2381 echo '</head>' . M3_NL;
2382 // タブでウィンドウを開く場合は背景を透過モードにする
2383 if ($this->isTransparentMode){
2384 echo '<body style="background-color:transparent;">' . M3_NL;
2386 echo '<body>' . M3_NL;
2389 if ($this->useBootstrap) echo '<div class="container">' . M3_NL;
2391 // 別ウィンドウで表示のときは、「閉じる」ボタンを表示
2392 if ($cmd == M3_REQUEST_CMD_SHOW_WIDGET || // ウィジェットの単体表示のとき
2393 $cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット詳細設定画面のとき
2394 $cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
2396 if ($this->isEditMode){// 一般画面編集モードのとき
2397 if (!empty($openBy)){
2398 // サーバ指定されている場合はサーバ情報を取得
2400 $server = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_SERVER);
2401 if (!empty($server)){
2403 $ret = $this->db->getServerById($server, $row);
2405 $serverName = 'サーバ名:' . $row['ts_name'];// サーバ名
2406 echo '<div align="left" style="float:left;padding-left:30px;"><label>' . convertToHtmlEntity($serverName) . '</label></div>';
2409 // タブ形式以外のときは「閉じる」ボタンを表示
2410 if ($openBy != 'tabs'){
2411 if ($openBy == 'logout'){
2412 $titleStr = 'ログアウト';
2413 echo '<div class="m3configclose"><a href="#" onclick="location.href=\'?cmd=logout\';"><img src="' . $rootUrl . self::CLOSE_ICON_FILE .
2414 '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></div>' . M3_NL;
2417 echo '<div class="m3configclose"><a href="#" onclick="window.close();"><img src="' . $rootUrl . self::CLOSE_ICON_FILE .
2418 '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></div>' . M3_NL;
2424 echo '<div class="m3configprev" style="display:none;"><a id="m3configprev" href="#"><img src="' . $rootUrl . self::PREV_ICON_FILE .
2425 '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></div>' . M3_NL;
2427 echo '<div class="m3confignext" style="display:none;"><a id="m3confignext" href="#"><img src="' . $rootUrl . self::NEXT_ICON_FILE .
2428 '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></div>' . M3_NL;
2431 echo '<div class="row">' . M3_NL;
2432 echo '<!-- Widget Start -->' . M3_NL;
2435 * Widget単体起動用のタグを閉じる
2437 * @param string $cmd 起動コマンド
2439 function endWidget($cmd)
2441 // ウィジェット単体表示のときのみ出力
2442 if (!$this->showWidget) return;
2444 echo '</div>' . M3_NL;
2445 echo '<!-- Widget End -->' . M3_NL;
2447 // ##### ウィジェットからの指定による処理 #####
2448 if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
2449 echo '<script type="text/javascript">' . M3_NL;
2450 echo '//<![CDATA[' . M3_NL;
2451 echo '$(function(){' . M3_NL;
2452 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
2453 echo str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
2454 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
2455 echo str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
2458 echo '//]]>' . M3_NL;
2459 echo '</script>' . M3_NL;
2463 if ($this->useBootstrap) echo '</div>' . M3_NL;
2465 echo '</body>' . M3_NL;
2466 echo '</html>' . M3_NL;
2469 * Widget単体RSS出力用のHTMLのヘッダ部(headタグ)出力
2471 * Widgetの出力方法は、以下のパターンがある
2472 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
2473 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
2475 * @param string $cmd 起動コマンド
2477 function startWidgetRss($cmd)
2481 * Widget単体RSS出力用のタグを閉じる
2483 * @param string $cmd 起動コマンド
2484 * @param string $rssContent RSS配信内容
2486 function endWidgetRss($cmd, $rssContent)
2488 global $gEnvManager;
2491 if ($this->isAbort) return;
2493 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
2496 $lang = $gEnvManager->getCurrentLanguage();
2497 $date = getW3CDate(); // RSS1.0用日付
2498 $copyright = $gEnvManager->getSiteCopyRight(); // 著作権
2499 $title = $this->rssChannel['title']; // タイトル
2500 $link = $this->rssChannel['link']; // RSS取得用URL
2501 $desc = $this->rssChannel['description']; // 説明
2502 $seq = $this->rssChannel['seq']; // 項目の並び順(URL)
2504 switch ($this->rssVersion){ // RSSバージョン
2507 echo '<rdf:RDF xmlns="http://purl.org/rss/1.0/" ';
2508 echo 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
2509 echo 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
2510 echo 'xml:lang="' . $lang . '">' . M3_NL;
2511 echo '<channel rdf:about="' . convertUrlToHtmlEntity($link) . '">' . M3_NL;
2512 echo '<title>' . convertToHtmlEntity($title) . '</title>' . M3_NL;
2513 echo '<link>' . convertUrlToHtmlEntity($link) . '</link>' . M3_NL; // 「convertUrlToHtmlEntity」が必要
2514 echo '<description>' . convertToHtmlEntity($desc) . '</description>' . M3_NL;
2515 echo '<dc:language>' . $lang . '</dc:language>' . M3_NL;
2516 if (!empty($copyright)) echo '<dc:rights>' . convertToHtmlEntity($copyright) . '</dc:rights>' . M3_NL;
2517 echo '<dc:date>' . $date . '</dc:date>' . M3_NL;
2518 echo '<items>' . M3_NL;
2519 if (count($seq) > 0){
2520 echo str_repeat(M3_INDENT_SPACE, 1) . '<rdf:Seq>' . M3_NL;
2521 for ($i = 0; $i < count($seq); $i++){
2522 echo str_repeat(M3_INDENT_SPACE, 2) . '<rdf:li rdf:resource="' . convertUrlToHtmlEntity($seq[$i]) . '" />' . M3_NL;
2524 echo str_repeat(M3_INDENT_SPACE, 1) . '</rdf:Seq>' . M3_NL;
2526 echo '</items>' . M3_NL;
2527 echo '</channel>' . M3_NL;
2529 echo '</rdf:RDF>' . M3_NL;
2536 header("Content-type: text/xml; charset=utf-8");
2539 * 直サーバ接続時のXML出力用のHTMLのヘッダ部(headタグ)出力
2541 * @param string $cmd 起動コマンド
2544 function startWidgetXml($cmd)
2547 //header("Content-type: text/xml; charset=utf-8");
2552 * @param string $cmd 起動コマンド
2555 function endWidgetXml()
2561 * @return string ドキュメントタイプ出力
2563 function getMobileDocType()
2565 global $gEnvManager;
2566 global $gInstanceManager;
2567 global $gRequestManager;
2569 $docTypeStr = ''; // 出力するDocType
2570 $agent = $gInstanceManager->getMobileAgent();
2571 if ($agent->isDoCoMo()){ // ドコモ端末のとき
2572 $htmlVer = $agent->getHTMLVersion();
2575 $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">';
2578 $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">';
2581 $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">';
2584 $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">';
2587 $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">';
2590 $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">';
2593 if (preg_match("/^DoCoMo\/1\.0/i", $gRequestManager->trimServerValueOf('HTTP_USER_AGENT'))){ // mova端末のとき
2594 // mova端末のときはドキュメントタイプなしにすると画面表示可能
2599 } else if ($agent->isEZweb()){ // au端末のとき
2600 if ($agent->isWAP2()){
2601 $docTypeStr = '<!DOCTYPE html PUBLIC "-//OPENWAVE//DTD XHTML 1.0//EN" "http://www.openwave.com/DTD/xhtml-basic.dtd">';
2603 } else if ($agent->isSoftBank()){ // ソフトバンク端末のとき
2604 if ($agent->isTypeW() || $agent->isType3GC()){
2605 $docTypeStr = '<!DOCTYPE html PUBLIC "-//J-PHONE//DTD XHTML Basic 1.0 Plus//EN" "xhtml-basic10-plus.dtd">';
2608 if ($gEnvManager->getIsMobileSite()){ // 携帯用サイトへのアクセスの場合
2609 echo '<?xml version="1.0" encoding="' . $gEnvManager->getMobileCharset() . '" ?>' . M3_NL;
2611 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
2613 if (empty($docTypeStr)) $docTypeStr = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
2614 echo $docTypeStr . M3_NL;
2619 * @return string XML宣言
2621 function getDefaultXmlDeclaration()
2623 return '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>';
2626 * HTMLのヘッダ部(headタグ内)出力
2628 * システムに共通な定義をHTMLのheadタグ内に出力する
2629 * mosFunc.phpからも実行されるので、このメソッドは引数なしに固定。
2630 * この関数は、以下の「形式1」または「形式2」でheadタグ内に記述する
2632 * 形式1: <!-- m3:HTMLHeader -->
2633 * 形式2(old style): <?php mosShowHead(); ?>
2635 function getHeader()
2637 global $gEnvManager;
2638 global $gRequestManager;
2640 $this->outputHead = true; // HTMLヘッダ出力を行ったかどうか
2643 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2645 // ######### 携帯用サイトの場合は別にヘッダを作成する #########
2646 if ($gEnvManager->getIsMobileSite()){
2648 echo '<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=' . $gEnvManager->getMobileCharset() . '" />' . M3_NL;
2651 echo '<meta http-equiv="Pragma" content="no-cache" />' . M3_NL;
2652 echo '<meta http-equiv="Cache-Control" content="no-cache" />' . M3_NL;
2653 echo '<meta http-equiv="Expires" content="-1" />' . M3_NL;
2656 echo '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
2657 } else { // PC用サイト、管理用サイト、スマートフォン用サイトのとき
2658 // $isHtml5 = false; // HTML5で出力するかどうか
2659 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
2660 $this->isHtml5 = true;
2662 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
2663 if (intval($tempVer) >= 2) $this->isHtml5 = true;
2666 // ********** メタタグの設定 **********
2669 //if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
2670 if ($this->isHtml5){
2671 //echo '<meta http-equiv="content-type" content="text/html; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
2672 echo '<meta charset="' . M3_HTML_CHARSET . '">' . M3_NL;
2674 echo '<meta http-equiv="content-script-type" content="text/javascript" />' . M3_NL;
2675 echo '<meta http-equiv="content-style-type" content="text/css" />' . M3_NL;
2676 echo '<meta http-equiv="content-type" content="application/xhtml+xml; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
2680 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 表示位置を表示するとき
2681 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
2683 if ($gEnvManager->getUseSslAdmin()){
2684 $rootUrl = $gEnvManager->getSslRootUrl();
2686 $rootUrl = $gEnvManager->getRootUrl();
2688 echo '<base href="' . $rootUrl . '/" />' . M3_NL;
2691 echo self::HEAD_TAGS; // HTMLヘッダの埋め込みデータ
2696 * @return string HTMLヘッダ出力文字列
2698 function getHeaderOutput()
2700 global $gEnvManager;
2701 global $gRequestManager;
2702 global $gInstanceManager;
2703 global $gSystemManager;
2705 $replaceStr = ''; // 変換文字列
2708 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2709 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
2711 // ********************************************************
2713 // ********************************************************
2714 // ##### テンプレートの設定、フレームの設定から必要なライブラリを取得 #####
2716 // if (!$this->useBootstrap) $this->useBootstrap = $gEnvManager->getCurrentTemplateUseBootstrap();
2717 if ($this->useBootstrap){
2718 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2719 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
2720 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
2721 if ($cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)以外のとき
2722 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
2724 } else { // ログインしていない場合(ログイン画面等)
2725 $this->addDefaultAdminScript(ScriptLibInfo::LIB_BOOTSTRAP);
2726 $this->addDefaultAdminScript(ScriptLibInfo::LIB_BOOTSTRAP_ADMIN);// Bootstrap管理画面オプション
2728 } else { // 一般画面へのアクセスの場合
2729 $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 一般画面でBootstrapを使用するかどうか
2730 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW){ // ログイン、ログアウト場合
2731 $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
2735 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
2736 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2737 //$this->addAdminCssFile(self::M3_NO_BOOTSTRAP_CSS_FILE); // Bootstrapを読み込まない場合は代替CSSを読み込む
2738 $this->addAdminScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
2740 //$this->addCssFile(self::M3_NO_BOOTSTRAP_CSS_FILE); // Bootstrapを読み込まない場合は代替CSSを読み込む
2741 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
2746 // ********************************************************
2748 // ********************************************************
2749 // ##### インストール時のヘッダ出力 #####
2750 if (defined('M3_STATE_IN_INSTALL')){
2753 if (count($this->headSubTitle) > 0) $title = htmlspecialchars(trim($this->headSubTitle[0]));
2755 // ********** メタタグの設定 **********
2756 $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
2758 // ##### インストーラ用のファイルの読み込み #####
2759 $scriptsUrl = '../scripts';
2761 // 管理機能用共通ライブラリのCSSの読み込み
2762 $count = count($this->defaultAdminCssFiles);
2763 for ($i = 0; $i < $count; $i++){
2765 $cssFilename = $this->defaultAdminCssFiles[$i];
2766 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
2767 $cssURL = $cssFilename;
2769 $cssURL = $scriptsUrl . '/' . $cssFilename;
2771 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2774 // 管理画面用の共通スクリプトを読み込む
2775 $count = count($this->defaultAdminScriptFiles);
2776 for ($i = 0; $i < $count; $i++){
2777 $scriptFilename = $this->defaultAdminScriptFiles[$i];
2780 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
2781 $scriptURL = $scriptFilename;
2785 $scriptURL = str_replace('http://', 'https://', $scriptURL);
2787 $scriptURL = str_replace('https://', 'http://', $scriptURL);
2790 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
2793 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
2794 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
2795 $replaceStr .= '<script type="text/javascript" src="' . $scriptURL . '"></script>' . M3_NL;
2801 $cleanType = $gEnvManager->getCurrentTemplateCleanType(); // テンプレートクリーンタイプ
2802 /* if ($this->db->getTemplate($gEnvManager->getCurrentTemplateId(), $templateRow)){
2803 $cleanType = $templateRow['tm_clean_type'];
2808 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2810 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
2812 $isSslPage = $this->isSslPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
2815 $rootUrl = $gEnvManager->getSslRootUrl();
2816 $scriptsUrl = $gEnvManager->getSslScriptsUrl(); // スクリプト読み込み用パス
2817 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
2818 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
2820 $rootUrl = $gEnvManager->getRootUrl();
2821 $scriptsUrl = $gEnvManager->getScriptsUrl(); // スクリプト読み込み用パス
2822 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
2823 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
2827 if (!$this->showWidget){// 単体実行以外のとき
2828 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスの場合
2830 // メイン画面は「サイト名 - 管理画面」、サブ画面は個別画面名
2831 $siteName = $gEnvManager->getSiteName();
2832 // if (empty($siteName)) $siteName = self::DEFAULT_SITE_NAME;
2833 $title = $siteName . ' - ' . self::DEFAULT_ADMIN_TITLE;
2834 $titleCount = count($this->headSubTitle);
2835 if ($titleCount > 0) $title = $this->headSubTitle[$titleCount -1]; // サブタイトルが設定されている場合は変更
2836 $replaceStr .= '<title>' . htmlspecialchars($title) . '</title>' . M3_NL;
2837 } else { // 管理画面以外の画面へのアクセスの場合
2839 $titleItemCount = 0; // タイトル項目数
2840 $defaultTitle = trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_TITLE));
2841 if (!empty($defaultTitle)) $titleItemCount++;
2842 if (!empty($this->headSubTitle)){ // サブタイトルが設定されているとき
2843 $titleItemCount += count($this->headSubTitle);
2847 if ($titleItemCount > 0){
2848 $format = $this->gSystem->getSystemConfig(self::CONFIG_KEY_HEAD_TITLE_FORMAT);
2849 if (empty($format)){
2850 $title = htmlspecialchars($defaultTitle);
2852 $formats = explode(';', $format);
2853 $titleItemCount = ($titleItemCount > count($formats)) ? count($formats) : $titleItemCount;
2854 $title = $formats[$titleItemCount -1];
2856 if (!empty($defaultTitle)){
2857 $title = str_replace('$1', htmlspecialchars($defaultTitle), $title);
2860 for ($i = 0; $i < count($this->headSubTitle); $i++){
2861 $key = '$' . $number;
2862 $value = htmlspecialchars(trim($this->headSubTitle[$i]));
2863 $title = str_replace($key, $value, $title);
2868 if (!empty($title)) $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
2871 if (!empty($this->headDescription)) $replaceStr .= '<meta name="description" content="' . htmlspecialchars($this->headDescription) . '" />' . M3_NL;
2874 if (!empty($this->headKeywords)) $replaceStr .= '<meta name="keywords" content="' . htmlspecialchars($this->headKeywords) . '" />' . M3_NL;
2876 // その他HTMLヘッダに出力するタグ文字列
2877 if (!empty($this->headOthers)){
2879 $this->headOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->headOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
2880 $replaceStr .= $this->headOthers . M3_NL;
2885 // ##### PC用URLと携帯用URLのアクセス別に処理 #####
2886 if ($gEnvManager->getIsMobileSite()){ // 携帯用URLのとき
2887 } else { // PC用URLまたはスマートフォン用URLのとき
2888 // ##### テンプレート情報に応じた処理 #####
2889 // テンプレートクリーンが必要な場合はJQueryを追加
2890 if ($cleanType != 0) $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
2893 $robots = htmlspecialchars(trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_ROBOTS)));
2894 if (!empty($robots)){
2895 $replaceStr .= '<meta name="robots" content="' . $robots . '" />' . M3_NL;
2899 $replaceStr .= '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
2902 $templateId = $gEnvManager->getCurrentTemplateId();
2903 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2904 // テンプレートのFaviconがない場合はシステムのデフォルトのFaviconを使用
2905 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
2906 if (file_exists($faviconPath)){ // ファイルが存在しているとき
2907 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
2908 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
2911 $faviconPath = $gEnvManager->getSystemRootPath() . self::DEFAULT_ADMIN_FAVICON_FILE;
2912 if (file_exists($faviconPath)){ // ファイルが存在しているとき
2913 $faviconFile = $rootUrl . self::DEFAULT_ADMIN_FAVICON_FILE;
2914 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
2918 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
2919 if (file_exists($faviconPath)){ // ファイルが存在しているとき
2920 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
2921 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
2924 // ##### 追加ライブラリの読み込み #####
2925 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用URLのとき
2926 $value = $gSystemManager->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面で常にjQuery Mobileを使用
2928 // ##### jQueryMobileが読み込まれる前に読み込む必要があるスクリプトを設定 #####
2929 if (!empty($this->headPreMobileScriptFiles)){ // jQueryMobileファイルの前に出力
2930 for ($l = 0; $l < count($this->headPreMobileScriptFiles); $l++){
2931 $this->addScriptFile($this->headPreMobileScriptFiles[$l]); // 通常機能用のスクリプト追加
2934 $this->addScriptFile($this->selectedJQueryMobileFilename);
2938 // ##### Ajaxライブラリの読み込み #####
2939 if (!$gEnvManager->isAdminDirAccess()){ // 通常画面へのアクセスのとき
2940 if ($this->db->isExistsWidgetWithAjax($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId())){// Ajaxライブラリを使用しているウィジェットがあるときは追加
2941 $this->addScriptFile($this->selectedJQueryFilename); // デフォルトAjaxライブラリ追加
2942 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
2946 // ##### 共通ライブラリの読み込み #####
2947 if (!$this->showWidget){// 単体実行以外のとき
2948 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
2949 for ($i = 0; $i < count($rows); $i++){
2950 $this->addScript($task, trim($rows[$i]['wd_add_script_lib']));
2954 // ##### 共通CSS読み込み #####
2955 if ($this->isEditMode){ // 一般画面編集モード
2956 $cssURL = $scriptsUrl . '/' . self::M3_EDIT_CSS_FILE;
2957 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2959 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2960 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
2961 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
2962 // 管理機能用共通ライブラリのCSSの読み込み
2963 $count = count($this->defaultAdminCssFiles);
2964 for ($i = 0; $i < $count; $i++){
2966 //$cssURL = $scriptsUrl . '/' . $this->defaultAdminCssFiles[$i];
2967 $cssFilename = $this->defaultAdminCssFiles[$i];
2968 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
2969 $cssURL = $cssFilename;
2971 $cssURL = $scriptsUrl . '/' . $cssFilename;
2973 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2976 // 管理権限なしで管理ディレクトリアクセスで必要なCSSファイルを読み込む
2977 $count = count($this->defaultAdminDirCssFiles);
2978 for ($i = 0; $i < $count; $i++){
2980 $cssURL = $scriptsUrl . '/' . $this->defaultAdminDirCssFiles[$i];
2981 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2986 $count = count($this->defaultCssFiles);
2987 for ($i = 0; $i < $count; $i++){
2989 $cssURL = $scriptsUrl . '/' . $this->defaultCssFiles[$i];
2990 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
2994 // ##### 表示モードによるCSS読み込み #####
2995 // ウィジェット付きポジション画面は管理画面のアクセスではない
2996 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
2998 $cssURL = $scriptsUrl . self::M3_ADMIN_WIDGET_CSS_FILE;
2999 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3002 // ##### ウィジェットごとのCSS読み込み #####
3004 $this->db->getWidgetsIdWithCss($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3005 for ($i = 0; $i < count($rows); $i++){
3006 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS;
3007 // ディレクトリがあるときはディレクトリ内読み込み
3008 if (is_dir($searchPath)){
3009 $dir = dir($searchPath);
3010 while (($file = $dir->read()) !== false){
3011 $filePath = $searchPath . '/' . $file;
3012 if ($file != '.' && $file != '..' && is_file($filePath)
3013 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3016 $cssURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS . '/' . $file;
3017 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3023 // ウィジェットからの追加のCSS読み込み
3024 $count = count($this->headCssFiles);
3025 for ($i = 0; $i < $count; $i++){
3026 $cssUrl = $this->headCssFiles[$i];
3027 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3028 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssUrl . '" />' . M3_NL;
3031 // ##### RSS配信情報の読み込み #####
3032 $count = count($this->headRssFiles);
3033 for ($i = 0; $i < $count; $i++){
3034 $rssUrl = $this->headRssFiles[$i]['href'];// リンク先URL
3035 $rssTitle = $this->headRssFiles[$i]['title'];// タイトル
3036 $replaceStr .= '<link rel="alternate" type="application/rss+xml" title="' . $rssTitle . '" href="' . convertUrlToHtmlEntity($rssUrl) . '" />' . M3_NL;
3039 // ##### 共通Javascriptの読み込み #####
3040 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3041 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3042 // 管理画面用の共通スクリプトを読み込む
3043 $count = count($this->defaultAdminScriptFiles);
3044 for ($i = 0; $i < $count; $i++){
3045 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3048 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3049 $scriptURL = $scriptFilename;
3053 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3055 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3058 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3061 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3062 //$scriptURL = $scriptsUrl . '/' . $scriptFilename;
3063 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3064 $replaceStr .= '<script type="text/javascript" src="' . $scriptURL . '"></script>' . M3_NL;
3066 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示のときは、ウィジェット操作ライブラリを読み込む
3068 $scriptURL = $scriptsUrl . '/' . self::M3_ADMIN_WIDGET_SCRIPT_FILENAME;
3069 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();// スクリプトをキャッシュ保存しない場合は、パラメータを付加
3070 $replaceStr .= '<script type="text/javascript" src="' . $scriptURL . '"></script>' . M3_NL;
3072 } else { // システム運用権限がない場合
3073 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3074 $count = count($this->defaultAdminDirScriptFiles);
3075 for ($i = 0; $i < $count; $i++){
3076 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3078 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3079 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3080 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3081 $replaceStr .= '<script type="text/javascript" src="' . $scriptURL . '"></script>' . M3_NL;
3085 // Googleマップライブラリの読み込み
3086 if ($this->useGooglemaps && $this->isContentGooglemaps) $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS)); // コンテンツにGoogleマップが含むかどうか
3088 $count = count($this->defaultScriptFiles);
3089 for ($i = 0; $i < $count; $i++){
3090 $defaultScriptFile = $this->defaultScriptFiles[$i];
3092 // ##### jQueryMobileスクリプトを追加する場合は直前に初期化スクリプトを追加 #####
3093 if ($defaultScriptFile == $this->selectedJQueryMobileFilename){
3094 if (count($this->headPreMobileScript) > 0){
3095 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3096 $replaceStr .= '//<![CDATA[' . M3_NL;
3097 for ($j = 0; $j < count($this->headPreMobileScript); $j++){
3098 $replaceStr .= $this->headPreMobileScript[$j];
3100 $replaceStr .= M3_NL;
3101 $replaceStr .= '//]]>' . M3_NL;
3102 $replaceStr .= '</script>' . M3_NL;
3107 if (strncasecmp($defaultScriptFile, 'http://', 7) == 0 || strncasecmp($defaultScriptFile, 'https://', 8) == 0){
3108 $scriptURL = $defaultScriptFile;
3112 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3114 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3117 $scriptURL = $scriptsUrl . '/' . $defaultScriptFile;
3120 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3121 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3122 $replaceStr .= '<script type="text/javascript" src="' . $scriptURL . '"></script>' . M3_NL;
3125 // ##### ウィジェットごとのJavaScript読み込み #####
3126 // スクリプトがあるウィジェットを取得
3127 $this->db->getWidgetsIdWithScript($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3128 for ($i = 0; $i < count($rows); $i++){
3129 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS;
3131 // ディレクトリがあるときはディレクトリ内読み込み
3132 if (is_dir($searchPath)){
3133 $dir = dir($searchPath);
3134 while (($file = $dir->read()) !== false){
3135 $filePath = $searchPath . '/' . $file;
3136 if ($file != '.' && $file != '..' && is_file($filePath)
3137 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3140 $scriptURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
3141 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3142 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3143 $replaceStr .= '<script type="text/javascript" src="' . $scriptURL . '"></script>' . M3_NL;
3149 // ウィジェットからの追加のCSS読み込み
3150 $count = count($this->headScriptFiles);
3151 for ($i = 0; $i < $count; $i++){
3152 $scriptUrl = $this->headScriptFiles[$i];
3153 if ($isSslPage) $scriptUrl = str_replace('http://', 'https://', $scriptUrl); // SSL化が必要なときは変換
3155 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3156 if (!$this->hasScriptCache) $scriptUrl .= $this->getCacheParam();
3157 $replaceStr .= '<script type="text/javascript" src="' . $scriptUrl . '"></script>' . M3_NL;
3161 $openType = $this->gSystem->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE);// ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
3163 // ##### ページへJavascriptの埋め込む #####
3164 // JavaScriptグローバル変数の設定
3165 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
3166 //$replaceStr .= '<!--' . M3_NL;
3167 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3168 $replaceStr .= '//<![CDATA[' . M3_NL;
3169 $replaceStr .= '// Magic3 Global values' . M3_NL;
3170 $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3172 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()){ // 管理画面へのアクセス、システム運用権限があり
3173 $pageId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID); // ページID
3174 $pageSubId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);// ページサブID
3177 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
3178 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
3181 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
3182 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
3184 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3186 // Googleマップライブラリの読み込み
3187 if ($this->useGooglemaps){
3188 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
3190 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
3193 // ウィジェット詳細設定画面専用のJavaScriptグローバル変数
3194 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){
3195 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3196 } else if (!empty($pageId)){
3197 $accessPoint = $this->gEnv->getAllDefaultPageId();
3198 for ($i = 0; $i < count($accessPoint); $i++){
3199 if ($pageId == $accessPoint[$i]){
3200 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $i . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3206 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3207 if (!empty($task)){ // 戻りタスクが設定されているときのみ最大化可能
3208 $replaceStr .= 'function gobackPagedef(){' . M3_NL;
3209 $replaceStr .= ' window.location.href = "' . $gEnvManager->getDefaultAdminUrl() . '?pageid=' . $pageId . '&pagesubid=' . $pageSubId . '&task=' . $task . '";' . M3_NL;
3210 $replaceStr .= '}' . M3_NL;
3211 $replaceStr .= '$(function(){' . M3_NL;
3212 $replaceStr .= ' $(document).keyup(function(e){' . M3_NL;
3213 $replaceStr .= ' if (e.which == 36) gobackPagedef();' . M3_NL;
3214 $replaceStr .= ' });' . M3_NL;
3215 $replaceStr .= '});' . M3_NL;
3218 // ##### 管理用テンプレートを使用している場合の処理 #####
3219 // Bootstrap用のスクリプト処理
3220 if ($this->useBootstrap){
3221 $replaceStr .= '$(function(){' . M3_NL;
3222 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
3223 $replaceStr .= '});' . M3_NL;
3226 } else if ($this->isPageEditable){ // 一般画面ページ編集可能モードのとき
3227 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
3228 if ($openType != '') $replaceStr .= 'var M3_CONFIG_WINDOW_OPEN_TYPE = ' . $openType . ';' . M3_NL;
3231 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
3232 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
3234 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3235 } else if ($this->isEditMode){ // 一般画面編集モード
3237 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3240 // ##### パネルメニュー(一般画面と管理画面の切り替え等)の表示 #####
3241 // PC用、携帯用、スマートフォン用画面とウィジェット付きポジションの管理画面時に表示
3242 if (($gEnvManager->isAdminDirAccess() && $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) || // 管理画面(ウィジェット付きポジション表示)のとき
3243 (!$gEnvManager->isAdminDirAccess() && // 一般用画面のとき
3244 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
3245 $cmd != M3_REQUEST_CMD_RSS)){ // RSS配信でない
3246 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
3247 if ($gEnvManager->isSystemManageUser()){ // システム運用権限ありの場合
3250 $adminTag = ''; // 管理画面ボタン
3251 $editTag = ''; // 編集ボタン
3252 $logoutTag = ''; // ログアウトボタン
3254 if ($gEnvManager->isAdminDirAccess()){ // 管理画面(ウィジェット付きポジション表示)の場合
3256 /* $titleStr = '編集終了';
3257 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
3258 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
3259 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
3260 $editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
3263 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
3264 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
3265 $editTag = '<div class="m3editend"><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
3266 $editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></div>';
3267 $linkStr .= $editTag;
3269 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
3270 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").prepend(\'' . $linkStr . '\');' . M3_NL; // appendでうまく表示できないのでprependで表示
3271 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
3272 } else if ($this->isAccessPointWithAdminMenu){ // 通常画面は、管理メニューを使用するアクセスポイントの場合のみ表示
3275 $linkUrl = $gEnvManager->getDefaultAdminUrl();
3276 $adminTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
3277 $adminTag .= '<img src="' . $rootUrl . self::ADMIN_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
3281 $linkUrl = $gEnvManager->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' .M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET;
3282 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_ID . '=' . $gEnvManager->getCurrentPageId();
3283 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
3284 $linkUrl .= '&' . M3_REQUEST_PARAM_BACKUP_URL . '=' . urlencode($gEnvManager->getCurrentRequestUri()); // URL退避用
3285 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
3286 $editTag .= '<img src="' . $rootUrl . self::EDIT_PAGE_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
3289 $titleStr = 'ログアウト';
3290 // if ($gEnvManager->isAdminDirAccess()){ // 管理画面の場合
3291 // $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
3292 // if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
3294 $linkUrl = $gEnvManager->getCurrentRequestUri();
3296 $linkUrl = createUrl($linkUrl, M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_LOGOUT);
3297 $logoutTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
3298 $logoutTag .= '<img src="' . $rootUrl . self::LOGOUT_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
3300 $linkStr .= '<div id="m3slidepanel">';
3301 $linkStr .= '<div class="m3panelopener m3topleft"><a href="#"><i class="glyphicon glyphicon-align-justify"></i></a></div>';
3302 $linkStr .= '<div style="top:-60px; visibility: visible;" class="m3panel_top m3-navbar-default">';
3303 $linkStr .= '<div tabindex="0" class="m3panel_wrap">';
3304 $linkStr .= '<ul class="m3-nav m3-navbar-nav">';
3305 if ($gEnvManager->isSystemAdmin()){ // 管理画面、編集モードは、管理者権限がある場合のみ有効
3306 $linkStr .= $adminTag;
3307 $linkStr .= $editTag;
3309 $linkStr .= $logoutTag;
3310 $linkStr .= '</ul>';
3311 $linkStr .= '</div>';
3312 $linkStr .= '</div>';
3313 $linkStr .= '</div>';
3315 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
3316 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").append(\'' . $linkStr . '\');' . M3_NL;
3317 //$this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("#m3slidemenubarpanel").m3SlideMenubar();' . M3_NL;
3318 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(".m3panel_top").m3slidepanel({ "position": "top", "type": "push" });' . M3_NL;
3319 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").css("position", "relative");' . M3_NL;
3320 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
3324 // 一般画面からのウィジェット操作用ツールバー
3325 if (!$gEnvManager->isAdminDirAccess() &&
3326 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
3327 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
3328 if ($gEnvManager->isSystemManageUser()){ // 一般用画面で管理者権限がある場合のみ有効
3330 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').each(function(){' . M3_NL;
3331 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var attrs = m3_splitAttr($(this).attr(\'m3\'));' . M3_NL;
3332 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var widgetId = attrs[\'widgetid\'];' . M3_NL;
3333 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var serialNo = attrs[\'serial\'];' . M3_NL;
3334 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var configId = attrs[\'configid\'];' . M3_NL;
3335 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var useconfig = attrs[\'useconfig\'];' . M3_NL;
3337 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'\';' . M3_NL;
3338 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (useconfig == 1){' . M3_NL;
3339 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
3340 'html += \'<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\\\'\' + widgetId + \'\\\', \' + configId + \', \' + serialNo + \');return false;" >' .
3341 '<img src="' . $rootUrl . self::CONFIG_ICON32_FILE . '" alt="ウィジェット設定" title="ウィジェット設定" width="32" height="32" /></a>\';' . M3_NL;
3342 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
3343 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
3344 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) .
3345 'html += \'<a href="javascript:void(0);" onclick="m3ShowAdjustWindow(\' + configId + \', \' + serialNo + \', M3_PAGE_ID, M3_PAGE_SUB_ID);return false;" >' .
3346 '<img src="' . $rootUrl . self::ADJUST_ICON32_FILE . '" alt="タイトル・位置調整" title="タイトル・位置調整" width="32" height="32" /></a>\';' . M3_NL;
3348 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (html != \'\'){' . M3_NL;
3349 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
3350 'html = \'<div class="m3tooltip" style="display:none;">\' + html + \'<a class="m3closebox" href="javascript:void(0);">' .
3351 '<img src="' . $rootUrl . self::CLOSE_BOX_ICON32_FILE . '" alt="閉じる" title="閉じる" width="11" height="11" /></a></div>\';' . M3_NL;
3353 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).append(html);' . M3_NL;
3354 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
3356 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).click(function(){' . M3_NL;
3357 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
3358 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (tooltipObj.css(\'display\') == \'none\'){' . M3_NL;
3359 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.show();' . M3_NL;
3360 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
3361 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.hide();' . M3_NL;
3362 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
3363 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
3364 // ウィジェットボーダーハイライト、ツールチップ表示
3365 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).hover(function(){' . M3_NL;
3366 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).addClass(\'m3_widget_highlight\');' . M3_NL;
3367 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
3368 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var pos = $(this).position();' . M3_NL;
3369 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var width = $(this).outerWidth();' . M3_NL;
3370 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipWidth = tooltipObj.outerWidth(true);' . M3_NL;
3371 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var x = pos.left + width - tooltipWidth;' . M3_NL;
3372 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var y = pos.top;' . M3_NL;
3373 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'tooltipObj.css({position: "absolute",top: y + "px", left: x + "px"}).show();' . M3_NL;
3374 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}, function(){' . M3_NL;
3375 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).removeClass(\'m3_widget_highlight\');' . M3_NL;
3376 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
3377 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'tooltipObj.hide();' . M3_NL;
3378 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
3380 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3closebox\').click(function(event){' . M3_NL;
3381 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).children(\'.m3tooltip\').hide();' . M3_NL;
3382 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
3384 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
3385 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var offset = $(this).offset();' . M3_NL;
3386 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).outerWidth();' . M3_NL;
3387 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3edittool\').each(function(){' . M3_NL;
3388 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).offset({left: offset.left});' . M3_NL;
3389 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).width(width);' . M3_NL;
3390 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
3391 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
3394 $this->initScript .= M3_INDENT_SPACE . 'var widgetWindow = \'<div class="m3_contextmenu" id="m3_widgetmenu" style="visibility:hidden;">\';' . M3_NL;
3395 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<ul>\';' . M3_NL;
3396 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
3397 $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;
3399 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<li id="m3_wconfig"><img src="\' + M3_ROOT_URL + \'/images/system/config.png" /> <span>ウィジェットの設定</span></li>\';' . M3_NL;
3400 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</ul>\';' . M3_NL;
3401 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</div>\';' . M3_NL;
3402 $this->initScript .= M3_INDENT_SPACE . '$("body").append(widgetWindow);' . M3_NL;
3403 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').contextMenu(\'m3_widgetmenu\', {' . M3_NL;
3404 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'menuStyle: {' . M3_NL;
3405 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// border : "2px solid green",' . M3_NL;
3406 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'backgroundColor: \'#FFFFFF\',' . M3_NL;
3407 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'width: "150px",' . M3_NL;
3408 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'textAlign: \'left\',' . M3_NL;
3409 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'font: \'12px/1.5 Arial, sans-serif\'' . M3_NL;
3410 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
3411 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'itemStyle: {' . M3_NL;
3412 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'padding: \'3px 3px\'' . M3_NL;
3413 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
3414 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'bindings: {' . M3_NL;
3415 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wconfig\': function(t){' . M3_NL;
3416 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
3417 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
3418 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'alert("このウィジェットには設定画面がありません");' . M3_NL;
3419 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'return;' . M3_NL;
3420 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
3421 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowConfigWindow(attrs[\'widgetid\'], attrs[\'configid\'], attrs[\'serial\']);' . M3_NL;
3422 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '},' . M3_NL;
3423 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wadjust\': function(t){' . M3_NL;
3424 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
3425 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowAdjustWindow(attrs[\'configid\'], attrs[\'serial\'], M3_PAGE_ID, M3_PAGE_SUB_ID);' . M3_NL;
3426 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
3427 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
3428 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onContextMenu: function(e){' . M3_NL;
3429 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'return true;' . M3_NL;
3430 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
3431 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onShowMenu: function(e, menu){' . M3_NL;
3432 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// メニュー項目の変更' . M3_NL;
3433 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var attrs = m3_splitAttr($(e.target).parents(\'dl\').attr(\'m3\'));' . M3_NL;
3434 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
3435 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(\'#m3_wconfig\', menu).remove();' . M3_NL;
3436 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
3437 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'return menu;' . M3_NL;
3438 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
3439 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
3442 // ポップアップメッセージがある場合は表示
3443 if (!empty($this->popupMsg)){
3444 $replaceStr .= 'alert("' . $this->popupMsg . '");' . M3_NL;
3447 if ($cleanType == 1){
3448 // HTMLのクリーン処理が必要なときはコードを埋め込む
3449 $this->initScript .= ' $(\'.PostHeaderIcons\').remove();' . M3_NL;// 不要なアイコン表示タグの削除
3450 $this->initScript .= ' $(\'.PostMetadataHeader\').each(function(i){' . M3_NL;
3451 $this->initScript .= ' if ($(this).text().trim() == \'\') $(this).remove();' . M3_NL;
3452 $this->initScript .= ' });' . M3_NL;
3455 if (!empty($this->initScript)){
3456 $replaceStr .= '$(function(){' . M3_NL;
3457 $replaceStr .= $this->initScript;
3458 $replaceStr .= '});' . M3_NL;
3461 //$replaceStr .= '// -->' . M3_NL;
3462 //$replaceStr .= '</script>' . M3_NL;
3463 $replaceStr .= '//]]>' . M3_NL;
3464 $replaceStr .= '</script>' . M3_NL;
3466 // HEADタグに埋め込むCSS,JavaScript,任意文字列
3467 if (count($this->headCss) > 0){
3468 // CSSの場合は全体をstyleタグで囲む
3469 $replaceStr .= '<style type="text/css">' . M3_NL;
3470 $replaceStr .= '<!--' . M3_NL;
3471 for ($i = 0; $i < count($this->headCss); $i++){
3472 $replaceStr .= $this->headCss[$i];
3474 $replaceStr .= M3_NL . '//-->' . M3_NL;
3475 $replaceStr .= '</style>' . M3_NL;
3477 if (count($this->headScript) > 0){
3478 // JavaScriptの場合は全体をscriptタグで囲む
3479 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
3480 //$replaceStr .= '<!--' . M3_NL;
3481 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3482 $replaceStr .= '//<![CDATA[' . M3_NL;
3483 for ($i = 0; $i < count($this->headScript); $i++){
3484 $replaceStr .= $this->headScript[$i];
3486 //$replaceStr .= M3_NL . '//-->' . M3_NL;
3487 //$replaceStr .= '</script>' . M3_NL;
3488 $replaceStr .= M3_NL;
3489 $replaceStr .= '//]]>' . M3_NL;
3490 $replaceStr .= '</script>' . M3_NL;
3492 if (count($this->headString) > 0){
3494 for ($i = 0; $i < count($this->headString); $i++){
3495 $replaceStr .= $this->headString[$i];
3504 * @param string $position HTMLテンプレート上の書き出し位置
3505 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
3506 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
3507 * @param array $attr その他属性
3508 * @return string 出力コンテンツ
3510 function getContents($position, $style = '', $templateVer = 0, $attr = array())
3512 static $render; // Joomla!v1.5テンプレート用
3513 global $gRequestManager;
3514 global $gEnvManager;
3517 $filename = $gEnvManager->getCurrentPageId();
3518 $subId = $gEnvManager->getCurrentPageSubId();
3519 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
3521 // ポジション名表示モードに応じて出力を作成
3522 $contents = ''; // 出力コンテンツ
3523 switch ($this->showPositionMode){
3525 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
3526 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
3527 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
3528 if ($ret){ // 1行以上データが取得できたとき
3529 $this->pageDefRows = $rows; // ページ定義レコード
3530 $this->pageDefPosition = $position;
3532 $this->pageDefRows = array();
3533 $this->pageDefPosition = '';
3537 $count = count($this->pageDefRows);
3539 if ($templateVer == 0){ // echo出力のとき(Joomla!v1.0テンプレートの場合)
3540 ob_start();// バッファ作成
3542 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
3543 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
3544 for ($i = 0; $i < $count; $i++){
3545 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
3546 $widgetId = $this->pageDefRows[$i]['wd_id'];
3548 // ### 遅延実行ウィジェットはキャッシュしない ###
3549 // キャッシュデータがあるときはキャッシュデータを使用
3550 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
3552 if (empty($cacheData)){ // キャッシュデータがないとき
3554 $ret = $this->pageDefLoop($i, $this->pageDefRows[$i], $style, $titleTag, $widgetHeaderType);
3556 $widgetContent = ob_get_contents();
3559 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
3561 // ウィジェットの内枠(コンテンツ外枠)を設定
3562 $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
3565 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
3566 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
3569 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
3570 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
3571 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
3572 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
3573 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
3574 if ($this->isPageEditable){ // 一般画面ページ編集可能モードのとき
3575 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
3576 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
3577 $hasAdmin = '0'; // 管理画面があるかどうか
3578 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
3579 $shared = '0'; // 共通属性があるかどうか
3580 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
3581 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
3582 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
3583 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget" rel="#m3editwidget" ' . $m3Option . '>' . $widgetContent . '</div>';
3585 } else { // キャッシュデータがあるとき
3586 $widgetContent = $cacheData;
3589 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
3590 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
3591 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
3593 $contents .= $widgetContent;
3595 ob_end_clean(); // バッファ破棄
3597 if ($i < $count) return '';// 処理中断のときは終了
3598 } else { // Joomla!v1.5テンプレートの場合
3599 for ($i = 0; $i < $count; $i++){
3600 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
3601 $widgetId = $this->pageDefRows[$i]['wd_id'];
3603 // ### 遅延実行ウィジェットはキャッシュしない ###
3604 // キャッシュデータがあるときはキャッシュデータを使用
3605 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
3607 if (empty($cacheData)){ // キャッシュデータがないとき
3609 $gEnvManager->setCurrentWidgetTitle('');
3611 // Joomla用のパラメータを初期化
3612 $gEnvManager->setCurrentWidgetJoomlaParam(array());
3615 $ret = $this->pageDefLoop($i, $this->pageDefRows[$i], $style, $titleTag, false);
3616 $widgetContent = ob_get_contents();
3618 $trimContent = trim($widgetContent);
3619 if (!empty($trimContent)){ // 出力が空でない場合
3620 $isRendered = false; // Joomla!の描画処理を行ったかどうか
3621 if (!empty($this->pageDefRows[$i]['pd_use_render'])){ // Joomla!の描画処理を使用する場合
3622 // Joomla!ウィジェットの出力に埋め込む
3623 if (strcasecmp($style, 'none') != 0){
3625 if (!isset($render)) $render = new JRender();
3627 // デフォルトのウィジェットタイトル取得
3628 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
3631 $joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
3633 // 遅延ウィジェットのときはタイトルタグを埋め込む
3634 if (!empty($titleTag)) $defaultTitle = $titleTag;
3636 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
3637 $title = $this->pageDefRows[$i]['pd_title'];
3638 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
3639 if (empty($title)) $title = $defaultTitle;
3641 $title = ''; // タイトルは非表示
3645 $params = array(); // ウィジェットごとの属性
3646 $widgetType = $this->pageDefRows[$i]['wd_type']; // ウィジェットタイプ
3648 // オプションのJoomlaクラス(縦型メニュー(art-vmenu)等)
3649 $joomlaClass = $this->pageDefRows[$i]['wd_joomla_class']; // 「wd_joomla_class」は使っていない?
3650 if (!empty($joomlaClass)) $params['moduleclass_sfx'] = $joomlaClass;
3651 if (isset($joomlaParam['moduleclass_sfx'])) $params['moduleclass_sfx'] = $joomlaParam['moduleclass_sfx'];// ウィジェットでjoomla用パラメータの設定があるとき
3653 if (strcmp($position, 'main') == 0){// メイン部のとき
3654 // ウィジェットの内枠(コンテンツ外枠)を設定
3655 // ウィジェットの内枠はレンダーで設定
3656 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
3658 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
3659 } else if (strStartsWith($position, 'user') || // ナビゲーションメニュー位置の場合
3660 strcasecmp($position, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
3661 $moduleContent = '';
3662 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
3663 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
3665 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
3666 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
3668 $moduleContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
3670 $widgetContent = $moduleContent;
3672 // ウィジェットの内枠(コンテンツ外枠)を設定。メニュー処理後に付加。
3673 // ウィジェットの内枠はレンダーで設定
3674 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
3675 } else { // その他の位置のとき
3676 // ウィジェットの内枠(コンテンツ外枠)を設定
3677 // ウィジェットの内枠はレンダーで設定
3678 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
3680 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
3682 $isRendered = true; // Joomla!の描画処理を行ったかどうか
3685 if (!$isRendered){ // Joomla!の描画処理を行っていない場合
3687 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
3689 // ウィジェットの内枠(コンテンツ外枠)を設定
3690 $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
3693 if (!$ret) return ''; // 処理中断のときは終了
3696 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
3697 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
3700 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
3701 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
3702 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
3703 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
3704 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
3705 if ($this->isPageEditable){ // 一般画面ページ編集可能モードのとき
3706 //$editInfo = 'widgetid:' . $this->pageDefRows[$i]['wd_id'];
3707 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
3708 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
3709 $hasAdmin = '0'; // 管理画面があるかどうか
3710 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
3711 $shared = '0'; // 共通属性があるかどうか
3712 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
3713 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
3714 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
3715 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget" rel="#m3editwidget" ' . $m3Option . '>' . $widgetContent . '</div>';
3717 } else { // キャッシュデータがあるとき
3718 $widgetContent = $cacheData;
3721 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
3722 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
3723 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
3725 $contents .= $widgetContent;
3729 if ($position == 'main'){ // メイン部のときは、メッセージを出力
3730 /*if (strlen($this->popupMsg) > 0){
3731 echo "\n<script language=\"javascript\">alert('" . addslashes($this->popupMsg) . "');</script>";
3733 } else if ($position == 'debug'){ // デバッグ文出力
3739 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:3px solid #f00;color:#700;">ポジション名: ';
3740 $contents .= '<b>' . $position . '</b>';
3741 $contents .= '</div>';
3743 case 2: // ポジション表示(ウィジェット付き)
3744 $rev = '555'; // データのリビジョン番号
3745 // ポジションのHTMLタグIDを作成
3748 for ($i = 0; $i < 100; $i++){
3749 $posId = $position . '_' . $num;
3750 $viewPosId = self::POSITION_TAG_HEAD . $posId;
3751 if (!in_array($viewPosId, $this->viewPosId)) break;
3754 $this->viewPosId[] = $viewPosId;// IDを保存
3756 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
3757 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
3758 $ret = $this->db->getPageDef($filename, $subId, $position, $rows);
3759 if ($ret){ // 1行以上データが取得できたとき
3760 $this->pageDefRows = $rows; // ページ定義レコード
3761 $this->pageDefPosition = $position;
3763 $this->pageDefRows = array();
3764 $this->pageDefPosition = '';
3768 if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
3769 $contents .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
3770 $contents .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
3773 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
3774 $contents .= $this->getWidgetList($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $widgetTagHead, $this->pageDefRows);
3776 $contents .= '</div>' . M3_NL;
3779 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">param error</div>';
3783 $this->viewPositions[] = $position;
3788 * ウィジェット共通のコンテンツ追加処理
3790 * @param string $src ウィジェット出力
3791 * @param array $pageDefParam 画面定義レコード
3792 * @return string コンテンツを付加したウィジェット出力
3794 function _addOptionContent($src, $pageDefParam)
3797 $dest = $pageDefParam['pd_top_content'] . $src . $pageDefParam['pd_bottom_content'];
3800 if ($pageDefParam['pd_show_readmore']){
3801 $title = $pageDefParam['pd_readmore_title'];
3802 if (empty($title)) $title = self::DEFAULT_READMORE_TITLE;
3803 $dest .= '<div><a href="' . convertUrlToHtmlEntity($pageDefParam['pd_readmore_url']) . '">' . convertToHtmlEntity($title) . '</a></div>';
3808 * BODYタグに付加するスタイルを取得(管理画面用)
3810 * @param string CSS文字列
3812 function getBodyStyle()
3814 // 画面透過モードのときスタイルを追加
3816 if ($this->isTransparentMode) $transCss = ' style="background-color:transparent;"';
3822 * @param string $position HTMLテンプレート上の書き出し位置
3823 * @return int コンテンツの数
3825 function getWidgetsCount($position)
3827 global $gRequestManager;
3828 global $gEnvManager;
3831 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3832 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3833 return 1; // ウィジェットが設定されていないポジション名を表示するために固定で値を返す
3836 // 単一ポジション以外の設定のときは固定で返す(or等)
3837 $pos = strpos($position, ' ');
3838 if ($pos !== false) return 1;
3841 $filename = $gEnvManager->getCurrentPageId();
3842 $subId = $gEnvManager->getCurrentPageSubId();
3843 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
3845 // 取得しようとするページ定義のポジションが既に取得しているポジションと異なるときはデータを取得
3846 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // 現在取得しているページ定義のポジション
3847 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
3848 if ($ret){ // 1行以上データが取得できたとき
3849 $this->pageDefRows = $rows; // ページ定義レコード
3850 $this->pageDefPosition = $position;
3852 $this->pageDefRows = array();
3853 $this->pageDefPosition = '';
3856 return count($this->pageDefRows);
3861 * 画面作成機能でウィジェット情報を取得するためのAjaxインターフェイス
3863 * @param RequestManager $request HTTPリクエスト処理クラス
3865 function getWidgetInfoByAjax($request)
3867 global $gEnvManager;
3868 global $gDesignManager;
3869 global $gCacheManager;
3871 // アクセスするページIDからPC用、携帯用、スマートフォン用かを判断
3872 $widgetDeviceType = 0; // 端末タイプをPC用に初期化
3873 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
3874 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
3875 $mobilePageIdPrefix = M3_DIR_NAME_MOBILE . '_';
3876 $smartphonePageIdPrefix = M3_DIR_NAME_SMARTPHONE . '_';
3877 if (strncmp($pageId, $mobilePageIdPrefix, strlen($mobilePageIdPrefix)) == 0){
3878 $widgetDeviceType = 1; // 携帯用
3879 } else if (strncmp($pageId, $smartphonePageIdPrefix, strlen($smartphonePageIdPrefix)) == 0){
3880 $widgetDeviceType = 2; // スマートフォン用
3883 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
3884 if ($task == 'list'){
3886 $ret = $this->db->getAvailableWidgetList($widgetDeviceType, $rows);
3888 $currentCategoryId = '_none'; // 現在のウィジェットカテゴリー初期化
3889 for ($i = 0; $i < count($rows); $i++){
3890 $widgetId = $rows[$i]['wd_id'];
3891 $desc = $rows[$i]['wd_description'];
3892 $widgetTag = self::WIDGET_TYPE_TAG_HEAD . $widgetId;
3893 $categoryId = $rows[$i]['wd_category_id'];
3896 if ($categoryId != $currentCategoryId){
3898 echo '</dd>' . M3_NL;
3899 echo '</dl>' . M3_NL;
3901 echo '<dl class="m3accordion">' . M3_NL;
3902 echo '<dt>' . $rows[$i]['wt_name'] . '</dt>' . M3_NL;
3903 echo '<dd>' . M3_NL;
3906 $currentCategoryId = $categoryId;
3909 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
3910 if ($gEnvManager->getUseSslAdmin()){
3911 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
3912 $image = $gEnvManager->getSslUrl($image);
3914 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
3915 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
3916 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
3921 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メインウィジェット
3922 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
3926 if (!empty($rows[$i]['wd_template_type'])){ // 対応テンプレートタイプ
3927 $templateTypeArray = explode(',', $rows[$i]['wd_template_type']);
3928 if (in_array('bootstrap', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_BOOTSTRAP; // Bootstrap型テンプレート対応
3931 echo '<dl class="m3_widgetlist_item" id="' . $widgetTag . '">' . M3_NL;
3932 echo '<dt>' . $widgetMark . $rows[$i]['wd_name'] . '</dt>' . M3_NL; // ウィジェット名
3933 echo '<dd><table width="100%"><tr valign="top"><td width="35">' . $imageTag . '</td><td>' . $desc . '</td></tr></table>';
3934 echo $functionMark . '</dd>' . M3_NL;
3935 echo '</dl>' . M3_NL;
3938 if ($i == count($rows) - 1){
3939 echo '</dd>' . M3_NL;
3940 echo '</dl>' . M3_NL;
3944 } else if ($task == 'wget' || $task == 'wdelete' || $task == 'wtoggle' || $task == 'wadd' || $task == 'wmove'){ // ウィジェット再取得、ウィジェット削除,ウィジェット共通属性変更、ウィジェット追加、ウィジェット移動のとき
3945 $rev = $request->trimValueOf('rev'); // リビジョン
3946 $serial = $request->trimValueOf('serial');
3947 $position = $request->trimValueOf('pos');
3948 $widgetsStr = $request->trimValueOf('widgets');
3949 if (empty($widgetsStr)){
3952 $widgets = explode(',', $widgetsStr);
3954 $shared = $request->trimValueOf('shared');
3955 $updatepos = explode(',', $request->trimValueOf('updatepos'));
3956 $index = $request->trimValueOf('index');
3959 if ($task == 'wmove'){
3960 $positions = explode(',', $position);
3961 if (count($positions) >= 2){
3962 $position = $positions[0];
3963 $position2 = $positions[1];
3965 $position = $positions[0];
3969 // ##### エラーチェック #####
3972 $rev = '111'; // データのリビジョン番号
3975 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows); // 0レコードでも正常とする
3977 // 変更前のウィジェットのシリアル番号をチェック
3978 if (count($widgets) == count($rows)){
3979 if (!($task == 'wmove' && empty($position2))){ // 同一ブロック内の移動の場合はチェックなし
3980 for ($i = 0; $i < count($rows); $i++){
3981 if ($widgets[$i] != $rows[$i]['pd_serial']){// シリアル番号
3992 if (!$isErr){ // エラーなしのとき
3993 if ($task == 'wdelete'){
3994 $ret = $this->db->deleteWidget($serial);
3995 } else if ($task == 'wtoggle'){
3997 if (empty($shared)) $newShared = 1;
3998 $ret = $this->db->toggleSharedWidget($pageId, $pageSubId, $serial, $newShared);
3999 } else if ($task == 'wadd'){ // ウィジェットの追加
4000 $widget = $request->trimValueOf('widget');
4003 if (empty($widget)) $isErr = true;
4006 if (!$isErr) $this->db->addWidget($pageId, $pageSubId, $position, $widget, $index);
4007 } else if ($task == 'wmove'){
4009 if (!$isErr) $this->db->moveWidget($pageId, $pageSubId, $position, $serial, $index);
4013 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows);// 0レコードでも正常とする
4015 // 移動のときは、移動元と移動先の再表示データを取得
4016 if ($task == 'wmove' && !empty($position2)){
4017 $ret = $this->db->getPageDef($pageId, $pageSubId, $position2, $rows2);// 0レコードでも正常とする
4022 echo '<div>' . M3_NL;
4023 for ($i = 0; $i < count($updatepos); $i++){
4025 $widgetTagHead = str_replace(self::POSITION_TAG_HEAD, self::WIDGET_TAG_HEAD, $updatepos[$i]);
4028 $posName = str_replace(self::POSITION_TAG_HEAD, '', substr($updatepos[$i], 0, strlen($updatepos[$i]) - strlen(strrchr($updatepos[$i], "_"))));
4029 if ($task == 'wmove' && $posName == $position2){
4032 if (strcasecmp($position2, 'user3') == 0 || strcasecmp($position2, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4033 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position2 . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
4034 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position2 . '</h2>' . M3_NL;
4037 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows2);
4041 if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
4042 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
4043 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
4046 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows);
4049 echo '</div>' . M3_NL;
4051 echo '</div>' . M3_NL;
4054 $gCacheManager->clearAllCache();
4058 * 画面作成用ウィジェット一覧データ出力
4060 * @param string $pageId ページID
4061 * @param string $pageSubId ページサブID
4062 * @param string $widgetTagHead HTMLウィジェットID用のヘッダ
4063 * @param array $rows ウィジェット一覧データ
4064 * @return string ウィジェット一覧出力
4066 function getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows)
4068 global $gEnvManager;
4069 global $gDesignManager;
4070 global $gSystemManager;
4072 if ($gEnvManager->getUseSslAdmin()){
4073 $rootUrl = $gEnvManager->getSslRootUrl();
4075 $rootUrl = $gEnvManager->getRootUrl();
4079 $line = $this->getPageInfo($pageId, $pageSubId);
4080 if (!empty($line)) $pageContentType = $line['pn_content_type'];
4082 $contents = ''; // ウィジェット一覧出力コンテンツ
4083 for ($i = 0; $i < count($rows); $i++){
4084 $widgetId = $rows[$i]['wd_id'];
4085 $desc = $rows[$i]['wd_description'];
4086 $widgetIndex = $rows[$i]['pd_index']; // 表示順
4087 $configId = $rows[$i]['pd_config_id']; // 定義ID
4088 $serial = $rows[$i]['pd_serial']; // シリアル番号
4089 $widgetTag = $widgetTagHead . '_' . $i; // ウィジェット識別用ユニークタグ
4090 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
4091 if ($gEnvManager->getUseSslAdmin()){
4092 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
4093 $image = $gEnvManager->getSslUrl($image);
4095 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
4096 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
4097 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
4100 if (empty($rows[$i]['pd_config_name'])){
4101 if ($rows[$i]['wd_use_instance_def'] && $configId == 0){ // インスタンス定義が必要で未定義のとき
4102 $configName = '<span style="color:red;">[未設定]</span>';
4107 $configName = '[' . $rows[$i]['pd_config_name'] . ']';
4109 $hasAdmin = '0'; // 管理画面があるかどうか
4110 $configImg = ''; // 設定アイコンの表示
4112 // ウィジェットの配置位置に問題があるかどうかを表示
4113 // メインコンテンツとページ属性が一致するかどうかチェック
4114 $widgetContentType = $rows[$i]['wd_content_type'];
4115 if (!empty($widgetContentType) && $widgetContentType != $pageContentType &&
4116 (in_array($widgetContentType, $this->_getAllContentType()) || in_array($widgetContentType, $this->_getAllFeatureType()))){
4117 //$title = 'ウィジェット配置注意';
4118 $title = 'ページ属性と不一致';
4119 $configImg .= '<img src="' . $rootUrl . self::NOTICE_ICON_FILE . '" alt="' . $title . '" title="' . $title . '" /> ';
4121 if ($rows[$i]['wd_has_admin']){
4123 $title = 'ウィジェット設定';
4124 $configImg .= '<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\'' . $widgetId . '\', \'' . $configId . '\', \'' . $serial . '\');return false;" >' .
4125 '<img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" alt="' . $title . '" title="' . $title . '" /></a> ';
4127 $shared = '0'; // 共通属性があるかどうか
4128 $sharedClassName = '';
4129 if (empty($rows[$i]['pd_sub_id'])){
4130 $shared = '1'; // 共通ウィジェットのとき
4131 $sharedClassName = 'm3_widget_shared'; // 共通ウィジェットのクラス
4133 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4137 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メインウィジェット
4138 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
4141 $dropdownMenuId = $widgetTag . '_dropdown';
4142 $operationMenu = '<div class="m3widgetdropdown">';
4143 // $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#"><i class="glyphicon glyphicon-list-alt"></i> <b class="caret"></b></a>';
4144 $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#" data-horizontal-offset="4"><b class="caret"></b></a>';
4145 $operationMenu .= '<div id="' . $dropdownMenuId . '" class="m3dropdown m3dropdown-tip m3dropdown-relative m3dropdown-anchor-right">';
4146 $operationMenu .= '<ul class="m3dropdown-menu">';
4147 $operationMenu .= '<li class="m3_wadjust"><a href="#"><img src="' . $rootUrl . self::ADJUST_ICON_FILE . '" /> <span>タイトル・位置調整</span></a></li>';
4148 if ($hasAdmin) $operationMenu .= '<li class="m3_wconfig"><a href="#"><img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" /> <span>ウィジェットの設定</span></a></li>';
4150 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>ページ共通属性を解除</span></a></li>';
4152 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>ページ共通属性を設定</span></a></li>';
4154 $operationMenu .= '<li class="m3_wdelete"><a href="#"><img src="' . $rootUrl . self::DELETE_ICON_FILE . '" /> <span>このウィジェットを削除</span></a></li>';
4155 $operationMenu .= '</ul>';
4156 $operationMenu .= '</div>';
4157 $operationMenu .= '</div>';
4159 $contents .= '<dl class="m3_widget m3_widget_sortable" id="' . $widgetTag . '" ' . $m3Option . ' >' . M3_NL;
4160 $contents .= '<dt class="m3_widget_with_check_box ' . $sharedClassName . '"><div class="m3widgettitle">' . $widgetMark . $rows[$i]['wd_name'] . '</div>' . $operationMenu . '</dt>' . M3_NL;
4161 $contents .= '<dd><table width="100%"><tr valign="top"><td width="35">' . $imageTag . '</td><td>' . $desc . '</td></tr></table>' . M3_NL;
4162 $contents .= '<table width="100%"><tr><td>' . $configName . '</td><td align="right">' . $configImg . $widgetIndex . '</td></tr></table></dd>' . M3_NL;
4163 $contents .= '</dl>' . M3_NL;
4170 * @param int $index 行番号
4171 * @param array $fetchedRow fetch取得した行
4172 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
4173 * @param string $titleTag タイトル埋め込み用タグ(遅延ウィジェットの場合のみ作成)
4174 * @param int $widgetHeaderType ウィジェットタイトルを出力方法(0=出力なし、1=Joomla!v1.0PC用出力、2=Joomla!v1.0携帯用出力)
4175 * @return bool 処理を継続するかどうか(true=続行、false=中断)
4177 function pageDefLoop($index, $fetchedRow, $style, &$titleTag, $widgetHeaderType = 0)
4179 global $gEnvManager;
4180 global $gErrorManager;
4181 global $gDesignManager;
4184 if ($this->isAbort) return false;
4186 // ウィジェット実行停止中のときは空で返す
4187 // 管理者、運営者どのレベルで制限をかける?
4188 if (!$fetchedRow['wd_active']) return true;
4190 // ページ共通属性ありの場合は現在のページが例外ページにないかチェック
4191 if (empty($fetchedRow['pd_sub_id'])){
4192 $exceptPageStr = $fetchedRow['pd_except_sub_id'];
4193 if (!empty($exceptPageStr)){
4194 $exceptPageArray = explode(',', $exceptPageStr);
4195 if (in_array($gEnvManager->getCurrentPageSubId(), $exceptPageArray)) return true; // 例外ページの場合は出力しない
4199 // ウィジェット表示タイプによる表示制御。システム管理者以上の場合は常時表示。
4200 if (!$gEnvManager->isSystemAdmin() && $fetchedRow['pd_view_control_type'] != 0){
4201 switch ($fetchedRow['pd_view_control_type']){
4202 case 1: // ログイン時のみ表示
4203 if (!$gEnvManager->isCurrentUserLogined()) return true; // ログインしていなければ終了
4205 case 2: // 非ログイン時のみ表示
4206 if ($gEnvManager->isCurrentUserLogined()) return true; // ログインしていれば終了
4217 $widgetId = $fetchedRow['wd_id'];
4218 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
4221 $configId = $fetchedRow['pd_config_id']; // ウィジェット定義ID
4222 if ($configId == 0) $configId = '';
4223 $prefix = $fetchedRow['wd_suffix']; // サフィックス文字列
4224 $title = $fetchedRow['wd_name']; // デフォルトのウィジェットタイトル
4225 if (empty($title)) $title = $fetchedRow['wd_id'];
4226 $serial = $fetchedRow['pd_serial']; // シリアル番号
4227 $cssStyle = $fetchedRow['pd_style']; // CSS
4228 $lateLaunchIndex = $fetchedRow['wd_launch_index']; // 遅延実行インデックス
4230 if (empty($fetchedRow['pd_sub_id'])) $shared = true;// 共通属性あり
4231 if ($this->nonSharedWidgetCount == -1) $this->nonSharedWidgetCount = 0; // 初期化されていない場合は初期化
4232 if (!$shared) $this->nonSharedWidgetCount++; // 非共通ウィジェットの数を更新
4234 // ウィジェットが遅延実行に指定されている場合は、ウィジェットのタグのみ埋め込む
4235 if ($lateLaunchIndex > 0){ // 遅延実行のとき
4237 if (!isset($this->lateLaunchWidgetList[$widgetId])){
4238 $this->lateLaunchWidgetList[$widgetId] = (int)$lateLaunchIndex;
4241 $maxNo = 0; // 最大シリアル番号
4242 $count = count($this->latelaunchWidgetParam);
4243 for ($i = 0; $i < $count; $i++){
4244 list($wId, $index, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5, $tmp6, $tmp7) = $this->latelaunchWidgetParam[$i];
4245 if ($wId == $widgetId) $maxNo = $index + 1;
4247 // Joomla!1.0テンプレートの場合はタイトルを修正
4248 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
4249 if (!empty($fetchedRow['pd_title'])) $title = $fetchedRow['pd_title'];
4251 $this->latelaunchWidgetParam[] = array($widgetId, $maxNo, $configId, $prefix, $serial, $style, $cssStyle, $title, $shared);
4254 echo self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
4257 $titleTag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
4260 if (!file_exists($widgetIndexFile)) {
4261 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
4264 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
4265 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
4266 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
4267 $this->lastHeadTitle = ''; // ヘッダ部titleにセットした文字列
4268 $this->lastHeadDescription = ''; // ヘッダ部descriptionにセットした文字列
4269 $this->lastHeadKeywords = ''; // ヘッダ部keywordsにセットした文字列
4271 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
4272 $joomlaTitleVisble = false;
4273 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
4274 if ($fetchedRow['pd_title_visible']){
4275 if ($widgetHeaderType == 1){ // PC用出力のとき
4276 $joomlaTitle = $fetchedRow['pd_title'];
4277 if (empty($joomlaTitle)) $joomlaTitle = $title;
4278 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
4279 echo '<tr><th>' . $joomlaTitle . '</th></tr>' . M3_NL;
4280 echo '<tr><td>' . M3_NL;
4281 $joomlaTitleVisble = true;
4282 } else if ($widgetHeaderType == 2){ // 携帯用出力のとき
4283 $joomlaTitle = $fetchedRow['pd_title'];
4284 if (empty($joomlaTitle)) $joomlaTitle = $title;
4285 echo '<div>' . $joomlaTitle . '</div>' . M3_NL;
4286 $joomlaTitleVisble = true;
4291 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
4292 // ウィジェット親のCSS定義があるときは、タグを追加
4293 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
4296 echo $gDesignManager->getAdditionalWidgetOutput(true);
4299 $gEnvManager->setCurrentWidgetId($widgetId);
4302 $gEnvManager->setCurrentWidgetConfigId($configId);
4305 $gEnvManager->setCurrentPageDefSerial($fetchedRow['pd_serial']);
4308 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
4311 $gEnvManager->setCurrentWidgetTitle($title);
4314 $gEnvManager->setCurrentWidgetStyle($style);
4316 // ウィジェットのページ共通状況を設定
4317 $gEnvManager->setIsCurrentWidgetShared($shared);
4320 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
4323 //require_once($widgetIndexFile);
4324 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
4325 $msg = 'widget-start(' . $widgetId . ')';
4326 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
4327 require($widgetIndexFile);
4328 $msg = 'widget-end(' . $widgetId . ')';
4329 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
4332 $gEnvManager->setCurrentWidgetId('');
4335 $gEnvManager->setCurrentWidgetConfigId('');
4338 $gEnvManager->setCurrentPageDefSerial(0);
4341 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
4344 $gEnvManager->setCurrentWidgetStyle('');
4346 // ウィジェットのページ共通状況を解除
4347 $gEnvManager->setIsCurrentWidgetShared(false);
4350 echo $gDesignManager->getAdditionalWidgetOutput(false);
4351 // echo "<!-- ".time()." -->";
4353 // ウィジェット親のCSS定義があるときは、タグを追加
4354 if (!empty($cssStyle)) echo '</div>' . M3_NL;
4356 //echo '</div>' . M3_NL;
4358 // Joomla!1.0テンプレートのときはタイトルを出力
4359 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用出力のとき
4360 echo '</td></tr>' . M3_NL;
4361 echo '</table>' . M3_NL;
4365 return true; // 処理継続
4368 * 定義IDを指定してウィジェットの出力を取得
4370 * @param string $widgetId ウィジェットID
4371 * @param int $configId ウィジェット定義ID
4372 * @return string ウィジェットの出力
4374 function getWidgetOutput($widgetId, $configId)
4376 global $gEnvManager;
4377 global $gErrorManager;
4379 // ウィジェットのアクセス権をチェック
4380 if (!$this->db->canAccessWidget($widgetId)) return '';
4383 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
4386 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
4388 // 必要なJavascriptライブラリを追加
4389 $scritLib = trim($row['wd_add_script_lib']);
4390 if (!empty($scritLib)) $this->addScript('', $scritLib);
4396 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
4399 $saveWidgetId = $gEnvManager->getCurrentWidgetId();
4400 $gEnvManager->setCurrentWidgetId($widgetId);
4403 $saveConfigId = $gEnvManager->getCurrentWidgetConfigId();
4404 $gEnvManager->setCurrentWidgetConfigId($configId);
4407 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
4410 //$gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
4413 //$gEnvManager->setCurrentWidgetTitle($title);
4415 // ウィジェットのページ共通状況を設定
4416 //$gEnvManager->setIsCurrentWidgetShared($shared);
4419 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
4422 //require_once($widgetIndexFile);
4423 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
4424 $msg = 'widget-start(' . $widgetId . ')';
4425 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
4426 if (file_exists($widgetIndexFile)){
4427 require($widgetIndexFile);
4429 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
4431 $msg = 'widget-end(' . $widgetId . ')';
4432 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
4435 $gEnvManager->setCurrentWidgetId($saveWidgetId);
4438 $gEnvManager->setCurrentWidgetConfigId($saveConfigId);
4441 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
4444 //$gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
4446 // ウィジェットのページ共通状況を解除
4447 //$gEnvManager->setIsCurrentWidgetShared(false);
4449 // 現在のバッファ内容を取得し、バッファを破棄
4450 $output = ob_get_contents();
4458 * @param int $cmdNo 実行コマンド(0=初期化、1=更新、2=計算、10=コンテンツ取得)
4459 * @param string $id ウィジェットID+インナーウィジェットID
4460 * @param string $configId インナーウィジェット定義ID
4461 * @param object $paramObj インナーウィジェットに渡すパラメータオブジェクト
4462 * @param object $optionParamObj インナーウィジェットに渡すパラメータオブジェクト(オプション)
4463 * @param object $resultObj インナーウィジェットから返る結果オブジェクト
4464 * @param string $content 出力内容
4465 * @param bool $isAdmin 管理者機能(adminディレクトリ以下)かどうか
4466 * @return bool true=成功、false=失敗
4468 function commandIWidget($cmdNo, $id, $configId, &$paramObj, &$optionParamObj, &$resultObj, &$content, $isAdmin = false)
4470 global $gEnvManager;
4472 // ウィジェットIDとインナーウィジェットIDを取り出す
4473 list($widgetId, $iWidgetId) = explode(M3_WIDGET_ID_SEPARATOR, $id);
4475 // インナーウィジェットに渡すパラメータを設定
4478 $cmd = self::IWIDTET_CMD_INIT; // 初期化
4479 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
4482 $cmd = self::IWIDTET_CMD_UPDATE; // 更新
4483 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
4486 $cmd = self::IWIDTET_CMD_CALC; // 計算
4487 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
4490 $cmd = self::IWIDTET_CMD_CONTENT; // コンテンツ取得
4491 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
4495 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
4499 // インナーウィジェットのエラー出力は呼び出しウィジェット側で受けるため、出力を抑止する
4500 ob_start();// バッファ作成
4503 if (empty($widgetId)){ // ウィジェットIDが指定されていないときは共通ディレクトリ
4504 //$gEnvManager->getIWidgetsPath() . '/' . $iWidgetId . '/' . $containerClass . '.php';
4507 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/' . M3_DIR_NAME_ADMIN . '/index.php';
4509 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/index.php';
4513 // 作業中のインナーウィジェットIDを設定
4514 $gEnvManager->setCurrentIWidgetId($id); // インナーウィジェットを設定
4516 // インナーウィジェット定義IDを設定
4517 $gEnvManager->setCurrentIWidgetConfigId($configId);
4520 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
4521 if (file_exists($widgetIndexFile)){
4522 require($widgetIndexFile);
4524 echo 'file not found error: ' . $widgetIndexFile;
4528 $gEnvManager->setCurrentIWidgetId('');
4530 // インナーウィジェット定義IDを解除
4531 $gEnvManager->setCurrentIWidgetConfigId('');
4533 // 現在のバッファ内容を取得し、バッファを破棄
4534 $content = ob_get_contents();
4538 if ($this->gInstance->getCmdParamManager()->getParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $obj, $option)){
4540 $optionParamObj = $option;
4544 if ($this->gInstance->getCmdParamManager()->getResult($id . M3_WIDGET_ID_SEPARATOR . $configId, $resObj)) $resultObj = $resObj;
4548 * コールバックメソッドを実行し、出力を返す
4550 * @param array $callback 実行するコールバック
4551 * @return string 出力結果
4553 function getOutputByCallbackMethod($callback)
4555 ob_start();// バッファ作成
4558 if (is_callable($callback)) call_user_func($callback);
4560 // 現在のバッファ内容を取得し、バッファを破棄
4561 $content = ob_get_contents();
4566 * ページ作成処理中断を行った場合のレスポンスヘッダ設定
4568 * @param int $responseCode レスポンスコード
4571 function setResponse($responseCode)
4573 switch ($responseCode){
4574 case 503: // サイト非公開(システムメンテナンス)
4575 header('HTTP/1.1 503 Service Temporarily Unavailable');
4576 header('Status: 503 Service Temporarily Unavailable');
4578 case 403: // アクセス禁止のとき
4579 header('HTTP/1.1 403 Forbidden');
4580 header('Status: 403 Forbidden');
4582 case 404: // 存在しないページのとき
4583 header("HTTP/1.1 404 Not Found");
4584 header("Status: 404 Not Found");
4591 * @param string $filePath ダウンロードするファイルのファイルパス
4592 * @param string $downloadFilename ダウンロード時のファイル名
4593 * @param bool $deleteFile 実行後ファイルを削除するかどうか(成功失敗に関係なく)
4594 * @return bool true=成功、false=失敗
4596 function downloadFile($filePath, $downloadFilename, $deleteFile=false)
4599 if (!file_exists($filePath)) return false;
4602 $fileSize = filesize($filePath);
4604 // バッファ内容が残っているときは破棄
4605 if (ob_get_level() > 0) ob_end_clean();
4607 header('Cache-Control: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
4608 header('Pragma: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
4609 header('Content-Disposition: attachment; filename=' . $downloadFilename);
4610 header('Content-Length: ' . $fileSize);
4611 header('Content-Type: application/octet-stream; name=' . $downloadFilename);
4612 $fp = fopen($filePath, "r");
4613 echo fread($fp, $fileSize);
4619 if ($deleteFile) unlink($filePath);
4625 * @param string $url 遷移先URL。未指定の場合は現在のスクリプト。URLでないときは、現在のスクリプトに付加。
4626 * @param bool $noMessage 画面を遷移させたとき、ドコモ携帯端末でダイアログ(サイトが移動しました(301))が出ないようにするオプション
4627 * @param int $responseCode レスポンスコード
4630 function redirect($url = '', $noMessage = false, $responseCode = 0)
4632 global $gEnvManager;
4634 // すでにリダイレクトが設定されている場合は終了
4635 if ($this->isRedirect) return; // リダイレクトするかどうか
4639 $toUrl = $gEnvManager->getCurrentScriptUrl();
4640 } else if (strncmp($toUrl, 'http://', 7) != 0 && strncmp($toUrl, 'https://', 8) != 0){ // URL以外のときはクエリー文字列と判断する
4641 $toUrl = $gEnvManager->getCurrentScriptUrl() . $toUrl;
4644 // SSL化が必要な場合はhttpsに変更
4646 if ($gEnvManager->isAdminUrlAccess($toUrl)){ // 管理画面へのアクセスのとき
4648 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
4651 $paramArray = array();
4652 //list($filename, $query) = explode('?', basename($toUrl));
4653 list($url, $query) = explode('?', $toUrl);
4654 $baseUrl = dirname($url);
4655 $filename = basename($url);
4656 if (empty($filename)) $filename = M3_FILENAME_INDEX;
4657 if (!empty($query)) parse_str($query, $paramArray); // クエリーの解析
4660 $pageId = basename($filename, '.php');
4661 $pageSubId = $paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID];
4664 $isSslPage = $this->isSslPage($pageId, $pageSubId);
4667 if ($this->gSystem->hierarchicalPage() && $filename == M3_FILENAME_INDEX){
4668 $toUrl = $baseUrl . '/' . $pageSubId . '/';
4669 unset($paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID]);
4671 $paramStr = $this->_createUrlParamStr($paramArray);
4672 if (!empty($paramStr)) $toUrl .= '?' . $paramStr;
4676 //$toUrl = str_replace('http://', 'https://', $toUrl);
4677 $toUrl = $gEnvManager->getSslUrl($toUrl); // SSL用URLに変換
4679 $toUrl = str_replace('https://', 'http://', $toUrl);
4682 // バッファ内容が残っているときは破棄
4683 if (ob_get_level() > 0) ob_end_clean();
4685 if (empty($responseCode)){
4687 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
4689 header('HTTP/1.1 301 Moved Permanently');
4691 } else { // レスポンスコードが指定されている場合
4692 switch ($responseCode){
4694 header('HTTP/1.1 301 Moved Permanently');
4697 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
4700 header('HTTP/1.1 303 See Other');
4703 header('HTTP/1.1 ' . (string)$responseCode);
4707 header('Location: ' . $toUrl);
4709 $this->isRedirect = true; // リダイレクトするかどうか
4715 * @return bool true=リダイレクト、false=リダイレクトでない
4717 function isRedirect()
4719 return $this->isRedirect;
4722 * 指定URLのディレクトリへリダイレクト
4726 function redirectToDirectory()
4728 global $gEnvManager;
4731 $dirPath = dirname($gEnvManager->getCurrentScriptUrl()) . '/';
4732 //$this->redirect($dirPath);
4733 $this->redirect($dirPath, false, 303); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/7/23)
4740 function redirectToInstall()
4742 global $gEnvManager;
4744 $sytemRootUrl = $gEnvManager->calcSystemRootUrl();
4745 //$this->redirect($sytemRootUrl . '/admin/install.php');
4746 $this->redirect($sytemRootUrl . '/admin/install.php', false, 303); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
4749 * ログイン、ログアウト処理を行った後、リダイレクト
4751 * @param RequestManager $request HTTPリクエスト処理クラス
4752 * @param bool $success ログインの成否
4753 * @param string $redirectUrl ログイン成功の場合のリダイレクト先
4754 * @return int 0=何も処理しなかった場合、1=ログイン処理、2=ログアウト処理、3=パスワード送信
4756 function standardLoginLogoutRedirect($request, &$success, $redirectUrl = '')
4758 global $gEnvManager;
4759 global $gAccessManager;
4760 global $gRequestManager;
4762 // ログイン、ログアウト処理、および、コンテナの起動
4763 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
4764 if ($cmd == M3_REQUEST_CMD_LOGIN){ // ログインの場合
4765 $act = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_ACT);
4766 if ($act == 'sendpwd'){ // パスワード送信の場合
4767 $success = $gAccessManager->sendPassword($request);
4771 $ret = $gAccessManager->userLogin($request);
4773 if (empty($redirectUrl)){
4774 // システム運用可能ユーザの場合でリダイレクト先が設定されていない場合はデフォルトの管理画面URLへ遷移
4775 $userInfo = $gEnvManager->getCurrentUserInfo();// ユーザ情報取得
4776 if ($userInfo->userType >= UserInfo::USER_TYPE_MANAGER){
4777 $ret = $this->db->getLoginUserRecordById($userInfo->userId, $userInfoRow);
4778 if ($ret && !empty($userInfoRow['lu_default_admin_url'])){
4779 $redirectUrl = $gEnvManager->getDefaultAdminUrl() . $userInfoRow['lu_default_admin_url'];
4785 $this->redirect($redirectUrl);
4786 $success = true; // ログイン成功
4787 } else { // ログイン失敗のとき
4788 $success = false; // ログイン失敗
4792 } else if ($cmd == M3_REQUEST_CMD_LOGOUT){ // ログアウト
4794 $gAccessManager->userLogout(true);
4797 $this->redirect($redirectUrl);
4804 * ウィジェットがセットされているページサブIDを取得
4806 * @param string $pageId ページID
4807 * @param string $widgetId 対象ウィジェットID
4808 * @param int $configId ウィジェット定義ID
4809 * @return string ページサブID
4811 function getPageSubIdByWidget($pageId, $widgetId, $configId = 0)
4815 // 対象のウィジェットのページサブIDを取得
4816 $ret = $this->db->getSubPageId($widgetId, $pageId, $rows);
4817 if ($ret){// データが存在する
4818 for ($i = 0; $i < count($rows); $i++){
4819 if (!empty($rows[$i]['pd_sub_id']) && $rows[$i]['pd_config_id'] == $configId){
4820 $pageSubId = $rows[$i]['pd_sub_id'];
4828 * その他のGET,POSTパラメータからページサブID取得
4830 * @param RequestManager $request HTTPリクエスト処理クラス
4831 * @param string $pageId ページID
4832 * @return string ページサブID
4834 function getPageSubIdByParam($request, $pageId)
4837 $task = $request->trimValueOf('task');
4838 $option = $request->trimValueOf('option');
4839 if ($task == 'search' && $option == 'com_search'){ // joomla!の検索結果表示の場合
4840 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_SEARCH, $pageId);// ページサブIDを取得
4841 $this->contentType = M3_VIEW_TYPE_SEARCH; // ページのコンテンツタイプ
4846 * コンテンツタイプとページIDからページサブID取得
4848 * @param string $contentType コンテンツタイプ
4849 * @param string $pageId ページID
4850 * @return string ページサブID
4852 function getPageSubIdByContentType($contentType, $pageId)
4854 $subId = $this->db->getSubPageIdWithContent($contentType, $pageId);// ページサブIDを取得
4858 * 指定のウィジェットがページ上にあるかを取得
4860 * @param string $pageId ページID
4861 * @param string $widgetId 対象ウィジェットID
4862 * @param bool $activePageOnly 公開中のページのウィジェットに制限するかどうか。falseの場合はすべてのページのウィジェットを対象とする。
4863 * @return bool true=ページ上にあり、false=ページ上になし
4865 function isWidgetOnPage($pageId, $widgetId, $activePageOnly=true)
4867 $ret = $this->db->isWidgetOnPage($pageId, $widgetId, $activePageOnly, 0/*定義セットID*/);
4871 * URLで示されるページ上のウィジェットをウィジェット種別で取得
4873 * @param string $url URL
4874 * @param string $widgetType 対象ウィジェットタイプ
4875 * @return string ウィジェットID
4877 function getWidgetIdByWidgetType($url, $widgetType)
4879 $ret = $this->getPageIdFromUrl($url, $pageId, $pageSubId, $param);
4882 if ($ret) $widgetId = $this->db->getWidgetIdByType($pageId, $pageSubId, $widgetType);
4886 * 現在アクティブなメインウィジェットをウィジェット種別で取得
4888 * @param string $widgetType 対象ウィジェットタイプ
4889 * @return string ウィジェットID
4891 function getActiveMainWidgetIdByWidgetType($widgetType)
4894 $widgetId = $this->db->getActiveMainWidgetIdByType($widgetType);
4898 * URLを解析して、ページID,サブページIDを取得
4900 * @param string $url URL
4901 * @param string $pageId ページID
4902 * @param string $pageSubId ページサブID
4903 * @param array $urlParam URLパラメータ
4904 * @return bool true=成功、false=失敗
4906 function getPageIdFromUrl($url, &$pageId, &$pageSubId, &$urlParam)
4908 global $gEnvManager;
4910 // ページID、ページサブIDを求める
4911 list($page, $other) = explode('?', str_replace($gEnvManager->getRootUrl(), '', $url));
4912 parse_str($other, $urlParam);
4914 $pageId = str_replace('/', '_', trim($page, '/'));
4915 $pageId = basename($pageId, '.php');
4918 $pageSubId = $param[M3_REQUEST_PARAM_PAGE_SUB_ID];
4919 if (empty($pageSubId)) $pageSubId = $gEnvManager->getDefaultPageSubId();
4923 * ウィジェットが組み込まれているページのURLを生成
4925 * @param string $widgetId 送信元ウィジェットID
4926 * @param string $param 実行パラメータ
4927 * @param string $pageId ウィジェットが存在するページID
4928 * @return string 生成したURL
4930 function getDefaultPageUrlByWidget($widgetId, $param = '', $pageId = '')
4932 global $gEnvManager;
4934 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
4936 // このウィジェットがマップされているページサブIDを取得
4938 $subPageId = $this->getPageSubIdByWidget($pageId, $widgetId);
4939 if (empty($subPageId)){
4940 // 見つからないときは互換ウィジェットを探す
4941 $targetWidgetId = $this->db->getCompatibleWidgetId($widgetId);
4942 if (!empty($targetWidgetId)){
4943 $subPageId = $this->getPageSubIdByWidget($pageId, $targetWidgetId);
4946 if (!empty($subPageId)) $sub = M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId;
4948 //$url = $gEnvManager->getDefaultUrl();
4949 $url = $gEnvManager->createPageUrl($pageId);
4950 if (!empty($sub)) $url .= '?' . $sub;
4951 if (!empty($param)) $url .= '&' . $param;
4955 * ウィジェット指定呼び出し用のURLを生成
4957 * @param string $toWidgetId 送信先ウィジェットID
4958 * @param string $fromWidgetId 送信元ウィジェットID
4959 * @param string $todo 実行パラメータ
4960 * @param string $pageId ページID(空のときは現在のURL)
4961 * @return string 生成したURL
4963 function createWidgetCmdUrl($toWidgetId, $fromWidgetId, $todo, $pageId = '')
4965 global $gEnvManager;
4967 $url = $gEnvManager->createPageUrl($pageId);
4969 $url .= '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_FIND_WIDGET;
4970 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $toWidgetId;
4971 if (!empty($fromWidgetId)) $url .= '&' . M3_REQUEST_PARAM_FROM . '=' . $fromWidgetId; // 送信元
4972 if (!empty($todo)) $url .= '&' . M3_REQUEST_PARAM_OPERATION_TODO . '=' . urlencode($todo);
4978 * @param string $widgetId 実行ウィジェットID
4979 * @param string $optionParam 追加パラメータ
4980 * @param string $pageId ページID(空のときは現在のURL)
4981 * @param string $pageSubId ページサブID
4982 * @return string 生成したURL
4984 function createRssCmdUrl($widgetId, $optionParam = '', $pageId = '', $pageSubId = '')
4986 global $gEnvManager;
4989 $url = $gEnvManager->createPageUrl() . '?';
4992 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // ページ共通属性ありのときは空
4993 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
4995 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_RSS;
4996 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
4997 if (!empty($optionParam)) $url .= '&' . $optionParam;
5003 * @param string $widgetId 実行ウィジェットID
5004 * @param string $optionParam 追加パラメータ
5005 * @param bool $byMacro マクロ変換で返すかどうか
5006 * @param string $pageId ページID(空のときは現在のURL)
5007 * @param string $pageSubId ページサブID
5008 * @return string 生成したURL
5010 //function createDirectWidgetCmdUrl($widgetId, $optionParam = '', $pageId = '', $pageSubId = '')
5011 function createDirectWidgetCmdUrl($widgetId, $optionParam = '', $byMacro = false, $pageId = '', $pageSubId = '')
5013 global $gEnvManager;
5017 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . M3_FILENAME_INDEX . '?';
5019 $url = $gEnvManager->createPageUrl() . '?';
5023 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // ページ共通属性ありのときは空
5024 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
5026 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_DO_WIDGET;
5027 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
5028 if (!empty($optionParam)) $url .= '&' . $optionParam;
5032 * キャッシュ制御用の付加パラメータを取得
5034 * @return string パラメータ
5036 function getCacheParam()
5038 $addParam = '?' . date('YmdHis');
5042 * 現在のURLにアクセス可能かチェック
5044 * @param bool $isActivePage ページが有効かどうか
5045 * @return bool true=可能、false=不可
5047 function canAccessUrl(&$isActivePage)
5049 global $gEnvManager;
5051 // 現在設定されているページIDを取得
5052 $pageId = $gEnvManager->getCurrentPageId();
5053 $pageSubId = $gEnvManager->getCurrentPageSubId();
5054 $ret = $this->db->canAccessPage($pageId, $pageSubId, $pageVisible, $pageSubVisible, $isAdminMenu);
5055 if ($ret){ // アクセス可能なときは、ユーザ制限もチェックする
5056 $isActivePage = true;
5059 if (!$pageVisible || !$pageSubVisible) return false;
5061 if (!$gEnvManager->isCurrentUserLogined() && $this->isUserLimitedPage($pageId, $pageSubId)){ // ユーザがログインされていない状態でユーザ制限されていればアクセス不可
5064 $this->isAccessPointWithAdminMenu = $isAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
5067 } else { // 無効ページのとき
5068 $isActivePage = false;
5073 * ウィジェットヘッダ(Joomla!1.0用)を出力タイプを取得
5075 * @return int 0=出力しない、1=Joomla!1.0テンプレートPC用、2=Joomla!1.0テンプレート携帯用
5077 function getTemplateWidgetHeaderType()
5079 global $gEnvManager;
5081 $templateId = $gEnvManager->getCurrentTemplateId();
5082 if ($templateId == self::ADMIN_TEMPLATE || // PC管理用テンプレート
5083 $templateId == self::M_ADMIN_TEMPLATE){ // 携帯管理用テンプレート
5085 } else if(strncmp($templateId, 'm/', 2) == 0){ // 携帯用テンプレート
5086 return 2; // 携帯テンプレート用出力
5088 return 1; // PCテンプレート用出力
5094 * @param string $pageId ページID
5095 * @param string $pageSubId ページサブID
5096 * @return bool true=必要、false=不要
5098 function isSslPage($pageId, $pageSubId)
5100 global $gEnvManager;
5103 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
5106 if ($pageId == $gEnvManager->getDefaultAdminPageId()){
5107 if ($gEnvManager->getUseSslAdmin()){ // 管理用ページにSSLを使用するかどうか
5112 } else { // その他のページのとき
5113 // 一般用ページにSSLを使用しない場合は不要を返す
5114 if (!$gEnvManager->getUseSsl()) return false;
5117 // 一般用ページでSSLを使用する場合は、データベースの設定をチェックする
5118 $line = $this->getPageInfo($pageId, $pageSubId);
5120 if ($line['pn_use_ssl']){
5129 * ユーザ制限が必要なページかどうかを判断
5131 * @param string $pageId ページID
5132 * @param string $pageSubId ページサブID
5133 * @return bool true=必要、false=不要
5135 function isUserLimitedPage($pageId, $pageSubId)
5137 global $gEnvManager;
5140 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
5142 $line = $this->getPageInfo($pageId, $pageSubId);
5144 if ($line['pn_user_limited']){
5155 * @param string $pageId ページID
5156 * @param string $pageSubId ページサブID
5157 * @return array ページ情報レコード
5159 function getPageInfo($pageId, $pageSubId)
5161 // ページ情報が空のときはデータをロード
5162 if (empty($this->pageInfo)){
5163 $records = $this->db->getPageInfoRecords();
5164 $count = count($records);
5165 $this->pageInfo = array();
5166 for ($i = 0; $i < $count; $i++){
5167 $pId = $records[$i]['pn_id'] . self::PAGE_ID_SEPARATOR . $records[$i]['pn_sub_id'];
5168 $this->pageInfo[$pId] = $records[$i];
5171 return $this->pageInfo[$pageId . self::PAGE_ID_SEPARATOR . $pageSubId];
5174 * 現在のページ情報からテンプレートIDを取得
5176 * @return string テンプレートID
5178 function getTemplateIdFromCurrentPageInfo()
5181 if (!empty($this->currentPageInfo)) $templateId = $this->currentPageInfo['pn_template_id'];
5185 * JavascriptライブラリのIDを取得
5187 * @param int $type 種別(0=すべて、1=jQuery関係すべて、2=jQueryプラグインのみ)
5188 * @return array JavascriptライブラリのID
5190 function getScriptLibId($type = 0)
5192 // Javascriptライブラリのすべてのキーを取得
5193 $keys = array_keys($this->libFiles);
5195 $destKeys = array();
5196 for ($i = 0; $i < count($keys); $i++){
5198 case 1: // jQuery関係すべて
5199 if (strStartsWith($keys[$i], 'jquery')) $destKeys[] = $keys[$i];
5201 case 2: // jQueryプラグインのみ
5202 if (strStartsWith($keys[$i], 'jquery.')) $destKeys[] = $keys[$i];
5209 * Javascriptライブラリの情報を取得
5211 * @param string $id ライブラリID
5212 * @return array ライブラリの情報
5214 function getScriptLibInfo($id)
5216 $libInfo = $this->libFiles[$id];
5217 if (isset($libInfo)){
5224 * 管理画面用jQueryUIテーマのURLを取得
5226 * @return string テーマURL
5228 function getAdminDefaultThemeUrl()
5230 // $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
5231 $themeFile = $this->gEnv->getAdminUrl(true/*「admin」削除*/) . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
5235 * 一般画面用jQueryUIテーマのURLを取得
5237 * @return string テーマURL
5239 function getDefaultThemeUrl()
5243 if (!isset($themeFile)){
5245 $theme = $this->gSystem->defaultTheme();
5246 if (!empty($theme)){
5247 $path = $this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
5248 if (file_exists($path)) $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
5256 * @param array $paramArray URL作成用のパス
5257 * @return string 作成したURLパラメータ
5259 function _createUrlParamStr($paramArray)
5262 if (count($paramArray) == 0) return $destParam;
5264 $sortParam = array();
5265 $keys = array_keys($paramArray);
5266 $keyCount = count($keys);
5267 for ($i = 0; $i < $keyCount; $i++){
5269 $value = $paramArray[$key];
5270 $orderNo = $this->urlParamOrder[$key];
5271 if (!isset($orderNo)) $orderNo = 100;
5272 $sortParam[] = array('key' => $key, 'value' => $value, 'no' => $orderNo);
5274 usort($sortParam, create_function('$a,$b', 'return $a["no"] - $b["no"];'));
5277 $sortCount = count($sortParam);
5278 for ($i = 0; $i < $sortCount; $i++){
5279 if ($i > 0) $destParam .= '&';
5280 $destParam .= rawurlencode($sortParam[$i]['key']) . '=' . rawurlencode($sortParam[$i]['value']);