9 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
11 * @package Magic3 Framework
12 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
13 * @copyright Copyright 2006-2018 Magic3 Project.
14 * @license http://www.gnu.org/copyleft/gpl.html GPL License
16 * @link http://www.magic3.org
18 require_once(M3_SYSTEM_INCLUDE_PATH . '/common/core.php');
19 require_once(M3_SYSTEM_INCLUDE_PATH . '/common/scriptLibInfo.php');
21 class PageManager extends Core
23 private $popupMsg; // ポップアップダイアログメッセージ
24 private $showPositionMode; // ポジション表示モード
25 private $showWidget; // ウィジェットの単体表示
26 private $systemHandleMode; // システム制御遷移モード(1=サイト非公開時)
27 private $isPageEditable; // フロント画面ページ編集可能モード
28 private $isTransparentMode; // 画面透過モード
29 private $isPersonalMode; // 機能アクセスパーソナルモード
30 private $isEditMode; // フロント画面編集モード
31 private $isLayout; // 画面レイアウト中かどうか
32 private $isPageTopUrl; // ページトップ(サブページ内のトップ位置)のURLかどうか
33 private $isContentDetailPage; // コンテンツ詳細画面のページかどうか
34 private $tmpData; // データ作成用
35 private $db; // DBオブジェクト
36 private $defaultScriptFiles; // デフォルトで読み込むスクリプトファイル
37 private $defaultCssFiles; // デフォルトで読み込むCSSファイル
38 private $defaultAdminScriptFiles; // デフォルトで読み込むスクリプトファイル(管理用)
39 private $defaultAdminCssFiles; // デフォルトで読み込むCSSファイル(管理用)
40 private $defaultAdminDirScriptFiles; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
41 private $defaultAdminDirCssFiles; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
42 private $headScriptFiles = array(); // ウィジェットからの追加で読み込むスクリプトファイル
43 private $headCssFiles = array(); // ウィジェットからの追加で読み込むCSSファイル
44 private $headRssFiles = array(); // HTMLヘッダに出力するRSS配信情報
45 private $currentWidgetPosition; // 現在のウィジェットのポジション
46 private $currentWidgetIndex; // 現在のウィジェットのポジション番号
47 private $pageDefPosition; // 現在取得しているページ定義のポジション
48 private $pageDefRows; // ページ定義レコード
49 private $nonSharedWidgetCount = -1; // 非共通ウィジェットの数(-1=ページ作成でないとき)
50 private $replaceHeadDone; // ヘッダマクロ変換処理が完了したかどうか
51 private $useHelp = false; // 標準ヘルプ機能を使用するかどうか
52 private $hasScriptCache = false; // JavaScriptファイルをブラウザにキャッシュさせるかどうか
53 private $isAccessPointWithAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
54 private $lateLaunchWidgetList; // 遅延実行ウィジェットのリスト
55 private $latelaunchWidgetParam; // 遅延実行ウィジェットのパラメータ
56 private $defPositions = array(); // テンプレート上のポジション(画面定義データすべて)
57 private $viewPositions = array(); // テンプレート上のポジション(ウィジェット表示ありのみ)
58 private $viewPosId = array(); // テンプレート上のポジションのタグID
59 private $updateParentWindow; // 親ウィンドウを再描画するかどうか
60 private $updateDefSerial; // 更新する項目のページ定義シリアル番号
61 private $headDescription; // HTMLヘッダ「description」に出力する文字列
62 private $headKeywords; // HTMLヘッダ「keywords」に出力する文字列
63 private $headOthers; // HTMLヘッダに出力するタグ文字列
64 private $adminHeadOthers; // HTMLヘッダに出力するタグ文字列(管理画面用)
65 private $lastHeadTitle; // 最後にヘッダ部titleにセットした文字列
66 private $lastHeadDescription; // 最後にヘッダ部descriptionにセットした文字列
67 private $lastHeadKeywords; // 最後にヘッダ部keywordsにセットした文字列
68 private $headFirstTag; // HTMLヘッダに最初に出力するタグ文字列
69 private $headCss = array(); // HTMLヘッダにCSS出力する文字列
70 private $headScript = array(); // HTMLヘッダにJavascript出力する文字列
71 private $headString = array(); // HTMLヘッダに出力する任意文字列
72 private $exportCss = array(); // 外部出力でCSS出力する文字列
73 private $lastHeadCss; // 最後に設定したHTMLヘッダにCSS出力する文字列
74 private $lastHeadScript; // 最後に設定したHTMLヘッダにJavascript出力する文字列
75 private $lastHeadString; // 最後に設定したHTMLヘッダに出力する任意文字列
76 private $headSubTitle = array(); // ヘッダタグサブタイトル
77 private $headSubTitleUrl = array(); // ヘッダサブタイトルのリンク先
78 private $headCanonicalUrl; // カノニカル属性URL
79 private $initScript = ''; // ウィンドウ初期化時に実行されるスクリプト
80 private $outputByHtml = true; // HTMLフォーマットで出力するかどうか
81 private $outputByStandardHead; // HTML文書の標準のヘッダタグを出力するかどうか
82 private $outputHead; // HTMLヘッダ出力を行ったかどうか
83 private $outputTheme; // jQueryUIテーマ出力を行ったかどうか
84 private $outputAjaxResponseBody; // AJAX用のレスポンスボディデータかどうか
85 private $isAbort; // ページ作成処理を中断するかどうか
86 private $isWidgetAbort; // 各ウィジェット処理を中断するかどうか
87 private $isRedirect; // リダイレクトするかどうか
88 private $isSystemPage; // システム制御ページを表示するかどうか
89 private $libFiles; // javascript追加用ライブラリ
90 private $pageDefRev = 234; // 画面定義のリビジョン番号
91 private $pageInfo; // すべてのページ情報
92 private $currentPageInfo; // 現在のページのページ情報
93 private $configWidgetInfo; // ウィジェット設定画面のウィジェットの情報
94 private $contentType = ''; // ページのコンテンツタイプ
95 private $mainContentTypeInfo; // フロント画面で使用する主要コンテンツタイプ
96 private $subContentTypeInfo; // フロント画面で使用する補助コンテンツタイプ
97 private $mainFeatureTypeInfo; // フロント画面で使用する主要機能タイプ
98 private $adminFeatureTypeInfo; // 管理画面専用で使用する主要機能タイプ
99 private $rssVersion; // RSSバージョン
100 private $rssChannel; // RSSチャンネルデータ
101 private $selectedJQueryFilename; // 使用対象のjQueryファイル
102 private $selectedJQueryUiFilename; // 使用対象のjQuery UIファイル
103 private $urlParamOrder; // URLパラメータの並び順
104 private $wysiwygEditor; // 管理画面用WYSIWYGエディター
105 private $optionTemplateId; // 追加設定するテンプレートID
106 private $optionSubTemplateId; // 追加設定するサブテンプレートID
107 private $isContentGooglemaps; // コンテンツにGoogleマップが含むかどうか
108 private $useGooglemaps; // Googleマップを使用するかどうか
109 private $useBootstrap; // Bootstrapを使用するかどうか
110 private $isHtml5; // HTML5で出力するかどうか
111 private $ckeditorCssFiles = array(); // CKEditor用のCSSファイル
112 private $ckeditorTemplateType; // CKEditor用のテンプレートタイプ
113 private $adminSubNavbarDef = array(); // 管理画面用のサブメニューバーの定義
114 private $adminBreadcrumbDef = array(); // 管理画面用パンくずリスト定義
115 private $adminBreadcrumbDefHelp = array(); // 管理画面用パンくずリストヘルプ定義
116 const CONFIG_KEY_HEAD_TITLE_FORMAT = 'head_title_format'; // ヘッダ作成用フォーマット
117 const ADMIN_WIDGET_ID = 'admin_main'; // 管理用ウィジェットのウィジェットID
118 //const CONTENT_TYPE_WIKI = 'wiki'; // ページのコンテンツタイプ(Wiki)
119 const WIDGET_ID_TAG_START = '{{WIDGETID:'; // 遅延実行用タグ
120 const WIDGET_ID_TAG_END = '}}'; // 遅延実行用タグ
121 const WIDGET_ID_TITLE_TAG_START = '{{WIDGETID_TITLE:'; // 遅延実行用タグ(タイトル埋め込み用)
122 const WIDGET_ID_TITLE_TAG_END = '}}'; // 遅延実行用タグ(タイトル埋め込み用)
123 const WIDGET_ID_SEPARATOR = ',';
124 const HEAD_TAGS = '{{HEAD_TAGS}}'; // HTMLヘッダ出力用タグ
125 const MENUBAR_TAGS = '{{MENUBAR_TAGS}}'; // メニューバー出力用タグ
126 const MENUBAR_SCRIPT_TAGS = '{{MENUBAR_SCRIPT_TAGS}}'; // メニューバー出力用スクリプトタグ
127 const WIDGET_ICON_IMG_SIZE = 32; // ウィジェットアイコンサイズ
128 const WIDGET_INVISIBLE_CLASS = 'm3invisible'; // 非表示ウィジェットクラス
129 const WIDGET_LOGIN_STATUS_CLASS = 'm3loginstatus'; // ログイン状態連動クラス
130 const WIDGET_OUTER_CLASS = 'm3_widget_outer'; // ウィジェット外枠クラス
131 const WIDGET_OUTER_CLASS_HEAD_POSITION = 'm3_pos_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
132 const WIDGET_OUTER_CLASS_WIDGET_TAG = 'm3_'; // ウィジェットの外枠クラス用ヘッダ(ポジション表示用)
133 // const WIDGET_INNER_CLASS = 'm3_widget_inner'; // ウィジェットの内側クラス
134 const POSITION_TAG_HEAD = 'm3pos_'; // ポジションの識別用タグIDヘッダ
135 const WIDGET_TAG_HEAD = 'm3widget_'; // ウィジェットの識別用タグIDヘッダ
136 // const WIDGET_TAG_HEAD_SHORT = 'm3_'; // ウィジェットの識別用タグIDヘッダ
137 const WIDGET_TYPE_TAG_HEAD = 'm3widgettype_'; // ウィジェット種別の識別用タグIDヘッダ
138 const WIDTET_CLASS_NAME = 'm3widget'; // ウィジェットオブジェクトのタグクラス名
139 const WIDTET_CLASS_TYPE_0 = 'm3widget_type0'; // ウィジェットオブジェクトのタグクラス(グローバル属性でない)
140 const WIDTET_CLASS_TYPE_1 = 'm3widget_type1'; // ウィジェットオブジェクトのタグクラス(グローバル属性)
141 const POSITION_CLASS_NAME = 'm3position'; // ポジションオブジェクトのタグクラス名
142 const JOOMLA10_DEFAULT_WIDGET_MENU_PARAM = 'class="moduletable"'; // Joomla!1.0用デフォルトメニューパラメータ値
143 const ADMIN_TEMPLATE = '_admin'; // PC管理用テンプレートID
144 const SCRIPT_LIB_SEPARATOR = ';'; // JavaScriptライブラリ読み込み設定のライブラリの区切り
145 const PAGE_ID_SEPARATOR = ','; // ページIDとページサブID連結用
146 const DEFAULT_ADMIN_FAVICON_FILE = '/images/system/favicon.ico'; // デフォルトの管理画面用faviconファイル
147 const DEFAULT_FAVICON_FILE = '/favicon.ico'; // デフォルトのfaviconファイル
148 // const DEFAULT_SITE_NAME = 'サイト名未設定'; // 管理画面用のデフォルトサイト名
149 const DEFAULT_ADMIN_TITLE = '管理画面'; // デフォルトの管理画面名
150 const WIDGET_TITLE_START = '['; // ウィジェットのタイトルの括弧
151 const WIDGET_TITLE_END = ']'; // ウィジェットのタイトルの括弧
152 const DEFAULT_RSS_VERSION = '1.0'; // デフォルトのRSSのバージョン
153 const CF_ACCESS_IN_INTRANET = 'access_in_intranet'; // イントラネット運用かどうか
154 const CF_USE_LATEST_SCRIPT_LIB = 'dev_use_latest_script_lib'; // 最新のJavaScriptライブラリを使用するかどうか
155 const CF_GOOGLE_MAPS_KEY = 'google_maps_key'; // Googleマップ利用キー
156 const CF_JQUERY_VERSION = 'jquery_version'; // jQueryバージョン
157 const CF_EXTERNAL_JQUERY = 'external_jquery'; // システム外部のjQueryを使用するかどうか
158 const CF_WYSIWYG_EDITOR = 'wysiwyg_editor'; // 管理画面用WYSIWYGエディター
159 const CF_ADMIN_JQUERY_VERSION = 'admin_jquery_version'; // 管理画面用jQueryバージョン
160 const SD_HEAD_OTHERS = 'head_others'; // ヘッダその他タグ
161 const DEFAULT_THEME_DIR = '/ui/themes/'; // jQueryUIテーマ格納ディレクトリ
162 const THEME_CSS_FILE = 'jquery-ui.custom.css'; // テーマファイル
163 const CONFIG_ICON_FILE = '/images/system/config.png'; // ウィジェット定義画面アイコン
164 const ADJUST_ICON_FILE = '/images/system/adjust_widget.png'; // 位置調整アイコン
165 const SHARED_ICON_FILE = '/images/system/shared.png'; // グローバル属性
166 const DELETE_ICON_FILE = '/images/system/delete.png'; // ウィジェット削除
167 const CONFIG_ICON32_FILE = '/images/system/config32.png'; // ウィジェット定義画面アイコン(ツールチップ用)
168 const ADJUST_ICON32_FILE = '/images/system/adjust_widget32.png'; // 位置調整アイコン(ツールチップ用)
169 const CLOSE_BOX_ICON32_FILE = '/images/system/close_box.png'; // ウィンドウ閉じるアイコン(ツールチップ用)
170 const NOTICE_ICON_FILE = '/images/system/notice16.png'; // ウィジェット配置注意アイコン
171 const ALERT_ICON_FILE = '/images/system/alert16.png'; // ウィジェット配置警告アイコン
172 // const ADMIN_ICON_FILE = '/images/system/admin64.png'; // パネルメニュー管理画面遷移用アイコン
173 // const LOGOUT_ICON_FILE = '/images/system/logout64.png'; // パネルメニューログアウト用アイコン
174 // const EDIT_PAGE_ICON_FILE = '/images/system/create_page64.png'; // パネルメニュー編集用アイコン
175 const ADMIN_ICON_FILE = '/images/system/home32.png'; // パネルメニュー管理画面遷移用アイコン
176 const LOGOUT_ICON_FILE = '/images/system/logout32.png'; // パネルメニューログアウト用アイコン
177 const EDIT_PAGE_ICON_FILE = '/images/system/create_page32.png'; // パネルメニュー編集用アイコン
178 // const EDIT_END_ICON_FILE = '/images/system/close32.png'; // パネルメニュー編集終了用アイコン
179 const EDIT_END_ICON_FILE = '/images/system/back32.png'; // パネルメニュー編集終了用アイコン
180 const CLOSE_ICON_FILE = '/images/system/close32.png'; // ウィンドウ閉じるアイコン
181 const PREV_ICON_FILE = '/images/system/prev48.png'; // ウィンドウ「前へ」アイコン
182 const NEXT_ICON_FILE = '/images/system/next48.png'; // ウィンドウ「次へ」アイコン
183 const DEFAULT_READMORE_TITLE = 'もっと読む'; // もっと読むボタンのデフォルトタイトル
184 const POS_HEAD_NAV_MENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // 特殊ポジションブロック(ナビゲーションメニュー型)
185 const POS_HEAD_MAIN = '<i class="glyphicon glyphicon-stop" rel="m3help" title="メイン型" data-placement="auto"></i> '; // 特殊ポジションブロック(メイン型)
186 const WIDGET_MARK_MAIN = '<i class="glyphicon glyphicon-stop" rel="m3help" title="メイン型" data-placement="auto"></i> '; // ウィジェットの機能マーク(メイン型ウィジェット)
187 const WIDGET_MARK_NAVMENU = '<i class="glyphicon glyphicon-th" rel="m3help" title="ナビゲーションメニュー" data-placement="auto"></i> '; // ウィジェットの機能マーク(ナビゲーションメニュー)
188 const WIDGET_FUNCTION_MARK_BOOTSTRAP = ' <span class="label label-warning" rel="m3help" title="Bootstrap型テンプレート対応" data-placement="auto">B</span>'; // ウィジェット機能マーク(Boostrap型テンプレート
189 const WIDGET_FUNCTION_MARK_WORDPRESS = ' <span class="label label-warning" rel="m3help" title="WordPress型テンプレート対応" data-placement="auto">W</span>'; // ウィジェット機能マーク(WordPress型テンプレート
190 const WIDGET_STYLE_NAVMENU = '_navmenu'; // ウィジェットの表示スタイル(ナビゲーションメニュー)
191 const WIDGET_STYLE_WORDPRESS = '_wordpress'; // ウィジェットの表示スタイル(WordPressテンプレート用出力)
192 const WIDGET_STYLE_WORDPRESS_NOTITLE = '_wordpress_notitle'; // ウィジェットの表示スタイル(WordPressテンプレート(タイトルなし)用出力)
195 const CONTENT_OBJ_ID = 'contentlib'; // 汎用コンテンツオブジェクトID
196 const BLOG_OBJ_ID = 'bloglib'; // ブログオブジェクトID
197 const LINKINFO_OBJ_ID = 'linkinfo'; // リンク情報オブジェクトID
200 const IWIDTET_CMD_CONTENT = 'content'; // コンテンツ取得
201 const IWIDTET_CMD_INIT = 'init'; // 初期化
202 const IWIDTET_CMD_UPDATE = 'update'; // 更新
203 const IWIDTET_CMD_CALC = 'calc'; // 計算
206 const M3_ADMIN_SCRIPT_FILENAME = 'm3admin2.0.3.js'; // 管理機能用スクリプト(CKEditor4.0.1対応)
207 const M3_ADMIN_WIDGET_SCRIPT_FILENAME = 'm3admin_widget2.0.10.js'; // 管理機能(ウィジェット操作)用スクリプト
208 const M3_ADMIN_WIDGET_CSS_FILE = '/m3/widget.css'; // 管理機能(ウィジェット操作)用CSSファイル
209 const M3_STD_SCRIPT_FILENAME = 'm3std1.5.2.js'; // 一般、管理機能共通スクリプト
210 const M3_OPTION_SCRIPT_FILENAME = 'm3opt1.2.1.js'; // AJAXを含んだオプションライブラリファイル(jQuery必須)
211 const M3_ADMIN_CSS_FILE = 'm3/admin.css'; // 管理機能用のCSS
212 const M3_EDIT_CSS_FILE = 'm3/edit.css'; // フロント画面編集用のCSS
213 const M3_DEFAULT_CSS_FILE = 'm3/default.css'; // フロント画面共通のデフォルトCSS
214 const M3_CKEDITOR_CSS_FILE = 'm3/ckeditor.css'; // CKEditorの編集エリア用CSS
217 const USE_BOOTSTRAP_ADMIN = false; // 管理画面でBootstrapを使用するかどうか(デフォルト値)
218 const BOOTSTRAP_BUTTON_CLASS = 'btn btn-default';
221 const FILEBROWSER_WIDTH_RATIO = '0.8'; // ファイルブラウザ幅比率
222 const FILEBROWSER_HEIGHT_RATIO = '0.8'; // ファイルブラウザ高さ比率
227 function __construct()
229 global $gInstanceManager;
231 global $gSystemManager;
232 global $gRequestManager;
235 parent::__construct();
237 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
238 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
241 $this->db = $gInstanceManager->getSytemDbObject();
244 $value = $gSystemManager->getSystemConfig(self::CF_ACCESS_IN_INTRANET); // イントラネット運用かどうか
245 if (empty($value)){ // インターネット運用
246 $this->useGooglemaps = true; // Googleマップを使用するかどうか
248 $this->useHelp = true; // ヘルプ機能
250 // デフォルトのWYSIWYGエディターを取得
251 $this->wysiwygEditor = $gSystemManager->getSystemConfig(self::CF_WYSIWYG_EDITOR); // 管理画面用WYSIWYGエディター
253 // ##### Javascriptライブラリのバージョン設定 #####
255 // アクセスする画面に応じてjQueryのバージョンを設定
256 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
257 $value = $gSystemManager->getSystemConfig(self::CF_ADMIN_JQUERY_VERSION);// 管理画面用jQueryバージョン
259 // 管理画面にBOOTSTRAPを使用するかどうか(初期値)
260 $this->useBootstrap = self::USE_BOOTSTRAP_ADMIN;
263 // 小画面デバイス最適化の場合は最新バージョンを使用
264 if ($gEnvManager->isSmallDeviceAdmin()) ScriptLibInfo::setCkeditorVer(1/*最新*/);
266 $value = $gSystemManager->getSystemConfig(self::CF_JQUERY_VERSION);// jQueryバージョン
268 ScriptLibInfo::setJQueryVer($value);
270 // WYSISIGエディターのタイプを設定。ScriptLibInfo::getLib()を実行する前に設定。
271 ScriptLibInfo::setWysiwygEditorType($this->wysiwygEditor);
274 $this->libFiles = ScriptLibInfo::getLib(); // ライブラリ取得
277 $this->selectedJQueryFilename = ScriptLibInfo::getJQueryFilename(0); // 使用対象のjQueryファイル
278 $this->selectedJQueryUiFilename = ScriptLibInfo::getJQueryFilename(1); // 使用対象のjQuery UIファイル
280 // ##### フロント画面用のデフォルトのJavascript、CSSを取得 #####
281 $this->defaultScriptFiles = array(
282 $this->selectedJQueryFilename, // jQuery
283 self::M3_STD_SCRIPT_FILENAME
285 $this->defaultCssFiles = array(
286 self::M3_DEFAULT_CSS_FILE // フロント画面共通のデフォルトCSS
289 // ##### 管理機能用のデフォルトのJavascript、CSSを取得 #####
290 if (defined('M3_STATE_IN_INSTALL')){ // インストーラの場合のスクリプト
291 $this->defaultAdminScriptFiles = array(
292 $this->selectedJQueryFilename, // jQuery
293 // self::M3_STD_SCRIPT_FILENAME,
294 self::M3_ADMIN_SCRIPT_FILENAME
296 $this->defaultAdminCssFiles = array(); // 管理機能用のCSS
298 $this->defaultAdminScriptFiles = array(
299 $this->selectedJQueryFilename, // jQuery
300 $this->selectedJQueryUiFilename, // jQuery UI Core
301 ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME, // jQuery Contextmenu Lib
302 self::M3_STD_SCRIPT_FILENAME,
303 self::M3_ADMIN_SCRIPT_FILENAME,
304 self::M3_OPTION_SCRIPT_FILENAME
306 $this->defaultAdminCssFiles = array(
307 self::M3_ADMIN_CSS_FILE // 管理機能用のCSS
311 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用
312 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用
313 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_NUMERIC); // 入力制限プラグイン
314 // $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
317 // 管理権限なしで管理ディレクトリアクセスで読み込むスクリプトファイル
318 $this->defaultAdminDirScriptFiles = array($this->selectedJQueryFilename); // jQuery
321 $this->lateLaunchWidgetList = array();
322 $this->latelaunchWidgetParam = array();
325 if ($gEnvManager->canUseDb()){
326 $value = $this->gSystem->getSystemConfig('script_cache_in_browser'); // ブラウザにJavaScriptファイルのキャッシュを保持するかどうか
327 if ($value != '') $this->hasScriptCache = $value;
330 $this->rssVersion = self::DEFAULT_RSS_VERSION; // RSSバージョン
332 // フロント画面で使用する主要コンテンツタイプ
333 $this->mainContentTypeInfo = array(
334 array( 'name' => '汎用コンテンツ', 'value' => M3_VIEW_TYPE_CONTENT),
335 array( 'name' => 'ブログ', 'value' => M3_VIEW_TYPE_BLOG),
336 array( 'name' => '製品', 'value' => M3_VIEW_TYPE_PRODUCT),
337 array( 'name' => 'BBS', 'value' => M3_VIEW_TYPE_BBS),
338 array( 'name' => 'Wiki', 'value' => M3_VIEW_TYPE_WIKI),
339 array( 'name' => 'イベント情報', 'value' => M3_VIEW_TYPE_EVENT),
340 array( 'name' => 'フォトギャラリー', 'value' => M3_VIEW_TYPE_PHOTO),
341 array( 'name' => '会員情報', 'value' => M3_VIEW_TYPE_MEMBER)
343 // フロント画面で使用する補助コンテンツタイプ(ページ属性に対応しない)
344 $this->subContentTypeInfo = array( array( 'name' => '新着情報', 'value' => M3_VIEW_TYPE_NEWS),
345 array( 'name' => 'コメント', 'value' => M3_VIEW_TYPE_COMMENT),
346 array( 'name' => 'イベント予約', 'value' => M3_VIEW_TYPE_EVENTENTRY),
347 array( 'name' => 'バナー', 'value' => M3_VIEW_TYPE_BANNER)
349 // フロント画面で使用する主要機能タイプ(「ダッシュボード」は含まない)
350 $this->mainFeatureTypeInfo = array( array( 'name' => '検索', 'value' => M3_VIEW_TYPE_SEARCH),
351 array( 'name' => 'Eコマース', 'value' => M3_VIEW_TYPE_COMMERCE),
352 array( 'name' => 'カレンダー', 'value' => M3_VIEW_TYPE_CALENDAR)
355 $this->adminFeatureTypeInfo = array( array( 'name' => 'ダッシュボード', 'value' => M3_VIEW_TYPE_DASHBOARD)
359 $this->urlParamOrder = array(
361 M3_REQUEST_PARAM_CONTENT_ID => -20, // 汎用コンテンツID
362 M3_REQUEST_PARAM_CONTENT_ID_SHORT => -19, // 汎用コンテンツID(略式)
363 M3_REQUEST_PARAM_PRODUCT_ID => -18, // 製品ID
364 M3_REQUEST_PARAM_PRODUCT_ID_SHORT => -17, // 製品ID(略式)
365 M3_REQUEST_PARAM_BLOG_ID => -16, // ブログID
366 M3_REQUEST_PARAM_BLOG_ID_SHORT => -15, // ブログID(略式)
367 M3_REQUEST_PARAM_BLOG_ENTRY_ID => -14, // ブログ記事ID
368 M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT => -13, // ブログ記事ID(略式)
369 M3_REQUEST_PARAM_BBS_ID => -12, // 掲示板投稿記事ID
370 M3_REQUEST_PARAM_BBS_ID_SHORT => -11, // 掲示板投稿記事ID(略式)
371 M3_REQUEST_PARAM_BBS_THREAD_ID => -10, // 掲示板投稿スレッドID
372 M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT => -9, // 掲示板投稿スレッドID(略式)
373 M3_REQUEST_PARAM_EVENT_ID => -4, // イベントID
374 M3_REQUEST_PARAM_EVENT_ID_SHORT => -3, // イベントID(略式)
375 M3_REQUEST_PARAM_PHOTO_ID => -2, // 画像ID
376 M3_REQUEST_PARAM_PHOTO_ID_SHORT => -1, // 画像ID(略式)
378 M3_REQUEST_PARAM_PAGE_SUB_ID => 1, // ページサブID
379 M3_REQUEST_PARAM_PAGE_CONTENT_ID => 2, // ページコンテンツID
380 M3_REQUEST_PARAM_WIDGET_ID => 3, // ウィジェットID
381 M3_REQUEST_PARAM_TEMPLATE_ID => 4, // テンプレートID
382 M3_REQUEST_PARAM_URL => 5, // リンク先等のURL
383 M3_REQUEST_PARAM_STAMP => 6, // 公開発行ID
384 M3_REQUEST_PARAM_OPTION => 7, // 通信オプション
385 M3_REQUEST_PARAM_OPERATION_COMMAND => 8, // 実行処理
386 M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND => 9, // Wikiコマンド実行
387 M3_REQUEST_PARAM_OPERATION_TASK => 10, // ウィジェット間共通処理
388 M3_REQUEST_PARAM_OPERATION_ACT => 11, // クライアントからの実行処理
389 M3_REQUEST_PARAM_OPERATION_LANG => 12, // 言語指定表示
390 M3_REQUEST_PARAM_SERIAL_NO => 13, // シリアル番号
391 M3_REQUEST_PARAM_PAGE_NO => 14, // ページ番号
392 M3_REQUEST_PARAM_LIST_NO => 15, // 一覧番号
393 M3_REQUEST_PARAM_ITEM_NO => 16, // 項目番号
394 M3_REQUEST_PARAM_OPERATION_TODO => 17, // 指定ウィジェットに実行させる処理
395 M3_REQUEST_PARAM_FROM => 18, // メッセージの送信元ウィジェットID
396 M3_REQUEST_PARAM_VIEW_STYLE => 19, // 表示スタイル
397 M3_REQUEST_PARAM_FORWARD => 20, // 画面遷移用パラメータ
398 M3_REQUEST_PARAM_OPEN_BY => 22, // ウィンドウの開き方
399 M3_REQUEST_PARAM_SHOW_HEADER => 23, // ヘッダ部表示制御
400 M3_REQUEST_PARAM_SHOW_FOOTER => 24, // フッタ部表示制御
401 M3_REQUEST_PARAM_SHOW_MENU => 25, // メニュー部表示制御
402 M3_REQUEST_PARAM_KEYWORD => 26, // 検索キーワード
403 M3_REQUEST_PARAM_HISTORY => 27, // 履歴インデックスNo
404 M3_REQUEST_PARAM_DEF_PAGE_ID => 28, // ページID(画面編集用)
405 M3_REQUEST_PARAM_DEF_PAGE_SUB_ID => 29, // ページサブID(画面編集用)
406 M3_REQUEST_PARAM_PAGE_DEF_SERIAL => 30, // ページ定義のレコードシリアル番号(設定画面起動時)
407 M3_REQUEST_PARAM_PAGE_DEF_CONFIG_ID => 31, // ページ定義のウィジェット定義ID(設定画面起動時)
408 M3_REQUEST_PARAM_BACK_URL => 32, // 戻り先URL
409 M3_REQUEST_PARAM_BACKUP_URL => 33, // URL退避用(画面編集時)
410 M3_REQUEST_PARAM_SERVER => 34, // サーバ指定
411 M3_REQUEST_PARAM_CATEGORY_ID => 35, // カテゴリID(共通)
412 M3_REQUEST_PARAM_WIDTH => 36, // 幅
413 M3_REQUEST_PARAM_HEIGHT => 37); // 高さ
418 * @return array コンテンツタイプ
420 public function _getAllContentType()
422 global $M3_ALL_CONTENT_TYPE;
424 return $M3_ALL_CONTENT_TYPE;
429 * @return array 機能タイプ
431 public function _getAllFeatureType()
433 global $M3_ALL_FEATURE_TYPE;
435 /* $featureType = array( M3_VIEW_TYPE_DASHBOARD, // ダッシュボード
436 M3_VIEW_TYPE_SEARCH, // 検索結果
437 M3_VIEW_TYPE_COMMERCE); // Eコマース
438 return $featureType;*/
439 return $M3_ALL_FEATURE_TYPE;
446 function setNoTimeout()
448 if (ini_get('safe_mode') == '0') set_time_limit(0);
453 * @param string $msg メッセージ
455 function setPopupMsg($msg)
457 $this->popupMsg = $msg;
460 * HTMLヘッダ「description」に出力する文字列を設定
462 * @param string $str 出力文字列
464 function setHeadDescription($str)
466 if (is_string($str) && !empty($str)){
467 $this->headDescription = $str;
468 $this->lastHeadDescription = $str; // 最後に設定した値を退避
472 * HTMLヘッダ「description」に出力する文字列を取得
474 * @return string $str 出力文字列
476 function getHeadDescription()
478 return $this->headDescription;
481 * HTMLヘッダ「keywords」に出力する文字列を設定
483 * @param string $str 出力文字列
485 function setHeadKeywords($str)
487 if (is_string($str) && !empty($str)){
488 $this->headKeywords = $str;
489 $this->lastHeadKeywords = $str; // 最後に設定した値を退避
493 * HTMLヘッダ「keywords」に出力する文字列を取得
495 * @return string $str 出力文字列
497 function getHeadKeywords()
499 return $this->headKeywords;
502 * HTMLヘッダに出力するタグ文字列を設定
504 * @param string $str 出力文字列
507 function setHeadOthers($str)
509 if (is_string($str) && !empty($str)){
510 $this->headOthers = $str;
514 * HTMLヘッダに出力するタグ文字列を追加
516 * @param string $str 出力文字列
519 function addHeadOthers($str)
521 if (is_string($str) && !empty($str)){
523 $pos = strpos($this->headOthers, $str);
524 if ($pos === false) $this->headOthers .= $str;
528 * HTMLヘッダに出力するタグ文字列を追加(管理画面用)
530 * @param string $str 出力文字列
533 function addAdminHeadOthers($str)
535 if (is_string($str) && !empty($str)){
537 $pos = strpos($this->adminHeadOthers, $str);
538 if ($pos === false) $this->adminHeadOthers .= $str;
542 * HTMLヘッダ「title」のサブタイトル出力する文字列を設定
544 * @param string $str 出力文字列
545 * @param string $url リンク先
546 * @param bool $isDefault デフォルト値かどうか
549 function setHeadSubTitle($str = '', $url = '', $isDefault = false)
551 // ##### ページのサブタイトルはデフォルトでページのMETAタイトルを使用し、メインウィジェット側で上書きする #####
553 static $isUpdated = false; // デフォルト値が更新されているかどうか
555 if (!is_string($str) || empty($str)) return;
559 $this->headSubTitle = array();
560 $this->headSubTitleUrl = array();
561 $this->lastHeadTitle = '';
563 } else { // デフォルトでない場合はデータを追加
564 if (!$isUpdated){ // デフォルト値が更新されていない場合は以前のデータを削除
565 $this->headSubTitle = array();
566 $this->headSubTitleUrl = array();
567 $this->lastHeadTitle = '';
568 $isUpdated = true; // デフォルト値は更新された
572 $this->headSubTitle[] = $str;
573 $this->headSubTitleUrl[] = $url;
574 $this->lastHeadTitle = $str; // 最後に設定した値を退避
577 * HTMLヘッダ「title」のサブタイトル出力する文字列を取得
579 * @return $array サブタイトルに設定されている文字列を連想配列(title=タイトル、url=リンク先URL)の配列で返す
581 function getHeadSubTitle()
583 $titleArray = array();
584 $titleCount = count($this->headSubTitle);
585 for ($i = 0; $i < $titleCount; $i++){
586 $line = array('title' => $this->headSubTitle[$i], 'url' => $this->headSubTitleUrl[$i]);
587 $titleArray[] = $line;
592 * HTMLヘッダに出力するCSSの文字列を設定
594 * @param string $css 追加するCSS内容
597 function addHeadCss($css)
599 $destCss = trim($css);
600 if (!empty($destCss)){
601 //if (!in_array($css, $this->headCss)) $this->headCss[] = $css;
602 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css; // CSS動的外部出力
604 $this->lastHeadCss = $css; // 最後に設定したHTMLヘッダにCSS出力する文字列
608 * 外部出力で出力するCSSの文字列を設定(ウィジェット共通設定からの設定値)
610 * @param string $css 追加するCSS内容
613 function addExportCss($css)
615 $destCss = trim($css);
616 if (!empty($destCss)){
617 if (!in_array($css, $this->exportCss)) $this->exportCss[] = $css;
621 * HTMLヘッダに出力するJavascriptの文字列を設定
623 * @param string $script 追加するJavascript内容
626 function addHeadScript($script)
628 $destScript = trim($script);
629 if (!empty($destScript)){
630 if (!in_array($script, $this->headScript)) $this->headScript[] = $script;
632 $this->lastHeadScript = $script; // 最後に設定したHTMLヘッダにJavascript出力する文字列
636 * HTMLヘッダに出力する任意文字列を設定
638 * @param string $str 追加する任意文字列
641 function addHeadString($str)
643 $destScript = trim($str);
644 if (!empty($destScript)){
645 if (!in_array($str, $this->headString)) $this->headString[] = $str;
647 $this->lastHeadString = $str; // 最後に設定したHTMLヘッダに出力する任意文字列
651 * HTMLヘッダに出力するCSSファイルを追加
653 * @param string,array $cssFile CSSファイルURLパス
656 function addHeadCssFile($cssFile)
658 if (is_array($cssFile)){ // 配列の場合
659 for ($i = 0; $i < count($cssFile); $i++){
660 $destCss = trim($cssFile[$i]);
661 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
664 $destCss = trim($cssFile);
665 if (!empty($destCss) && !in_array($destCss, $this->headCssFiles)) $this->headCssFiles[] = $destCss;
669 * HTMLヘッダに出力するJavascriptライブラリを追加
671 * @param string,array $scriptLib JavascriptライブラリID
674 function addHeadAdminScriptLib($scriptLib)
676 if (is_array($scriptLib)){ // 配列の場合
677 for ($i = 0; $i < count($scriptLib); $i++){
678 $destScript = trim($scriptLib[$i]);
679 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
682 $destScript = trim($scriptLib);
683 if (!empty($destScript)) $this->addAdminScript('', $destScript);// スクリプト追加
687 * HTMLヘッダに出力するJavascriptライブラリを追加
689 * @param string,array $scriptLib JavascriptライブラリID
692 function addHeadScriptLib($scriptLib)
694 if (is_array($scriptLib)){ // 配列の場合
695 for ($i = 0; $i < count($scriptLib); $i++){
696 $destScript = trim($scriptLib[$i]);
697 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
700 $destScript = trim($scriptLib);
701 if (!empty($destScript)) $this->addScript('', $destScript);// スクリプト追加
705 * HTMLヘッダに出力するJavascriptファイルを追加
707 * @param string,array $scriptFile JavascriptファイルURLパス
710 function addHeadScriptFile($scriptFile)
712 if (is_array($scriptFile)){ // 配列の場合
713 for ($i = 0; $i < count($scriptFile); $i++){
714 $destScript = trim($scriptFile[$i]);
715 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
718 $destScript = trim($scriptFile);
719 if (!empty($destScript) && !in_array($destScript, $this->headScriptFiles)) $this->headScriptFiles[] = $destScript;
723 * HTMLヘッダに出力するRSSファイルを追加
725 * @param array $rssFile タイトル(title)、配信用URL(href)の連想配列。複数の場合は連想配列の配列。
728 function addHeadRssFile($rssFile)
731 if (!is_array($rssFile)) return;
734 if (is_array($line)){ // 複数追加の場合
735 for ($i = 0; $i < count($line); $i++){
737 $url = trim($line[$i]['href']);
739 for ($j = 0; $j < count($this->headRssFiles); $j++){
740 $storedUrl = $this->headRssFiles[$j]['href'];
741 if ($url == $storedUrl) break;
743 if ($j == count($this->headRssFiles)){ // 見つからないときは追加
744 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
745 'title' => $line[$i]['title']); // タイトル
751 $url = trim($rssFile['href']);
753 for ($i = 0; $i < count($this->headRssFiles); $i++){
754 $storedUrl = $this->headRssFiles[$i]['href'];
755 if ($url == $storedUrl) break;
757 if ($i == count($this->headRssFiles)){ // 見つからないときは追加
758 $this->headRssFiles[] = array( 'href' => $url, // リンク先URL
759 'title' => $rssFile['title']); // タイトル
765 * HTMLヘッダに最初に出力するタグ文字列を設定
767 * @param string $str 追加するタグ文字列
770 function setHeadFirstTag($str)
772 if (!empty($str)) $this->headFirstTag = $str;
775 * ヘッダ部に出力するカノニカル属性URLを設定
777 * @param string $url URL
780 function setCanonicalUrl($url)
782 if (!empty($url)) $this->headCanonicalUrl = $url; // カノニカル属性URL
785 * RSSチャンネル部に出力するデータを設定
787 * @param array $rssData RSSチャンネル部データ
790 function setRssChannel($rssData)
792 if (!empty($rssData)) $this->rssChannel = $rssData; // RSSチャンネルデータ
797 * @param int $mode 0=ポジション表示しない(通常画面)、1=ポジション表示、2=ウィジェット込みポジション表示
799 function showPosition($mode)
801 $this->showPositionMode = $mode;
806 * @return bool true=レイアウト中、false=レイアウト中でない
810 return $this->isLayout; // 画面レイアウト中かどうか
815 function showWidget()
817 $this->showWidget = true;
822 * @param bool true=単体表示、false=単体表示でない
824 function getShowWidget()
826 return $this->showWidget;
831 * @param int $mode 0=設定なし、1=ログイン画面、10=サイト非公開、11=アクセス不可、12=存在しないページ
833 function setSystemHandleMode($mode)
835 $this->systemHandleMode = $mode;
840 function getSystemHandleMode()
842 return $this->systemHandleMode;
849 function setEditMode()
851 $this->isEditMode = true;
856 * @return bool true=編集モードオン、false=編集モードオフ
858 function isEditMode()
860 return $this->isEditMode;
867 function setPersonalMode()
869 $this->isPersonalMode = true;
874 * @return bool true=パーソナルモードオン、false=パーソナルモードオフ
876 function isPersonalMode()
878 return $this->isPersonalMode;
881 * 出力フォーマットがHTMLであるかを設定
883 * @param bool $isHtml HTMLフォーマットかどうか
886 function setOutputByHtml($isHtml)
888 $this->outputByHtml = $isHtml;
892 * AJAX用のレスポンスボディデータかどうかを設定
894 * @param bool $isResponseBody レスポンスボディデータかどうか
897 function setOutputAjaxResponseBody($isResponseBody)
899 $this->outputAjaxResponseBody = $isResponseBody;
904 * @param bool $status ヘルプ機能を使用するかどうか
907 function setUseHelp($status)
909 $this->useHelp = $status;
914 * @return bool ヘルプ機能を使用するかどうか
916 function getUseHelp()
918 return $this->useHelp;
921 * 表示するコンテンツにGoogleマップが含まれているかを設定
923 * @param bool $status Googleマップを含むかどうか
926 function setIsContentGooglemaps($status)
928 $this->isContentGooglemaps = $status; // コンテンツにGoogleマップが含むかどうか
931 * 表示するコンテンツにGoogleマップが含まれているかを取得
933 * @return bool ヘルプ機能を使用するかどうか
935 function isContentGooglemaps()
937 return $this->isContentGooglemaps;
940 * JavaScriptのブラウザキャッシュの使用可否を設定
942 * @param bool $status ブラウザキャッシュを使用するかどうか
945 function setHasScriptCache($status)
947 $this->hasScriptCache = $status;
954 function useBootstrap()
956 $this->useBootstrap = true; // Bootstrapを使用するかどうか
959 * Bootstrapを強制的に未使用に設定
963 function cancelBootstrap()
965 $this->useBootstrap = false; // Bootstrapを使用するかどうか
970 * @return bool true=使用、false=使用しない
972 function getUseBootstrap()
974 return $this->useBootstrap; // Bootstrapを使用するかどうか
983 $this->isHtml5 = true; // HTML5で出力するかどうか
986 * ページ作成処理を中断するかどうかを取得
988 * @return bool true=中断、false=継続
990 function isPageAbort()
992 return $this->isAbort;
997 * @param string $pos ポジション
998 * @param int $index インデックス番号
1001 function getCurrentWidgetPosition(&$pos, &$index)
1003 $pos = $this->currentWidgetPosition; // 現在のウィジェットのポジション
1004 $index = $this->currentWidgetIndex; // 現在のウィジェットのポジション番号
1009 * @param int $defSerial ページ定義シリアル番号
1012 function updateParentWindow($defSerial = 0)
1014 $this->updateParentWindow = true;
1015 $this->updateDefSerial = $defSerial; // 更新する項目のページ定義シリアル番号
1020 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1023 function addCssFile($path)
1025 $destPath = trim($path, '/');
1026 if (!in_array($destPath, $this->defaultCssFiles)) $this->defaultCssFiles[] = $destPath;
1031 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1034 function addAdminCssFile($path)
1036 $destPath = trim($path, '/');
1037 if (!in_array($destPath, $this->defaultAdminCssFiles)) $this->defaultAdminCssFiles[] = $destPath;
1042 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスまたは絶対パス(scriptディレクトリ以外の場合)で指定する)
1045 function addCkeditorCssFile($path)
1047 $destPath = trim($path, '/');
1048 if (!in_array($destPath, $this->ckeditorCssFiles)) $this->ckeditorCssFiles[] = $destPath;
1053 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1056 function addScriptFile($path)
1058 $destPath = trim($path, '/');
1059 if (!empty($destPath) && !in_array($destPath, $this->defaultScriptFiles)) $this->defaultScriptFiles[] = $destPath;
1064 * @param string $path 追加するファイルのパス(「ルート/scripts」ディレクトリからの相対パスで指定する)
1067 function addAdminScriptFile($path)
1069 $destPath = trim($path, '/');
1070 if (!in_array($destPath, $this->defaultAdminScriptFiles)) $this->defaultAdminScriptFiles[] = $destPath;
1075 * @return array テンプレートID,サブテンプレートIDの配列
1077 function getOptionTemplateId()
1079 global $gEnvManager;
1082 $pageId = $gEnvManager->getCurrentPageId();
1084 switch ($this->contentType){
1085 case M3_VIEW_TYPE_CONTENT: // ページのコンテンツタイプ
1087 $contentLibObj = $this->gInstance->getObject(self::CONTENT_OBJ_ID);
1088 if (isset($contentLibObj)) list($this->optionTemplateId, $this->optionSubTemplateId) = $contentLibObj->getOptionTemplate();
1090 case M3_VIEW_TYPE_BLOG: // ページがブログタイプのとき
1091 if ($pageId == $this->gEnv->getDefaultPageId()){ // PCサイトのとき
1092 // ブログライブラリオブジェクトからテンプレートを取得
1093 $blogLibObj = $this->gInstance->getObject(self::BLOG_OBJ_ID);
1094 if (isset($blogLibObj)) list($this->optionTemplateId, $this->optionSubTemplateId) = $blogLibObj->getOptionTemplate();
1098 return array($this->optionTemplateId, $this->optionSubTemplateId);
1101 * 使用した非共通ウィジェットの数を取得
1103 * @return int ウィジェット数
1105 function getNonSharedWidgetCount()
1107 return $this->nonSharedWidgetCount;
1112 * @return string コンテンツタイプ
1114 function getContentType()
1116 return $this->contentType;
1119 * フロント画面で使用する主要コンテンツタイプの情報取得
1121 * @return array コンテンツタイプの情報の連想配列
1123 function getMainContentTypeInfo()
1125 return $this->mainContentTypeInfo; // 主要コンテンツタイプ
1128 * フロント画面で使用する補助コンテンツタイプの情報取得
1130 * @return array コンテンツタイプの情報の連想配列
1132 function getSubContentTypeInfo()
1134 return $this->subContentTypeInfo; // 補助コンテンツタイプ
1137 * フロント画面で使用する主要コンテンツタイプを取得
1139 * @return array コンテンツタイプの配列
1141 function getMainContentTypes()
1144 //return array_map(create_function('$a', 'return $a["value"];'), $this->mainContentTypeInfo);
1145 $types = array_map(function($a){ return $a["value"]; }, $this->mainContentTypeInfo);
1149 * フロント画面で使用するサブコンテンツタイプを取得
1151 * @return array コンテンツタイプの配列
1153 function getSubContentTypes()
1156 // return array_map(create_function('$a', 'return $a["value"];'), $this->subContentTypeInfo);
1157 $types = array_map(function($a){ return $a["value"]; }, $this->subContentTypeInfo);
1161 * フロント画面で使用する主要機能タイプ情報を取得
1163 * @return array 機能タイプの情報の連想配列
1165 function getMainFeatureTypeInfo()
1167 return $this->mainFeatureTypeInfo; // 主要機能タイプ
1170 * フロント画面で使用する主要機能タイプを取得
1172 * @return array 機能タイプの配列
1174 function getMainFeatureTypes()
1177 // return array_map(create_function('$a', 'return $a["value"];'), $this->mainFeatureTypeInfo);
1178 $types = array_map(function($a){ return $a["value"]; }, $this->mainFeatureTypeInfo);
1185 * @return array ページ属性情報の連想配列
1187 function getAllPageAttributeTypeInfo()
1189 return array_merge($this->mainContentTypeInfo, $this->subContentTypeInfo, $this->mainFeatureTypeInfo, $this->adminFeatureTypeInfo);
1192 * 管理画面用のサブメニューバーの定義を設定
1194 * @param array $def メニューバー定義
1197 function setAdminSubNavbarDef($def)
1199 $this->adminSubNavbarDef = $def;
1202 * 管理画面用のサブメニューバーの定義を取得
1204 * @return array メニューバーの定義
1206 function getAdminSubNavbarDef()
1208 return $this->adminSubNavbarDef;
1213 * @param array $def パンくずリスト定義
1214 * @param array $help ヘルプ(title,bodyの連想配列)
1217 function setAdminBreadcrumbDef($def, $help = array())
1219 $this->adminBreadcrumbDef = $def;
1220 if (!empty($help)) $this->adminBreadcrumbDefHelp = $help; // 管理画面用パンくずリストヘルプ定義
1225 * @param array $help ヘルプ(title,bodyの連想配列)
1226 * @return array パンくずリスト定義
1228 function getAdminBreadcrumbDef(&$help)
1231 $argNum = func_num_args();
1233 // ヘルプ取得用パラメータが存在する場合は定義を設定
1234 if ($argNum > 0) $help = $this->adminBreadcrumbDefHelp;
1236 return $this->adminBreadcrumbDef;
1241 * HTTPヘッダを設定する。セッションを取得する。サブページIDを設定する。
1243 * @param RequestManager $request HTTPリクエスト処理クラス
1246 function startPage($request)
1248 global $gEnvManager;
1249 global $gRequestManager;
1250 global $gInstanceManager;
1251 global $gAccessManager;
1252 global $gSystemManager;
1253 global $gDispManager;
1254 global $gOpeLogManager;
1257 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
1258 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
1259 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
1260 $pageId = $gEnvManager->getCurrentPageId();
1262 // ###### クライアントIDの読み込み、再設定 ######
1263 // この後、クライアントIDがアクセスログに記録される
1264 $clientId = $request->getCookieValue(M3_COOKIE_CLIENT_ID);
1265 if (empty($clientId)){ // クライアントIDが設定されていないとき(初回アクセス)
1267 $clientId = $this->gAccess->createClientId();
1269 $this->gAccess->setClientId($clientId); // クライアントIDを設定
1272 $this->gEnv->setCanUseCookie(true);
1274 $request->setCookieValue(M3_COOKIE_CLIENT_ID, $clientId, M3_COOKIE_EXPIRE_CLIENT_ID);
1276 // インストール時の管理画面用ライブラリを追加(フレームコンテナでの設定を反映)
1277 if (defined('M3_STATE_IN_INSTALL')){
1279 if ($this->useBootstrap){
1280 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
1281 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
1284 // 管理者キーがあればGETまたはPOST値のセッションIDを使用する
1285 // if ($gEnvManager->isAdminDirAccess()){
1286 // if ($gAccessManager->isValidAdminKey()) session_id($gRequestManager->trimValueOf(session_name()));
1290 // 最終HTML(ページ全体で使用するHTML)の出力
1291 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
1292 $gRequestManager->stopSessionUpdate(); // セッションの更新を停止
1298 // ##### インストール時はここで終了 #####
1299 if (defined('M3_STATE_IN_INSTALL')) return; // インストール時は実行しない
1301 // セッションを再生成する(セキュリティ対策)
1302 if ($gSystemManager->regenerateSessionId()){
1303 $gAccessManager->setOldSessionId(session_id()); // 古いセッションIDを保存
1304 session_regenerate_id(true);
1308 $userInfo = $gRequestManager->getSessionValueWithSerialize(M3_SESSION_USER_INFO);
1309 if (!$gAccessManager->checkSessionSecurity($userInfo)) return; // セキュリティ問題ありの場合はここで終了
1310 // ##### ここで終了した場合はページサブIDが未設定のためページ不正のエラーが発生しアクセスエラー画面が表示される #####
1312 // ##### POST時のリファラーチェック #####
1313 // WooCommerceのAJAX処理が通らないのでチェックしない?
1314 /* if ($gRequestManager->isPostMethod() && !$this->_checkReferer()){
1315 $errMsg = '不正なPOSTデータ(リファラー異常)を検出しました。アクセス元IP: ' . $gAccessManager->getClientIp();
1316 $msgDetail = 'アクセスをブロックしました。account=' . $userInfo->account . ', userid=' . $userInfo->userId;
1317 $gOpeLogManager->writeUserError(__METHOD__, $errMsg, 2210, $msgDetail);
1322 $gRequestManager->_doSessionOpenEventCallback();
1325 $gInstanceManager->setUserInfo($userInfo);
1327 // ##### 自動ログイン #####
1328 // ログイン中でない場合は自動ログインでユーザ情報を取得
1329 $gAccessManager->startAutoLogin();
1332 if (M3_SYSTEM_DEBUG) echo 'Debug mode<br />';
1334 // ##### ユーザアクセスモードの設定 #####
1335 if (!empty($userInfo) && $userInfo->isPersonal()) $this->setPersonalMode(); // パーソナルモードをオン
1336 /* if (($userInfo->userType == UserInfo::USER_TYPE_MANAGER && $userInfo->userOptType == UserInfo::USER_OPT_TYPE_PAGE_MANAGER)|| // ページ運用者の場合
1337 $userInfo->userType < UserInfo::USER_TYPE_MANAGER){ // システム運用者よりも権限が低い場合
1340 $this->setPersonalMode();
1343 // ##### ページIDの修正 #####
1344 // ポジション表示の場合はページID、ページサブIDを再設定。再設定はシステム管理者のみ可能。
1345 if (($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 管理画面(ウィジェットなしポジション表示)のとき
1346 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) && // 管理画面(ウィジェット付きポジション表示)のとき
1347 // $gEnvManager->isSystemAdmin()){
1348 $gEnvManager->isSystemManageUser()){ // システム運用可能の場合(2018/8/5変更)
1350 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1351 if (empty($pageId)) $pageId = $this->gEnv->getDefaultPageId(); // 値がないときはデフォルトのページIDを設定
1352 $this->gEnv->setCurrentPageId($pageId);
1353 $subId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1354 if (!empty($subId)) $this->gEnv->setCurrentPageSubId($subId);
1357 // ##### サブページIDの設定 #####
1358 if ($gEnvManager->isAdminDirAccess() && // 管理画面へのアクセスのとき
1359 ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT)){ // ログイン、ログアウト場合は管理画面のページサブIDを指定
1360 $subId = $gEnvManager->getAdminDefaultPageSubId(); // 管理画面用のデフォルトページサブID
1362 if (empty($subId)) $subId = $request->trimValueOf(M3_REQUEST_PARAM_PAGE_SUB_ID);// ページサブIDを取得
1364 if (empty($subId)){ // サブページIDが設定されていないとき
1365 // URLパラメータからコンテンツ形式を取得し、ページを選択
1366 $params = $gRequestManager->getQueryArray();
1367 $paramCount = count($params);
1369 // コマンド以外のパラメータ数が1つだけのときはパラメータからページ属性を判断する
1370 // 値が空でもキーがあれば属性を持つとする
1371 if ($paramCount == 0){
1372 $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1374 //if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemAdmin() && empty($task)){
1375 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser() && empty($task)){
1376 // ダッシュボード機能は、パラメータなし、管理者ディレクトリ、システム運用者の条件で使用可能(2018/8/5変更)
1377 // POST値にタスクがある場合はダッシュボードとしない
1378 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_DASHBOARD, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1380 } else if ($paramCount > 0 && !$gEnvManager->isAdminDirAccess()){ // パラメータ付きの場合(2013/3/23)
1381 // ##### ページ属性から画面を選択(管理画面は対応しない) ###
1382 // 最初のURLパラメータでコンテンツを判断
1383 // プレビュー(cmd=preview)等のパターンで複数パラメータがある
1385 $firstKey = key($params);
1386 $firstValue = $params[$firstKey];
1388 if (!empty($firstValue)){ // 「key=value」の形式であること
1390 case M3_REQUEST_PARAM_CONTENT_ID: // コンテンツIDのとき
1391 case M3_REQUEST_PARAM_CONTENT_ID_SHORT:
1392 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1393 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1394 if (!$checkStatus) return; // エラーの場合は終了
1396 // ローカルメニューのURLからページを特定。ページが特定できないときはページ属性で取得。
1397 $url = $gEnvManager->getMacroPath($gEnvManager->getCurrentRequestUri());
1398 $ret = $this->db->getSubPageIdByMenuItemUrl($url, $gEnvManager->getCurrentPageId(), M3_VIEW_TYPE_CONTENT, $rows);
1400 $rowCount = count($rows);
1401 for ($i = 0; $i < $rowCount; $i++){
1402 // コンテンツを表示するウィジェットがあるときはページサブIDを確定
1403 //$widgetId = $this->db->getWidgetIdByType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);
1404 $widgetId = $this->db->getWidgetIdByContentType($gEnvManager->getCurrentPageId(), $rows[$i]['pd_sub_id'], M3_VIEW_TYPE_CONTENT);// コンテンツタイプでの取得に変更(2012/6/20)
1405 if (!empty($widgetId)){
1406 $subId = $rows[$i]['pd_sub_id'];
1411 if (empty($subId)) $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_CONTENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1412 $this->contentType = M3_VIEW_TYPE_CONTENT; // ページのコンテンツタイプ
1414 // コンテンツ詳細ページかどうかを設定
1415 if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT) $this->isContentDetailPage = true;
1417 case M3_REQUEST_PARAM_PRODUCT_ID: // 製品IDのとき
1418 case M3_REQUEST_PARAM_PRODUCT_ID_SHORT:
1419 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1420 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1421 if (!$checkStatus) return; // エラーの場合は終了
1423 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PRODUCT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1424 $this->contentType = M3_VIEW_TYPE_PRODUCT; // ページのコンテンツタイプ
1426 // コンテンツ詳細ページかどうかを設定
1427 $this->isContentDetailPage = true;
1429 case M3_REQUEST_PARAM_BBS_ID: // 掲示板投稿記事のとき
1430 case M3_REQUEST_PARAM_BBS_ID_SHORT:
1431 case M3_REQUEST_PARAM_BBS_THREAD_ID:
1432 case M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT:
1433 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1434 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1435 if (!$checkStatus) return; // エラーの場合は終了
1437 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BBS, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1438 $this->contentType = M3_VIEW_TYPE_BBS; // ページのコンテンツタイプ
1440 // コンテンツ詳細ページかどうかを設定
1441 if ($firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID || $firstKey == M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT) $this->isContentDetailPage = true;
1443 case M3_REQUEST_PARAM_EVENT_ID: // イベント記事のとき
1444 case M3_REQUEST_PARAM_EVENT_ID_SHORT:
1445 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1446 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1447 if (!$checkStatus) return; // エラーの場合は終了
1449 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_EVENT, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1450 $this->contentType = M3_VIEW_TYPE_EVENT; // ページのコンテンツタイプ
1452 // コンテンツ詳細ページかどうかを設定
1453 $this->isContentDetailPage = true;
1455 case M3_REQUEST_PARAM_PHOTO_ID: // フォトギャラリー写真のとき
1456 case M3_REQUEST_PARAM_PHOTO_ID_SHORT:
1457 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1458 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1459 if (!$checkStatus) return; // エラーの場合は終了
1461 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_PHOTO, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1462 $this->contentType = M3_VIEW_TYPE_PHOTO; // ページのコンテンツタイプ
1464 // コンテンツ詳細ページかどうかを設定
1465 $this->isContentDetailPage = true;
1467 case M3_REQUEST_PARAM_BLOG_ID: // ブログIDのとき
1468 case M3_REQUEST_PARAM_BLOG_ID_SHORT:
1469 case M3_REQUEST_PARAM_BLOG_ENTRY_ID:
1470 case M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT:
1471 // ### 値をチェックし不正文字がある場合はエラー画面へ遷移 ###
1472 $checkStatus = $this->_checkFirstValueRedirect($firstValue);
1473 if (!$checkStatus) return; // エラーの場合は終了
1475 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_BLOG, $gEnvManager->getCurrentPageId());// ページサブIDを取得
1476 $this->contentType = M3_VIEW_TYPE_BLOG; // ページのコンテンツタイプ
1478 // コンテンツ詳細ページかどうかを設定
1479 if ($firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT) $this->isContentDetailPage = true;
1481 default: // オプションのURLコンテンツパラメータからサブページIDを取得
1482 $ret = $this->db->getSubPageIdByUrlContentParam($gEnvManager->getCurrentPageId(), $firstKey, $row);
1483 if ($ret) $subId = $row['pd_sub_id'];
1491 // 「http://www.example.com?ページ名」「wcmd」の場合はwikiコンテンツページを選択
1492 $wikiCmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_WIKI_COMMAND);
1493 $pageName = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
1495 if (!empty($wikiCmd) || !empty($pageName)){ // Wikiコンテンツページを指定のとき
1497 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_WIKI, $gEnvManager->getCurrentPageId());
1498 $this->contentType = M3_VIEW_TYPE_WIKI; // ページのコンテンツタイプ
1500 // コンテンツ詳細ページかどうかを設定
1501 $this->isContentDetailPage = true;
1504 // その他のGET,POSTパラメータからページサブID取得
1506 // 検索用パラメータなどでリダイレクト先のURLが取得できた場合は遷移
1507 $subId = $this->getPageSubIdByParam($request, $redirectUrl);
1508 if (!empty($subId) && !empty($redirectUrl)) $this->redirect($redirectUrl);
1511 // ページサブIDが取得できない場合はデフォルトを使用
1512 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
1513 } else { // ページサブIDが設定されているとき
1514 // URLパラメータからコンテンツ形式を取得し、ページを選択
1515 $params = $gRequestManager->getQueryArray();
1516 $paramCount = count($params);
1517 if ($paramCount == 1) $this->isPageTopUrl = true; // ページトップ(サブページ内のトップ位置)のURLかどうか
1520 $gEnvManager->setCurrentPageSubId($subId);// サブページIDを設定
1522 // SSL通信機能がオンの場合は、アクセスされたURLのSSLをチェックし不正の場合は正しいURLにリダイレクト
1523 // 設定に間違いがある場合、管理画面にアクセスできなくなるので、フロント画面のみ制御
1524 // if ($gEnvManager->getUseSsl() || $gEnvManager->getUseSslAdmin()){
1525 if ($gEnvManager->getUseSsl()){ // フロント画面のSSL設定のみチェック(2016/7/30)
1526 if (!$gEnvManager->isAdminDirAccess()){ // 管理画面以外へのアクセスのとき
1527 // ルートURLがSSLの場合はSSLに固定
1528 if ($gEnvManager->isRootUrlSsl()){ // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
1531 $isSsl = $gEnvManager->isSslByCurrentPage();
1533 $currentUrl = $gEnvManager->getCurrentRequestUri();
1535 $correctUrl = str_replace('http://', 'https://', $currentUrl);
1537 $correctUrl = str_replace('https://', 'http://', $currentUrl);
1539 if ($currentUrl != $correctUrl) $this->redirect($correctUrl);
1543 $gEnvManager->initMultiDomain();
1546 $gDispManager->load();
1548 // Magic3管理用のスクリプトを追加
1549 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
1550 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
1551 // $this->isEditMode = true; // フロント画面編集モード
1552 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定(コンテキストメニュー表示)
1555 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1556 //if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE){ // ウィジェット設定画面またはテンプレート設定画面のとき
1557 $this->addAdminScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1559 // Googleマップライブラリの読み込み
1560 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1561 $this->defaultAdminScriptFiles[] = ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS);
1563 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1564 $this->isLayout = true; // 画面レイアウト中かどうか
1565 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_IDTABS); // 管理パネル用スクリプト追加(ポジション表示追加分)
1566 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_M3_DROPDOWN); // 管理パネル用スクリプト追加(ドロップダウンメニュー)
1567 //$this->useBootstrap = true; // Bootstrapを使用
1568 //$this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1570 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1571 $this->addAdminScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1573 // スクリプトが必要なウィジェットをすべて取得
1574 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1575 for ($i = 0; $i < count($rows); $i++){
1576 $this->addAdminScript($task, trim($rows[$i]['wd_add_script_lib']));
1578 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
1580 $widgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
1581 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
1582 if ($ret) $this->addAdminScript($task, trim($this->configWidgetInfo['wd_add_script_lib_a'])); // 管理機能用スクリプト
1585 } else { // フロント画面へのアクセスのとき
1586 // フロント画面用スクリプトファイル追加
1587 $this->addScriptFile($this->selectedJQueryFilename);// 常にjQueryを使用
1589 if ($cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
1590 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
1591 if ($gEnvManager->isSystemManageUser()){
1592 $this->isEditMode = true; // フロント画面編集モード
1593 $this->isPageEditable = true; // フロント画面ページ編集可能モードに設定
1595 // システム運用権限がある場合は管理用スクリプトを追加
1596 // フロント画面と管理画面の切り替え用のスライドメニューバーには管理用スクリプト,CSSが必要
1597 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1598 $this->addScriptFile(ScriptLibInfo::JQUERY_CONTEXTMENU_FILENAME); // jQuery Contextmenu Lib
1599 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1600 //$this->addScript('', ScriptLibInfo::LIB_JQUERY_JQEASYPANEL); // パネルメニュー(フロント画面と管理画面の切り替え等)用
1601 $this->addScript('', ScriptLibInfo::LIB_JQUERY_M3_SLIDEPANEL); // 管理パネル用スクリプト追加
1602 $this->addScript('', ScriptLibInfo::LIB_JQUERY_COOKIE); // 管理パネル用スクリプト追加
1603 $this->addScript('', ScriptLibInfo::LIB_JQUERY_EASING); // 管理パネル用スクリプト追加
1604 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1605 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1607 $this->addCssFile(self::M3_ADMIN_CSS_FILE); // 管理機能用CSS
1608 } else if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1609 $this->isEditMode = true; // フロント画面編集モード
1611 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
1612 if ($gEnvManager->isContentEditableUser()){ // コンテンツ編集可能ユーザの場合
1613 $this->isEditMode = true; // フロント画面編集モード
1615 // $this->addScript('', ScriptLibInfo::LIB_JQUERY_RESPONSIVETABLE);// 管理画面作成用
1616 $this->addScript('', ScriptLibInfo::getWysiwygEditorLibId()); // WYSIWYGエディターを追加
1617 $this->addScriptFile(self::M3_ADMIN_SCRIPT_FILENAME); // 管理スクリプトライブラリ追加
1618 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
1619 $this->addScript('', ScriptLibInfo::LIB_JQUERY_HOVERINTENT);// HELP用スクリプト追加
1620 $this->addScript('', ScriptLibInfo::LIB_JQUERY_CLUETIP);// HELP用スクリプト追加
1622 // Googleマップライブラリの読み込み
1623 if ($this->useGooglemaps && $this->wysiwygEditor == ScriptLibInfo::LIB_CKEDITOR){ // CKEditorの場合はGoogleマップライブラリを読み込む
1624 $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS));
1631 $row = $this->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
1633 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1634 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1637 $this->currentPageInfo = $row; // 現在のページのページ情報
1640 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
1641 /* $defPageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
1642 $defPageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
1645 $row = $this->getPageInfo($defPageId, $defPageSubId);
1647 // ショートURLで取得できない場合は、ページコンテンツタイプを取得
1648 if (empty($this->contentType)) $this->contentType = $row['pn_content_type'];
1651 $this->currentPageInfo = $row; // 現在のページのページ情報
1655 // $ret = $this->db->getPageDefOnPage($defPageId, $defPageSubId, $rows);
1656 $ret = $this->db->getPageDefOnPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
1658 for ($i = 0; $i < count($rows); $i++){
1659 $position = $rows[$i]['pd_position_id'];
1660 if (!in_array($position, $this->defPositions)) $this->defPositions[] = $position; // 画面定義データのポジション(すべて)
1666 if ($openBy == 'tabs') $this->isTransparentMode = true; // 画面透過モード
1669 * URLの最初のパラメータが不正文字の場合はエラー画面へリダイレクト
1671 * @param string $value URLの最初のパラメータ値
1672 * @return bool true=正常、false=異常
1674 function _checkFirstValueRedirect($value)
1676 global $gEnvManager;
1677 global $gOpeLogManager;
1679 // 半角英小文字大文字、数字、アンダーバー、ハイフン、カンマのみ使用可能。
1680 if (preg_match("/[^0-9a-zA-Z-_,]/", $value)){
1681 $errMessage = 'URLパラメータの不正。';
1682 $gOpeLogManager->writeUserAccess(__METHOD__, '不正なアクセスを検出しました。' . $errMessage, 2200, 'アクセスをブロックしました。URL: ' . $gEnvManager->getCurrentRequestUri());
1684 // $this->redirect('?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=_accessdeny');
1686 $this->isSystemPage = true;
1699 global $gEnvManager;
1700 global $gSystemManager;
1702 $lang = $gEnvManager->getCurrentLanguage();
1704 // デフォルト言語とカレント言語が異なる場合のみ実行
1705 if ($lang != $gEnvManager->getDefaultLanguage()){
1707 $gSystemManager->roadSiteDefByLang($lang);
1711 $this->headDescription = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_DESCRIPTION); // HTMLヘッダ「description」に出力する文字列
1712 $this->headKeywords = $gSystemManager->getSiteDef(M3_TB_FIELD_SITE_KEYWORDS); // HTMLヘッダ「keywords」に出力する文字列
1713 $this->headOthers = $gSystemManager->getSiteDef(self::SD_HEAD_OTHERS); // HTMLヘッダに出力するタグ文字列
1715 // デフォルトのページ情報でヘッダを更新
1716 if (!empty($this->currentPageInfo)){
1717 $title = $this->currentPageInfo['pn_meta_title']; // 画面タイトル
1718 $desc = $this->currentPageInfo['pn_meta_description']; // ページ要約
1719 $keyword = $this->currentPageInfo['pn_meta_keywords']; // ページキーワード
1720 $headOthers = $this->currentPageInfo['pn_head_others']; // ヘッダその他タグ
1722 if (!empty($title)) $this->setHeadSubTitle($title, '', true); // デフォルト値として設定
1723 if (!empty($desc)) $this->setHeadDescription($desc);
1724 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1725 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1728 // 現在の言語のページ情報でヘッダを更新
1729 $ret = $this->db->getPageInfo($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $lang, $row);
1731 $title = $row['pn_meta_title']; // 画面タイトル
1732 $desc = $row['pn_meta_description']; // ページ要約
1733 $keyword = $row['pn_meta_keywords']; // ページキーワード
1734 $headOthers = $row['pn_head_others']; // ヘッダその他タグ
1736 if (!empty($title)) $this->setHeadSubTitle($title, '', true); // デフォルト値として設定
1737 if (!empty($desc)) $this->setHeadDescription($desc);
1738 if (!empty($keyword)) $this->setHeadKeywords($keyword);
1739 if (!empty($headOthers)) $this->setHeadOthers($headOthers);
1742 // $this->currentPageInfo = $row; // 現在のページのページ情報
1746 * スクリプト追加情報から、管理機能用のJavascriptファイル、CSSを追加する
1748 * @param string $task 指定タスク
1749 * @param string $scriptInfo スクリプト追加情報
1752 function addAdminScript($task, $scriptInfo)
1754 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1755 for ($i = 0; $i < count($itemArray); $i++){
1756 $pos = strpos($itemArray[$i], '=');
1757 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1758 $libs = trim($itemArray[$i]);
1759 } else { // タスク指定のとき
1760 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1761 $libTask = trim($libTask);
1762 $libs = trim($libs);
1764 if (strEndsWith($libTask, '_')){ // 「task_subtask」形式のタスクのとき
1765 if (!strStartsWith($task, $libTask)) $libs = ''; // タスクIDの先頭部が異なるときは追加しない
1767 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1770 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1771 $libsArray = explode(',', $libs);
1772 for ($j = 0; $j < count($libsArray); $j++){
1773 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1776 $setLibArray = ScriptLibInfo::getLibSet($lib);
1777 $setLibCount = count($setLibArray);
1778 if ($setLibCount > 0){ // ライブラリセットの場合
1779 for ($k = 0; $k < $setLibCount; $k++){
1780 $this->_addAdminScript($setLibArray[$k]);
1783 $this->_addAdminScript($lib);
1790 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1792 * @param string $lib ライブラリID
1795 function _addAdminScript($lib)
1798 if (!isset($this->libFiles[$lib])) return;
1801 // if (strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1802 // jQuery UIライブラリを追加
1803 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1804 if (isset($dependentLib)){
1805 for ($i = 0; $i < count($dependentLib); $i++){
1806 $addLib = $dependentLib[$i];
1809 if (isset($this->libFiles[$addLib]['script'])){
1810 $scriptFiles = $this->libFiles[$addLib]['script'];
1811 for ($m = 0; $m < count($scriptFiles); $m++){
1812 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1816 if (isset($this->libFiles[$addLib]['script_lang'])){
1817 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1818 for ($m = 0; $m < count($scriptFiles); $m++){
1819 $this->addAdminScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1823 if (isset($this->libFiles[$addLib]['css'])){
1824 $cssFiles = $this->libFiles[$addLib]['css'];
1825 for ($m = 0; $m < count($cssFiles); $m++){
1826 $this->addAdminCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1831 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1832 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1833 $this->outputTheme = true;
1838 if (isset($this->libFiles[$lib]['script'])){
1839 $scriptFiles = $this->libFiles[$lib]['script'];
1841 // ##### ライブラリ情報を作成する場合 #####
1842 if (empty($scriptFiles)){
1843 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
1844 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
1847 for ($i = 0; $i < count($scriptFiles); $i++){
1848 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1852 if (isset($this->libFiles[$lib]['script_lang'])){
1853 $scriptFiles = ScriptLibInfo::getLangScript($lib);
1854 for ($i = 0; $i < count($scriptFiles); $i++){
1855 $this->addAdminScriptFile($scriptFiles[$i]); // 管理機能用のスクリプト追加
1859 if (isset($this->libFiles[$lib]['css'])){
1860 $cssFiles = $this->libFiles[$lib]['css'];
1861 for ($i = 0; $i < count($cssFiles); $i++){
1862 $this->addAdminCssFile($cssFiles[$i]); // 管理機能用のCSS追加
1866 if (strncmp($lib, 'jquery-ui.', 10) == 0){ // jQuery UIのwidgetsまたはeffectsのとき。jQuery UI Coreはデフォルトで読み込まれている。
1868 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
1869 $this->addAdminCssFile($this->getAdminDefaultThemeUrl()); // CSS追加(絶対パス)
1870 $this->outputTheme = true;
1875 * スクリプト追加情報から、通常機能用のJavascriptファイル、CSSを追加する
1877 * @param string $task 指定タスク
1878 * @param string $scriptInfo スクリプト追加情報
1881 function addScript($task, $scriptInfo)
1883 $itemArray = explode(self::SCRIPT_LIB_SEPARATOR, strtolower(trim($scriptInfo)));// 小文字に変換したものを解析
1884 for ($i = 0; $i < count($itemArray); $i++){
1885 $pos = strpos($itemArray[$i], '=');
1886 if ($pos === false){// 見つからないときは、タスクが指定されないとき
1887 $libs = trim($itemArray[$i]);
1888 } else { // タスク指定のとき
1889 list($libTask, $libs) = explode('=', trim($itemArray[$i]));
1890 $libTask = trim($libTask);
1891 $libs = trim($libs);
1892 if (empty($libTask) || $libTask != $task) $libs = ''; // タスクが異なるときは追加しない
1894 if (!empty($libs)){ // // スクリプト、CSSの追加を行うとき
1895 $libsArray = explode(',', $libs);
1896 for ($j = 0; $j < count($libsArray); $j++){
1897 $lib = strtolower(trim($libsArray[$j]));// 小文字に変換
1899 // jQueryライブラリ等、デフォルトでは追加されないライブラリを追加
1900 $setLibArray = ScriptLibInfo::getLibSet($lib);// ライブラリセットを展開
1901 $setLibCount = count($setLibArray);
1902 if ($setLibCount > 0){ // ライブラリセットの場合
1903 for ($k = 0; $k < $setLibCount; $k++){
1904 $this->_addScript($setLibArray[$k]);
1907 $this->_addScript($lib);
1914 * ライブラリIDに対応するJavascriptファイル、CSSを追加する
1916 * @param string $lib ライブラリID
1919 function _addScript($lib)
1922 if (!isset($this->libFiles[$lib])) return;
1924 // ライブラリの依存ライブラリファイルを追加
1925 if (strcmp($lib, 'jquery') == 0){// jQuery本体のとき
1926 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1927 } else if (strncmp($lib, 'jquery.', 7) == 0){ // jQueryプラグインのとき
1928 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1931 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1932 if (isset($dependentLib)){
1933 for ($i = 0; $i < count($dependentLib); $i++){
1934 $addLib = $dependentLib[$i];
1937 if (isset($this->libFiles[$addLib]['script'])){
1938 $scriptFiles = $this->libFiles[$addLib]['script'];
1939 for ($m = 0; $m < count($scriptFiles); $m++){
1940 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1944 if (isset($this->libFiles[$addLib]['script_lang'])){
1945 $scriptFiles = ScriptLibInfo::getLangScript($addLib);
1946 for ($m = 0; $m < count($scriptFiles); $m++){
1947 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1951 if (isset($this->libFiles[$addLib]['css'])){
1952 $cssFiles = $this->libFiles[$addLib]['css'];
1953 for ($m = 0; $m < count($cssFiles); $m++){
1954 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
1959 } else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI) == 0){ // jQuery UI
1960 $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1961 //} else if (strcmp($lib, ScriptLibInfo::LIB_JQUERY_UI_PLUS) == 0){ // jQuery UI plus
1962 // $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
1963 // $this->addScriptFile($this->selectedJQueryUiFilename); // jQuery Coreスクリプト追加
1964 } else if (strncmp($lib, 'jquery-ui.', 10) == 0 || // jQuery UIのwidgetsまたはeffectsのとき
1965 strcmp($lib, ScriptLibInfo::LIB_ELFINDER) == 0 || strcmp($lib, ScriptLibInfo::LIB_JQUERY_TIMEPICKER) == 0){ // elFinder、timepickerを使用する場合
1968 if (strncmp($lib, 'jquery-ui.', 10) == 0){
1969 $jQueryUiInfo = ScriptLibInfo::getJQueryUiInfo();// ライブラリ情報取得
1970 $dependentLib = $jQueryUiInfo[$lib]; // 依存ライブラリ取得
1972 $dependentLib = ScriptLibInfo::getDependentLib($lib);
1974 for ($i = 0; $i < count($dependentLib); $i++){
1975 $addLib = $dependentLib[$i];
1978 if (isset($this->libFiles[$addLib]['script'])){
1979 $scriptFiles = $this->libFiles[$addLib]['script'];
1980 for ($m = 0; $m < count($scriptFiles); $m++){
1981 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1985 if (isset($this->libFiles[$addLib]['script_lang'])){
1986 $scriptFiles = ScriptLibInfo::getLangScript($addLib);;
1987 for ($m = 0; $m < count($scriptFiles); $m++){
1988 $this->addScriptFile($scriptFiles[$m]); // 通常機能用のスクリプト追加
1992 if (isset($this->libFiles[$addLib]['css'])){
1993 $cssFiles = $this->libFiles[$addLib]['css'];
1994 for ($m = 0; $m < count($cssFiles); $m++){
1995 $this->addCssFile($cssFiles[$m]); // 通常機能用のCSS追加
2000 if (!$this->outputTheme){ // jQueryUIテーマ出力を行ったかどうか
2001 $this->addCssFile($this->getDefaultThemeUrl()); // 通常機能用のCSS追加
2002 $this->outputTheme = true;
2007 if (isset($this->libFiles[$lib]['script'])){
2008 $scriptFiles = $this->libFiles[$lib]['script'];
2010 // ##### ライブラリ情報を作成する場合 #####
2011 if (empty($scriptFiles)){
2012 $generatedLib = ScriptLibInfo::generateLib($lib); // ライブラリ取得
2013 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2016 for ($i = 0; $i < count($scriptFiles); $i++){
2017 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
2021 if (isset($this->libFiles[$lib]['script_lang'])){
2022 $scriptFiles = ScriptLibInfo::getLangScript($lib);
2023 for ($i = 0; $i < count($scriptFiles); $i++){
2024 $this->addScriptFile($scriptFiles[$i]); // 通常機能用のスクリプト追加
2028 if (isset($this->libFiles[$lib]['css'])){
2029 $cssFiles = $this->libFiles[$lib]['css'];
2030 for ($i = 0; $i < count($cssFiles); $i++){
2031 $this->addCssFile($cssFiles[$i]); // 通常機能用のCSS追加
2036 * 非ログイン時の管理機能用のJavascriptファイル、CSSを追加する
2038 * @param array, string $lib 追加ライブラリID
2041 function addPermittedAdminScript($lib)
2043 if (is_array($lib)){
2044 for ($j = 0; $j < count($lib); $j++){
2048 if (isset($this->libFiles[$libId]['script'])){
2049 $scriptFiles = $this->libFiles[$libId]['script'];
2051 // ##### ライブラリ情報を作成する場合 #####
2052 if (empty($scriptFiles)){
2053 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
2054 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2057 for ($i = 0; $i < count($scriptFiles); $i++){
2058 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2062 if (isset($this->libFiles[$libId]['script_lang'])){
2063 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2064 for ($i = 0; $i < count($scriptFiles); $i++){
2065 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2069 if (isset($this->libFiles[$libId]['css'])){
2070 $cssFiles = $this->libFiles[$libId]['css'];
2071 for ($i = 0; $i < count($cssFiles); $i++){
2072 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2080 if (isset($this->libFiles[$libId]['script'])){
2081 $scriptFiles = $this->libFiles[$libId]['script'];
2083 // ##### ライブラリ情報を作成する場合 #####
2084 if (empty($scriptFiles)){
2085 $generatedLib = ScriptLibInfo::generateLib($libId); // ライブラリ取得
2086 if (!empty($generatedLib)) $scriptFiles = $generatedLib['script'];
2089 for ($i = 0; $i < count($scriptFiles); $i++){
2090 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2094 if (isset($this->libFiles[$libId]['script_lang'])){
2095 $scriptFiles = ScriptLibInfo::getLangScript($libId);
2096 for ($i = 0; $i < count($scriptFiles); $i++){
2097 $this->defaultAdminDirScriptFiles[] = $scriptFiles[$i]; // デフォルトで読み込むスクリプトファイル(管理ディレクトリ用)
2101 if (isset($this->libFiles[$libId]['css'])){
2102 $cssFiles = $this->libFiles[$libId]['css'];
2103 for ($i = 0; $i < count($cssFiles); $i++){
2104 $this->defaultAdminDirCssFiles[] = $cssFiles[$i]; // デフォルトで読み込むCSSファイル(管理ディレクトリ用)
2114 * ・ウィジェットで生成されたHTTPヘッダを設定する
2116 * @param RequestManager $request HTTPリクエスト処理クラス
2117 * @param bool $getOutput 出力を取得するかどうか
2118 * @return string 最終出力HTML
2120 function endPage($request, $getOutput = false)
2122 global $gRequestManager;
2123 global $gInstanceManager;
2124 global $gEnvManager;
2125 global $gDispManager;
2126 global $gAccessManager;
2129 if ($this->isAbort) return '';
2134 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2136 // 最終HTML(ページ全体で使用するHTML)の出力
2137 if ($cmd == M3_REQUEST_CMD_CSS){ // CSS生成のとき
2139 if (count($this->exportCss) > 0){
2140 for ($i = 0; $i < count($this->exportCss); $i++){
2141 $contents .= $this->exportCss[$i] . M3_NL;
2146 header('Content-type: text/css');
2148 // 画面情報、ユーザ情報の保存は行わない
2150 } else if ($cmd != M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体オペレーションのときは出力しない
2152 $contents = $this->getLastContents($request);
2154 echo $this->getLastContents($request);
2159 $userInfo = $gInstanceManager->getUserInfo();
2160 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2163 $gRequestManager->_doSessionCloseEventCallback();
2166 $gDispManager->save();
2168 // キャッシュリミッタは、各リクエスト毎に(アウトプットバッファー が無効な場合は、
2169 // session_start()がコールされる 前に) session_cache_limiter()をコールする必要がある。
2171 // session_cache_limiter('private');
2172 // session_cache_expire(5);
2173 if ($this->isRedirect) return ''; // リダイレクトの場合は終了
2175 // ########## HTTPヘッダ出力処理 ########
2176 if (headers_sent($filename, $linenum)){ // HTTPヘッダが既に送信されているとき
2177 echo "$filename の $linenum 行目でヘッダがすでに送信されています。";
2180 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// 過去の日付
2181 header('Cache-Control: no-store, no-cache, must-revalidate');// HTTP/1.1
2182 header('Cache-Control: post-check=0, pre-check=0', false);
2183 header('Pragma: no-cache');
2186 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
2189 header('Content-Type: text/html; charset=UTF-8'); // 2018/4/19 Firefoxで文字化けが起きる場合があるので追加
2191 // Ajax用JSON型データをHTTPヘッダに格納
2192 $gInstanceManager->getAjaxManager()->header();
2194 // システム制御画面が設定されている場合はステータスコードを変更
2195 if (!$this->isRedirect){ // リダイレクトがセットされていない場合
2196 switch ($this->systemHandleMode){
2197 case 10: // サイト非公開(システムメンテナンス)
2198 header('HTTP/1.1 503 Service Temporarily Unavailable');
2199 header('Status: 503 Service Temporarily Unavailable');
2201 case 11: // アクセス禁止のとき
2202 header('HTTP/1.1 403 Forbidden');
2203 header('Status: 403 Forbidden');
2205 case 12: // 存在しないページのとき
2206 header("HTTP/1.1 404 Not Found");
2207 header("Status: 404 Not Found");
2212 // ##### 自動ログイン #####
2213 $gAccessManager->endAutoLogin();
2220 * 注意)exitSystem()でシステムを終了させる必要あり
2224 function abortPage()
2226 global $gInstanceManager;
2227 global $gRequestManager;
2229 // HTTPヘッダを削除(PHP 5.3以上で有効)
2230 if (version_compare(PHP_VERSION, '5.3.0') >= 0) header_remove();
2232 // exit()等でabortPage()が最後の処理になってしまう可能性があるのでなるべく必要な処理を行う
2233 //if (ob_get_level() > 0) ob_end_clean();// バッファ内容が残っているときは破棄
2234 while (ob_get_level()) ob_end_clean(); // バッファ削除方法変更(2009/12/2)
2237 $userInfo = $gInstanceManager->getUserInfo();
2238 $gRequestManager->setSessionValueWithSerialize(M3_SESSION_USER_INFO, $userInfo);
2241 $gRequestManager->_doSessionCloseEventCallback();
2243 $this->isAbort = true; // ページ作成処理を中断するかどうか
2250 function abortWidget()
2252 $this->isWidgetAbort = true; // 各ウィジェット処理を中断するかどうか
2259 function exitSystem()
2261 global $gEnvManager;
2262 global $gAccessManager;
2264 // DBが使用可能であれば、アクセスログのユーザを登録
2265 if ($gEnvManager->canUseDb()) $gAccessManager->accessLogUser();
2270 * Joomla!v1.5タグを読み込んでウィジェット実行
2272 * @param string $srcBuf バッファデータ
2273 * @param int $templateVer テンプレートバージョン(99=レイアウト用テンプレート、0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
2274 * @return string 変換後文字列
2276 function launchWidgetByJoomlaTag($srcBuf, $templateVer)
2282 if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\s*\/>#iU', $srcBuf, $matches)){
2283 $count = count($matches[1]);
2284 for ($i = 0; $i < $count; $i++)
2287 $type = $matches[1][$i];
2289 if (strcasecmp($type, 'head') == 0){ // ヘッダ埋め込みタグの場合
2292 $contents = ob_get_contents();
2293 } else if (strcasecmp($type, 'modules') == 0 || strcasecmp($type, 'module') == 0 || // 一般ウィジェット用配置ブロックの場合
2294 strcasecmp($type, 'navmenu') == 0){ // ナビゲーションメニューウィジェット用配置ブロックの場合
2295 $name = ''; // ポジション名
2296 $posType = ''; // ポジションのタイプ
2297 $style = ''; // 表示スタイル
2298 $params = explode(' ', $matches[2][$i]);
2299 $paramArray = array();
2300 for ($j = 0; $j < count($params); $j++){
2301 list($key, $value) = explode('=', $params[$j]);
2303 $value = trim($value, "\"'");
2304 if (!empty($key)) $paramArray[$key] = $value;
2306 $value = $paramArray['name'];
2309 $attr['name'] = $value;
2311 $value = $paramArray['type']; // 配置ブロックのタイプを属性に格納。テンプレート内での参照用。
2314 $attr['type'] = $value;
2316 $value = $paramArray['id'];
2317 if (isset($value)) $attr['id'] = $value;
2319 // スタイルが設定されている場合はオプションスタイルを取得
2320 $value = $paramArray['style'];
2323 $attr['style'] = $value;
2325 $optionStyle = $paramArray[$value]; // オプションのスタイル
2326 if (isset($optionStyle)) $attr[$value] = $optionStyle;
2328 /* for ($j = 0; $j < count($params); $j++){
2329 list($key, $value) = explode('=', $params[$j]);
2330 if (strcasecmp($key, 'name') == 0){
2331 $name = strtolower(trim($value, "\"'"));
2332 $attr['name'] = $name;
2333 } else if (strcasecmp($key, 'style') == 0){
2335 $style = trim($value, "\"'");
2336 } else if (strcasecmp($key, 'artstyle') == 0){ // テンプレート側指定の表示スタイル(Artisteer用)
2337 $attr['artstyle'] = trim($value, "\"'");
2338 } else if (strcasecmp($key, 'bootstyle') == 0){ // テンプレート側指定の表示スタイル(Bootstrap用)
2339 $attr['bootstyle'] = trim($value, "\"'");
2340 } else if (strcasecmp($key, 'drstyle') == 0){ // テンプレート側指定の表示スタイル(Themer用)
2341 $attr['drstyle'] = trim($value, "\"'");
2345 if (!empty($name)){ // ポジション名が取得できたとき
2346 // Joomla!では、テンプレートの「jdoc:include」タグの属性styleが空のときは「none」で処理される
2347 // Joomla!デフォルトで設定可能なのは「none,table,horz,xhtml,rounded,outline」
2348 // 配置ブロックがナビゲーション型に固定されていない場合はテンプレートの種類によってナビゲーションかどうかを判断
2349 if (strcasecmp($type, 'navmenu') == 0){ // メニューウィジェット用配置ブロックの場合
2350 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2351 $attr['type'] = $type; // テンプレート内での参照用
2353 switch ($templateVer){
2354 case 0: // デフォルトテンプレート(Joomla!v1.0)
2355 case 1: // Joomla!v1.5
2356 case 2: // Joomla!v2.5
2357 case 10: // Bootstrap v3.0
2359 if (strcasecmp($name, 'user3') == 0 || // ナビゲーションメニュー位置の場合
2360 strcasecmp($name, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
2361 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
2362 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2365 case 99: // レイアウト用テンプレート
2366 global $gRequestManager;
2367 static $templateType; // レイアウト用テンプレートタイプを一度だけ取得
2368 static $templateGenerator;
2370 if (!isset($templateType)){
2373 // レイアウト用テンプレートの場合は対象とするテンプレートの情報を取得して判断する
2374 $pageId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
2375 $pageSubId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
2377 // ページ用個別に設定されたテンプレートがある場合は取得
2379 $line = $this->getPageInfo($pageId, $pageSubId);
2380 if (!empty($line)) $curTemplate = $line['pn_template_id'];
2383 if (empty($curTemplate)){
2384 if ($pageId == $this->gEnv->getDefaultPageId()){ // 通常サイトのとき
2385 $curTemplate = $this->gSystem->defaultTemplateId();
2386 } else if ($pageId == $this->gEnv->getDefaultSmartphonePageId()){ // スマートフォン用サイトのとき
2387 $curTemplate = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
2392 $ret = $this->db->getTemplate($curTemplate, $row);
2394 $templateType = $row['tm_type'];
2395 $templateGenerator = $row['tm_generator'];
2399 if ($templateType != 99){
2400 // Themlerテンプレート場合は配置ポジション名が「hmenu」をナビゲーション型とする
2401 if ($templateGenerator == 'themler'){
2402 if (strcasecmp($name, 'hmenu') == 0){ // Joomla!v3テンプレート対応
2403 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2406 if (strcasecmp($name, 'user3') == 0 || // ナビゲーションメニュー位置の場合
2407 strcasecmp($name, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
2408 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
2415 if (empty($style)) $style = 'none';
2418 $contents = $this->getContents($name, $style, $templateVer, $attr);
2420 } else if (strcasecmp($type, 'component') == 0){ // メインポジションタグの場合
2422 $style = ''; // 表示スタイル
2423 $params = explode(' ', $matches[2][$i]);
2424 for ($j = 0; $j < count($params); $j++){
2425 list($key, $value) = explode('=', $params[$j]);
2426 if (strcasecmp($key, 'style') == 0){
2428 $style = trim($value, "\"'");
2432 if ($style != 'none') $style = 'xhtml';
2433 $contents = $this->getContents('main', $style, $templateVer, $attr);
2434 } else if (strcasecmp($type, 'message') == 0){ // メッセージタグの場合
2436 $replace[$i] = $contents;
2439 $destBuf = str_replace($matches[0], $replace, $srcBuf);
2446 * 遅延実行インデックスのついているウィジェットをインデックス順に実行し、出力バッファデータ内のタグの位置に出力を埋め込む
2448 * @param RequestManager $request HTTPリクエスト処理クラス
2449 * @param string $srcBuf バッファデータ
2450 * @return string 変換後文字列
2452 function lateLaunchWidget($request, $srcBuf)
2454 static $render; // HTML生成オブジェクト
2455 global $gEnvManager;
2456 global $gErrorManager;
2457 global $gDesignManager;
2459 // ページ作成中断またはウィジェット処理中断のときは終了
2460 if ($this->isAbort || $this->isWidgetAbort) return '';
2462 // ウィジェットヘッダ(Joomla!1.0用)を出力のタイプを取得
2463 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
2466 $templateVer = $gEnvManager->getCurrentTemplateType();
2468 // 遅延実行ウィジェットをインデックス順にソート
2469 asort($this->lateLaunchWidgetList, SORT_NUMERIC);
2473 foreach ($this->lateLaunchWidgetList as $widgetId => $value){
2475 $count = count($this->latelaunchWidgetParam);
2476 for ($i = 0; $i < $count; $i++){
2477 list($wId, $maxNo, $confId, $preId, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $pageDefRec) = $this->latelaunchWidgetParam[$i];
2478 if ($wId == $widgetId){
2480 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
2481 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
2482 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
2485 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
2486 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
2492 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
2495 $configId = $confId; // ウィジェット定義ID
2496 if ($configId == 0) $configId = '';
2497 $prefix = $preId; // サフィックス文字列
2499 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
2500 $joomlaTitleVisble = false;
2501 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
2502 if (!empty($title)){
2503 if ($widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2504 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
2505 echo '<tr><th>' . $title . '</th></tr>' . M3_NL;
2506 echo '<tr><td>' . M3_NL;
2507 $joomlaTitleVisble = true;
2508 } else if ($widgetHeaderType == 2){ // 携帯用ウィジェットヘッダ出力
2509 echo '<div>' . $title . '</div>' . M3_NL;
2510 $joomlaTitleVisble = true;
2515 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
2516 // ウィジェット親のCSS定義があるときは、タグを追加
2517 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
2520 echo $gDesignManager->getAdditionalWidgetOutput(true);
2523 $gEnvManager->setCurrentWidgetId($widgetId);
2526 $gEnvManager->setCurrentWidgetConfigId($configId);
2529 $gEnvManager->setCurrentPageDefSerial($serial);
2532 $gEnvManager->setCurrentPageDefRec($pageDefRec);
2535 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
2538 $gEnvManager->setCurrentWidgetTitle('');
2541 $gEnvManager->setCurrentWidgetStyle($style);
2543 // ウィジェットのグローバル属性状況を設定
2544 $gEnvManager->setIsCurrentWidgetShared($shared);
2547 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
2550 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
2551 $msg = 'widget-start(' . $widgetId . ')';
2552 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2553 require($widgetIndexFile);
2554 $msg = 'widget-end(' . $widgetId . ')';
2555 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
2558 $gEnvManager->setCurrentWidgetId('');
2561 $gEnvManager->setCurrentWidgetConfigId('');
2564 $gEnvManager->setCurrentPageDefSerial(0);
2567 $gEnvManager->setCurrentPageDefRec();
2570 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
2573 $gEnvManager->setCurrentWidgetStyle('');
2575 // ウィジェットのグローバル属性状況を解除
2576 $gEnvManager->setIsCurrentWidgetShared(false);
2579 $newTitle = $gEnvManager->getCurrentWidgetTitle();
2582 echo $gDesignManager->getAdditionalWidgetOutput(false);
2584 // ウィジェット親のCSS定義があるときは、タグを追加
2585 if (!empty($cssStyle)) echo '</div>' . M3_NL;
2587 //echo '</div>' . M3_NL;
2589 // Joomla!1.0テンプレートのときはタイトルを出力
2590 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用ウィジェットヘッダ出力
2591 echo '</td></tr>' . M3_NL;
2592 echo '</table>' . M3_NL;
2595 // 現在のバッファ内容を取得し、バッファを破棄
2596 $srcContents = ob_get_contents();
2599 // ### テンプレート側のウィジェット生成処理使える場合はウィジェットの出力と入れ替える ###
2600 // ### 先のrequire($widgetIndexFile)で必要なデータは作成されている ###
2601 if ($templateVer >= 1 && $templateVer < 100){ // Joomla!v1.5,v2.5テンプレートのとき
2602 $widgetType = $pageDefRec['wd_type']; // ウィジェットタイプ
2603 if ($widgetType == 'breadcrumb'){ // パンくずリスト
2605 if (!isset($render)) $render = new JRender();
2607 $templateContents = $render->getBreadcrumbContents('', '', '', array(), array(), $pageDefRec, $templateVer); // テンプレートバージョンのみ必要
2608 if (!empty($templateContents)) $srcContents = $templateContents;
2613 $tag = self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END;
2614 $destBuf = str_replace($tag, $srcContents, $destBuf);
2617 if (!empty($newTitle)) $title = $newTitle;
2618 $tag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
2619 $destBuf = str_replace($tag, $title, $destBuf);
2621 // ##### 外部出力用のCSSがある場合は追加 #####
2622 if (!empty($exportCss)){
2624 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $index; // ウィジェット識別用ユニークタグ
2625 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
2626 $this->addExportCss($exportCss);
2632 // ##### HTMLヘッダ出力処理 #####
2633 $destBuf = $this->replaceHead($destBuf);
2640 * @param string $jobType ジョブタイプ
2643 function launchJob($jobType)
2645 global $gEnvManager;
2647 // ジョブタイプから実行するウィジェットIDを取得
2648 $widgetId = $this->getWidgetIdByJobType($jobType);
2649 if (empty($widgetId)) return;
2652 $gEnvManager->setCurrentWidgetId($widgetId);
2655 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/admin/job.php';
2657 if (file_exists($widgetIndexFile)){
2659 // $this->_db->writeWidgetLog($widgetId, 1/*単体実行*/, $cmd);
2661 require_once($widgetIndexFile);
2663 echo 'file not found: ' . $widgetIndexFile;
2667 $gEnvManager->setCurrentWidgetId();
2672 * @param string $srcBuf 変換元
2673 * @return string 変換後文字列
2675 function replaceHead($srcBuf)
2679 // ##### ヘッダ部分の置換 #####
2680 if ($this->outputHead){ // HTMLヘッダ出力を行っているとき
2683 // HTMLヘッダに最初に出力するタグ文字列がある場合は追加
2684 if (!empty($this->headFirstTag)) $replaceStr .= $this->headFirstTag;
2686 // METAタグcharset等のHTML文書の標準のヘッダタグを出力
2687 if ($this->outputByStandardHead) $replaceStr .= $this->getStandardHead();
2690 $replaceStr .= $this->getHeaderOutput();
2693 $destBuf = str_replace(self::HEAD_TAGS, $replaceStr, $destBuf);
2695 $this->replaceHeadDone = true; // ヘッダマクロ変換処理が完了したかどうか
2703 function enableReplaceHead()
2705 $this->outputHead = true;
2708 * ウィジェット検索モードの場合のページサブIDの設定
2710 * @param RequestManager $request HTTPリクエスト処理クラス
2712 function redirectToUpdatedPageSubId($request)
2714 global $gEnvManager;
2716 // 現在設定されているページIDを取得
2717 $pageId = $gEnvManager->getCurrentPageId();
2718 $pageSubId = $gEnvManager->getCurrentPageSubId();
2721 $fromWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_FROM);
2724 $targetWidgetId = $request->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
2726 // 対象のウィジェットのページサブIDを取得
2727 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2728 if ($ret){// データが存在する
2729 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2730 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2731 if ($ret){// データが存在する
2732 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2734 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2739 for ($i = 0; $i < count($rows); $i++){
2740 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2745 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2746 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2748 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2751 } else { // 対象のウィジェットが見つからない場合は、互換ウィジェットを探す
2752 $widgetId = $this->db->getCompatibleWidgetId($targetWidgetId);
2753 if (!empty($widgetId)){
2754 $targetWidgetId = $widgetId;
2756 // 対象のウィジェットのページサブIDを取得
2757 $ret = $this->db->getSubPageId($targetWidgetId, $pageId, $rows);
2758 if ($ret){// データが存在する
2759 if (empty($rows[0]['pd_sub_id'])){ // 共通ウィジェットのときは、送信元にあわせる
2760 $ret = $this->db->getSubPageId($fromWidgetId, $pageId, $rows2);
2761 if ($ret){// データが存在する
2762 if (empty($rows2[0]['pd_sub_id'])){ // 送信元が共通ウィジェットのときは、既に設定されているページサブIDを使用
2764 $gEnvManager->setCurrentPageSubId($rows2[0]['pd_sub_id']);
2769 for ($i = 0; $i < count($rows); $i++){
2770 $ret = $this->db->isExistsWidgetOnPage($pageId, $rows[$i]['pd_sub_id'], $fromWidgetId);
2775 if ($i == count($rows)){ // 送信元が見つからない場合は1番目のページサブIDを使用
2776 $gEnvManager->setCurrentPageSubId($rows[0]['pd_sub_id']);
2778 $gEnvManager->setCurrentPageSubId($rows[$i]['pd_sub_id']);// 存在するときは見つかったページサブIDで更新
2784 // ページサブIDが見つからないときは、既に設定されている値を使用
2785 // 既に設定されている値は、URL「sub」パラメータで指定されている値か
2786 // 設定されていない場合はデフォルトのサブページID
2787 // ********** 指定ページへリダイレクト ***********
2789 $todo = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TODO);
2790 $todo = str_replace(M3_TODO_SEPARATOR, '&', $todo); // セパレータを変換
2791 // $redirectUrl = '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2792 $redirectUrl = $gEnvManager->createPageUrl() . '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
2793 if (!empty($todo)) $redirectUrl .= '&' . $todo;
2794 $this->redirect($redirectUrl);
2799 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2800 * 追加するHTMLは主にウィンドウ制御用のスクリプト
2802 * @return string 最終HTML
2804 function getLastContents()
2806 global $gEnvManager;
2807 global $gRequestManager;
2810 $initScript = ''; // 初期化用スクリプト
2811 $pageId = $gEnvManager->getCurrentPageId();
2812 $pageSubId = $gEnvManager->getCurrentPageSubId();
2813 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
2815 if (!$gEnvManager->isSystemManageUser()) return ''; // システム運用権限がない場合は終了
2818 if ($cmd == M3_REQUEST_CMD_RSS || // RSS配信のときは終了
2819 $cmd == M3_REQUEST_CMD_DO_WIDGET) return ''; // ウィジェット単体オペレーションのときは出力しない
2821 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
2823 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
2824 /* // テンプレート上のポジション名
2825 if (count($this->viewPosId) > 0){
2827 for ($i = 0; $i < count($this->viewPosId); $i++){
2828 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
2829 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
2831 $posArrayStr .= ']';
2832 $contents .= 'var M3_POSITIONS=' . $posArrayStr . ';' . M3_NL;
2835 $contents .= 'var M3_REVISION=' . $this->pageDefRev . ';' . M3_NL;*/
2838 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2839 $contents .= M3_INDENT_SPACE . 'window.m3.m3UpdateByConfig(serial);' . M3_NL;
2840 $contents .= '}' . M3_NL;
2841 } else if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット設定画面
2842 } else { // ダッシュボード画面、メイン管理画面
2844 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2845 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2846 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2847 $contents .= '}' . M3_NL;
2850 // ウィジェット単体実行以外のときの処理
2851 if (!$this->showWidget){
2852 if ($this->updateParentWindow){ // 管理画面からの親画面の更新
2853 $initScript .= M3_INDENT_SPACE . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
2858 $contents .= 'function m3UpdateByConfig(serial){' . M3_NL;
2859 $contents .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
2860 $contents .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
2861 $contents .= '}' . M3_NL;
2865 if (!empty($contents) || !empty($initScript)){
2866 // $destContents .= '<script type="text/javascript">' . M3_NL;
2867 // $destContents .= '//<![CDATA[' . M3_NL;
2868 $destContents .= $contents;
2869 if (!empty($initScript)){ // 初期化用スクリプト
2870 $destContents .= '$(function(){' . M3_NL;
2871 $destContents .= $initScript;
2872 $destContents .= '});' . M3_NL;
2874 // $destContents .= '//]]>' . M3_NL;
2875 // $destContents .= '</script>' . M3_NL;
2877 return $destContents;
2882 * テンプレートの出力が完了した後、HTMLとして出力する最後の出力を行う
2884 * @param RequestManager $request HTTPリクエスト処理クラス
2885 * @return string 最終HTML
2887 function getOptionContents($request)
2889 global $gEnvManager;
2894 if ($this->isAbort) return '';
2896 // AJAX用のレスポンスボディデータのときは終了
2897 if ($this->outputAjaxResponseBody) return '';
2900 // AJAXを送信する場合は空文字列では送信できないので、ダミーデータを返す
2901 if ($this->isWidgetAbort) $contents .= 'NO DATA' . M3_NL;
2904 if ($this->outputByHtml){ // HTML出力のとき
2905 $contents .= '<!-- created by ' . M3_SYSTEM_NAME . ' v' . M3_SYSTEM_VERSION . ' - http://www.magic3.org -->' . M3_NL;
2906 $contents .= '<!-- convert time: ' . sprintf('%01.03f', microtime(true) - M3_MTIME) . ' -->' . M3_NL;
2911 * Widget単体起動用のHTMLのヘッダ部(headタグ)出力
2913 * startWidget(),endWidget()は、以下のコマンドを処理する
2914 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
2915 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
2916 * ・M3_REQUEST_CMD_CONFIG_TEMPLATE(テンプレート設定画面)
2917 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
2918 * Widgetの出力方法は、以下のパターンがある
2919 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
2920 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
2922 * @param string $cmd 起動コマンド
2924 function startWidget($cmd)
2926 global $gEnvManager;
2927 global $gRequestManager;
2929 // ウィジェット単体表示のときのみ出力
2930 if (!$this->showWidget) return;
2933 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
2934 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
2936 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
2937 if (intval($tempVer) >= 2) $this->isHtml5 = true; // HTML5で出力するかどうか
2940 if ($this->isHtml5){
2941 echo '<!DOCTYPE html>' . M3_NL;
2942 echo '<html dir="ltr" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2943 echo '<head>' . M3_NL;
2945 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . M3_NL;
2946 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $gEnvManager->getCurrentLanguage() . '" lang="' . $gEnvManager->getCurrentLanguage() . '">' . M3_NL;
2947 echo '<head>' . M3_NL;
2948 // echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' . M3_NL;
2951 // HTMLのヘッダ部(headタグ内)出力
2954 // ##### 作成対象がウィジェットの場合とテンプレートの場合に分ける #####
2955 if ($cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE){ // テンプレート設定画面の場合
2956 $templateId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_TEMPLATE_ID);// テンプレートID
2959 $widgetId = $gEnvManager->getCurrentWidgetId(); // カレントのウィジェットID
2963 if ($gEnvManager->getUseSslAdmin()){
2964 $rootUrl = $gEnvManager->getSslRootUrl();
2965 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
2966 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
2968 $rootUrl = $gEnvManager->getRootUrl();
2969 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
2970 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
2973 // ##### テンプレートのCSSの読み込み #####
2974 // テンプレートは管理用テンプレートに固定されている
2975 //if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || // ウィジェット設定のとき
2976 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
2977 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
2978 $curTemplateUrl = $templatesUrl . '/' . $gEnvManager->getCurrentTemplateId();
2979 if ($this->isHtml5){
2980 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/style.css" media="screen">' . M3_NL;
2981 echo '<link rel="stylesheet" href="' . $curTemplateUrl . '/css/widget.css" media="screen">' . M3_NL; // ウィジェット設定画面用CSS
2982 echo '<!--[if IE]><link rel="stylesheet" href="' . $curTemplateUrl . '/css/iestyles.css" media="screen"><![endif]-->' . M3_NL;
2983 echo '<!--[if lt IE 9]><script src="' . $curTemplateUrl . '/html5shiv.js"></script><![endif]-->' . M3_NL;
2985 echo '<link href="' . $curTemplateUrl . '/css/style.css" rel="stylesheet" type="text/css" />' . M3_NL;
2986 echo '<!--[if IE]><link rel="stylesheet" type="text/css" media="screen" href="' . $curTemplateUrl . '/css/iestyles.css" /><![endif]-->' . M3_NL;
2990 $ret = $this->db->getWidgetInfo($widgetId, $row);
2992 // ##### 共通ライブラリ読み込み設定 #####
2993 if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
2994 $scritLib = trim($row['wd_add_script_lib']);
2995 if (!empty($scritLib)) $this->addScript($task, $scritLib);
2998 // CSS読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
2999 if ($row['wd_read_css']){
3000 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_CSS;
3001 if (is_dir($searchPath)){
3002 $dir = dir($searchPath);
3003 while (($file = $dir->read()) !== false){
3004 $filePath = $searchPath . '/' . $file;
3005 if ($file != '.' && $file != '..' && is_file($filePath)
3006 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3009 $cssURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_CSS . '/' . $file;
3010 echo '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3017 // スクリプト読み込みが指定されていて、ディレクトリがあるときはディレクトリ内読み込み
3018 if ($row['wd_read_scripts']){
3019 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS;
3020 if (is_dir($searchPath)){
3021 $dir = dir($searchPath);
3022 while (($file = $dir->read()) !== false){
3023 $filePath = $searchPath . '/' . $file;
3024 if ($file != '.' && $file != '..' && is_file($filePath)
3025 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3028 $scriptURL = $widgetsUrl . '/' . $widgetId . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
3030 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3031 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3032 echo '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3038 // ##### スクリプト用出力用タグを埋め込む #####
3039 // ウィジェット設定画面用メニューバーの作成
3040 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3041 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3042 echo self::MENUBAR_SCRIPT_TAGS; // メニューバー出力用タグ
3045 // ##### 作成対象がウィジェットの場合とテンプレートの場合に分ける #####
3047 if ($cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE){ // テンプレート設定画面の場合
3048 $title = self::WIDGET_TITLE_START . 'テンプレート' . self::WIDGET_TITLE_END . ' ' . $templateId;
3049 $gEnvManager->setCurrentWidgetTitle($title);
3050 echo '<title>' . htmlspecialchars($title) . '</title>' . M3_NL;
3052 $title = $row['wd_name'];
3053 if (empty($title)) $title = $row['wd_id'];
3054 $gEnvManager->setCurrentWidgetTitle($title);
3055 echo '<title>' . self::WIDGET_TITLE_START . htmlspecialchars($title) . self::WIDGET_TITLE_END . '</title>' . M3_NL;
3057 echo '</head>' . M3_NL;
3059 // タブでウィンドウを開く場合は背景を透過モードにする
3060 if ($this->isTransparentMode){
3061 echo '<body style="background-color:transparent;">' . M3_NL;
3063 echo '<body>' . M3_NL;
3065 // ウィジェット設定画面用メニューバーの作成
3066 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3067 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット設定画面またはフロント画面編集モードのとき
3069 $desc = $row['wd_description']; // 説明
3070 $gEnvManager->setCurrentWidgetParams('desc', $desc);
3072 echo self::MENUBAR_TAGS; // メニューバー出力用タグ
3075 if ($this->useBootstrap) echo '<div class="container">' . M3_NL;
3077 // 別ウィンドウで表示のときは、「閉じる」ボタンを表示
3078 if ($cmd == M3_REQUEST_CMD_SHOW_WIDGET || // ウィジェットの単体表示のとき
3079 $cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3080 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // ウィジェット単体実行でフロント画面編集モードのとき
3082 // if ($this->isEditMode){// フロント画面編集モードのとき
3083 if (!empty($openBy)){
3084 // サーバ指定されている場合はサーバ情報を取得
3086 $server = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_SERVER);
3087 if (!empty($server)){
3089 $ret = $this->db->getServerById($server, $row);
3091 $serverName = 'サーバ名:' . $row['ts_name'];// サーバ名
3092 echo '<div align="left" style="float:left;padding-left:30px;"><label>' . convertToHtmlEntity($serverName) . '</label></div>';
3095 // タブ、インナーフレーム、ダイアログ表示以外のときは「閉じる」ボタンを表示
3096 if ($openBy != 'tabs' && $openBy != 'iframe' && $openBy != 'dialog'){ // 以外
3097 if ($openBy == 'logout'){
3098 $titleStr = 'ログアウト';
3099 echo '<div class="m3configclose"><a href="#" onclick="location.href=\'?cmd=logout\';" data-placement="left" data-container="body" title="' . $titleStr . '" rel="m3help"><img src="' . $rootUrl . self::CLOSE_ICON_FILE .
3100 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
3103 echo '<div class="m3configclose"><a href="#" onclick="window.close();" data-placement="left" data-container="body" title="' . $titleStr . '" rel="m3help"><img src="' . $rootUrl . self::CLOSE_ICON_FILE .
3104 '" alt="' . $titleStr . '" /></a></div>' . M3_NL;
3110 echo '<div class="m3configprev" style="display:none;"><a id="m3configprev" href="#"><img src="' . $rootUrl . self::PREV_ICON_FILE .
3111 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
3113 echo '<div class="m3confignext" style="display:none;"><a id="m3confignext" href="#"><img src="' . $rootUrl . self::NEXT_ICON_FILE .
3114 '" alt="' . $titleStr . '" title="' . $titleStr . '" rel="m3help" /></a></div>' . M3_NL;
3117 echo '<!-- Widget Start -->' . M3_NL;
3122 * startWidget(),endWidget()は、以下のコマンドを処理する
3123 * ・M3_REQUEST_CMD_SHOW_WIDGET(ウィジェットの単体表示)
3124 * ・M3_REQUEST_CMD_CONFIG_WIDGET(ウィジェット設定画面)
3125 * ・M3_REQUEST_CMD_CONFIG_TEMPLATE(テンプレート設定画面)
3126 * ・M3_REQUEST_CMD_DO_WIDGET(ウィジェット単体実行)
3128 * @param string $cmd 起動コマンド
3129 * @param string $srcContent HTML出力ソース
3131 function endWidget($cmd, $srcContent)
3133 global $gDesignManager;
3135 // ウィジェット単体表示のときのみ出力
3136 if (!$this->showWidget) return;
3140 $breadcrumbHtml = '';
3141 if (!empty($this->adminSubNavbarDef)) $breadcrumbHtml .= $gDesignManager->createSubMenubar($this->adminSubNavbarDef);
3142 if (!empty($this->adminBreadcrumbDef)) $breadcrumbHtml .= $gDesignManager->createAdminBreadcrumb($this->adminBreadcrumbDef);
3143 $destContent = str_replace(self::MENUBAR_TAGS, $breadcrumbHtml, $srcContent);
3146 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3147 $replaceStr .= '//<![CDATA[' . M3_NL;
3151 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェットの設定管理
3153 $replaceStr .= 'function m3UpdateByConfig(serial){' . M3_NL;
3154 $replaceStr .= M3_INDENT_SPACE . 'var href = window.location.href.split("#");' . M3_NL;
3155 $replaceStr .= M3_INDENT_SPACE . 'window.location.href = href[0];' . M3_NL;
3156 $replaceStr .= M3_INDENT_SPACE . 'm3UpdateParentWindow();' . M3_NL; // 親ウィンドウ更新
3157 $replaceStr .= '}' . M3_NL;
3160 $replaceStr .= 'function hideIEErrors(){' . M3_NL;
3161 $replaceStr .= M3_INDENT_SPACE . 'return true;' . M3_NL;
3162 $replaceStr .= '}' . M3_NL;
3163 $replaceStr .= 'window.onerror = hideIEErrors;' . M3_NL;
3167 $replaceStr .= '$(function(){' . M3_NL;
3169 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE || // ウィジェット設定画面またはテンプレート設定画面のとき
3170 ($cmd == M3_REQUEST_CMD_DO_WIDGET && $this->isEditMode)){ // フロント画面編集モードのとき
3171 if (!empty($this->adminSubNavbarDef) || !empty($this->adminBreadcrumbDef)){
3172 $menubarHeight = $gDesignManager->getSubMenubarHeight();
3173 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("nav.secondlevel").css("margin-top", "0");' . M3_NL;
3174 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . '$("body").css("padding-top", "' . $menubarHeight . 'px");' . M3_NL;
3177 // ##### ウィジェットからの指定による処理 #####
3178 if ($this->updateParentWindow){ // 親ウィンドウ再描画のとき
3179 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){ // ウィジェット詳細設定画面のとき
3180 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindowByConfig(' . $this->updateDefSerial . ');' . M3_NL;// 更新する項目のページ定義シリアル番号
3181 } else if ($cmd == M3_REQUEST_CMD_DO_WIDGET){ // ウィジェット単体実行のとき
3182 $replaceStr .= str_repeat(M3_INDENT_SPACE, 1) . 'm3UpdateParentWindow();' . M3_NL;
3185 $replaceStr .= '});' . M3_NL;
3186 $replaceStr .= '//]]>' . M3_NL;
3187 $replaceStr .= '</script>' . M3_NL;
3188 $destContent = str_replace(self::MENUBAR_SCRIPT_TAGS, $replaceStr, $destContent);
3189 echo $destContent;// 変換したコンテンツを出力
3191 echo '<!-- Widget End -->' . M3_NL;
3194 if ($this->useBootstrap) echo '</div>' . M3_NL;
3196 echo '</body>' . M3_NL;
3197 echo '</html>' . M3_NL;
3200 * Widget単体RSS出力用のHTMLのヘッダ部(headタグ)出力
3202 * Widgetの出力方法は、以下のパターンがある
3203 * ・HTMLヘッダ付加 - Widget単体で画面出力するためにHTMLヘッダを付加するパターン
3204 * ・HTMLヘッダなし - Wiget単体のタグ出力のみのパターン
3206 * @param string $cmd 起動コマンド
3208 function startWidgetRss($cmd)
3212 * Widget単体RSS出力用のタグを閉じる
3214 * @param string $cmd 起動コマンド
3215 * @param string $rssContent RSS配信内容
3217 function endWidgetRss($cmd, $rssContent)
3219 global $gEnvManager;
3222 if ($this->isAbort) return;
3224 echo '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>' . M3_NL;
3227 $lang = $gEnvManager->getCurrentLanguage();
3228 $date = getW3CDate(); // RSS1.0用日付
3229 $copyright = $gEnvManager->getSiteCopyRight(); // 著作権
3230 $title = $this->rssChannel['title']; // タイトル
3231 $link = $this->rssChannel['link']; // RSS取得用URL
3232 $desc = $this->rssChannel['description']; // 説明
3233 $seq = $this->rssChannel['seq']; // 項目の並び順(URL)
3235 switch ($this->rssVersion){ // RSSバージョン
3238 echo '<rdf:RDF xmlns="http://purl.org/rss/1.0/" ';
3239 echo 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
3240 echo 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
3241 echo 'xml:lang="' . $lang . '">' . M3_NL;
3242 echo '<channel rdf:about="' . convertUrlToHtmlEntity($link) . '">' . M3_NL;
3243 echo '<title>' . convertToHtmlEntity($title) . '</title>' . M3_NL;
3244 echo '<link>' . convertUrlToHtmlEntity($link) . '</link>' . M3_NL; // 「convertUrlToHtmlEntity」が必要
3245 echo '<description>' . convertToHtmlEntity($desc) . '</description>' . M3_NL;
3246 echo '<dc:language>' . $lang . '</dc:language>' . M3_NL;
3247 if (!empty($copyright)) echo '<dc:rights>' . convertToHtmlEntity($copyright) . '</dc:rights>' . M3_NL;
3248 echo '<dc:date>' . $date . '</dc:date>' . M3_NL;
3249 echo '<items>' . M3_NL;
3250 if (count($seq) > 0){
3251 echo str_repeat(M3_INDENT_SPACE, 1) . '<rdf:Seq>' . M3_NL;
3252 for ($i = 0; $i < count($seq); $i++){
3253 echo str_repeat(M3_INDENT_SPACE, 2) . '<rdf:li rdf:resource="' . convertUrlToHtmlEntity($seq[$i]) . '" />' . M3_NL;
3255 echo str_repeat(M3_INDENT_SPACE, 1) . '</rdf:Seq>' . M3_NL;
3257 echo '</items>' . M3_NL;
3258 echo '</channel>' . M3_NL;
3260 echo '</rdf:RDF>' . M3_NL;
3267 header("Content-type: text/xml; charset=utf-8");
3270 * 直サーバ接続時のXML出力用のHTMLのヘッダ部(headタグ)出力
3272 * @param string $cmd 起動コマンド
3275 function startWidgetXml($cmd)
3278 //header("Content-type: text/xml; charset=utf-8");
3283 * @param string $cmd 起動コマンド
3286 function endWidgetXml()
3292 * @return string XML宣言
3294 function getDefaultXmlDeclaration()
3296 return '<?xml version="1.0" encoding="' . M3_HTML_CHARSET . '" ?>';
3299 * HTMLのヘッダ部(headタグ内)出力
3301 * システムに共通な定義をHTMLのheadタグ内に出力する
3302 * mosFunc.phpからも実行されるので、このメソッドは引数なしに固定。
3303 * この関数は、以下の「形式1」または「形式2」でheadタグ内に記述する
3305 * 形式1: <!-- m3:HTMLHeader -->
3306 * 形式2(old style): <?php mosShowHead(); ?>
3308 function getHeader()
3311 $this->outputHead = true; // HTMLヘッダ出力を行ったかどうか
3312 $this->outputByStandardHead = true; // HTML文書の標準のヘッダタグを出力するか
3314 // ##### Magic3システムで必要なヘッダ出力用のタグを埋め込む #####
3315 echo self::HEAD_TAGS; // HTMLヘッダの埋め込みデータ
3318 * HTML文書の標準のヘッダタグを出力
3320 * @return string 標準ヘッダ文字列
3322 function getStandardHead()
3324 global $gEnvManager;
3325 global $gRequestManager;
3327 $headStr = ''; // ヘッダ文字列;
3330 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3332 if ($gEnvManager->getIsSmartphoneSite()){ // スマートフォン用サイトのときはHTML5で設定
3333 $this->isHtml5 = true;
3335 $tempVer = $gEnvManager->getCurrentTemplateType(); // テンプレートタイプを取得(0=デフォルト(Joomla!v1.0),1=Joomla!v1.5,2=Joomla!v2.5)
3336 if (intval($tempVer) >= 2) $this->isHtml5 = true;
3340 if ($this->isHtml5){
3341 $headStr .= '<meta charset="' . M3_HTML_CHARSET . '">' . M3_NL;
3343 $headStr .= '<meta http-equiv="content-script-type" content="text/javascript" />' . M3_NL;
3344 $headStr .= '<meta http-equiv="content-style-type" content="text/css" />' . M3_NL;
3345 $headStr .= '<meta http-equiv="content-type" content="application/xhtml+xml; charset=' . M3_HTML_CHARSET .'" />' . M3_NL;
3347 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3348 // Bootstrapで必要なMETAタグを追加
3349 $headStr .= '<meta name="viewport" content="width=device-width, initial-scale=1">' . M3_NL;
3353 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 表示位置を表示するとき
3354 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 表示位置を表示するとき(ウィジェット付き)
3356 if ($gEnvManager->getUseSslAdmin()){
3357 $rootUrl = $gEnvManager->getSslRootUrl();
3359 $rootUrl = $gEnvManager->getRootUrl();
3361 $headStr .= '<base href="' . $rootUrl . '/" />' . M3_NL;
3368 * @return string HTMLヘッダ出力文字列
3370 function getHeaderOutput()
3372 global $gEnvManager;
3373 global $gRequestManager;
3374 global $gInstanceManager;
3375 global $gSystemManager;
3377 $replaceStr = ''; // 変換文字列
3380 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
3381 $task = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
3382 $widgetId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_WIDGET_ID);
3383 $openBy = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
3385 // ********************************************************
3387 // ********************************************************
3388 // ##### テンプレートの設定、フレームの設定から必要なライブラリを取得 #####
3390 // if (!$this->useBootstrap) $this->useBootstrap = $gEnvManager->getCurrentTemplateUseBootstrap();
3391 if ($this->useBootstrap){
3392 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3393 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3394 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP); // 管理画面でBootstrapを使用するかどうか
3395 if ($cmd != M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)以外のとき
3396 $this->addAdminScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3398 // テンプレートタイプが管理画面のBootstrapバージョン(v3.0)と異なる場合はBootstrapを使用しない場合の管理機能用スクリプトを読み込む
3399 $templateType = $gEnvManager->getCurrentTemplateType();
3400 if ($templateType != 10) $this->addAdminScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3402 } else { // ログインしていない場合(ログイン画面等)
3403 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP);
3404 $this->addPermittedAdminScript(ScriptLibInfo::LIB_BOOTSTRAP_ADMIN);// Bootstrap管理画面オプション
3406 } else { // フロント画面へのアクセスの場合
3407 // ### Bootstrapのjsとcssはテンプレート側で読み込む ###
3408 // ### フロントからプレビューコマンドでログイン画面を表示させるパターンがあるので注意 ###
3409 // if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW || // ログイン、ログアウト場合
3410 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || ($cmd == M3_REQUEST_CMD_PREVIEW && !$gEnvManager->isCurrentUserLogined()) || // ログイン、ログアウト場合
3411 ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy) && $gEnvManager->isContentEditableUser())){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
3413 $this->addScript('', ScriptLibInfo::LIB_BOOTSTRAP_ADMIN); // Bootstrap管理画面オプション
3415 if ($gEnvManager->isSystemManageUser() || // システム運用権限がある場合
3416 $gEnvManager->isContentEditableUser()){ // 投稿ユーザの場合
3417 // テンプレートタイプが管理画面のBootstrapバージョン(v3.0)と異なる場合はBootstrapを使用しない場合の管理機能用スクリプトを読み込む
3418 $templateType = $gEnvManager->getCurrentTemplateType();
3419 if ($templateType != 10) $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3424 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効(ログイン中の場合)
3425 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3426 $this->addAdminScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3428 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3430 } else if ($gEnvManager->isContentEditableUser()){ // 投稿ユーザの場合
3431 $this->addScript('', ScriptLibInfo::LIB_NOBOOTSTRAP); // Bootstrapを使用しない場合の管理機能用スクリプト
3435 // ********************************************************
3437 // ********************************************************
3438 // ##### インストール時のヘッダ出力 #####
3439 if (defined('M3_STATE_IN_INSTALL')){
3442 if (count($this->headSubTitle) > 0) $title = htmlspecialchars(trim($this->headSubTitle[0]));
3444 // ********** メタタグの設定 **********
3445 $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3447 // ##### インストーラ用のファイルの読み込み #####
3448 $scriptsUrl = '../scripts';
3450 // 管理機能用共通ライブラリのCSSの読み込み
3451 $count = count($this->defaultAdminCssFiles);
3452 for ($i = 0; $i < $count; $i++){
3454 $cssFilename = $this->defaultAdminCssFiles[$i];
3455 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3456 $cssURL = $cssFilename;
3458 $cssURL = $scriptsUrl . '/' . $cssFilename;
3460 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3463 // 管理画面用の共通スクリプトを読み込む
3464 $count = count($this->defaultAdminScriptFiles);
3465 for ($i = 0; $i < $count; $i++){
3466 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3469 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3470 $scriptURL = $scriptFilename;
3474 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3476 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3479 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3482 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3483 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3484 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3487 // ##### ページへJavascriptの埋め込む #####
3488 // JavaScriptグローバル変数の設定
3489 $rootUrl = $gEnvManager->getRootUrl();
3490 if (empty($rootUrl)) $rootUrl = $gEnvManager->calcSystemRootUrl();
3491 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3492 $replaceStr .= '//<![CDATA[' . M3_NL;
3493 $replaceStr .= '// Magic3 Global values' . M3_NL;
3494 if (!empty($rootUrl)) $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3495 $replaceStr .= '//]]>' . M3_NL;
3496 $replaceStr .= '</script>' . M3_NL;
3501 $cleanType = $gEnvManager->getCurrentTemplateCleanType(); // テンプレートクリーンタイプ
3502 /* if ($this->db->getTemplate($gEnvManager->getCurrentTemplateId(), $templateRow)){
3503 $cleanType = $templateRow['tm_clean_type'];
3508 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3510 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
3512 $isSslPage = $this->isSslPage($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId());
3515 $rootUrl = $gEnvManager->getSslRootUrl();
3516 $scriptsUrl = $gEnvManager->getSslScriptsUrl(); // スクリプト読み込み用パス
3517 $widgetsUrl = $gEnvManager->getSslWidgetsUrl(); // ウィジェット格納パス
3518 $templatesUrl = $gEnvManager->getSslTemplatesUrl(); // テンプレート読み込み用パス
3520 $rootUrl = $gEnvManager->getRootUrl();
3521 $scriptsUrl = $gEnvManager->getScriptsUrl(); // スクリプト読み込み用パス
3522 $widgetsUrl = $gEnvManager->getWidgetsUrl(); // ウィジェット格納パス
3523 $templatesUrl = $gEnvManager->getTemplatesUrl(); // テンプレート読み込み用パス
3527 if (!$this->showWidget){// 単体実行以外のとき
3528 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスの場合
3530 // メイン画面は「サイト名 - 管理画面」、サブ画面は個別画面名
3531 $siteName = $gEnvManager->getSiteName();
3532 // if (empty($siteName)) $siteName = self::DEFAULT_SITE_NAME;
3533 $title = $siteName . ' - ' . self::DEFAULT_ADMIN_TITLE;
3534 $titleCount = count($this->headSubTitle);
3535 if ($titleCount > 0) $title = $this->headSubTitle[$titleCount -1]; // サブタイトルが設定されている場合は変更
3536 $replaceStr .= '<title>' . htmlspecialchars($title) . '</title>' . M3_NL;
3538 // その他HTMLヘッダに出力するタグ文字列
3539 if (!empty($this->adminHeadOthers)){
3541 $this->adminHeadOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->adminHeadOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3542 $replaceStr .= $this->adminHeadOthers . M3_NL;
3544 } else { // 管理画面以外の画面へのアクセスの場合
3546 $titleItemCount = 0; // タイトル項目数
3547 $defaultTitle = trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_TITLE));
3548 if (!empty($defaultTitle)) $titleItemCount++;
3549 if (!empty($this->headSubTitle)){ // サブタイトルが設定されているとき
3550 $titleItemCount += count($this->headSubTitle);
3554 if ($titleItemCount > 0){
3555 $format = $this->gSystem->getSystemConfig(self::CONFIG_KEY_HEAD_TITLE_FORMAT);
3556 if (empty($format)){
3557 $title = htmlspecialchars($defaultTitle);
3559 $formats = explode(';', $format);
3560 $titleItemCount = ($titleItemCount > count($formats)) ? count($formats) : $titleItemCount;
3561 $title = $formats[$titleItemCount -1];
3563 if (!empty($defaultTitle)){
3564 $title = str_replace('$1', htmlspecialchars($defaultTitle), $title);
3567 for ($i = 0; $i < count($this->headSubTitle); $i++){
3568 $key = '$' . $number;
3569 $value = htmlspecialchars(trim($this->headSubTitle[$i]));
3570 $title = str_replace($key, $value, $title);
3575 if (!empty($title)) $replaceStr .= '<title>' . $title . '</title>' . M3_NL;
3578 if (!empty($this->headDescription)) $replaceStr .= '<meta name="description" content="' . htmlspecialchars($this->headDescription) . '" />' . M3_NL;
3581 if (!empty($this->headKeywords)) $replaceStr .= '<meta name="keywords" content="' . htmlspecialchars($this->headKeywords) . '" />' . M3_NL;
3583 // その他HTMLヘッダに出力するタグ文字列
3584 if (!empty($this->headOthers)){
3586 $this->headOthers = $gInstanceManager->getTextConvManager()->convContentMacro($this->headOthers, false/*改行コードをbrタグに変換しない*/, array(), true/*変換後の値はHTMLエスケープ処理する*/);
3587 $replaceStr .= $this->headOthers . M3_NL;
3592 // ##### PC用URLと携帯用URLのアクセス別に処理 #####
3593 // ##### テンプレート情報に応じた処理 #####
3594 // テンプレートクリーンが必要な場合はJQueryを追加
3595 if ($cleanType != 0) $this->addScriptFile($this->selectedJQueryFilename); // JQueryスクリプト追加
3598 $robots = htmlspecialchars(trim($this->gSystem->getSiteDef(M3_TB_FIELD_SITE_ROBOTS)));
3599 if (!empty($robots)){
3600 $replaceStr .= '<meta name="robots" content="' . $robots . '" />' . M3_NL;
3604 $replaceStr .= '<meta name="generator" content="' . M3_SYSTEM_NAME . ' ver.' . M3_SYSTEM_VERSION . ' - ' . M3_SYSTEM_DESCRIPTION . '" />' . M3_NL;
3606 // カノニカル属性、Faviconの読み込み
3607 $templateId = $gEnvManager->getCurrentTemplateId();
3608 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3609 // テンプレートのFaviconがない場合はシステムのデフォルトのFaviconを使用
3610 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3611 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3612 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3613 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3616 $faviconPath = $gEnvManager->getSystemRootPath() . self::DEFAULT_ADMIN_FAVICON_FILE;
3617 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3618 $faviconFile = $rootUrl . self::DEFAULT_ADMIN_FAVICON_FILE;
3619 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3624 if (!empty($this->headCanonicalUrl)) $replaceStr .= '<link rel="canonical" href="' . convertUrlToHtmlEntity($this->headCanonicalUrl) .'" />' . M3_NL; // カノニカル属性URL
3627 $faviconPath = $gEnvManager->getTemplatesPath() . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3628 if (file_exists($faviconPath)){ // ファイルが存在しているとき
3629 $faviconFile = $templatesUrl . '/' . $templateId . self::DEFAULT_FAVICON_FILE;
3630 $replaceStr .= '<link rel="shortcut icon" href="' . $faviconFile .'" />' . M3_NL;
3634 // ##### Ajaxライブラリの読み込み #####
3635 if (!$gEnvManager->isAdminDirAccess()){ // 通常画面へのアクセスのとき
3636 if ($this->db->isExistsWidgetWithAjax($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId())){// Ajaxライブラリを使用しているウィジェットがあるときは追加
3637 $this->addScriptFile($this->selectedJQueryFilename); // デフォルトAjaxライブラリ追加
3638 $this->addScriptFile(self::M3_OPTION_SCRIPT_FILENAME); // Magic3のオプションライブラリ追加
3642 // ##### 共通ライブラリの読み込み #####
3643 if (!$this->showWidget){// 単体実行以外のとき
3644 $this->db->getWidgetsIdWithLib($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3645 for ($i = 0; $i < count($rows); $i++){
3646 $this->addScript($task, trim($rows[$i]['wd_add_script_lib']));
3650 // ##### 共通CSS読み込み #####
3651 if (($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()) || $this->isEditMode){ // フロント画面編集モード
3652 $cssURL = $scriptsUrl . '/' . self::M3_EDIT_CSS_FILE;
3653 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3655 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3656 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
3657 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3658 // 管理機能用共通ライブラリのCSSの読み込み
3659 $count = count($this->defaultAdminCssFiles);
3660 for ($i = 0; $i < $count; $i++){
3662 //$cssURL = $scriptsUrl . '/' . $this->defaultAdminCssFiles[$i];
3663 $cssFilename = $this->defaultAdminCssFiles[$i];
3664 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3665 $cssURL = $cssFilename;
3667 $cssURL = $scriptsUrl . '/' . $cssFilename;
3669 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3672 // 管理権限なしで管理ディレクトリアクセスで必要なCSSファイルを読み込む
3673 $count = count($this->defaultAdminDirCssFiles);
3674 for ($i = 0; $i < $count; $i++){
3676 $cssURL = $scriptsUrl . '/' . $this->defaultAdminDirCssFiles[$i];
3677 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3682 $count = count($this->defaultCssFiles);
3683 for ($i = 0; $i < $count; $i++){
3685 $cssFilename = $this->defaultCssFiles[$i];
3686 if (strncasecmp($cssFilename, 'http://', 7) == 0 || strncasecmp($cssFilename, 'https://', 8) == 0){
3687 $cssURL = $cssFilename;
3689 $cssURL = $scriptsUrl . '/' . $cssFilename;
3691 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3695 // ##### 表示モードによるCSS読み込み #####
3696 // ウィジェット付きポジション画面は管理画面のアクセスではない
3697 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3699 $cssURL = $scriptsUrl . self::M3_ADMIN_WIDGET_CSS_FILE;
3700 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3703 // ##### ウィジェットごとのCSS読み込み #####
3705 $this->db->getWidgetsIdWithCss($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3706 for ($i = 0; $i < count($rows); $i++){
3707 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS;
3708 // ディレクトリがあるときはディレクトリ内読み込み
3709 if (is_dir($searchPath)){
3710 $dir = dir($searchPath);
3711 while (($file = $dir->read()) !== false){
3712 $filePath = $searchPath . '/' . $file;
3713 if ($file != '.' && $file != '..' && is_file($filePath)
3714 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3717 $cssURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_CSS . '/' . $file;
3718 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . $cssURL . '" />' . M3_NL;
3724 // ##### 外部出力用CSS読み込み #####
3725 // ウィジェットからの追加のCSS読み込み
3726 $count = count($this->headCssFiles);
3727 for ($i = 0; $i < $count; $i++){
3728 $cssUrl = $this->headCssFiles[$i];
3729 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3730 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3733 // 外部出力用CSSデータがある場合はURLを追加
3734 if (!empty($this->exportCss)){
3735 $cssUrl = $this->createCssCmdUrl($isSslPage, date('YmdHis'));
3736 if ($isSslPage) $cssUrl = str_replace('http://', 'https://', $cssUrl); // SSL化が必要なときは変換
3737 $replaceStr .= '<link rel="stylesheet" type="text/css" href="' . convertUrlToHtmlEntity($cssUrl) . '" />' . M3_NL;
3740 // ##### RSS配信情報の読み込み #####
3741 $count = count($this->headRssFiles);
3742 for ($i = 0; $i < $count; $i++){
3743 $rssUrl = $this->headRssFiles[$i]['href'];// リンク先URL
3744 $rssTitle = $this->headRssFiles[$i]['title'];// タイトル
3745 $replaceStr .= '<link rel="alternate" type="application/rss+xml" title="' . $rssTitle . '" href="' . convertUrlToHtmlEntity($rssUrl) . '" />' . M3_NL;
3748 // ##### 共通Javascriptの読み込み #####
3749 if ($gEnvManager->isAdminDirAccess()){ // 管理画面へのアクセスのとき
3750 if ($gEnvManager->isSystemManageUser()){ // システム運用権限がある場合のみ有効
3751 // 管理画面用の共通スクリプトを読み込む
3752 $count = count($this->defaultAdminScriptFiles);
3753 for ($i = 0; $i < $count; $i++){
3754 $scriptFilename = $this->defaultAdminScriptFiles[$i];
3757 if (strncasecmp($scriptFilename, 'http://', 7) == 0 || strncasecmp($scriptFilename, 'https://', 8) == 0){
3758 $scriptURL = $scriptFilename;
3762 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3764 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3767 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3770 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3771 //$scriptURL = $scriptsUrl . '/' . $scriptFilename;
3772 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3773 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3775 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示のときは、ウィジェット操作ライブラリを読み込む
3777 $scriptURL = $scriptsUrl . '/' . self::M3_ADMIN_WIDGET_SCRIPT_FILENAME;
3778 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();// スクリプトをキャッシュ保存しない場合は、パラメータを付加
3779 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3781 } else { // システム運用権限がない場合
3782 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3783 $count = count($this->defaultAdminDirScriptFiles);
3784 for ($i = 0; $i < $count; $i++){
3785 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3787 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3788 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3789 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3790 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3794 // Googleマップライブラリの読み込み
3795 if ($this->useGooglemaps && $this->isContentGooglemaps) $this->addScriptFile(ScriptLibInfo::getScript(ScriptLibInfo::LIB_GOOGLEMAPS)); // コンテンツにGoogleマップが含むかどうか
3797 $useExternalJquery = $gSystemManager->getSystemConfig(self::CF_EXTERNAL_JQUERY); // システム外部のjQueryを使用するかどうか
3799 $count = count($this->defaultScriptFiles);
3800 for ($i = 0; $i < $count; $i++){
3801 $defaultScriptFile = $this->defaultScriptFiles[$i];
3803 // 外部のjQueryを使用する場合はSCRIPTタグを出力しない
3804 if ($defaultScriptFile == $this->selectedJQueryFilename && $useExternalJquery) continue;
3807 if (strncasecmp($defaultScriptFile, 'http://', 7) == 0 || strncasecmp($defaultScriptFile, 'https://', 8) == 0){
3808 $scriptURL = $defaultScriptFile;
3812 $scriptURL = str_replace('http://', 'https://', $scriptURL);
3814 $scriptURL = str_replace('https://', 'http://', $scriptURL);
3817 $scriptURL = $scriptsUrl . '/' . $defaultScriptFile;
3820 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3821 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3822 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3825 // ### フロントからプレビューコマンドでログイン画面を表示させるパターンがあるので注意 ###
3826 // if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || $cmd == M3_REQUEST_CMD_PREVIEW){ // ログイン、ログアウト場合
3827 if ($cmd == M3_REQUEST_CMD_LOGIN || $cmd == M3_REQUEST_CMD_LOGOUT || ($cmd == M3_REQUEST_CMD_PREVIEW && !$gEnvManager->isCurrentUserLogined())){ // ログイン、ログアウト場合
3828 // 管理権限なしで管理ディレクトリアクセスで必要なスクリプトを読み込む
3829 $count = count($this->defaultAdminDirScriptFiles);
3830 for ($i = 0; $i < $count; $i++){
3831 $scriptFilename = $this->defaultAdminDirScriptFiles[$i];
3832 if (!in_array($scriptFilename, $this->defaultScriptFiles)){ // 既に追加されていない場合のみ追加
3833 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3834 $scriptURL = $scriptsUrl . '/' . $scriptFilename;
3835 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3836 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3841 // ***** [WordPressテンプレート] jQueryの読み込み後、ヘッダ部に出力するテンプレート用のJavascriptがあれば読み込む *****
3842 $headData = $this->gEnv->getWpHeadScriptsData();
3843 if (!empty($headData)) $replaceStr .= $headData;
3845 // ##### ウィジェットごとのJavaScript読み込み #####
3846 // スクリプトがあるウィジェットを取得
3847 $this->db->getWidgetsIdWithScript($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $rows);
3848 for ($i = 0; $i < count($rows); $i++){
3849 $searchPath = $gEnvManager->getWidgetsPath() . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS;
3851 // ディレクトリがあるときはディレクトリ内読み込み
3852 if (is_dir($searchPath)){
3853 $dir = dir($searchPath);
3854 while (($file = $dir->read()) !== false){
3855 $filePath = $searchPath . '/' . $file;
3856 if ($file != '.' && $file != '..' && is_file($filePath)
3857 && strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のファイルは読み込まない
3860 $scriptURL = $widgetsUrl . '/' . $rows[$i]['wd_id'] . '/' . M3_DIR_NAME_SCRIPTS . '/' . $file;
3861 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3862 if (!$this->hasScriptCache) $scriptURL .= $this->getCacheParam();
3863 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptURL) . '"></script>' . M3_NL;
3869 // ウィジェットからの追加のCSS読み込み
3870 $count = count($this->headScriptFiles);
3871 for ($i = 0; $i < $count; $i++){
3872 $scriptUrl = $this->headScriptFiles[$i];
3873 if ($isSslPage) $scriptUrl = str_replace('http://', 'https://', $scriptUrl); // SSL化が必要なときは変換
3875 // スクリプトをキャッシュ保存しない場合は、パラメータを付加
3876 if (!$this->hasScriptCache) $scriptUrl .= $this->getCacheParam();
3877 $replaceStr .= '<script type="text/javascript" src="' . convertUrlToHtmlEntity($scriptUrl) . '"></script>' . M3_NL;
3880 // ##### ページへJavascriptの埋め込む #####
3881 // JavaScriptグローバル変数の設定
3882 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
3883 //$replaceStr .= '<!--' . M3_NL;
3884 $replaceStr .= '<script type="text/javascript">' . M3_NL;
3885 $replaceStr .= '//<![CDATA[' . M3_NL;
3886 $replaceStr .= '// Magic3 Global values' . M3_NL;
3887 $replaceStr .= 'var M3_ROOT_URL = "' . $rootUrl . '";' . M3_NL; // システムルートURL
3889 if ($gEnvManager->isAdminDirAccess() && $gEnvManager->isSystemManageUser()){ // 管理画面へのアクセス、システム運用権限があり
3890 $pageId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID); // ページID
3891 $pageSubId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);// ページサブID
3894 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
3897 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
3898 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
3900 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
3903 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
3904 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
3905 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
3907 // Googleマップライブラリの読み込み
3908 if ($this->useGooglemaps){
3909 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
3911 // CKEditor拡張プラグイン用の定義
3912 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
3913 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
3915 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
3919 if ($this->isPersonalMode){
3920 $replaceStr .= 'var M3_PERSONAL_MODE = true;' . M3_NL;
3922 $replaceStr .= 'var M3_PERSONAL_MODE = false;' . M3_NL;
3924 // 管理画面の小画面デバイス最適化を行うかどうか
3925 if ($gEnvManager->isSmallDeviceAdmin()){
3926 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = true;' . M3_NL;
3928 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = false;' . M3_NL;
3931 // ウィジェット詳細設定画面専用のJavaScriptグローバル変数
3932 if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET){
3933 //if ($cmd == M3_REQUEST_CMD_CONFIG_WIDGET || $cmd == M3_REQUEST_CMD_CONFIG_TEMPLATE){ // ウィジェット設定画面またはテンプレート設定画面のとき
3934 // ##### CKEditor用の設定 #####
3935 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3937 // CKEditor用のCSSファイル
3938 if (!empty($this->ckeditorCssFiles)){
3939 // 編集エリア用のCSSファイルを追加
3940 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3941 //array_unshift($this->ckeditorCssFiles, $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE);
3943 //$fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
3944 $fileList = implode(', ', array_map(function($a){ return "'" . $a . "'"; }, $this->ckeditorCssFiles));
3945 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3947 // CKEditor用(レイアウト)のCSSファイル
3948 $cssFiles = array();
3949 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_ADMIN_CSS; // BootstrapのCSSを追加
3950 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
3951 // $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
3952 $fileList = implode(', ', array_map(function($a){ return "'" . $a . "'"; }, $cssFiles));
3953 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
3955 // CKEditor用のテンプレートタイプ
3956 if (isset($this->ckeditorTemplateType)){
3957 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
3959 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION){ // ポジション表示
3960 $replaceStr .= 'var M3_POSITION_DATA = "' . implode(',', $this->defPositions) . '";' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
3961 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = 0;' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
3962 } else if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3964 $positionData = $this->getRestPositionData();
3967 if (count($this->viewPosId) > 0){
3969 for ($i = 0; $i < count($this->viewPosId); $i++){
3970 $posArrayStr .= '\'#' . $this->viewPosId[$i] . '\'';
3971 if ($i < count($this->viewPosId) - 1) $posArrayStr .= ',';
3973 $posArrayStr .= ']';
3974 $replaceStr .= 'var M3_POSITIONS = ' . $posArrayStr . ';' . M3_NL;
3977 $replaceStr .= 'var M3_REVISION = ' . $this->pageDefRev . ';' . M3_NL;
3980 $replaceStr .= 'var M3_REST_POSITION_DATA = \'' . $positionData . '\';' . M3_NL;
3981 } else if (!empty($pageId)){
3982 $accessPoint = $this->gEnv->getAllDefaultPageId();
3983 for ($i = 0; $i < count($accessPoint); $i++){
3984 if ($pageId == $accessPoint[$i]){
3985 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $i . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
3989 } else { // メインの管理画面の場合
3990 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = 0;' . M3_NL; // 管理画面画面の端末タイプ(主にテスト用に使用)
3993 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // ウィジェット付きポジション表示
3994 if (!empty($task)){ // 戻りタスクが設定されているときのみ最大化可能
3995 $replaceStr .= 'function gobackPagedef(){' . M3_NL;
3996 $replaceStr .= ' window.location.href = "' . $gEnvManager->getDefaultAdminUrl() . '?pageid=' . $pageId . '&pagesubid=' . $pageSubId . '&task=' . $task . '";' . M3_NL;
3997 $replaceStr .= '}' . M3_NL;
3998 $replaceStr .= '$(function(){' . M3_NL;
3999 $replaceStr .= ' $(document).keyup(function(e){' . M3_NL;
4000 $replaceStr .= ' if (e.which == 36) gobackPagedef();' . M3_NL;
4001 $replaceStr .= ' });' . M3_NL;
4002 $replaceStr .= '});' . M3_NL;
4005 // ##### 管理用テンプレートを使用している場合の処理 #####
4006 // Bootstrap用のスクリプト処理
4007 if ($this->useBootstrap){
4008 $replaceStr .= '$(function(){' . M3_NL;
4009 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
4010 $replaceStr .= '});' . M3_NL;
4013 } else if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4014 $replaceStr .= 'var M3_DEFAULT_ADMIN_URL="' . $gEnvManager->getDefaultAdminUrl() . '";' . M3_NL; // 管理機能URL
4017 $replaceStr .= 'var M3_PAGE_ID = "' . $gEnvManager->getCurrentPageId() . '";' . M3_NL;
4018 $replaceStr .= 'var M3_PAGE_SUB_ID = "' . $gEnvManager->getCurrentPageSubId() . '";' . M3_NL;
4020 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4023 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4024 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4025 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4027 // Googleマップライブラリの読み込み
4028 if ($this->useGooglemaps){
4029 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
4031 // CKEditor拡張プラグイン用の定義
4032 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
4033 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
4035 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
4039 if ($this->isPersonalMode){
4040 $replaceStr .= 'var M3_PERSONAL_MODE = true;' . M3_NL;
4042 $replaceStr .= 'var M3_PERSONAL_MODE = false;' . M3_NL;
4046 $templateType = $gEnvManager->getCurrentTemplateType();
4047 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4048 } else if ($this->isEditMode){ // フロント画面編集モード(コンテンツ編集可能ユーザ)
4049 if ($cmd == M3_REQUEST_CMD_DO_WIDGET && !empty($openBy)){ // ウィジェット単体実行でウィンドウを持つ場合の追加スクリプト
4051 $replaceStr .= 'var M3_WYSIWYG_EDITOR = "' . $this->wysiwygEditor . '";' . M3_NL;
4054 $replaceStr .= 'var M3_FILEBROWSER_VER = "' . $this->libFiles[ScriptLibInfo::LIB_ELFINDER]['version'] . '";' . M3_NL; // バージョン
4055 $replaceStr .= 'var M3_FILEBROWSER_WIDTH_RATIO = ' . self::FILEBROWSER_WIDTH_RATIO . ';' . M3_NL; // ファイルブラウザ幅比率
4056 $replaceStr .= 'var M3_FILEBROWSER_HEIGHT_RATIO = ' . self::FILEBROWSER_HEIGHT_RATIO . ';' . M3_NL; // ファイルブラウザ高さ比率
4058 // Googleマップライブラリの読み込み
4059 if ($this->useGooglemaps){
4060 $replaceStr .= 'var M3_USE_GOOGLEMAPS = true;' . M3_NL;
4062 // CKEditor拡張プラグイン用の定義
4063 $googleMapsKey = $this->gSystem->getSystemConfig(self::CF_GOOGLE_MAPS_KEY); // Googleマップ利用キー
4064 if (!empty($googleMapsKey)) $replaceStr .= 'var M3_GOOGLEMAPS_KEY="' . $googleMapsKey . '";' . M3_NL; // システムルートURL
4066 $replaceStr .= 'var M3_USE_GOOGLEMAPS = false;' . M3_NL;
4069 // 起動がパーソナルモードかどうか(常にパーソナルモード)
4070 $replaceStr .= 'var M3_PERSONAL_MODE = true;' . M3_NL;
4072 // 管理画面の小画面デバイス最適化を行うかどうか
4073 if ($gEnvManager->isSmallDeviceAdmin()){
4074 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = true;' . M3_NL;
4076 $replaceStr .= 'var M3_SMALL_DEVICE_OPTIMIZE = false;' . M3_NL;
4079 // ##### CKEditor用の設定 #####
4081 $ret = $this->db->getWidgetInfo($widgetId, $this->configWidgetInfo);
4082 $replaceStr .= 'var M3_CONFIG_WIDGET_DEVICE_TYPE = ' . $this->configWidgetInfo['wd_device_type'] . ';' . M3_NL; // ウィジェット設定画面のウィジェットの端末タイプ
4084 // CKEditor用のCSSファイル
4085 if (!empty($this->ckeditorCssFiles)){
4086 // 編集エリア用のCSSファイルを追加
4087 $this->ckeditorCssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4088 //array_unshift($this->ckeditorCssFiles, $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE);
4090 // $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->ckeditorCssFiles));
4091 $fileList = implode(', ', array_map(function($a){ return "'" . $a . "'"; }, $this->ckeditorCssFiles));
4092 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4094 // CKEditor用(レイアウト)のCSSファイル
4095 $cssFiles = array();
4096 $cssFiles[] = $scriptsUrl . '/' . ScriptLibInfo::BOOTSTRAP_ADMIN_CSS; // BootstrapのCSSを追加
4097 $cssFiles[] = $scriptsUrl . '/' . self::M3_CKEDITOR_CSS_FILE;
4098 // $fileList = implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $cssFiles));
4099 $fileList = implode(', ', array_map(function($a){ return "'" . $a . "'"; }, $cssFiles));
4100 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_LAYOUT_CSS_FILES = [ ' . $fileList . ' ];' . M3_NL;
4102 // CKEditor用のテンプレートタイプ
4103 if (isset($this->ckeditorTemplateType)){
4104 $replaceStr .= 'var M3_CONFIG_WIDGET_CKEDITOR_TEMPLATE_TYPE = ' . $this->ckeditorTemplateType . ';' . M3_NL;
4107 // Bootstrap用のスクリプト処理
4108 if ($this->useBootstrap){
4109 $replaceStr .= '$(function(){' . M3_NL;
4110 $replaceStr .= ' $(\'.button\').addClass(\'' . self::BOOTSTRAP_BUTTON_CLASS . '\');' . M3_NL;
4111 $replaceStr .= '});' . M3_NL;
4114 // プレビュー画面用にテンプレートタイプを出力
4115 $templateType = $gEnvManager->getCurrentTemplateType();
4116 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4118 // ##### ヘルプシステムの組み込み #####
4119 if ($this->useHelp){ // ヘルプ表示のとき
4120 $replaceStr .= '$(function(){' . M3_NL;
4121 $replaceStr .= ' if (jQuery().tooltip) $(\'[rel=m3help]\').tooltip({ placement: \'top\'});' . M3_NL;
4122 $replaceStr .= '});' . M3_NL;
4126 if (!$gEnvManager->isAdminDirAccess()){ // フロント画面のとき
4127 // テンプレートタイプを追加(ファイルローダ等で使用)
4128 $templateType = $gEnvManager->getCurrentTemplateType();
4129 if (isset($templateType)) $replaceStr .= 'var M3_TEMPLATE_TYPE = ' . $templateType . ';' . M3_NL;
4133 // ##### パネルメニュー(フロント画面と管理画面の切り替え等)の表示 #####
4134 // PC用、携帯用、スマートフォン用画面とウィジェット付きポジションの管理画面時に表示
4135 if (($gEnvManager->isAdminDirAccess() && $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET) || // 管理画面(ウィジェット付きポジション表示)のとき
4136 (!$gEnvManager->isAdminDirAccess() && // 一般用画面のとき
4137 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4138 $cmd != M3_REQUEST_CMD_RSS)){ // RSS配信でない
4139 //if ($gEnvManager->isSystemAdmin()){ // 管理者権限がある場合のみ有効
4140 if ($gEnvManager->isSystemManageUser()){ // システム運用権限ありの場合
4142 $menubarTag = ''; // 管理用メニューバー
4143 $adminTag = ''; // 管理画面ボタン
4144 $editTag = ''; // 編集ボタン
4145 $logoutTag = ''; // ログアウトボタン
4147 if ($gEnvManager->isAdminDirAccess()){ // 管理画面(ウィジェット付きポジション表示)の場合
4149 /* $titleStr = '編集終了';
4150 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4151 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4152 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '">';
4153 $editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" title="' . $titleStr . '" /></a></li>';
4156 $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4157 if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4158 //$editTag = '<div class="m3editend"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4159 //$editTag .= '<img src="' . $rootUrl . self::EDIT_END_ICON_FILE . '" alt="' . $titleStr . '" /></a></div>';
4160 $editTag = '<div class="m3editend m3topright"><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4161 $editTag .= '<i class="glyphicon glyphicon-ok-sign"></i></a></div>';
4162 $menubarTag .= $editTag;
4164 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4165 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4166 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").prepend(\'' . $menubarTag . '\');' . M3_NL; // appendでうまく表示できないのでprependで表示
4167 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4168 } else if ($this->isAccessPointWithAdminMenu){ // 通常画面は、管理メニューを使用するアクセスポイントの場合のみ表示
4170 $titleStr = '管理画面へ遷移';
4171 $linkUrl = $gEnvManager->getDefaultAdminUrl();
4172 $adminTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4173 $adminTag .= '<img src="' . $rootUrl . self::ADMIN_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4176 $titleStr = '画面を編集';
4177 $linkUrl = $gEnvManager->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' .M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET;
4178 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_ID . '=' . $gEnvManager->getCurrentPageId();
4179 $linkUrl .= '&' . M3_REQUEST_PARAM_DEF_PAGE_SUB_ID . '=' . $gEnvManager->getCurrentPageSubId();
4180 $linkUrl .= '&' . M3_REQUEST_PARAM_BACKUP_URL . '=' . urlencode($gEnvManager->getCurrentRequestUri()); // URL退避用
4181 $editTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4182 $editTag .= '<img src="' . $rootUrl . self::EDIT_PAGE_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4185 $titleStr = 'ログアウト';
4186 // if ($gEnvManager->isAdminDirAccess()){ // 管理画面の場合
4187 // $linkUrl = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BACKUP_URL); // 退避していたURLを取得
4188 // if (empty($linkUrl)) $linkUrl = $gEnvManager->getDefaultUrl();
4190 $linkUrl = $gEnvManager->getCurrentRequestUri();
4192 $linkUrl = createUrl($linkUrl, M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_LOGOUT);
4193 $logoutTag = '<li><a href="' . convertUrlToHtmlEntity($linkUrl) . '" rel="m3help" data-placement="bottom" data-container="body" title="' . $titleStr . '">';
4194 $logoutTag .= '<img src="' . $rootUrl . self::LOGOUT_ICON_FILE . '" alt="' . $titleStr . '" /></a></li>';
4197 $widgetToolTag .= '<li><div class="m3widgettoolbutton m3-nav m3-navbar-nav" data-toggle="buttons">';
4198 $widgetToolTag .= '<button type="button" class="m3-navbar-btn btn btn-sm" data-color="success" rel="m3help" data-placement="bottom" data-container="body" title="ウィジェットツール"><span class="title"> ウィジェットツール</span></button>';
4199 $widgetToolTag .= '<input type="checkbox" class="hidden" />';
4200 $widgetToolTag .= '</div></li>';
4202 //$menubarTag .= '<div id="m3slidepanel">';
4203 $menubarTag .= '<div id="m3slidepanel" class="m3panel_top m3-navbar-default" style="top:-60px; visibility: visible;">';
4204 $menubarTag .= '<div class="m3panelopener m3topleft"><a href="#" rel="m3help" data-placement="bottom" data-container="body" title="メニューバーを表示"><i class="glyphicon glyphicon-align-justify"></i></a></div>';
4205 // $menubarTag .= '<div tabindex="0" class="m3panel_wrap">';
4206 $menubarTag .= '<div>';
4207 $menubarTag .= '<ul class="m3-nav m3-navbar-nav">';
4208 if ($gEnvManager->isSystemAdmin()){ // 管理画面、編集モードは、管理者権限がある場合のみ有効
4209 $menubarTag .= $adminTag;
4210 $menubarTag .= $editTag;
4212 $menubarTag .= $logoutTag;
4213 $menubarTag .= $widgetToolTag;
4214 $menubarTag .= '</ul>';
4215 $menubarTag .= '</div>';
4216 $menubarTag .= '</div>';
4217 // $menubarTag .= '</div>';
4219 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window.parent && window.parent.frames.length == 0){' . M3_NL;// インラインフレームでないときパネルメニューを表示
4220 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (window == window.parent){' . M3_NL;// インラインフレームでないときパネルメニューを表示(修正 2016/9/1)
4221 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").append(\'' . $menubarTag . '\');' . M3_NL;
4222 //$this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("#m3slidemenubarpanel").m3SlideMenubar();' . M3_NL;
4223 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(".m3panel_top").m3slidepanel({ "position": "top", "type": "push" });' . M3_NL;
4224 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$("body").css("position", "relative");' . M3_NL;
4225 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetHelp($(\'#m3slidepanel\'));' . M3_NL;
4226 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'm3SetupWidgetTool(\'m3widgettoolbutton\');' . M3_NL;
4227 $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . '}' . M3_NL;
4231 // ##### フロント画面からのウィジェット操作用ツールバー #####
4232 if (!$gEnvManager->isAdminDirAccess() &&
4233 $cmd != M3_REQUEST_CMD_DO_WIDGET && // ウィジェット単体実行でない
4234 $cmd != M3_REQUEST_CMD_RSS){ // RSS配信でない
4235 if ($gEnvManager->isSystemManageUser()){ // 一般用画面で管理者権限がある場合のみ有効
4237 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').each(function(){' . M3_NL;
4238 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var attrs = m3_splitAttr($(this).attr(\'m3\'));' . M3_NL;
4239 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var widgetId = attrs[\'widgetid\'];' . M3_NL;
4240 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var serialNo = attrs[\'serial\'];' . M3_NL;
4241 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var configId = attrs[\'configid\'];' . M3_NL;
4242 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var useconfig = attrs[\'useconfig\'];' . M3_NL;
4244 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'\';' . M3_NL;
4245 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (useconfig == 1){' . M3_NL;
4246 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4247 'html += \'<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\\\'\' + widgetId + \'\\\', \' + configId + \', \' + serialNo + \');return false;" rel="m3help" data-container="body" title="ウィジェット設定">' .
4248 '<img src="' . $rootUrl . self::CONFIG_ICON32_FILE . '" alt="ウィジェット設定" width="32" height="32" /></a>\';' . M3_NL;
4249 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4250 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4251 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) .
4252 'html += \'<a href="javascript:void(0);" onclick="m3ShowAdjustWindow(\' + configId + \', \' + serialNo + \', M3_PAGE_ID, M3_PAGE_SUB_ID);return false;" rel="m3help" data-container="body" title="タイトル・スタイル調整">' .
4253 '<img src="' . $rootUrl . self::ADJUST_ICON32_FILE . '" alt="タイトル・スタイル調整" width="32" height="32" /></a>\';' . M3_NL;
4255 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'if (html != \'\'){' . M3_NL;
4256 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) .
4257 'html = \'<div class="m3tooltip" style="display:none;">\' + html + \'<a class="m3closebox" href="javascript:void(0);" rel="m3help" data-container="body" title="閉じる">' .
4258 '<img src="' . $rootUrl . self::CLOSE_BOX_ICON32_FILE . '" alt="閉じる" width="11" height="11" /></a></div>\';' . M3_NL;
4260 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).append(html);' . M3_NL;
4261 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4263 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).click(function(){' . M3_NL;
4264 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4265 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (tooltipObj.css(\'display\') == \'none\'){' . M3_NL;
4266 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (_m3ShowWidgetTool){' . M3_NL;
4267 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'tooltipObj.show();' . M3_NL;
4268 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4269 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4270 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.hide();' . M3_NL;
4271 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4272 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4273 // ウィジェットボーダーハイライト、ツールチップ表示
4274 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).hover(function(){' . M3_NL;
4275 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4276 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(this).addClass(\'m3_widget_highlight\');' . M3_NL;
4277 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4278 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var pos = $(this).position();' . M3_NL;
4279 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var width = $(this).outerWidth();' . M3_NL;
4280 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var tooltipWidth = tooltipObj.outerWidth(true);' . M3_NL;
4281 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var x = pos.left + width - tooltipWidth;' . M3_NL;
4282 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var y = pos.top;' . M3_NL;
4283 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'tooltipObj.css({position: "absolute",top: y + "px", left: x + "px"}).show();' . M3_NL;
4284 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4285 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}, function(){' . M3_NL;
4286 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).removeClass(\'m3_widget_highlight\');' . M3_NL;
4287 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var tooltipObj = $(this).children(\'.m3tooltip\');' . M3_NL;
4288 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'tooltipObj.hide();' . M3_NL;
4289 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4291 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3closebox\').click(function(event){' . M3_NL;
4292 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).children(\'.m3tooltip\').hide();' . M3_NL;
4293 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4295 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4296 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var offset = $(this).offset();' . M3_NL;
4297 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).outerWidth();' . M3_NL;
4298 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).find(\'.m3edittool\').each(function(){' . M3_NL;
4299 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).offset({left: offset.left});' . M3_NL;
4300 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '$(this).width(width);' . M3_NL;
4301 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '});' . M3_NL;
4302 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4305 $this->initScript .= M3_INDENT_SPACE . 'var widgetWindow = \'<div class="m3_contextmenu" id="m3_widgetmenu" style="visibility:hidden;">\';' . M3_NL;
4306 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<ul>\';' . M3_NL;
4307 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'<li id="m3_wconfig"><img src="\' + M3_ROOT_URL + \'/images/system/config.png" /> <span>ウィジェットの設定</span></li>\';' . M3_NL;
4308 if ($gEnvManager->isSystemAdmin()){ // 位置調整は管理者権限がある場合のみ有効(管理ウィジェットの機能のため)
4309 $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;
4311 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</ul>\';' . M3_NL;
4312 $this->initScript .= M3_INDENT_SPACE . 'widgetWindow += \'</div>\';' . M3_NL;
4313 $this->initScript .= M3_INDENT_SPACE . '$("body").append(widgetWindow);' . M3_NL;
4314 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3_widget\').contextMenu(\'m3_widgetmenu\', {' . M3_NL;
4315 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'menuStyle: {' . M3_NL;
4316 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// border : "2px solid green",' . M3_NL;
4317 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'backgroundColor: \'#FFFFFF\',' . M3_NL;
4318 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'width: "150px",' . M3_NL;
4319 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'textAlign: \'left\',' . M3_NL;
4320 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'font: \'12px/1.5 Arial, sans-serif\'' . M3_NL;
4321 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4322 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'itemStyle: {' . M3_NL;
4323 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'padding: \'3px 3px\'' . M3_NL;
4324 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4325 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'bindings: {' . M3_NL;
4326 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wconfig\': function(t){' . M3_NL;
4327 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4328 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4329 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'alert("このウィジェットには設定画面がありません");' . M3_NL;
4330 $this->initScript .= str_repeat(M3_INDENT_SPACE, 5) . 'return;' . M3_NL;
4331 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '}' . M3_NL;
4332 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowConfigWindow(attrs[\'widgetid\'], attrs[\'configid\'], attrs[\'serial\']);' . M3_NL;
4333 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '},' . M3_NL;
4334 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '\'m3_wadjust\': function(t){' . M3_NL;
4335 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'var attrs = m3_splitAttr($(\'#\' + t.id).attr(\'m3\'));' . M3_NL;
4336 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'm3ShowAdjustWindow(attrs[\'configid\'], attrs[\'serial\'], M3_PAGE_ID, M3_PAGE_SUB_ID);' . M3_NL;
4337 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4338 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4339 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onContextMenu: function(e){' . M3_NL;
4340 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (_m3ShowWidgetTool){' . M3_NL;
4341 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return true;' . M3_NL;
4342 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '} else {' . M3_NL;
4343 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . 'return false;' . M3_NL;
4344 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4345 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '},' . M3_NL;
4346 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'onShowMenu: function(e, menu){' . M3_NL;
4347 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '// メニュー項目の変更' . M3_NL;
4348 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'var attrs = m3_splitAttr($(e.target).parents(\'dl\').attr(\'m3\'));' . M3_NL;
4349 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'if (attrs[\'useconfig\'] == \'0\'){' . M3_NL;
4350 $this->initScript .= str_repeat(M3_INDENT_SPACE, 4) . '$(\'#m3_wconfig\', menu).remove();' . M3_NL;
4351 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . '}' . M3_NL;
4352 $this->initScript .= str_repeat(M3_INDENT_SPACE, 3) . 'return menu;' . M3_NL;
4353 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '}' . M3_NL;
4354 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4357 $this->initScript .= M3_INDENT_SPACE . '$(\'div.m3content_private\').each(function(){' . M3_NL;
4358 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var pos = $(this).position();' . M3_NL;
4359 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var top = pos.top;' . M3_NL;
4360 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var left = pos.left;' . M3_NL;
4361 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var width = $(this).css(\'width\');' . M3_NL;
4362 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var height = $(this).css(\'height\');' . M3_NL;
4363 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var html = \'<div class="m3content_overlay"><div><h2>非公開</h2></div></div>\';' . M3_NL;
4364 $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . '$(this).prepend(html);' . M3_NL;
4365 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'var overlayObj = $(this).children(\'.m3content_overlay div\');' . M3_NL;
4366 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 2) . 'overlayObj.css({ position:"absolute", top:top + "px", left:left + "px" }).show();' . M3_NL;
4367 $this->initScript .= M3_INDENT_SPACE . '});' . M3_NL;
4370 // ##### フロント画面のデフォルトのJavaスクリプト #####
4371 // if (!$gEnvManager->isAdminDirAccess()){
4372 // $this->initScript .= str_repeat(M3_INDENT_SPACE, 1) . 'if (jQuery().tooltip) $(\'[rel=tooltip]\').tooltip();' . M3_NL; // 標準ツールチップ作成
4374 // ポップアップメッセージがある場合は表示
4375 if (!empty($this->popupMsg)){
4376 $replaceStr .= 'alert("' . $this->popupMsg . '");' . M3_NL;
4379 if ($cleanType == 1){
4380 // HTMLのクリーン処理が必要なときはコードを埋め込む
4381 $this->initScript .= ' $(\'.PostHeaderIcons\').remove();' . M3_NL;// 不要なアイコン表示タグの削除
4382 $this->initScript .= ' $(\'.PostMetadataHeader\').each(function(i){' . M3_NL;
4383 $this->initScript .= ' if ($(this).text().trim() == \'\') $(this).remove();' . M3_NL;
4384 $this->initScript .= ' });' . M3_NL;
4388 $replaceStr .= $this->getLastContents();
4391 if (!empty($this->initScript)){
4392 $replaceStr .= '$(function(){' . M3_NL;
4393 $replaceStr .= $this->initScript;
4394 $replaceStr .= '});' . M3_NL;
4397 //$replaceStr .= '// -->' . M3_NL;
4398 //$replaceStr .= '</script>' . M3_NL;
4399 $replaceStr .= '//]]>' . M3_NL;
4400 $replaceStr .= '</script>' . M3_NL;
4402 // HEADタグに埋め込むCSS,JavaScript,任意文字列
4403 if (count($this->headCss) > 0){
4404 // CSSの場合は全体をstyleタグで囲む
4405 $replaceStr .= '<style type="text/css">' . M3_NL;
4406 $replaceStr .= '<!--' . M3_NL;
4407 for ($i = 0; $i < count($this->headCss); $i++){
4408 $replaceStr .= $this->headCss[$i];
4410 $replaceStr .= M3_NL . '//-->' . M3_NL;
4411 $replaceStr .= '</style>' . M3_NL;
4413 if (count($this->headScript) > 0){
4414 // JavaScriptの場合は全体をscriptタグで囲む
4415 //$replaceStr .= '<script type="text/javascript">' . M3_NL;
4416 //$replaceStr .= '<!--' . M3_NL;
4417 $replaceStr .= '<script type="text/javascript">' . M3_NL;
4418 $replaceStr .= '//<![CDATA[' . M3_NL;
4419 for ($i = 0; $i < count($this->headScript); $i++){
4420 $replaceStr .= $this->headScript[$i];
4422 //$replaceStr .= M3_NL . '//-->' . M3_NL;
4423 //$replaceStr .= '</script>' . M3_NL;
4424 $replaceStr .= M3_NL;
4425 $replaceStr .= '//]]>' . M3_NL;
4426 $replaceStr .= '</script>' . M3_NL;
4428 if (count($this->headString) > 0){
4430 for ($i = 0; $i < count($this->headString); $i++){
4431 $replaceStr .= $this->headString[$i];
4439 * @param string $position HTMLテンプレート上の書き出し位置
4440 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
4441 * @param int $templateVer テンプレートバージョン(0=デフォルト(Joomla!v1.0)、-1=携帯用、1=Joomla!v1.5、2=Joomla!v2.5)
4442 * @param array $attr その他属性
4443 * @return string 出力コンテンツ
4445 function getContents($position, $style = '', $templateVer = 0, $attr = array())
4447 static $render; // HTML生成オブジェクト
4448 global $gRequestManager;
4449 global $gEnvManager;
4452 $filename = $gEnvManager->getCurrentPageId();
4453 $subId = $gEnvManager->getCurrentPageSubId();
4454 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
4456 // ポジション名表示モードに応じて出力を作成
4457 $contents = ''; // 出力コンテンツ
4458 switch ($this->showPositionMode){
4460 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4461 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4462 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
4463 if ($ret){ // 1行以上データが取得できたとき
4464 $this->pageDefRows = $rows; // ページ定義レコード
4465 $this->pageDefPosition = $position;
4467 $this->pageDefRows = array();
4468 $this->pageDefPosition = '';
4472 $count = count($this->pageDefRows);
4474 if ($templateVer == 0){ // ########## Joomla!v1.0テンプレートの場合 ##########
4475 ob_start();// バッファ作成
4477 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4478 $widgetHeaderType = $this->getTemplateWidgetHeaderType();
4479 for ($i = 0; $i < $count; $i++){
4480 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4481 $widgetId = $this->pageDefRows[$i]['wd_id'];
4483 // ### 遅延実行ウィジェットはキャッシュしない ###
4484 // キャッシュデータがあるときはキャッシュデータを使用
4485 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4487 if (empty($cacheData)){ // キャッシュデータがないとき
4489 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $launchWidgetTag, $titleTag, $widgetHeaderType);
4491 $widgetContent = ob_get_contents();
4494 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4496 // ウィジェットの内枠(コンテンツ外枠)を設定
4497 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4500 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4501 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4504 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4505 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4506 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4507 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4508 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4509 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4510 // ウィジェット表示タイプによる表示制御
4511 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4512 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
4513 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4514 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4515 if (!empty($controlType)){
4516 switch ($controlType){
4517 case 1: // ログイン時のみ表示
4518 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4519 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
4521 case 2: // 非ログイン時のみ表示
4522 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4523 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
4529 if (!empty($pageState)){
4530 switch ($pageState){
4532 if (!$this->isPageTopUrl){
4533 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4534 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
4542 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4543 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4544 $hasAdmin = '0'; // 管理画面があるかどうか
4545 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4546 $shared = '0'; // 共通属性があるかどうか
4547 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4548 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4549 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4550 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
4552 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4553 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4555 } else { // キャッシュデータがあるとき
4556 $widgetContent = $cacheData;
4559 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4560 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4561 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4563 $contents .= $widgetContent;
4565 // ##### 外部出力用のCSSがある場合は追加 #####
4566 $exportCss = $this->pageDefRows[$i]['pd_css'];
4567 if (!empty($exportCss)){
4569 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4570 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4571 $this->addExportCss($exportCss);
4574 ob_end_clean(); // バッファ破棄
4576 if ($i < $count) return '';// 処理中断のときは終了
4577 } else if ($templateVer == 100){ // ########## WordPressテンプレートの場合 ##########
4578 ob_start();// バッファ作成
4580 // ウィジェットヘッダ(Joomla!1.0用)を出力するテンプレートかどうかチェック
4581 //$widgetHeaderType = $this->getTemplateWidgetHeaderType();
4582 for ($i = 0; $i < $count; $i++){
4583 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4584 $widgetId = $this->pageDefRows[$i]['wd_id'];
4586 // ### 遅延実行ウィジェットはキャッシュしない ###
4587 // キャッシュデータがあるときはキャッシュデータを使用
4588 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4590 if (empty($cacheData)){ // キャッシュデータがないとき
4591 // WordPressウィジェット用のパラメータ設定
4592 $gEnvManager->setWpWidgetClass(''); // ウィジェットクラス名初期化
4595 // $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $launchWidgetTag, $titleTag, $widgetHeaderType);
4596 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $launchWidgetTag, $titleTag, 0/*タイトル出力なし*/);
4598 $widgetContent = ob_get_contents();
4600 // WordPressウィジェット用のパラメータ設定
4601 $widgetClassName = $gEnvManager->getWpWidgetClass(); // ウィジェットクラス名
4603 $trimContent = trim($widgetContent);
4604 if (!empty($trimContent)){ // 出力が空でない場合
4607 if (!isset($render)) $render = new WPRender(); // WordPress用HTML生成オブジェクト
4609 // デフォルトのウィジェットタイトル取得
4610 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4613 //$joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4615 // 遅延ウィジェットのときはタイトルタグを埋め込む
4616 if (!empty($titleTag)) $defaultTitle = $titleTag;
4618 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4619 $title = $this->pageDefRows[$i]['pd_title'];
4620 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4621 if (empty($title)) $title = $defaultTitle;
4623 $title = ''; // タイトルは非表示
4626 // 強制的にタイトルを非表示にする場合はタイトルを修正
4627 if (!empty($title) && $this->pageDefRows[$i]['wd_hide_title']){
4628 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4629 $title = '[' . $title . ']';
4635 // WordPress用パラメータ作成
4636 $params = array(); // ウィジェットごとの属性
4637 if (!empty($widgetClassName)) $params['moduleclass'] = $widgetClassName; // ウィジェットクラス名
4640 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . ($i + 1); // ウィジェット識別用ユニークタグ
4642 if (strcmp($position, 'main') == 0){// メイン部のとき
4643 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
4645 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer, $widgetTag);
4649 // $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4651 // ウィジェットの内枠(コンテンツ外枠)を設定
4652 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4656 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4657 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4660 // $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4661 // $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4662 // if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4663 // $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4664 // $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4666 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4667 // ウィジェット表示タイプによる表示制御
4668 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4669 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
4670 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4671 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4672 if (!empty($controlType)){
4673 switch ($controlType){
4674 case 1: // ログイン時のみ表示
4675 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4676 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
4678 case 2: // 非ログイン時のみ表示
4679 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4680 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
4686 if (!empty($pageState)){
4687 switch ($pageState){
4689 if (!$this->isPageTopUrl){
4690 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4691 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
4699 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4700 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4701 $hasAdmin = '0'; // 管理画面があるかどうか
4702 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4703 $shared = '0'; // 共通属性があるかどうか
4704 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4705 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4706 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4707 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
4709 // $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4710 // $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4712 } else { // キャッシュデータがあるとき
4713 $widgetContent = $cacheData;
4716 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4717 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4718 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4720 $contents .= $widgetContent;
4722 // ##### 外部出力用のCSSがある場合は追加 #####
4723 $exportCss = $this->pageDefRows[$i]['pd_css'];
4724 if (!empty($exportCss)){
4726 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4727 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4728 $this->addExportCss($exportCss);
4731 ob_end_clean(); // バッファ破棄
4733 if ($i < $count) return '';// 処理中断のときは終了
4734 } else { // ########## Joomla!v1.5テンプレートの場合 ##########
4735 // テンプレート側で指定されたメニューの表示属性を設定
4736 $gEnvManager->setMenuAttr($attr);
4740 if (!empty($attr['type'])) $posType = $attr['type'];
4742 for ($i = 0; $i < $count; $i++){
4743 $pageDefParam = $this->pageDefRows[$i]; // 画面定義パラメータ
4744 $widgetId = $this->pageDefRows[$i]['wd_id'];
4746 // ### 遅延実行ウィジェットはキャッシュしない ###
4747 // キャッシュデータがあるときはキャッシュデータを使用
4748 $cacheData = $this->gCache->getWidgetCache($request, $this->pageDefRows[$i], $metaTitle, $metaDesc, $metaKeyword);
4750 if (empty($cacheData)){ // キャッシュデータがないとき
4752 $gEnvManager->setCurrentWidgetTitle('');
4754 // Joomla用のパラメータを初期化
4755 $gEnvManager->setCurrentWidgetJoomlaParam(array());
4759 $ret = $this->pageDefLoop($position, $i, $this->pageDefRows[$i], $style, $launchWidgetTag, $titleTag, 0/*タイトル出力なし*/);
4760 $widgetContent = ob_get_contents();
4762 $trimContent = trim($widgetContent);
4763 if (!empty($trimContent)){ // 出力が空でない場合
4764 $isRendered = false; // Joomla!の描画処理を行ったかどうか
4765 if (!empty($this->pageDefRows[$i]['pd_use_render'])){ // Joomla!の描画処理を使用する場合
4766 // Joomla!ウィジェットの出力に埋め込む
4767 if (strcasecmp($style, 'none') != 0){
4769 if (!isset($render)) $render = new JRender();
4771 // デフォルトのウィジェットタイトル取得
4772 $defaultTitle = $gEnvManager->getCurrentWidgetTitle();
4775 $joomlaParam = $gEnvManager->getCurrentWidgetJoomlaParam();
4777 // 遅延ウィジェットのときはタイトルタグを埋め込む
4778 if (!empty($titleTag)) $defaultTitle = $titleTag;
4780 // タイトルが空でタイトル表示を行う場合は、デフォルトタイトルを使用
4781 $title = $this->pageDefRows[$i]['pd_title'];
4782 if ($this->pageDefRows[$i]['pd_title_visible']){ // タイトル表示のとき
4783 if (empty($title)) $title = $defaultTitle;
4785 $title = ''; // タイトルは非表示
4788 // 強制的にタイトルを非表示にする場合はタイトルを修正
4789 if (!empty($title) && $this->pageDefRows[$i]['wd_hide_title']){
4790 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4791 $title = '[' . $title . ']';
4798 $params = array(); // ウィジェットごとの属性
4799 $widgetType = $this->pageDefRows[$i]['wd_type']; // ウィジェットタイプ
4801 // オプションのJoomlaクラス(縦型メニュー(art-vmenu)等)
4802 $joomlaClass = $this->pageDefRows[$i]['wd_joomla_class']; // 「wd_joomla_class」は使っていない?
4803 if (!empty($joomlaClass)) $params['moduleclass_sfx'] = $joomlaClass;
4804 if (isset($joomlaParam['moduleclass_sfx'])) $params['moduleclass_sfx'] = $joomlaParam['moduleclass_sfx'];// ウィジェットでjoomla用パラメータの設定があるとき
4806 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
4807 $moduleContent = '';
4809 // ウィジェットタイプがメニューのときはナビゲーションメニューを生成
4810 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4812 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
4813 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4814 $widgetContent = $moduleContent;
4816 // ウィジェットタイプに応じた処理を実行
4817 if ($widgetType == 'breadcrumb'){ // パンくずリスト
4818 $moduleContent = '';
4820 if (empty($launchWidgetTag)){ // 遅延実行の場合はここでパンくずリストを作成しないで遅延実行時に行う
4821 $moduleContent = $render->getBreadcrumbContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4823 $moduleContent = $launchWidgetTag; // 遅延実行ウィジェットのタグのみ取得
4826 // パンくずリストで作成できないときはデフォルトの出力を取得
4827 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4828 $widgetContent = $moduleContent;
4830 if (strcmp($position, 'main') == 0){// メイン部のとき
4831 // ウィジェットの内枠(コンテンツ外枠)を設定
4832 // ウィジェットの内枠はレンダーで設定
4833 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4834 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4835 } else { // その他の位置のとき
4836 // ウィジェットの内枠(コンテンツ外枠)を設定
4837 // ウィジェットの内枠はレンダーで設定
4838 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4840 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4844 /* if (strcmp($position, 'main') == 0){// メイン部のとき
4845 // ウィジェットの内枠(コンテンツ外枠)を設定
4846 // ウィジェットの内枠はレンダーで設定
4847 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4848 $widgetContent = $render->getComponentContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4849 // } else if (strStartsWith($position, 'user') || // ナビゲーションメニュー位置の場合
4850 } else if (strcasecmp($position, 'user3') == 0 || // ナビゲーションメニュー位置の場合
4851 strcasecmp($position, 'position-1') == 0 || // Joomla!v2.5テンプレート対応
4852 strcasecmp($posType, 'hmenu') == 0){ // Joomla!v3テンプレート対応
4854 $moduleContent = '';
4855 if ($style == self::WIDGET_STYLE_NAVMENU){ // ナビゲーションバーメニューはメニュータイプのウィジェットのみ実行
4856 if ($widgetType == 'menu') $moduleContent = $render->getNavMenuContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4858 // ナビゲーションバータイプで作成できないときはデフォルトの出力を取得
4859 if (empty($moduleContent)) $moduleContent = $render->getModuleContents('xhtml', $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4861 $moduleContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4863 $widgetContent = $moduleContent;
4865 // ウィジェットの内枠(コンテンツ外枠)を設定。メニュー処理後に付加。
4866 // ウィジェットの内枠はレンダーで設定
4867 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4868 } else { // その他の位置のとき
4869 // ウィジェットの内枠(コンテンツ外枠)を設定
4870 // ウィジェットの内枠はレンダーで設定
4871 //$widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4873 $widgetContent = $render->getModuleContents($style, $widgetContent, $title, $attr, $params, $pageDefParam, $templateVer);
4875 $isRendered = true; // Joomla!の描画処理を行ったかどうか
4878 if (!$isRendered){ // Joomla!の描画処理を行っていない場合
4880 $widgetContent = $this->_addOptionContent($widgetContent, $pageDefParam);
4882 // ウィジェットの内枠(コンテンツ外枠)を設定
4883 // $widgetContent = '<div class="' . self::WIDGET_INNER_CLASS . '">' . $widgetContent . '</div>';
4886 if (!$ret) return ''; // 処理中断のときは終了
4889 $this->gCache->setWidgetCache($gRequestManager, $this->pageDefRows[$i], $widgetContent,
4890 $this->lastHeadTitle, $this->lastHeadDescription, $this->lastHeadKeywords);
4893 $widgetClassSuffix = $this->pageDefRows[$i]['pd_suffix']; // 追加CSSクラスサフィックス
4894 $widgetOuterClass = self::WIDGET_OUTER_CLASS . ' ' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . str_replace('/', '_', $widgetId);// ウィジェットの外枠のクラス
4895 if (!empty($widgetClassSuffix)) $widgetOuterClass .= ' ' . $widgetOuterClass . '_' . $widgetClassSuffix; // 追加CSSクラス
4896 $widgetOuterClass .= ' ' . self::WIDGET_OUTER_CLASS_HEAD_POSITION . $position; // ポジションブロッククラス
4897 $widgetContent = '<div class="' . $widgetOuterClass . '">' . $widgetContent . '</div>';
4898 if ($this->isPageEditable){ // フロント画面ページ編集可能モードのとき
4899 // ウィジェット表示タイプによる表示制御
4900 $widgetStatusClass = '';// ウィジェットの状態表示クラス
4901 $widgetStatusLabelOption = ''; // ウィジェット状態表示ラベル
4902 $controlType = $this->pageDefRows[$i]['pd_view_control_type'];
4903 $pageState = $this->pageDefRows[$i]['pd_view_page_state'];
4904 if (!empty($controlType)){
4905 switch ($controlType){
4906 case 1: // ログイン時のみ表示
4907 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4908 $widgetStatusLabelOption .= ' data-bg-text="ログイン時のみ表示"';
4910 case 2: // 非ログイン時のみ表示
4911 $widgetStatusClass .= ' ' . self::WIDGET_LOGIN_STATUS_CLASS;
4912 $widgetStatusLabelOption .= ' data-bg-text="非ログイン時のみ表示"';
4918 if (!empty($pageState)){
4919 switch ($pageState){
4921 if (!$this->isPageTopUrl){
4922 $widgetStatusClass .= ' ' . self::WIDGET_INVISIBLE_CLASS; // ページトップ(サブページ内のトップ位置)でなければ非表示
4923 $widgetStatusLabelOption .= ' data-bg-text="非表示中"';
4931 //$editInfo = 'widgetid:' . $this->pageDefRows[$i]['wd_id'];
4932 $configId = $this->pageDefRows[$i]['pd_config_id']; // 定義ID
4933 $serial = $this->pageDefRows[$i]['pd_serial']; // シリアル番号
4934 $hasAdmin = '0'; // 管理画面があるかどうか
4935 if ($this->pageDefRows[$i]['wd_has_admin']) $hasAdmin = '1';
4936 $shared = '0'; // 共通属性があるかどうか
4937 if (empty($this->pageDefRows[$i]['pd_sub_id'])) $shared = '1'; // 共通ウィジェットのとき
4938 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
4939 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4940 $widgetContent = '<div id="' . $widgetTag . '" class="m3_widget' . $widgetStatusClass . '" rel="#m3editwidget" ' . $m3Option . $widgetStatusLabelOption . '>' . $widgetContent . '</div>';
4942 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4943 $widgetContent = '<div id="' . $widgetTag . '">' . $widgetContent . '</div>';
4945 } else { // キャッシュデータがあるとき
4946 $widgetContent = $cacheData;
4949 if (!empty($metaTitle)) $this->setHeadSubTitle($metaTitle);
4950 if (!empty($metaDesc)) $this->setHeadDescription($metaDesc);
4951 if (!empty($metaKeyword)) $this->setHeadKeywords($metaKeyword);
4953 $contents .= $widgetContent;
4955 // ##### 外部出力用のCSSがある場合は追加 #####
4956 $exportCss = $this->pageDefRows[$i]['pd_css'];
4957 if (!empty($exportCss)){
4959 $widgetTag = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
4960 $exportCss = str_replace(M3_TAG_START . M3_TAG_MACRO_WIDGET_CSS_ID . M3_TAG_END, $widgetTag, $exportCss);
4961 $this->addExportCss($exportCss);
4966 if ($position == 'main'){ // メイン部のときは、メッセージを出力
4967 /*if (strlen($this->popupMsg) > 0){
4968 echo "\n<script language=\"javascript\">alert('" . addslashes($this->popupMsg) . "');</script>";
4970 } else if ($position == 'debug'){ // デバッグ文出力
4976 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:3px solid #f00;color:#700;">ポジション名: ';
4977 $contents .= '<b>' . $position . '</b>';
4978 $contents .= '</div>';
4981 if (!in_array($position, $this->defPositions)) $this->defPositions[] = $position; // テンプレート上のポジション
4983 case 2: // ポジション表示(ウィジェット付き)
4984 $rev = '555'; // データのリビジョン番号
4985 // ポジションのHTMLタグIDを作成
4988 for ($i = 0; $i < 100; $i++){
4989 $posId = $position . '_' . $num;
4990 $viewPosId = self::POSITION_TAG_HEAD . $posId;
4991 if (!in_array($viewPosId, $this->viewPosId)) break;
4994 $this->viewPosId[] = $viewPosId;// IDを保存
4996 // ページ定義を取得。同じポジションが続く場合は最初の一度だけ定義を取得
4997 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // ポジションが異なる場合
4998 $ret = $this->db->getPageDef($filename, $subId, $position, $rows);
4999 if ($ret){ // 1行以上データが取得できたとき
5000 $this->pageDefRows = $rows; // ページ定義レコード
5001 $this->pageDefPosition = $position;
5003 $this->pageDefRows = array();
5004 $this->pageDefPosition = '';
5008 // ナビゲーション型のポジションの場合はアイコン付加
5009 //if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5010 if ($style == self::WIDGET_STYLE_NAVMENU){
5011 $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加(ナビゲーションメニュー型)
5012 } else if (strcasecmp($position, 'main') == 0){
5013 $posHead = self::POS_HEAD_MAIN; // 特殊ポジションブロックのアイコン付加(メイン型)
5015 $contents .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5016 $contents .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
5019 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
5020 //$contents .= $this->getWidgetList($gEnvManager->getCurrentPageId(), $gEnvManager->getCurrentPageSubId(), $widgetTagHead, $this->pageDefRows);
5021 $contents .= $this->getWidgetList($filename, $subId, $widgetTagHead, $this->pageDefRows);
5023 $contents .= '</div>' . M3_NL;
5026 $contents .= '<div style="background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">param error</div>';
5030 $this->viewPositions[] = $position;
5035 * 各部品のHTML出力(WordPressテンプレート専用)
5037 * @param string $position HTMLテンプレート上の書き出し位置
5038 * @param bool $showTitle タイトルを表示するかどうか
5039 * @return string 出力コンテンツ
5041 function getWPContents($position, $showTitle = true)
5044 return $this->getContents($position, self::WIDGET_STYLE_WORDPRESS/*WordPressテンプレート用出力*/, 100/*WordPressテンプレート*/);
5046 return $this->getContents($position, self::WIDGET_STYLE_WORDPRESS_NOTITLE/*WordPressテンプレート(タイトルなし)用出力*/, 100/*WordPressテンプレート*/);
5050 * その他のポジションブロックデータを取得
5052 * @param string ポジション作成用タグ
5054 function getRestPositionData()
5056 global $gEnvManager;
5058 $restPositionData = '';
5060 $pageId = $gEnvManager->getCurrentPageId();
5061 $subId = $gEnvManager->getCurrentPageSubId();
5063 $restPositions = array_values(array_diff($this->defPositions/*全ポジション*/, $this->viewPositions/*表示済みポジション*/));
5064 $positionCount = count($restPositions);
5065 for ($i = 0; $i < $positionCount; $i++){
5066 $posHead = ''; // アイコン付加用
5067 $position = $restPositions[$i];
5068 $posId = $position . '_0';
5069 $viewPosId = self::POSITION_TAG_HEAD . $posId;
5072 $ret = $this->db->getPageDef($pageId, $subId, $position, $rows);
5074 //$pageDefRows = $rows; // ページ定義レコード
5076 $restPositionData .= '<div id="' . $viewPosId . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">'; // リビジョン番号を付加
5077 $restPositionData .= '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>';
5080 $widgetTagHead = self::WIDGET_TAG_HEAD . $posId;
5081 $contents = $this->getWidgetList($pageId, $subId, $widgetTagHead, $rows);
5082 $contents = str_replace(M3_NL, '', $contents);
5083 $contents = str_replace('\'', '\\\'', $contents);
5084 $restPositionData .= $contents;
5085 $restPositionData .= '</div>';
5087 $this->viewPosId[] = $viewPosId;// IDを保存
5090 return $restPositionData;
5093 * ウィジェット共通のコンテンツ追加処理
5095 * @param string $src ウィジェット出力
5096 * @param array $pageDefParam 画面定義レコード
5097 * @return string コンテンツを付加したウィジェット出力
5099 function _addOptionContent($src, $pageDefParam)
5102 $dest = $pageDefParam['pd_top_content'] . $src . $pageDefParam['pd_bottom_content'];
5105 if ($pageDefParam['pd_show_readmore']){
5106 $title = $pageDefParam['pd_readmore_title'];
5107 if (empty($title)) $title = self::DEFAULT_READMORE_TITLE;
5108 $dest .= '<div><a href="' . convertUrlToHtmlEntity($pageDefParam['pd_readmore_url']) . '">' . convertToHtmlEntity($title) . '</a></div>';
5113 * BODYタグに付加するスタイルを取得(管理画面用)
5115 * @param string CSS文字列
5117 function getBodyStyle()
5119 // 画面透過モードのときスタイルを追加
5121 if ($this->isTransparentMode) $transCss = ' style="background-color:transparent;"';
5127 * @param string $position HTMLテンプレート上の書き出し位置
5128 * @return int ウィジェットの数
5130 function getWidgetsCount($position)
5132 global $gRequestManager;
5133 global $gEnvManager;
5134 static $widgetCountArray = array();
5136 // 管理画面へのアクセスでログインされていないときは0を返す
5137 if ($gEnvManager->isAdminDirAccess() && !$gEnvManager->isSystemManageUser()){ // 管理画面へのアクセスのときでシステム運用権限がない場合
5142 $cmd = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
5143 if ($cmd == M3_REQUEST_CMD_SHOW_POSITION || // 管理画面(ウィジェットなしポジション表示)のとき
5144 $cmd == M3_REQUEST_CMD_SHOW_POSITION_WITH_WIDGET){ // 管理画面(ウィジェット付きポジション表示)のとき
5145 return 1; // ウィジェットが設定されていないポジション名を表示するために固定で値を返す
5148 // 単一ポジション以外の設定のときは固定で返す(or等)
5149 $pos = strpos($position, ' ');
5150 if ($pos !== false) return 1;
5152 // 既にウィジェット数が取得されている場合は保存値を返す
5153 $widgetCount = $widgetCountArray[$position];
5154 if (isset($widgetCount)) return $widgetCount;
5157 $filename = $gEnvManager->getCurrentPageId();
5158 $subId = $gEnvManager->getCurrentPageSubId();
5159 if (empty($subId)) $subId = $gEnvManager->getDefaultPageSubId();
5161 // 取得しようとするページ定義のポジションが既に取得しているポジションと異なるときはデータを取得
5162 if (empty($this->pageDefPosition) || $position != $this->pageDefPosition){ // 現在取得しているページ定義のポジション
5163 $ret = $this->db->getPageDef($filename, $subId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
5164 if ($ret){ // 1行以上データが取得できたとき
5165 $this->pageDefRows = $rows; // ページ定義レコード
5166 $this->pageDefPosition = $position;
5168 $this->pageDefRows = array();
5169 $this->pageDefPosition = '';
5172 // ### ウィジェット数を取得 ###
5173 // テンプレートのカラム制御を行うためにウィジェット表示条件でウィジェット数を取得
5175 $rowCount = count($this->pageDefRows);
5176 for ($i = 0; $i < $rowCount; $i++){
5177 // $condition = trim($this->pageDefRows[$i]['wd_visible_condition']);
5178 $condition = trim($this->pageDefRows[$i]['pd_visible_condition']);
5179 if (empty($condition)){ // ウィジェット表示条件が設定されていない場合はウィジェットを表示
5181 } else { // ウィジェット表示条件が設定されている場合はパラメータをチェック
5182 $conds = explode(';', $condition);
5183 for ($j = 0; $j < count($conds); $j++){
5184 $pos = strpos($conds[$j], '=');
5185 if ($pos !== false){ // URLクエリーパラメータ条件がマッチした場合はウィジェットを表示
5186 list($key, $value) = explode('=', trim($conds[$j]));
5188 $value = trim($value);
5189 if (!empty($key) && !empty($value)){
5190 $requestValue = $gRequestManager->trimValueOf($key);
5191 if ($value == $requestValue) $widgetCount++;
5197 // $widgetCount = count($this->pageDefRows);
5198 $widgetCountArray[$position] = $widgetCount;
5199 return $widgetCount;
5202 * ウィジェットのページ定義シリアル番号からウィジェットCSS IDを取得
5204 * @param int $defSerial ページ定義シリアル番号
5205 * @param string $pageId ページID
5206 * @param string $subpage ページサブID
5207 * @param string $position 表示位置ID
5208 * @return string CSSエレメントID
5210 function getWidgetCssId($defSerial, $pageId, $pageSubId, $position)
5213 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows, 0/*定義セットIdデフォルト*/, true/*表示ウィジェットのみ*/);
5215 $rowCount = count($rows);
5216 for ($i = 0; $i < $rowCount; $i++){
5218 if ($row['pd_serial'] == $defSerial){
5219 $elementId = self::WIDGET_TAG_HEAD . $position . '_' . $i; // ウィジェット識別用ユニークタグ
5229 * 画面作成機能でウィジェット情報を取得するためのAjaxインターフェイス
5231 * @param RequestManager $request HTTPリクエスト処理クラス
5233 function getWidgetInfoByAjax($request)
5235 global $gEnvManager;
5236 global $gDesignManager;
5237 global $gCacheManager;
5239 // アクセスするページIDからPC用、携帯用、スマートフォン用かを判断
5240 $widgetDeviceType = 0; // 端末タイプをPC用に初期化
5241 $pageId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
5242 $pageSubId = $request->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_SUB_ID);
5243 $mobilePageIdPrefix = M3_DIR_NAME_MOBILE . '_';
5244 $smartphonePageIdPrefix = M3_DIR_NAME_SMARTPHONE . '_';
5245 if (strncmp($pageId, $mobilePageIdPrefix, strlen($mobilePageIdPrefix)) == 0){
5246 $widgetDeviceType = 1; // 携帯用
5247 } else if (strncmp($pageId, $smartphonePageIdPrefix, strlen($smartphonePageIdPrefix)) == 0){
5248 $widgetDeviceType = 2; // スマートフォン用
5251 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
5252 if ($task == 'list'){
5254 $ret = $this->db->getAvailableWidgetList($widgetDeviceType, $rows);
5256 $currentCategoryId = '_none'; // 現在のウィジェットカテゴリー初期化
5257 for ($i = 0; $i < count($rows); $i++){
5258 $widgetId = $rows[$i]['wd_id'];
5259 $desc = $rows[$i]['wd_description'];
5260 $widgetTag = self::WIDGET_TYPE_TAG_HEAD . $widgetId;
5261 // $categoryId = $rows[$i]['wd_category_id'];
5262 $categoryId = $rows[$i]['pid']; // 親カテゴリーID
5265 if ($categoryId != $currentCategoryId){
5267 echo '</dd>' . M3_NL;
5268 echo '</dl>' . M3_NL;
5270 echo '<dl class="m3accordion">' . M3_NL;
5271 // echo '<dt>' . $rows[$i]['wt_name'] . '</dt>' . M3_NL;
5272 echo '<dt>' . $rows[$i]['pname'] . '</dt>' . M3_NL; // 親カテゴリー名
5273 echo '<dd>' . M3_NL;
5276 $currentCategoryId = $categoryId;
5279 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
5280 if ($gEnvManager->getUseSslAdmin()){
5281 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
5282 $image = $gEnvManager->getSslUrl($image);
5284 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
5285 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
5286 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
5291 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5292 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5296 if (!empty($rows[$i]['wd_template_type'])){ // 対応テンプレートタイプ
5297 $templateTypeArray = explode(',', $rows[$i]['wd_template_type']);
5298 if (in_array('bootstrap', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_BOOTSTRAP; // Bootstrap型テンプレート対応
5299 if (in_array('wordpress', $templateTypeArray)) $functionMark .= self::WIDGET_FUNCTION_MARK_WORDPRESS; // WordPress型テンプレート対応
5301 if (!empty($functionMark)) $functionMark = '<hr />' . $functionMark;
5303 echo '<dl class="m3_widgetlist_item" id="' . $widgetTag . '">' . M3_NL;
5304 echo '<dt>' . $widgetMark . $rows[$i]['wd_name'] . '</dt>' . M3_NL; // ウィジェット名
5305 echo '<dd><table style="width:100%;"><tr style="vertical-align:top;"><td style="width:35px;">' . $imageTag . '</td><td>' . $desc . '</td></tr></table>';
5306 echo $functionMark . '</dd>' . M3_NL;
5307 echo '</dl>' . M3_NL;
5310 if ($i == count($rows) - 1){
5311 echo '</dd>' . M3_NL;
5312 echo '</dl>' . M3_NL;
5316 } else if ($task == 'wget' || $task == 'wdelete' || $task == 'wtoggle' || $task == 'wadd' || $task == 'wmove'){ // ウィジェット再取得、ウィジェット削除,ウィジェット共通属性変更、ウィジェット追加、ウィジェット移動のとき
5317 $rev = $request->trimValueOf('rev'); // リビジョン
5318 $serial = $request->trimValueOf('serial');
5319 $position = $request->trimValueOf('pos');
5320 $widgetsStr = $request->trimValueOf('widgets');
5321 if (empty($widgetsStr)){
5324 $widgets = explode(',', $widgetsStr);
5326 $shared = $request->trimValueOf('shared');
5327 $updatepos = explode(',', $request->trimValueOf('updatepos'));
5328 $index = $request->trimValueOf('index');
5331 if ($task == 'wmove'){
5332 $positions = explode(',', $position);
5333 if (count($positions) >= 2){
5334 $position = $positions[0];
5335 $position2 = $positions[1];
5337 $position = $positions[0];
5341 // ##### エラーチェック #####
5344 $rev = '111'; // データのリビジョン番号
5347 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows); // 0レコードでも正常とする
5349 // 変更前のウィジェットのシリアル番号をチェック
5350 if (count($widgets) == count($rows)){
5351 if (!($task == 'wmove' && empty($position2))){ // 同一ブロック内の移動の場合はチェックなし
5352 for ($i = 0; $i < count($rows); $i++){
5353 if ($widgets[$i] != $rows[$i]['pd_serial']){// シリアル番号
5364 if (!$isErr){ // エラーなしのとき
5365 if ($task == 'wdelete'){
5366 $ret = $this->db->deleteWidget($serial);
5367 } else if ($task == 'wtoggle'){
5369 if (empty($shared)) $newShared = 1;
5370 $ret = $this->db->toggleSharedWidget($pageId, $pageSubId, $serial, $newShared);
5371 } else if ($task == 'wadd'){ // ウィジェットの追加
5372 $widget = $request->trimValueOf('widget');
5375 if (empty($widget)) $isErr = true;
5378 if (!$isErr) $this->db->addWidget($pageId, $pageSubId, $position, $widget, $index);
5379 } else if ($task == 'wmove'){
5381 if (!$isErr) $this->db->moveWidget($pageId, $pageSubId, $position, $serial, $index);
5385 $ret = $this->db->getPageDef($pageId, $pageSubId, $position, $rows);// 0レコードでも正常とする
5387 // 移動のときは、移動元と移動先の再表示データを取得
5388 if ($task == 'wmove' && !empty($position2)){
5389 $ret = $this->db->getPageDef($pageId, $pageSubId, $position2, $rows2);// 0レコードでも正常とする
5392 // ##### 該当するページのテンプレートタイプを取得 #####
5394 $templateGenerator = '';
5396 // ページ用個別に設定されたテンプレートがある場合は取得
5398 $line = $this->getPageInfo($pageId, $pageSubId);
5399 if (!empty($line)) $curTemplate = $line['pn_template_id'];
5402 if (empty($curTemplate)){
5403 if ($pageId == $this->gEnv->getDefaultPageId()){ // 通常サイトのとき
5404 $curTemplate = $this->gSystem->defaultTemplateId();
5405 } else if ($pageId == $this->gEnv->getDefaultSmartphonePageId()){ // スマートフォン用サイトのとき
5406 $curTemplate = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
5411 $ret = $this->db->getTemplate($curTemplate, $row);
5413 $templateType = $row['tm_type'];
5414 $templateGenerator = $row['tm_generator'];
5419 echo '<div>' . M3_NL;
5420 for ($i = 0; $i < count($updatepos); $i++){
5422 $widgetTagHead = str_replace(self::POSITION_TAG_HEAD, self::WIDGET_TAG_HEAD, $updatepos[$i]);
5425 $posName = str_replace(self::POSITION_TAG_HEAD, '', substr($updatepos[$i], 0, strlen($updatepos[$i]) - strlen(strrchr($updatepos[$i], "_"))));
5426 if ($task == 'wmove' && $posName == $position2){
5427 // Themlerテンプレート場合は配置ポジション名が「hmenu」をナビゲーション型とする
5429 if ($templateGenerator == 'themler'){
5430 if (strcasecmp($position2, 'hmenu') == 0){ // Joomla!v3テンプレート対応
5431 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
5434 if (strcasecmp($position2, 'user3') == 0 || // ナビゲーションメニュー位置の場合
5435 strcasecmp($position2, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
5436 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
5442 if ($style == self::WIDGET_STYLE_NAVMENU){
5443 $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加(ナビゲーションメニュー型)
5444 } else if (strcasecmp($position2, 'main') == 0){
5445 $posHead = self::POS_HEAD_MAIN; // 特殊ポジションブロックのアイコン付加(メイン型)
5447 //if (strcasecmp($position2, 'user3') == 0 || strcasecmp($position2, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5448 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position2 . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5449 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position2 . '</h2>' . M3_NL;
5452 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows2);
5454 // Themlerテンプレート場合は配置ポジション名が「hmenu」をナビゲーション型とする
5456 if ($templateGenerator == 'themler'){
5457 if (strcasecmp($position, 'hmenu') == 0){ // Joomla!v3テンプレート対応
5458 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
5461 if (strcasecmp($position, 'user3') == 0 || // ナビゲーションメニュー位置の場合
5462 strcasecmp($position, 'position-1') == 0){ // Joomla!v2.5テンプレート対応
5463 $style = self::WIDGET_STYLE_NAVMENU; // デフォルトはナビゲーション型
5469 if ($style == self::WIDGET_STYLE_NAVMENU){
5470 $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加(ナビゲーションメニュー型)
5471 } else if (strcasecmp($position, 'main') == 0){
5472 $posHead = self::POS_HEAD_MAIN; // 特殊ポジションブロックのアイコン付加(メイン型)
5474 //if (strcasecmp($position, 'user3') == 0 || strcasecmp($position, 'position-1') == 0) $posHead = self::POS_HEAD_NAV_MENU; // 特殊ポジションブロックのアイコン付加
5475 echo '<div id="' . $updatepos[$i] . '" class="m3_widgetpos_box" m3="pos:' . $position . ';rev:' . $rev . ';">' . M3_NL; // リビジョン番号を付加
5476 echo '<h2 class="m3_widgetpos_box_title">' . $posHead . $position . '</h2>' . M3_NL;
5479 echo $this->getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows);
5482 echo '</div>' . M3_NL;
5484 echo '</div>' . M3_NL;
5487 $gCacheManager->clearAllCache();
5491 * 画面作成用ウィジェット一覧データ出力
5493 * @param string $pageId ページID
5494 * @param string $pageSubId ページサブID
5495 * @param string $widgetTagHead HTMLウィジェットID用のヘッダ
5496 * @param array $rows ウィジェット一覧データ
5497 * @return string ウィジェット一覧出力
5499 function getWidgetList($pageId, $pageSubId, $widgetTagHead, $rows)
5501 global $gEnvManager;
5502 global $gDesignManager;
5503 global $gSystemManager;
5505 if ($gEnvManager->getUseSslAdmin()){
5506 $rootUrl = $gEnvManager->getSslRootUrl();
5508 $rootUrl = $gEnvManager->getRootUrl();
5512 $line = $this->getPageInfo($pageId, $pageSubId);
5513 if (!empty($line)) $pageContentType = $line['pn_content_type'];
5515 $contents = ''; // ウィジェット一覧出力コンテンツ
5516 for ($i = 0; $i < count($rows); $i++){
5517 $widgetId = $rows[$i]['wd_id'];
5518 $desc = $rows[$i]['wd_description'];
5519 $widgetIndex = $rows[$i]['pd_index']; // 表示順
5520 $configId = $rows[$i]['pd_config_id']; // 定義ID
5521 $serial = $rows[$i]['pd_serial']; // シリアル番号
5522 $isShared = empty($rows[$i]['pd_sub_id']); // グローバル属性が設定されているかどうか
5523 $widgetTag = $widgetTagHead . '_' . $i; // ウィジェット識別用ユニークタグ
5524 $image = $gDesignManager->getWidgetIconUrl($widgetId, self::WIDGET_ICON_IMG_SIZE);
5525 if ($gEnvManager->getUseSslAdmin()){
5526 //$image = str_replace('http://', 'https://', $image); // SSL通信の場合はSSL用に変換
5527 $image = $gEnvManager->getSslUrl($image);
5529 $imageTag = '<img class="' . self::WIDTET_CLASS_NAME . '" src="' . $image . '" ';
5530 $imageTag .= 'width="' . self::WIDGET_ICON_IMG_SIZE . '"';
5531 $imageTag .= ' height="' . self::WIDGET_ICON_IMG_SIZE . '"';
5534 if (empty($rows[$i]['pd_config_name'])){
5535 if ($rows[$i]['wd_use_instance_def'] && $configId == 0){ // インスタンス定義が必要で未定義のとき
5536 $configName = '<span style="color:red;">[未設定]</span>';
5541 $configName = '[' . $rows[$i]['pd_config_name'] . ']';
5543 $hasAdmin = '0'; // 管理画面があるかどうか
5544 $configImg = ''; // 設定アイコンの表示
5546 // ウィジェットの配置位置に問題があるかどうかを表示
5547 // メインコンテンツとページ属性が一致するかどうかチェック
5548 $widgetContentType = $rows[$i]['wd_content_type'];
5549 //if (!empty($widgetContentType) && $widgetContentType != $pageContentType &&
5550 if (!empty($widgetContentType) && $widgetContentType != $pageContentType && empty($rows[$i]['wd_content_widget_id']) && // 編集用のウィジェットが別にある場合は除く(2015/3/24))
5551 (in_array($widgetContentType, $this->_getAllContentType()) || in_array($widgetContentType, $this->_getAllFeatureType()))){
5552 //$title = 'ウィジェット配置注意';
5553 $title = 'ページ属性と不一致';
5554 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::NOTICE_ICON_FILE . '" alt="' . $title . '" /></span> ';
5556 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type']) && $isShared){ // メイン型ウィジェットがグローバル属性を持つとき
5557 $title = 'メイン型ウィジェットはグローバル属性を設定できません';
5558 $configImg .= '<span rel="m3help" data-container="body" title="' . $title . '"><img src="' . $rootUrl . self::ALERT_ICON_FILE . '" alt="' . $title . '" /></span> ';
5560 if ($rows[$i]['wd_has_admin']){
5562 $title = 'ウィジェット設定';
5563 $configImg .= '<a href="javascript:void(0);" onclick="m3ShowConfigWindow(\'' . $widgetId . '\', \'' . $configId . '\', \'' . $serial . '\');return false;" rel="m3help" data-container="body" title="' . $title . '">' .
5564 '<img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" alt="' . $title . '"/></a> ';
5567 $configImg .= '<span rel="m3help" data-container="body" title="表示順">' . $widgetIndex . '</span>';
5569 $shared = '0'; // 共通属性があるかどうか
5570 $sharedClassName = '';
5571 //if (empty($rows[$i]['pd_sub_id'])){
5572 if ($isShared){ // グローバル属性ウィジェットのとき
5574 $sharedClassName = 'm3_widget_shared'; // 共通ウィジェットのクラス
5576 $m3Option = 'm3="widgetid:' . $widgetId . '; serial:' . $serial . '; configid:' . $configId . '; useconfig:' . $hasAdmin . '; shared:' . $shared . '"';
5580 if ($rows[$i]['wd_edit_content'] && !empty($rows[$i]['wd_type'])) $widgetMark = self::WIDGET_MARK_MAIN; // メイン型ウィジェット
5581 if ($rows[$i]['wd_type'] == 'menu' && $rows[$i]['wd_type_option'] == 'nav') $widgetMark = self::WIDGET_MARK_NAVMENU; // ナビゲーションメニュー
5584 $dropdownMenuId = $widgetTag . '_dropdown';
5585 $operationMenu = '<div class="m3widgetdropdown">';
5586 // $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#"><i class="glyphicon glyphicon-list-alt"></i> <b class="caret"></b></a>';
5587 $operationMenu .= '<a class="m3widgetdropdownbutton" data-dropdown="#' . $dropdownMenuId . '" href="#" data-horizontal-offset="4"><b class="caret"></b></a>';
5588 $operationMenu .= '<div id="' . $dropdownMenuId . '" class="m3dropdown m3dropdown-tip m3dropdown-relative m3dropdown-anchor-right">';
5589 $operationMenu .= '<ul class="m3dropdown-menu">';
5590 if ($hasAdmin) $operationMenu .= '<li class="m3_wconfig"><a href="#"><img src="' . $rootUrl . self::CONFIG_ICON_FILE . '" /> <span>ウィジェットの設定</span></a></li>';
5591 $operationMenu .= '<li class="m3_wadjust"><a href="#"><img src="' . $rootUrl . self::ADJUST_ICON_FILE . '" /> <span>タイトル・スタイル調整</span></a></li>';
5593 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を解除</span></a></li>';
5595 $operationMenu .= '<li class="m3_wshared"><a href="#"><img src="' . $rootUrl . self::SHARED_ICON_FILE . '" /> <span>グローバル属性を設定</span></a></li>';
5597 $operationMenu .= '<li class="m3_wdelete"><a href="#"><img src="' . $rootUrl . self::DELETE_ICON_FILE . '" /> <span>このウィジェットを削除</span></a></li>';
5598 $operationMenu .= '</ul>';
5599 $operationMenu .= '</div>';
5600 $operationMenu .= '</div>';
5602 $contents .= '<dl class="m3_widget m3_widget_sortable" id="' . $widgetTag . '" ' . $m3Option . ' >' . M3_NL;
5603 $contents .= '<dt class="m3_widget_with_check_box ' . $sharedClassName . '"><div class="m3widgettitle">' . $widgetMark . $rows[$i]['wd_name'] . '</div>' . $operationMenu . '</dt>' . M3_NL;
5604 $contents .= '<dd><table style="width:100%;"><tr style="vertical-align:top;"><td style="width:35px;border:none;">' . $imageTag . '</td><td style="border:none;">' . $desc . '</td></tr></table><hr />' . M3_NL;
5605 $contents .= '<table style="width:100%;"><tr><td style="border:none;">' . $configName . '</td><td style="text-align:right;border:none;">' . $configImg . '</td></tr></table></dd>' . M3_NL;
5606 $contents .= '</dl>' . M3_NL;
5613 * @param string $position HTMLテンプレート上の書き出し位置
5614 * @param int $index 行番号
5615 * @param array $fetchedRow fetch取得した行
5616 * @param string $style ウィジェットの表示スタイル(空の場合=Joomla!v1.0テンプレート用、空以外=Joomla!v1.5テンプレート用)
5617 * @param string $launchWidgetTag 遅延ウィジェット埋め込み用タグ(遅延ウィジェットの場合のみ作成)
5618 * @param string $titleTag タイトル埋め込み用タグ(遅延ウィジェットの場合のみ作成)
5619 * @param int $widgetHeaderType ウィジェットタイトルを出力方法(0=出力なし、1=Joomla!v1.0PC用出力、2=Joomla!v1.0携帯用出力)
5620 * @return bool 処理を継続するかどうか(true=続行、false=中断)
5622 function pageDefLoop($position, $index, $fetchedRow, $style, &$launchWidgetTag, &$titleTag, $widgetHeaderType = 0)
5624 global $gEnvManager;
5625 global $gErrorManager;
5626 global $gDesignManager;
5628 // ページ作成中断またはウィジェット処理中断のときは終了
5629 if ($this->isAbort || $this->isWidgetAbort) return false;
5631 // ウィジェット実行停止中のときは空で返す
5632 // 管理者、運営者どのレベルで制限をかける?
5633 if (!$fetchedRow['wd_active']) return true;
5635 // グローバル属性ありの場合は現在のページが例外ページにないかチェック
5636 if (empty($fetchedRow['pd_sub_id'])){
5637 $exceptPageStr = $fetchedRow['pd_except_sub_id'];
5638 if (!empty($exceptPageStr)){
5639 $exceptPageArray = explode(',', $exceptPageStr);
5640 if (in_array($gEnvManager->getCurrentPageSubId(), $exceptPageArray)) return true; // 例外ページの場合は出力しない
5644 // ウィジェット表示タイプによる表示制御。システム管理者以上の場合は常時表示。
5645 if (!$gEnvManager->isSystemAdmin()){
5646 if (!empty($fetchedRow['pd_view_control_type'])){
5647 switch ($fetchedRow['pd_view_control_type']){
5648 case 1: // ログイン時のみ表示
5649 if (!$gEnvManager->isCurrentUserLogined()) return true; // ログインしていなければ終了
5651 case 2: // 非ログイン時のみ表示
5652 if ($gEnvManager->isCurrentUserLogined()) return true; // ログインしていれば終了
5658 if (!empty($fetchedRow['pd_view_page_state'])){
5659 switch ($fetchedRow['pd_view_page_state']){
5661 if (!$this->isPageTopUrl) return true; // ページトップ(サブページ内のトップ位置)でなければ終了
5670 $launchWidgetTag = ''; // 遅延ウィジェット埋め込み用タグ
5674 $widgetId = $fetchedRow['wd_id'];
5675 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5678 $configId = $fetchedRow['pd_config_id']; // ウィジェット定義ID
5679 if ($configId == 0) $configId = '';
5680 $prefix = $fetchedRow['wd_suffix']; // サフィックス文字列
5681 $title = $fetchedRow['wd_name']; // デフォルトのウィジェットタイトル
5682 if (empty($title)) $title = $fetchedRow['wd_id'];
5683 $widgetHeadTitle = $fetchedRow['pd_title']; // ウィジェットのヘッドタイトル
5684 if (empty($widgetHeadTitle)) $widgetHeadTitle = $title; // ウィジェットのヘッドタイトルが空の場合はウィジェットタイトルを取得
5685 $serial = $fetchedRow['pd_serial']; // シリアル番号
5686 $cssStyle = $fetchedRow['pd_style']; // CSS
5687 $lateLaunchIndex = $fetchedRow['wd_launch_index']; // 遅延実行インデックス
5689 if (empty($fetchedRow['pd_sub_id'])) $shared = true;// 共通属性あり
5690 if ($this->nonSharedWidgetCount == -1) $this->nonSharedWidgetCount = 0; // 初期化されていない場合は初期化
5691 if (!$shared) $this->nonSharedWidgetCount++; // 非共通ウィジェットの数を更新
5693 // ウィジェットが遅延実行に指定されている場合は、ウィジェットのタグのみ埋め込む
5694 if ($lateLaunchIndex > 0){ // 遅延実行のとき
5696 if (!isset($this->lateLaunchWidgetList[$widgetId])){
5697 $this->lateLaunchWidgetList[$widgetId] = (int)$lateLaunchIndex;
5700 $maxNo = 0; // 最大シリアル番号
5701 $count = count($this->latelaunchWidgetParam);
5702 for ($i = 0; $i < $count; $i++){
5703 list($wId, $maxNo, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5, $tmp6, $tmp7, $tmp8, $tmp9, $tmp10, $tmp11) = $this->latelaunchWidgetParam[$i];
5704 if ($wId == $widgetId) $maxNo = $maxNo + 1;
5706 // Joomla!1.0テンプレートの場合はタイトルを修正
5707 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5708 if (!empty($fetchedRow['pd_title'])) $title = $fetchedRow['pd_title'];
5710 $this->latelaunchWidgetParam[] = array($widgetId, $maxNo, $configId, $prefix, $serial, $style, $cssStyle, $title, $shared, $exportCss, $position, $index, $fetchedRow);
5713 $launchWidgetTag = self::WIDGET_ID_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TAG_END; // 遅延ウィジェット埋め込み用タグ
5714 echo $launchWidgetTag;
5717 $titleTag = self::WIDGET_ID_TITLE_TAG_START . $widgetId . self::WIDGET_ID_SEPARATOR . $maxNo . self::WIDGET_ID_TITLE_TAG_END;
5720 if (!file_exists($widgetIndexFile)) {
5721 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5724 $this->lastHeadCss = ''; // 最後に設定したHTMLヘッダにCSS出力する文字列
5725 $this->lastHeadScript = ''; // 最後に設定したHTMLヘッダにJavascript出力する文字列
5726 $this->lastHeadString = ''; // 最後に設定したHTMLヘッダに出力する任意文字列
5727 $this->lastHeadTitle = ''; // ヘッダ部titleにセットした文字列
5728 $this->lastHeadDescription = ''; // ヘッダ部descriptionにセットした文字列
5729 $this->lastHeadKeywords = ''; // ヘッダ部keywordsにセットした文字列
5732 $this->currentWidgetPosition = $position; // 現在のウィジェットのポジション
5733 $this->currentWidgetIndex = $index; // 現在のウィジェットのポジション番号
5735 // Joomla!1.0テンプレートのときはウィジェットタイトルを出力
5736 $joomlaTitleVisble = false;
5737 if ($widgetHeaderType > 0 && empty($style)){ // Joomla!1.0テンプレートのとき
5738 if ($fetchedRow['pd_title_visible']){
5739 if ($widgetHeaderType == 1){ // PC用出力のとき
5740 $joomlaTitle = $fetchedRow['pd_title'];
5741 if (empty($joomlaTitle)) $joomlaTitle = $title;
5742 echo '<table ' . self::JOOMLA10_DEFAULT_WIDGET_MENU_PARAM . '>' . M3_NL;
5743 echo '<tr><th>' . $joomlaTitle . '</th></tr>' . M3_NL;
5744 echo '<tr><td>' . M3_NL;
5745 $joomlaTitleVisble = true;
5746 } else if ($widgetHeaderType == 2){ // 携帯用出力のとき
5747 $joomlaTitle = $fetchedRow['pd_title'];
5748 if (empty($joomlaTitle)) $joomlaTitle = $title;
5749 echo '<div>' . $joomlaTitle . '</div>' . M3_NL;
5750 $joomlaTitleVisble = true;
5755 //echo '<div class="' . self::WIDGET_OUTER_CLASS_WIDGET_TAG . $widgetId . '">' . M3_NL;
5756 // ウィジェット親のCSS定義があるときは、タグを追加
5757 if (!empty($cssStyle)) echo '<div style="' . $cssStyle . '">' . M3_NL;
5760 echo $gDesignManager->getAdditionalWidgetOutput(true);
5763 $gEnvManager->setCurrentWidgetId($widgetId);
5766 $gEnvManager->setCurrentWidgetConfigId($configId);
5769 $gEnvManager->setCurrentPageDefSerial($fetchedRow['pd_serial']);
5772 $gEnvManager->setCurrentPageDefRec($fetchedRow);
5775 $gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5777 // ウィジェットのヘッドタイトルを設定
5778 $gEnvManager->setCurrentWidgetHeadTitle($widgetHeadTitle);
5781 $gEnvManager->setCurrentWidgetTitle($title);
5784 $gEnvManager->setCurrentWidgetStyle($style);
5786 // ウィジェットのグローバル属性状況を設定
5787 $gEnvManager->setIsCurrentWidgetShared($shared);
5790 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5793 //require_once($widgetIndexFile);
5794 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5795 $msg = 'widget-start(' . $widgetId . ')';
5796 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5797 require($widgetIndexFile);
5798 $msg = 'widget-end(' . $widgetId . ')';
5799 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5802 $gEnvManager->setCurrentWidgetId('');
5805 $gEnvManager->setCurrentWidgetConfigId('');
5808 $gEnvManager->setCurrentPageDefSerial(0);
5811 $gEnvManager->setCurrentPageDefRec();
5814 $gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
5817 $gEnvManager->setCurrentWidgetStyle('');
5819 // ウィジェットのグローバル属性状況を解除
5820 $gEnvManager->setIsCurrentWidgetShared(false);
5823 echo $gDesignManager->getAdditionalWidgetOutput(false);
5824 // echo "<!-- ".time()." -->";
5826 // ウィジェット親のCSS定義があるときは、タグを追加
5827 if (!empty($cssStyle)) echo '</div>' . M3_NL;
5829 //echo '</div>' . M3_NL;
5831 // Joomla!1.0テンプレートのときはタイトルを出力
5832 if ($joomlaTitleVisble && $widgetHeaderType == 1){ // PC用出力のとき
5833 echo '</td></tr>' . M3_NL;
5834 echo '</table>' . M3_NL;
5838 return true; // 処理継続
5841 * 定義IDを指定してウィジェットの出力を取得
5843 * @param string $widgetId ウィジェットID
5844 * @param int $configId ウィジェット定義ID
5845 * @return string ウィジェットの出力
5847 function getWidgetOutput($widgetId, $configId = 0)
5849 global $gEnvManager;
5850 global $gErrorManager;
5852 // ウィジェットのアクセス権をチェック
5853 if (!$this->db->canAccessWidget($widgetId)) return '';
5856 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
5859 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
5861 // 必要なJavascriptライブラリを追加
5862 $scritLib = trim($row['wd_add_script_lib']);
5863 if (!empty($scritLib)) $this->addScript('', $scritLib);
5869 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/index.php';
5872 $saveWidgetId = $gEnvManager->getCurrentWidgetId();
5873 $gEnvManager->setCurrentWidgetId($widgetId);
5876 $saveConfigId = $gEnvManager->getCurrentWidgetConfigId();
5877 $gEnvManager->setCurrentWidgetConfigId($configId);
5880 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
5883 //$gEnvManager->setCurrentWidgetPrefix($prefix); // プレフィックス文字列
5886 //$gEnvManager->setCurrentWidgetTitle($title);
5888 // ウィジェットのグローバル属性状況を設定
5889 //$gEnvManager->setIsCurrentWidgetShared($shared);
5892 $this->db->writeWidgetLog($widgetId, 0/*ページ実行*/);
5895 //require_once($widgetIndexFile);
5896 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5897 $msg = 'widget-start(' . $widgetId . ')';
5898 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5899 if (file_exists($widgetIndexFile)){
5900 require($widgetIndexFile);
5902 if ($gEnvManager->isSystemManageUser()) echo '<span class="error">widget not found error: ' . $widgetId . '</span>'; // システム運用者の場合はエラーメッセージ表示
5904 $msg = 'widget-end(' . $widgetId . ')';
5905 $gErrorManager->writeDebug(__METHOD__, $msg); // 時間計測用
5908 $gEnvManager->setCurrentWidgetId($saveWidgetId);
5911 $gEnvManager->setCurrentWidgetConfigId($saveConfigId);
5914 //$gEnvManager->setCurrentPageDefSerial(0); // 未使用?
5917 //$gEnvManager->setCurrentWidgetPrefix(''); // プレフィックス文字列
5919 // ウィジェットのグローバル属性状況を解除
5920 //$gEnvManager->setIsCurrentWidgetShared(false);
5922 // 現在のバッファ内容を取得し、バッファを破棄
5923 $output = ob_get_contents();
5931 * @param int $cmdNo 実行コマンド(0=初期化、1=更新、2=計算、10=コンテンツ取得)
5932 * @param string $id ウィジェットID+インナーウィジェットID
5933 * @param string $configId インナーウィジェット定義ID
5934 * @param object $paramObj インナーウィジェットに渡すパラメータオブジェクト
5935 * @param object $optionParamObj インナーウィジェットに渡すパラメータオブジェクト(オプション)
5936 * @param object $resultObj インナーウィジェットから返る結果オブジェクト
5937 * @param string $content 出力内容
5938 * @param bool $isAdmin 管理者機能(adminディレクトリ以下)かどうか
5939 * @return bool true=成功、false=失敗
5941 function commandIWidget($cmdNo, $id, $configId, &$paramObj, &$optionParamObj, &$resultObj, &$content, $isAdmin = false)
5943 global $gEnvManager;
5945 // ウィジェットIDとインナーウィジェットIDを取り出す
5946 list($widgetId, $iWidgetId) = explode(M3_WIDGET_ID_SEPARATOR, $id);
5948 // インナーウィジェットに渡すパラメータを設定
5951 $cmd = self::IWIDTET_CMD_INIT; // 初期化
5952 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5955 $cmd = self::IWIDTET_CMD_UPDATE; // 更新
5956 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
5959 $cmd = self::IWIDTET_CMD_CALC; // 計算
5960 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5963 $cmd = self::IWIDTET_CMD_CONTENT; // コンテンツ取得
5964 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd); // 設定されているパラメータの更新は行わない
5968 $this->gInstance->getCmdParamManager()->setParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $paramObj, $optionParamObj);
5972 // インナーウィジェットのエラー出力は呼び出しウィジェット側で受けるため、出力を抑止する
5973 ob_start();// バッファ作成
5976 if (empty($widgetId)){ // ウィジェットIDが指定されていないときは共通ディレクトリ
5977 //$gEnvManager->getIWidgetsPath() . '/' . $iWidgetId . '/' . $containerClass . '.php';
5980 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/' . M3_DIR_NAME_ADMIN . '/index.php';
5982 $widgetIndexFile = $gEnvManager->getWidgetsPath() . '/' . $widgetId . '/include/iwidgets/' . $iWidgetId . '/index.php';
5986 // 作業中のインナーウィジェットIDを設定
5987 $gEnvManager->setCurrentIWidgetId($id); // インナーウィジェットを設定
5989 // インナーウィジェット定義IDを設定
5990 $gEnvManager->setCurrentIWidgetConfigId($configId);
5993 // ウィジェットの呼び出しは、複数回存在する可能性があるのでrequire_once()で呼び出さない
5994 if (file_exists($widgetIndexFile)){
5995 require($widgetIndexFile);
5997 echo 'file not found error: ' . $widgetIndexFile;
6001 $gEnvManager->setCurrentIWidgetId('');
6003 // インナーウィジェット定義IDを解除
6004 $gEnvManager->setCurrentIWidgetConfigId('');
6006 // 現在のバッファ内容を取得し、バッファを破棄
6007 $content = ob_get_contents();
6011 if ($this->gInstance->getCmdParamManager()->getParam($id . M3_WIDGET_ID_SEPARATOR . $configId, $cmd, $obj, $option)){
6013 $optionParamObj = $option;
6017 if ($this->gInstance->getCmdParamManager()->getResult($id . M3_WIDGET_ID_SEPARATOR . $configId, $resObj)) $resultObj = $resObj;
6021 * コールバックメソッドを実行し、出力を返す
6023 * @param array $callback 実行するコールバック
6024 * @return string 出力結果
6026 function getOutputByCallbackMethod($callback)
6028 ob_start();// バッファ作成
6031 if (is_callable($callback)) call_user_func($callback);
6033 // 現在のバッファ内容を取得し、バッファを破棄
6034 $content = ob_get_contents();
6039 * ページ作成処理中断を行った場合のレスポンスヘッダ設定
6041 * @param int $responseCode レスポンスコード
6044 function setResponse($responseCode)
6046 switch ($responseCode){
6047 case 400: // リクエストにエラーがあるとき
6048 header('HTTP/1.1 400 Bad request');
6049 header('Status: 400 Bad request');
6051 case 403: // アクセス禁止のとき
6052 header('HTTP/1.1 403 Forbidden');
6053 header('Status: 403 Forbidden');
6055 case 404: // 存在しないページのとき
6056 header("HTTP/1.1 404 Not Found");
6057 header("Status: 404 Not Found");
6059 case 500: // サーバ内部エラー
6060 header('HTTP/1.1 500 Internal Server Error');
6061 header('Status: 500 Internal Server Error');
6063 case 503: // サイト非公開(システムメンテナンス)
6064 header('HTTP/1.1 503 Service Temporarily Unavailable');
6065 header('Status: 503 Service Temporarily Unavailable');
6072 * @param string $filePath ダウンロードするファイルのファイルパス
6073 * @param string $downloadFilename ダウンロード時のファイル名
6074 * @param bool $deleteFile 実行後ファイルを削除するかどうか(成功失敗に関係なく)
6075 * @return bool true=成功、false=失敗
6077 function downloadFile($filePath, $downloadFilename, $deleteFile=false)
6080 if (!file_exists($filePath)) return false;
6083 $fileSize = filesize($filePath);
6085 // バッファ内容が残っているときは破棄
6086 if (ob_get_level() > 0) ob_end_clean();
6088 header('Cache-Control: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
6089 header('Pragma: public'); // IE6+SSHでダウンロードエラーが出る問題を回避
6090 header('Content-Disposition: attachment; filename=' . $downloadFilename);
6091 header('Content-Length: ' . $fileSize);
6092 header('Content-Type: application/octet-stream; name=' . $downloadFilename);
6093 $fp = fopen($filePath, "r");
6094 echo fread($fp, $fileSize);
6100 if ($deleteFile) unlink($filePath);
6104 * システム制御ページを表示するかどうかを返す
6106 * @return bool true=システム制御ページを表示、false=システム制御ページを表示しない
6108 function isSystemPage()
6110 return $this->isSystemPage;
6115 * @param string $url 遷移先URL。未指定の場合は現在のスクリプト。URLでないときは、現在のスクリプトに付加。
6116 * @param bool $noMessage 画面を遷移させたとき、ドコモ携帯端末でダイアログ(サイトが移動しました(301))が出ないようにするオプション
6117 * @param int $responseCode レスポンスコード
6118 * @param bool $autoSsl リダイレクト先のページの状態に合わせてSSLを制御するかどうか
6121 function redirect($url = '', $noMessage = false, $responseCode = 0, $autoSsl = true)
6123 global $gEnvManager;
6125 // すでにリダイレクトが設定されている場合は終了
6126 if ($this->isRedirect) return; // リダイレクトするかどうか
6130 $toUrl = $gEnvManager->getCurrentScriptUrl();
6131 } else if (strncmp($toUrl, 'http://', 7) != 0 && strncmp($toUrl, 'https://', 8) != 0){ // URL以外のときはクエリー文字列と判断する
6132 $toUrl = $gEnvManager->getCurrentScriptUrl() . $toUrl;
6135 // SSL化が必要な場合はhttpsに変更
6138 if ($gEnvManager->isAdminUrlAccess($toUrl)){ // 管理画面へのアクセスのとき
6139 // ルートURLがSSLの場合は管理画面は常にSSL付き
6140 if ($gEnvManager->isRootUrlSsl()) $isSslPage = true;
6143 if ($gEnvManager->getUseSslAdmin()) $isSslPage = true; // 管理画面でSSLを使用するとき
6144 } else { // フロント画面へのアクセスのとき
6146 $paramArray = array();
6147 //list($filename, $query) = explode('?', basename($toUrl));
6148 list($url, $query) = explode('?', $toUrl);
6149 $baseUrl = dirname($url);
6150 $filename = basename($url);
6151 if (empty($filename)) $filename = M3_FILENAME_INDEX;
6152 if (!empty($query)) parse_str($query, $paramArray); // クエリーの解析
6155 $pageId = basename($filename, '.php');
6156 $pageSubId = $paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID];
6159 $isSslPage = $this->isSslPage($pageId, $pageSubId);
6162 if ($this->gSystem->hierarchicalPage() && $filename == M3_FILENAME_INDEX){
6163 $toUrl = $baseUrl . '/' . $pageSubId . '/';
6164 unset($paramArray[M3_REQUEST_PARAM_PAGE_SUB_ID]);
6166 $paramStr = $this->_createUrlParamStr($paramArray);
6167 if (!empty($paramStr)) $toUrl .= '?' . $paramStr;
6171 //$toUrl = str_replace('http://', 'https://', $toUrl);
6172 $toUrl = $gEnvManager->getSslUrl($toUrl); // SSL用URLに変換
6174 $toUrl = str_replace('https://', 'http://', $toUrl);
6178 // バッファ内容が残っているときは破棄
6179 if (ob_get_level() > 0) ob_end_clean();
6181 if (empty($responseCode)){
6183 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
6185 // header('HTTP/1.1 301 Moved Permanently');
6186 header('HTTP/1.1 302 Moved Temporary'); // ドメインのURLをHTTPからHTTPに変更するとChromeで問題が発生したので301から302リダイレクトに変更(2018/4/30)
6188 } else { // レスポンスコードが指定されている場合
6189 switch ($responseCode){
6191 // ##### 301リダイレクトはChromeではブラウザにキャッシュされてしまうので注意 #####
6192 header('HTTP/1.1 301 Moved Permanently');
6195 header('HTTP/1.1 302 Found(Moved Temporary)'); // ダイアログメッセージを抑止(ドコモ携帯端末用)
6198 header('HTTP/1.1 303 See Other');
6200 case 500: // サーバ内部エラー
6201 header('HTTP/1.1 500 Internal Server Error');
6202 header('Status: 500 Internal Server Error');
6204 case 503: // サイト非公開(システムメンテナンス)
6205 header('HTTP/1.1 503 Service Temporarily Unavailable');
6206 header('Status: 503 Service Temporarily Unavailable');
6209 header('HTTP/1.1 ' . (string)$responseCode);
6213 header('Location: ' . $toUrl);
6215 $this->isRedirect = true; // リダイレクトするかどうか
6220 * @return bool true=リダイレクト、false=リダイレクトでない
6222 function isRedirect()
6224 return $this->isRedirect;
6227 * 指定URLのディレクトリへリダイレクト
6231 function redirectToDirectory()
6233 global $gEnvManager;
6236 $dirPath = dirname($gEnvManager->getCurrentScriptUrl()) . '/';
6237 //$this->redirect($dirPath);
6238 $this->redirect($dirPath, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/7/23)
6243 * @param string $url 遷移先URL
6246 function redirectInInstall($url)
6248 $this->redirect($url, false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
6255 function redirectToInstall()
6257 global $gEnvManager;
6259 $sytemRootUrl = $gEnvManager->calcSystemRootUrl();
6260 //$this->redirect($sytemRootUrl . '/admin/install.php');
6261 $this->redirect($sytemRootUrl . '/admin/install.php', false, 303, false/*SSLは自動制御しない*/); // Firefoxでredirect先がキャッシュに残る問題を回避(2012/8/1)
6264 * ログイン、ログアウト処理を行った後、リダイレクト
6266 * @param RequestManager $request HTTPリクエスト処理クラス
6267 * @param bool $success ログインの成否
6268 * @param string $redirectUrl ログイン成功の場合のリダイレクト先
6269 * @return int 0=何も処理しなかった場合、1=ログイン処理、2=ログアウト処理、3=パスワード送信
6271 function standardLoginLogoutRedirect($request, &$success, $redirectUrl = '')
6273 global $gEnvManager;
6274 global $gAccessManager;
6275 global $gRequestManager;
6277 // ログイン、ログアウト処理、および、コンテナの起動
6278 $cmd = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_COMMAND);
6279 if ($cmd == M3_REQUEST_CMD_LOGIN){ // ログインの場合
6280 $act = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_ACT);
6281 if ($act == 'sendpwd'){ // パスワード送信の場合
6282 $success = $gAccessManager->sendPassword($request);
6286 $ret = $gAccessManager->userLogin($request);
6288 if (empty($redirectUrl)){
6289 // システム運用可能ユーザの場合でリダイレクト先が設定されていない場合はデフォルトの管理画面URLへ遷移
6290 $userInfo = $gEnvManager->getCurrentUserInfo();// ユーザ情報取得
6291 if ($userInfo->userType >= UserInfo::USER_TYPE_MANAGER){
6292 $ret = $this->db->getLoginUserRecordById($userInfo->userId, $userInfoRow);
6293 if ($ret && !empty($userInfoRow['lu_default_admin_url'])){
6294 $redirectUrl = $gEnvManager->getDefaultAdminUrl() . $userInfoRow['lu_default_admin_url'];
6300 $this->redirect($redirectUrl);
6301 $success = true; // ログイン成功
6302 } else { // ログイン失敗のとき
6303 $success = false; // ログイン失敗
6307 } else if ($cmd == M3_REQUEST_CMD_LOGOUT){ // ログアウト
6309 $gAccessManager->userLogout(true);
6312 $this->redirect($redirectUrl);
6321 * @param int $errStatus HTTPエラーステータスコード
6324 function showError($errStatus)
6327 $this->setResponse($errStatus);
6330 $msg = 'NOT DEFINED ERROR';
6331 switch ($errStatus){
6332 case 403: // アクセス禁止のとき
6335 case 404: // 存在しないページのとき
6338 case 500: // サーバ内部エラー
6339 $msg = 'Internal Server Error';
6341 case 503: // サイト非公開(システムメンテナンス)
6342 $msg = 'Service Temporarily Unavailable';
6346 echo '<!doctype html>';
6349 echo '<title>' . $msg . '</title>';
6352 echo '<h2>' . $msg . '</h2>';
6357 * ウィジェットがセットされているページサブIDを取得
6359 * @param string $pageId ページID
6360 * @param string $widgetId 対象ウィジェットID
6361 * @param int $configId ウィジェット定義ID
6362 * @return string ページサブID
6364 function getPageSubIdByWidget($pageId, $widgetId, $configId = 0)
6368 // 対象のウィジェットのページサブIDを取得
6369 $ret = $this->db->getSubPageId($widgetId, $pageId, $rows);
6370 if ($ret){// データが存在する
6371 for ($i = 0; $i < count($rows); $i++){
6372 if (!empty($rows[$i]['pd_sub_id']) && $rows[$i]['pd_config_id'] == $configId){
6373 $pageSubId = $rows[$i]['pd_sub_id'];
6381 * その他のGET,POSTパラメータからページサブID取得
6383 * @param RequestManager $request HTTPリクエスト処理クラス
6384 * @param string $redirectUrl リダイレクト用URL
6385 * @return string ページサブID
6387 function getPageSubIdByParam($request, &$redirectUrl)
6389 global $gEnvManager;
6393 $task = $request->trimValueOf('task');
6394 $option = $request->trimValueOf('option');
6395 if ($task == 'search' && $option == 'com_search'){ // joomla!の検索結果表示の場合
6396 $this->contentType = M3_VIEW_TYPE_SEARCH; // ページのコンテンツタイプ
6398 $subId = $this->db->getSubPageIdWithContent(M3_VIEW_TYPE_SEARCH, $gEnvManager->getCurrentPageId());// ページサブIDを取得
6399 if (!empty($subId)){
6401 $keyword = $request->trimValueOf('searchword');
6402 $redirectUrl = $gEnvManager->createPageUrl();
6403 $redirectUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subId;
6404 $redirectUrl .= '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=search&' . M3_REQUEST_PARAM_KEYWORD . '=' . urlencode($keyword);
6410 * コンテンツタイプとページIDからページサブID取得
6412 * @param string $contentType コンテンツタイプ
6413 * @param string $pageId ページID
6414 * @return string ページサブID
6416 function getPageSubIdByContentType($contentType, $pageId)
6418 $subId = $this->db->getSubPageIdWithContent($contentType, $pageId);// ページサブIDを取得
6422 * 指定のウィジェットがページ上にあるかを取得
6424 * @param string $pageId ページID
6425 * @param string $widgetId 対象ウィジェットID
6426 * @param bool $activePageOnly 公開中のページのウィジェットに制限するかどうか。falseの場合はすべてのページのウィジェットを対象とする。
6427 * @return bool true=ページ上にあり、false=ページ上になし
6429 function isWidgetOnPage($pageId, $widgetId, $activePageOnly=true)
6431 $ret = $this->db->isWidgetOnPage($pageId, $widgetId, $activePageOnly, 0/*定義セットID*/);
6435 * URLで示されるページ上のウィジェットをウィジェット種別で取得
6437 * @param string $url URL
6438 * @param string $widgetType 対象ウィジェットタイプ
6439 * @return string ウィジェットID
6441 function getWidgetIdByWidgetType($url, $widgetType)
6443 $ret = $this->getPageIdFromUrl($url, $pageId, $pageSubId, $param);
6446 if ($ret) $widgetId = $this->db->getWidgetIdByType($pageId, $pageSubId, $widgetType);
6450 * ページコンテンツタイプ、コンテンツタイプからウィジェットIDを取得
6452 * @param string $pageId ページID
6453 * @param string $contentType コンテンツタイプ
6454 * @return string ウィジェットID
6456 function getWidgetIdWithPageInfoByContentType($pageId, $contentType)
6458 $widgetId = $this->db->getWidgetIdWithPageInfoByContentType($pageId, $contentType);
6462 * ジョブタイプからウィジェットIDを取得
6464 * @param string $jobType ジョブタイプ
6465 * @return string ウィジェットID
6467 function getWidgetIdByJobType($jobType)
6469 global $gEnvManager;
6470 global $gErrorManager;
6474 $linkInfoObj = $this->gInstance->getObject(self::LINKINFO_OBJ_ID);
6475 if (isset($linkInfoObj)) $widgetId = $linkInfoObj->getJobWidget($jobType);
6477 // ウィジェットのアクセス権をチェック
6478 if (!$this->db->canAccessWidget($widgetId)) return '';
6481 if (!$this->db->getWidgetInfo($widgetId, $row)) return '';
6484 if (intval($row['wd_device_type']) != intval($gEnvManager->getCurrentPageDeviceType())) return '';
6489 * 現在アクティブなメイン型ウィジェットをウィジェット種別で取得
6491 * @param string $widgetType 対象ウィジェットタイプ
6492 * @return string ウィジェットID
6494 function getActiveMainWidgetIdByWidgetType($widgetType)
6497 $widgetId = $this->db->getActiveMainWidgetIdByType($widgetType);
6501 * URLを解析して、ページID,サブページIDを取得
6503 * @param string $url URL
6504 * @param string $pageId ページID
6505 * @param string $pageSubId ページサブID
6506 * @param array $urlParam URLパラメータ
6507 * @return bool true=成功、false=失敗
6509 function getPageIdFromUrl($url, &$pageId, &$pageSubId, &$urlParam)
6511 global $gEnvManager;
6513 // ページID、ページサブIDを求める
6514 list($page, $other) = explode('?', str_replace($gEnvManager->getRootUrl(), '', $url));
6515 parse_str($other, $urlParam);
6517 $pageId = str_replace('/', '_', trim($page, '/'));
6518 $pageId = basename($pageId, '.php');
6521 $pageSubId = $param[M3_REQUEST_PARAM_PAGE_SUB_ID];
6522 if (empty($pageSubId)) $pageSubId = $gEnvManager->getDefaultPageSubId();
6526 * ウィジェットが組み込まれているページのURLを生成
6528 * @param string $widgetId 送信元ウィジェットID
6529 * @param string $param 実行パラメータ
6530 * @param string $pageId ウィジェットが存在するページID
6531 * @return string 生成したURL
6533 function getDefaultPageUrlByWidget($widgetId, $param = '', $pageId = '')
6535 global $gEnvManager;
6537 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6539 // このウィジェットがマップされているページサブIDを取得
6541 $subPageId = $this->getPageSubIdByWidget($pageId, $widgetId);
6542 if (empty($subPageId)){
6543 // 見つからないときは互換ウィジェットを探す
6544 $targetWidgetId = $this->db->getCompatibleWidgetId($widgetId);
6545 if (!empty($targetWidgetId)){
6546 $subPageId = $this->getPageSubIdByWidget($pageId, $targetWidgetId);
6549 if (!empty($subPageId)) $sub = M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $subPageId;
6551 //$url = $gEnvManager->getDefaultUrl();
6552 $url = $gEnvManager->createPageUrl($pageId);
6553 if (!empty($sub)) $url .= '?' . $sub;
6554 if (!empty($param)) $url .= '&' . $param;
6558 * 現在のアクセスポイントの指定のページ属性のページURLを生成
6560 * @param string $contentType コンテンツタイプ
6561 * @param string $param 追加パラメータ
6562 * @param bool $omitPageId ページID省略形を使用するかどうか
6563 * @return string 生成したURL
6565 function createContentPageUrl($contentType, $param = '', $omitPageId = true)
6567 global $gEnvManager;
6568 static $urlArray = array();
6570 // 複数回呼ばれるのでコンテンツタイプごとにページまでのURLは保存しておく
6571 $baseUrl = $urlArray[$contentType];
6572 if (!isset($baseUrl)){
6573 // コンテンツタイプからページサブIDを取得
6574 $pageSubId = $this->getPageSubIdByContentType($contentType, $gEnvManager->getCurrentPageId()); // DBから取得
6576 if (empty($pageSubId)){ // ページサブIDが取得できない場合はデフォルトのページサブIDを取得
6577 $pageSubId = $gEnvManager->getDefaultPageSubId();
6578 } else if ($pageSubId == $gEnvManager->getDefaultPageSubId()){ // デフォルトページの場合
6579 if ($omitPageId) $pageSubId = ''; // ページID省略形を使用する場合はページサブIDを省略
6582 // 現在のアクセスポイントのURLを取得
6583 $baseUrl = $gEnvManager->createPageUrl();
6586 if (!empty($pageSubId)) $baseUrl .= '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId;
6589 $urlArray[$contentType] = $baseUrl;
6594 if (!empty($param)){
6595 if (strEndsWith($url, '.php') || strEndsWith($url, '/')){
6605 * ウィジェット指定呼び出し用のURLを生成
6607 * @param string $toWidgetId 送信先ウィジェットID
6608 * @param string $fromWidgetId 送信元ウィジェットID
6609 * @param string $todo 実行パラメータ
6610 * @param string $pageId ページID(空のときは現在のURL)
6611 * @return string 生成したURL
6613 function createWidgetCmdUrl($toWidgetId, $fromWidgetId, $todo, $pageId = '')
6615 global $gEnvManager;
6617 $url = $gEnvManager->createPageUrl($pageId);
6619 $url .= '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_FIND_WIDGET;
6620 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $toWidgetId;
6621 if (!empty($fromWidgetId)) $url .= '&' . M3_REQUEST_PARAM_FROM . '=' . $fromWidgetId; // 送信元
6622 if (!empty($todo)) $url .= '&' . M3_REQUEST_PARAM_OPERATION_TODO . '=' . urlencode($todo);
6628 * @param string $widgetId 実行ウィジェットID
6629 * @param string $optionParam 追加パラメータ
6630 * @param string $pageId ページID(空のときは現在のURL)
6631 * @param string $pageSubId ページサブID
6632 * @return string 生成したURL
6634 function createRssCmdUrl($widgetId, $optionParam = '', $pageId = '', $pageSubId = '')
6636 global $gEnvManager;
6639 $url = $gEnvManager->createPageUrl() . '?';
6642 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6643 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6645 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_RSS;
6646 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6647 if (!empty($optionParam)) $url .= '&' . $optionParam;
6653 * @param bool $isSslPage SSLが必要なページかどうか
6654 * @param string $optionParam 追加パラメータ
6655 * @return string 生成したURL
6657 function createCssCmdUrl($isSslPage, $optionParam = '')
6659 global $gEnvManager;
6660 global $gRequestManager;
6663 // $url = $gEnvManager->createPageUrl() . '?';
6664 $url = $gEnvManager->createPageUrl(''/*現在のページ*/, $isSslPage) . '?';
6667 $pageSubId = $this->gEnv->getCurrentPageSubId();
6668 $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6670 // コンテンツ詳細画面の場合はコンテンツパラメータを追加
6671 if ($this->isContentDetailPage){
6672 switch ($this->contentType){
6673 case M3_VIEW_TYPE_CONTENT: // 汎用コンテンツ
6674 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID);
6675 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_CONTENT_ID_SHORT);
6676 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentsId . '&';
6678 case M3_VIEW_TYPE_PRODUCT: // 製品
6679 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID);
6680 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PRODUCT_ID_SHORT);
6681 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PRODUCT_ID . '=' . $contentsId . '&';
6683 case M3_VIEW_TYPE_BBS: // BBS
6684 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID);
6685 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BBS_THREAD_ID_SHORT);
6686 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BBS_THREAD_ID . '=' . $contentsId . '&';
6688 case M3_VIEW_TYPE_BLOG: // ブログ
6689 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID);
6690 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT);
6691 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $contentsId . '&';
6693 case M3_VIEW_TYPE_WIKI: // Wiki
6694 $contentsId = $gRequestManager->getWikiPageFromQuery(); // 「=」なしのパラメータはwikiパラメータとする
6695 if (!empty($contentsId)) $url .= $contentsId . '&';
6697 case M3_VIEW_TYPE_EVENT: // イベント
6698 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID);
6699 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_EVENT_ID_SHORT);
6700 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_EVENT_ID . '=' . $contentsId . '&';
6702 case M3_VIEW_TYPE_PHOTO: // フォトギャラリー
6703 $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID);
6704 if (empty($contentsId)) $contentsId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_PHOTO_ID_SHORT);
6705 if (!empty($contentsId)) $url .= M3_REQUEST_PARAM_PHOTO_ID . '=' . $contentsId . '&';
6710 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_CSS;
6711 if (!empty($optionParam)) $url .= '&' . $optionParam;
6717 * @param string $widgetId 実行ウィジェットID
6718 * @param string $optionParam 追加パラメータ
6719 * @param bool $byMacro マクロ変換で返すかどうか
6720 * @param string $pageId ページID(空のときは現在のURL)
6721 * @param string $pageSubId ページサブID
6722 * @return string 生成したURL
6724 function createDirectWidgetCmdUrl($widgetId, $optionParam = '', $byMacro = false, $pageId = '', $pageSubId = '')
6726 global $gEnvManager;
6730 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . M3_FILENAME_INDEX . '?';
6732 $url = $gEnvManager->createPageUrl() . '?';
6736 if (empty($pageSubId)) $pageSubId = $this->gEnv->getCurrentWidgetPageSubId(); // グローバル属性ありのときは空
6737 if (!empty($pageSubId)) $url .= M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $pageSubId . '&';
6739 $url .= M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_DO_WIDGET;
6740 $url .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $widgetId;
6741 if (!empty($optionParam)) $url .= '&' . $optionParam;
6747 * @return array パラメータ文字列の配列
6749 function getUrlParamOrder()
6751 return $this->urlParamOrder; // URLパラメータの並び順
6754 * キャッシュ制御用の付加パラメータを取得
6756 * @return string パラメータ
6758 function getCacheParam()
6760 $addParam = '?' . date('YmdHis');
6764 * 現在のURLにアクセス可能かチェック
6766 * @param bool $isActivePage ページが有効かどうか
6767 * @param int $errCode エラーコード
6768 * @return bool true=可能、false=不可
6770 function canAccessUrl(&$isActivePage, &$errCode)
6772 global $gEnvManager;
6774 $errCode = 0; // エラーコード初期化
6776 // 現在設定されているページIDを取得
6777 $pageId = $gEnvManager->getCurrentPageId();
6778 $pageSubId = $gEnvManager->getCurrentPageSubId();
6779 $ret = $this->db->canAccessPage($pageId, $pageSubId, $pageVisible, $pageSubVisible, $isAdminMenu);
6780 if ($ret){ // アクセス可能なときは、ユーザ制限もチェックする
6781 $isActivePage = true;
6784 if (!$pageVisible || !$pageSubVisible) return false;
6786 if (!$gEnvManager->isCurrentUserLogined() && $this->isUserLimitedPage($pageId, $pageSubId)){ // ユーザがログインされていない状態でユーザ制限されていればアクセス不可
6789 $this->isAccessPointWithAdminMenu = $isAdminMenu; // 管理メニューを使用するアクセスポイントかどうか
6792 } else { // 無効ページのとき
6793 $isActivePage = false;
6795 // ページIDの文字のチェック。ページIDは半角英小文字、数字、アンダーバー、ハイフンのみ使用可能。
6796 if (preg_match("/[^0-9a-z-_]/", $pageSubId)) $errCode = 1; // 不正文字検出
6801 * ウィジェットヘッダ(Joomla!1.0用)を出力タイプを取得
6803 * @return int 0=出力しない、1=Joomla!1.0テンプレートPC用、2=Joomla!1.0テンプレート携帯用
6805 function getTemplateWidgetHeaderType()
6807 global $gEnvManager;
6809 $templateId = $gEnvManager->getCurrentTemplateId();
6810 if ($templateId == self::ADMIN_TEMPLATE){ // PC管理用テンプレート
6812 } else if(strncmp($templateId, 'm/', 2) == 0){ // 携帯用テンプレート
6813 return 2; // 携帯テンプレート用出力
6815 return 1; // PCテンプレート用出力
6821 * @param string $pageId ページID
6822 * @param string $pageSubId ページサブID
6823 * @return bool true=必要、false=不要
6825 function isSslPage($pageId, $pageSubId)
6827 global $gEnvManager;
6830 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6833 if ($pageId == $gEnvManager->getDefaultAdminPageId()){
6834 if ($gEnvManager->getUseSslAdmin()){ // 管理用ページにSSLを使用するかどうか
6841 // ##### フロント画面の場合 #####
6842 if ($gEnvManager->isRootUrlSsl()) return true; // ルートURLがSSLの場合はフロント画面のすべてがSSL付き
6844 // 一般用ページにSSLを使用しない場合は不要を返す
6845 if (!$gEnvManager->getUseSsl()) return false;
6847 // 一般用ページでSSLを使用する場合は、データベースの設定をチェックする
6848 $line = $this->getPageInfo($pageId, $pageSubId);
6850 if ($line['pn_use_ssl']){
6859 * ユーザ制限が必要なページかどうかを判断
6861 * @param string $pageId ページID
6862 * @param string $pageSubId ページサブID
6863 * @return bool true=必要、false=不要
6865 function isUserLimitedPage($pageId, $pageSubId)
6867 global $gEnvManager;
6870 if (empty($pageId)) $pageId = $gEnvManager->getDefaultPageId();
6872 $line = $this->getPageInfo($pageId, $pageSubId);
6874 if ($line['pn_user_limited']){
6885 * @param string $pageId ページID
6886 * @param string $pageSubId ページサブID
6887 * @return array ページ情報レコード
6889 function getPageInfo($pageId, $pageSubId)
6891 // ページ情報が空のときはデータをロード
6892 if (empty($this->pageInfo)){
6893 $records = $this->db->getPageInfoRecords();
6894 $count = count($records);
6895 $this->pageInfo = array();
6896 for ($i = 0; $i < $count; $i++){
6897 $pId = $records[$i]['pn_id'] . self::PAGE_ID_SEPARATOR . $records[$i]['pn_sub_id'];
6898 $this->pageInfo[$pId] = $records[$i];
6901 return $this->pageInfo[$pageId . self::PAGE_ID_SEPARATOR . $pageSubId];
6906 * @return array ページ情報レコード
6908 function getCurrentPageInfo()
6910 return $this->currentPageInfo;
6913 * 現在のページ情報からテンプレートIDを取得
6915 * @param string $subTemplateId テンプレートIDが取得できるときはサブページIDが返る
6916 * @return string テンプレートID
6918 function getTemplateIdFromCurrentPageInfo(&$subTemplateId)
6921 if (!empty($this->currentPageInfo)){
6922 $templateId = $this->currentPageInfo['pn_template_id'];
6923 $subTemplateId = $this->currentPageInfo['pn_sub_template_id']; // サブテンプレートID
6928 * JavascriptライブラリのIDを取得
6930 * @param int $type 種別(0=すべて、1=jQuery関係すべて、2=jQueryプラグインのみ)
6931 * @return array JavascriptライブラリのID
6933 function getScriptLibId($type = 0)
6935 // Javascriptライブラリのすべてのキーを取得
6936 $keys = array_keys($this->libFiles);
6938 $destKeys = array();
6939 for ($i = 0; $i < count($keys); $i++){
6941 case 1: // jQuery関係すべて
6942 if (strStartsWith($keys[$i], 'jquery')) $destKeys[] = $keys[$i];
6944 case 2: // jQueryプラグインのみ
6945 if (strStartsWith($keys[$i], 'jquery.')) $destKeys[] = $keys[$i];
6952 * Javascriptライブラリの情報を取得
6954 * @param string $id ライブラリID
6955 * @return array ライブラリの情報
6957 function getScriptLibInfo($id)
6959 $libInfo = $this->libFiles[$id];
6960 if (isset($libInfo)){
6967 * 管理画面用jQueryUIテーマのURLを取得
6969 * @return string テーマURL
6971 function getAdminDefaultThemeUrl()
6973 // $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
6974 $themeFile = $this->gEnv->getAdminUrl(true/*「admin」削除*/) . self::DEFAULT_THEME_DIR . $this->gSystem->adminDefaultTheme() . '/'. self::THEME_CSS_FILE;
6978 * フロント画面用jQueryUIテーマのURLを取得
6980 * @return string テーマURL
6982 function getDefaultThemeUrl()
6986 if (!isset($themeFile)){
6988 $theme = $this->gSystem->defaultTheme();
6989 if (!empty($theme)){
6990 $path = $this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
6991 if (file_exists($path)) $themeFile = $this->gEnv->getRootUrl() . self::DEFAULT_THEME_DIR . $theme . '/'. self::THEME_CSS_FILE;
6999 * @param array $paramArray URL作成用のパス
7000 * @return string 作成したURLパラメータ
7002 function _createUrlParamStr($paramArray)
7005 if (count($paramArray) == 0) return $destParam;
7007 $sortParam = array();
7008 $keys = array_keys($paramArray);
7009 $keyCount = count($keys);
7010 for ($i = 0; $i < $keyCount; $i++){
7012 $value = $paramArray[$key];
7013 $orderNo = $this->urlParamOrder[$key];
7014 if (!isset($orderNo)) $orderNo = 100;
7015 $sortParam[] = array('key' => $key, 'value' => $value, 'no' => $orderNo);
7017 // usort($sortParam, create_function('$a,$b', 'return $a["no"] - $b["no"];'));
7018 usort($sortParam, function($a, $b)
7020 return $a['no'] - $b['no'];
7024 $sortCount = count($sortParam);
7025 for ($i = 0; $i < $sortCount; $i++){
7026 if ($i > 0) $destParam .= '&';
7027 $destParam .= rawurlencode($sortParam[$i]['key']) . '=' . rawurlencode($sortParam[$i]['value']);
7032 * DBからCSSファイル(テンプレート独自のCSSまたは外部のCSS)を取得
7034 * @param string $templateId テンプレートID
7035 * @return bool true=取得成功、false=取得失敗
7037 function loadCssFiles($templateId = '')
7039 if (empty($templateId)) $templateId = $this->gSystem->defaultTemplateId(); // PC画面デフォルトのテンプレートを取得
7041 $ret = $this->db->getTemplate($templateId, $row);
7042 if (!$ret) return false;
7044 // 編集エディタ用パラメータが初期化されていない場合は初期化
7045 if (empty($row['tm_editor_param'])){
7046 // テンプレートを解析し、使用しているCSSファイルを取得
7047 $editorParamObj = $this->parseTemplate($templateId);
7050 $updateParam = array();
7051 $updateParam['tm_editor_param'] = serialize($editorParamObj);
7052 $ret = $this->db->updateTemplate($templateId, $updateParam);
7054 $editorParamObj = unserialize($row['tm_editor_param']);
7057 if (isset($editorParamObj)){
7058 $this->ckeditorCssFiles = array();
7059 $cssFiles = $editorParamObj->cssFiles;
7060 for ($i = 0; $i < count($cssFiles); $i++){
7061 $cssFile = $cssFiles[$i];
7063 if (strStartsWith($cssFile, '//')){ // URLが「//」で始まる外部ファイルの場合はそのまま追加
7064 $this->ckeditorCssFiles[] = $cssFile;
7065 } else if (strStartsWith($cssFile, '/')){ // URLが「/」で始まる相対パスの場合はURLに変換
7066 $this->ckeditorCssFiles[] = $this->gEnv->getAdminUrl(true/*adminディレクトリ削除*/) . $cssFile;
7068 $this->ckeditorCssFiles[] = $cssFile;
7077 * URLで指定した画面のCSSファイル(テンプレート独自のCSSまたは外部のCSS)を取得
7079 * @param string $url 取得画面のURL
7082 function loadCssFilesByUrl($url)
7084 // ##### cURLを使用する場合はセッションのブロックを解除する #####
7085 session_write_close();
7088 curl_setopt($ch, CURLOPT_URL, $url);
7089 curl_setopt($ch, CURLOPT_USERAGENT, M3_SYSTEM_NAME . '/' . M3_SYSTEM_VERSION); // ユーザエージェント
7090 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 画面に出力しない
7091 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
7092 curl_setopt($ch, CURLOPT_TIMEOUT, 3);
7093 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); // セッションを維持
7094 $content = curl_exec($ch);
7098 $urlArray = array();
7100 $pattern = '/<head\b[^>]*?>(.*?)<\/head\b[^>]*?>/si';
7101 if (preg_match($pattern, $content, $matches)) $headContent = $matches[0];
7104 $pattern = '/<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>/si';
7105 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7106 foreach ($matches as $match){
7107 if (strEndsWith($match[1], '.css')){ // ファイル名の拡張子が「css」の場合
7108 $urlArray[] = $match[1];
7110 // typeが「text/css」を取得
7111 $attrPattern = '/type\s*=\s*[\'"]+(.+?)[\'"]/si';
7112 if (preg_match($attrPattern, $match[0], $attrMatch)){
7113 if (strcasecmp($attrMatch[1], 'text/css') == 0){
7114 $urlArray[] = $match[1];
7118 // relが「stylesheet」を取得
7119 $attrPattern = '/rel\s*=\s*[\'"]+(.+?)[\'"]/si';
7120 if (preg_match($attrPattern, $match[0], $attrMatch)){
7121 if (strcasecmp($attrMatch[1], 'stylesheet') == 0){
7122 $urlArray[] = $match[1];
7130 // ifで制御されているCSSファイルを除く
7131 $delUrlArray = array();
7132 $pattern = '/<!--\[if\b.*?\]>[\s\S]*<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>[\s\S]*<!\[endif\]-->/si';
7133 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7134 foreach ($matches as $match) $delUrlArray[] = $match[1];
7137 // ##### テンプレート独自のCSSまたは外部のCSSを取得する #####
7138 $this->ckeditorCssFiles = array();
7139 $cssFiles = array_merge(array_diff($urlArray, $delUrlArray)); // CKEditor用のCSSファイル
7140 for ($i = 0; $i < count($cssFiles); $i++){
7141 $cssFileUrl = $cssFiles[$i];
7143 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7144 $baseUrl = $this->gEnv->getRootUrl();
7145 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7146 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7149 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7151 if (strStartsWith($relativePath, '//')){ // URLが「//」で始まる外部ファイルの場合
7152 $this->ckeditorCssFiles[] = $cssFileUrl;
7153 } else if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){ // テンプレートディレクトリの場合
7154 $this->ckeditorCssFiles[] = $cssFileUrl;
7155 } else if (strStartsWith($relativePath, '/')){ // テンプレートディレクトリ以外のディレクトリの場合
7156 } else { // 外部URLの場合
7157 $this->ckeditorCssFiles[] = $cssFileUrl;
7162 $pattern = '/var\s*M3_TEMPLATE_TYPE\s*=\s*(\d+?)\s*;/si';
7163 if (preg_match($pattern, $headContent, $matches)) $this->ckeditorTemplateType = $matches[1]; // CKEditor用のテンプレートタイプ
7166 * CKEditor用のテンプレートタイプを取得
7168 * @return int テンプレートタイプ
7170 function getCkeditorTemplateType()
7172 return $this->ckeditorTemplateType;
7177 * @return bool true=正常、false=不正
7179 /* function _checkReferer()
7181 global $gEnvManager;
7182 global $gRequestManager;
7185 $referer = $gRequestManager->trimServerValueOf('HTTP_REFERER');
7186 $uri = $gEnvManager->getCurrentRequestUri();
7187 if (empty($referer) || $referer != $uri){
7194 * テンプレート画面を解析してCSSファイルやポジションの情報を取得
7196 * @param string $templateId テンプレートID
7197 * @return テンプレート情報オブジェクト
7199 function parseTemplate($templateId)
7201 // ##### cURLを使用する場合はセッションのブロックを解除する #####
7202 session_write_close();
7205 $url = $this->gEnv->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_SHOW_POSITION . '&template=' . $templateId;
7208 $tmplateInfoObj = new stdClass;
7209 $tmplateInfoObj->cssFiles = array(); // テンプレートで使用されているCSSファイル
7212 curl_setopt($ch, CURLOPT_URL, $url);
7213 curl_setopt($ch, CURLOPT_USERAGENT, M3_SYSTEM_NAME . '/' . M3_SYSTEM_VERSION); // ユーザエージェント
7214 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 画面に出力しない
7215 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
7216 curl_setopt($ch, CURLOPT_TIMEOUT, 3);
7217 curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id()); // セッションを維持
7218 $content = curl_exec($ch);
7222 $urlArray = array();
7224 $pattern = '/<head\b[^>]*?>(.*?)<\/head\b[^>]*?>/si';
7225 if (preg_match($pattern, $content, $matches)) $headContent = $matches[0];
7228 $pattern = '/<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>/si';
7229 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7230 foreach ($matches as $match){
7231 if (strEndsWith($match[1], '.css')){ // ファイル名の拡張子が「css」の場合
7232 $urlArray[] = $match[1];
7234 // typeが「text/css」を取得
7235 $attrPattern = '/type\s*=\s*[\'"]+(.+?)[\'"]/si';
7236 if (preg_match($attrPattern, $match[0], $attrMatch)){
7237 if (strcasecmp($attrMatch[1], 'text/css') == 0){
7238 $urlArray[] = $match[1];
7242 // relが「stylesheet」を取得
7243 $attrPattern = '/rel\s*=\s*[\'"]+(.+?)[\'"]/si';
7244 if (preg_match($attrPattern, $match[0], $attrMatch)){
7245 if (strcasecmp($attrMatch[1], 'stylesheet') == 0){
7246 $urlArray[] = $match[1];
7254 // ifで制御されているCSSファイルを除く
7255 $delUrlArray = array();
7256 $pattern = '/<!--\[if\b.*?\]>[\s\S]*<link[^<]*?href\s*=\s*[\'"]+(.+?)[\'"]+[^>]*?>[\s\S]*<!\[endif\]-->/si';
7257 if (preg_match_all($pattern, $headContent, $matches, PREG_SET_ORDER)){
7258 foreach ($matches as $match) $delUrlArray[] = $match[1];
7261 // テンプレート独自のCSSまたは外部のCSSを取得する
7262 $cssFiles = array_merge(array_diff($urlArray, $delUrlArray)); // CKEditor用のCSSファイル
7263 for ($i = 0; $i < count($cssFiles); $i++){
7264 $cssFileUrl = $cssFiles[$i];
7266 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7267 $baseUrl = $this->gEnv->getRootUrl();
7268 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7269 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7272 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7274 if (strStartsWith($relativePath, '//')){ // URLが「//」で始まる外部ファイルの場合
7275 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7276 } else if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){ // テンプレートディレクトリの場合
7277 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7278 } else if (strStartsWith($relativePath, '/')){ // テンプレートディレクトリ以外のディレクトリの場合
7279 } else { // 外部URLの場合
7280 $tmplateInfoObj->cssFiles[] = $cssFileUrl;
7285 for ($i = 0; $i < count($tmplateInfoObj->cssFiles); $i++){
7286 $cssFileUrl = $tmplateInfoObj->cssFiles[$i];
7289 if (strncasecmp($cssFileUrl, 'http://', strlen('http://')) == 0){
7290 $baseUrl = $this->gEnv->getRootUrl();
7291 } else if (strncasecmp($cssFileUrl, 'https://', strlen('https://')) == 0){
7292 $baseUrl = $this->gEnv->getSslRootUrl(); // SSLの場合
7295 $relativePath = str_replace($baseUrl, '', $cssFileUrl); // ルートURLからの相対パスを取得
7297 // テンプレート内のCSSの場合は相対パスに変換
7298 if (strStartsWith($relativePath, '/' . M3_DIR_NAME_TEMPLATES . '/')){// テンプレートディレクトリの場合
7299 $tmplateInfoObj->cssFiles[$i] = $relativePath;
7301 $tmplateInfoObj->cssFiles[$i] = $cssFileUrl;
7306 $tmplateInfoObj->positions = array();
7307 $pattern = '/var\s*M3_POSITION_DATA\s*=\s*[\'"]+(.+?)[\'"]/si';
7308 if (preg_match($pattern, $headContent, $matches) && !empty($matches[1])){
7309 $tmplateInfoObj->positions = explode(',', $matches[1]);
7311 return $tmplateInfoObj;
7314 * デフォルトのテンプレートからレイアウト用テンプレートで使用していないポジションを取得
7316 * @return array ポジション名の配列
7318 function getLayoutTemplatePosition()
7320 $removePositions = array('header', 'extra1', 'extra2', 'brand', 'hmenu', 'user3', 'banner1', 'top1', 'top2', 'top3',
7321 'left', 'banner2', 'breadcrumb', 'user1', 'user2', 'banner3', 'main-top', 'main', 'main-bottom', 'banner4', 'user4', 'user5', 'banner5',
7322 'right','bottom1', 'bottom2', 'bottom3', 'banner6', 'syndicate', 'copyright', 'footer'); // レイアウト用テンプレートに存在するので削除するポジション
7324 // URLパラメータからデフォルトのテンプレートを取得
7325 $pageId = $this->gRequest->trimValueOf(M3_REQUEST_PARAM_DEF_PAGE_ID);
7328 if ($pageId == $this->gEnv->getDefaultPageId()){ // 通常サイトのとき
7329 $templateId = $this->gSystem->defaultTemplateId();
7330 } else if ($pageId == $this->gEnv->getDefaultSmartphonePageId()){ // スマートフォン用サイトのとき
7331 $templateId = $this->gSystem->defaultSmartphoneTemplateId(); // スマートフォン用デフォルトテンプレート
7335 $ret = $this->db->getTemplate($templateId, $row);
7336 if (!$ret) return array();
7337 if (empty($row['tm_editor_param'])) return array();
7339 // レイアウト用テンプレートに存在しないポジション名のみ返す
7340 $editorParamObj = unserialize($row['tm_editor_param']);
7341 if (isset($editorParamObj)){
7342 if (isset($editorParamObj->positions)){
7343 $srcArray = $editorParamObj->positions;
7344 $destArray = array();
7345 for ($i = 0; $i < count($srcArray); $i++){
7346 $position = $srcArray[$i];
7347 if (!in_array($position, $removePositions)) $destArray[] = $position;