7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
9 * @package Magic3 Framework
10 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11 * @copyright Copyright 2006-2017 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_mainDb.php');
19 class admin_mainPagedefWidgetContainer extends BaseAdminWidgetContainer
21 private $db; // DB接続オブジェクト
22 private $serialNo; // シリアルNo
23 private $pageId; // ページID
24 private $pageSubId; // ページサブID
25 private $position; // 表示ポジション
26 private $defaultPageSubId; // デフォルトのページID
27 private $templateId; // テンプレートID
28 private $subTemplateId; // サブテンプレートID
29 private $pageTemplateId; // 個別ページのテンプレートID
30 private $pageSubTemplateId; // 個別ページのサブテンプレートID
31 private $pageTitle; // 選択ページのタイトル
32 private $templateTitle; // テンプレートタイトル
33 private $pageInfoRows; // ページ情報
34 private $isExistsDefItems; // ページ定義項目が存在するかどうか
35 private $subTemplateInfo; // サブテンプレート情報(Themler設定ファイルからの読み込み用)
36 const BREADCRUMB_TITLE = '画面構成';
37 const BREADCRUMB_TITLE_PC = 'PC画面'; // 画面タイトル名(パンくずリスト)
38 const BREADCRUMB_TITLE_MOBILE = '携帯画面'; // 画面タイトル名(パンくずリスト)
39 const BREADCRUMB_TITLE_SMARTPHONE = 'スマートフォン画面'; // 画面タイトル名(パンくずリスト)
40 const TEMPLATE_NORMAL_ICON_FILE = '/images/system/layout16.png'; // 通常テンプレートアイコン
41 const TEMPLATE_PLAIN_ICON_FILE = '/images/system/layout_plain16.png'; // デザインなしテンプレートアイコン
42 const TEMPLATE_NORMAL32_ICON_FILE = '/images/system/layout32.png'; // 通常テンプレートアイコン
43 const TEMPLATE_PLAIN32_ICON_FILE = '/images/system/layout_plain32.png'; // デザインなしテンプレートアイコン
44 const TEMPLATE_THUMBNAIL_FILENAME = 'template_thumbnail.png'; // テンプレートサムネール
45 const TEMPLATE_THUMBNAIL_FILENAME_WP = 'screenshot'; // テンプレートサムネール(WordPressテンプレート)
46 const PLAIN_TEMPLATE_ID = '_layout'; // デザインなしテンプレート
47 const TITLE_PRE_ICON_HOME = '<i class="glyphicon glyphicon-home" rel="m3help" title="トップページ"></i> '; // タイトル付加用アイコン(ホーム)
48 const TITLE_PRE_ICON_LOCK = '<i class="glyphicon glyphicon-lock" rel="m3help" title="SSL"></i> '; // タイトル付加用アイコン(鍵)
49 const TITLE_PRE_ICON_MINUS = '<i class="glyphicon glyphicon-minus-sign" rel="m3help" title="非表示"></i> '; // タイトル付加用アイコン(マイナス記号)
50 const BUTTON_ICON_TEMPLATE_CHECK = '<i class="glyphicon glyphicon-check"></i> '; // テンプレート一覧付加用アイコン(チェックあり)
51 const BUTTON_ICON_TEMPLATE_UNCHECKED = '<i class="glyphicon glyphicon-unchecked"></i> '; // テンプレート一覧付加用アイコン(チェックなし)
52 const BUTTON_ICON_TEMPLATE_CHECK_WITH_HELP = '<i class="glyphicon glyphicon-check" rel="m3help" title="ページに固定"></i> '; // テンプレート一覧付加用アイコン(チェックあり)
53 const HELP_SELECT_BUTTON = 'rel="m3help" title="ページに固定"'; // テンプレート一覧付加用ボタンのヘルプ(ページ専用テンプレート)
54 const TEMPLATE_TYPE_LABEL_BOOTSTRAP = ' <span class="label label-info" rel="m3help" title="Bootstrap型">B</span>'; // Boostrap型テンプレートラベル
55 const TEMPLATE_TYPE_LABEL_THEMLER = ' <span class="label label-info" rel="m3help" title="Themler製">T</span>'; // Themler製テンプレートラベル
56 const TEMPLATE_TYPE_LABEL_WORDPRESS = ' <span class="label label-info" rel="m3help" title="WordPress型">W</span>'; // WordPress型テンプレートラベル
61 function __construct()
64 parent::__construct();
67 $this->db = new admin_mainDb();
72 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
73 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
75 * @param RequestManager $request HTTPリクエスト処理クラス
76 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
77 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
79 function _setTemplate($request, &$param)
81 $task = $request->trimValueOf('task');
83 if ($task == 'pagedef_detail'){ // 詳細設定画面
84 return 'pagedef_detail.tmpl.html';
86 return 'pagedef.tmpl.html';
92 * ヘルプの設定を行う場合はヘルプIDを返す。
93 * ヘルプデータの読み込むディレクトリは「自ウィジェットディレクトリ/include/help」に固定。
95 * @param RequestManager $request HTTPリクエスト処理クラス
96 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
97 * @return string ヘルプID。ヘルプデータはファイル名「help_[ヘルプID].php」で作成。ヘルプを使用しない場合は空文字列「''」を返す。
99 function _setHelp($request, &$param)
106 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
108 * @param RequestManager $request HTTPリクエスト処理クラス
109 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
112 function _postAssign($request, &$param)
114 $task = $request->trimValueOf('task'); // 処理区分
117 $titles = array(self::BREADCRUMB_TITLE);
120 case 'pagedef_mobile': // 携帯用設定画面のとき
121 $titles[] = self::BREADCRUMB_TITLE_MOBILE;
123 case 'pagedef_smartphone': // スマートフォン用設定画面のとき
124 $titles[] = self::BREADCRUMB_TITLE_SMARTPHONE;
127 $titles[] = self::BREADCRUMB_TITLE_PC;
130 $this->gPage->setAdminBreadcrumbDef($titles);
135 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
137 * @param RequestManager $request HTTPリクエスト処理クラス
138 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
141 function _assign($request, &$param)
144 $localeText = array();
145 $localeText['label_page_id'] = $this->_('Page Id'); // ページID
146 $localeText['label_page_sub_id'] = $this->_('Page Id'); // ページサブID
147 $localeText['label_show_detail'] = $this->_('Show Detail'); // 詳細
148 $localeText['label_default_template'] = $this->_('Default Template'); // デフォルトテンプレート
149 $localeText['label_change_template'] = $this->_('Change Template'); // 変更
150 $localeText['label_page_layout'] = $this->_('Page Layout'); // 画面デザイン
151 $localeText['label_layout'] = $this->_('Layout'); // レイアウト
152 $localeText['label_preview'] = $this->_('Preview'); // プレビュー
153 $localeText['label_maximize'] = $this->_('Maximize'); // 最大化
154 $localeText['label_preview_in_other_window'] = $this->_('Preview in other window'); // 別画面でプレビュー
155 $localeText['label_site_preview'] = $this->_('Site Preview');// 実際の画面
156 $localeText['label_page'] = $this->_('Page'); // ページ
157 $localeText['label_template'] = $this->_('Template'); // テンプレート
158 $localeText['label_default_value'] = $this->_('Default Value'); // デフォルト値
161 $localeText['msg_update_line'] = $this->_('Update line data?'); // データを更新しますか?
162 $localeText['msg_delete_line'] = $this->_('Delete line data?'); // データを削除しますか?
163 $localeText['msg_delete_all_line'] = $this->_('Delete all line data?');// すべての項目を削除しますか?
164 $localeText['label_all'] = $this->_('All'); // すべて
165 $localeText['label_page_def_detail'] = $this->_('Page Definition Detail');// ページ定義詳細
166 $localeText['label_go_back'] = $this->_('Go back');// 戻る
167 $localeText['label_position'] = $this->_('Position');// ポジション名
168 $localeText['label_order'] = $this->_('Order');// 表示順
169 $localeText['label_widget_id'] = $this->_('Widget ID');// ウィジェットID
170 $localeText['label_widget_name'] = $this->_('Widget Name');// ウィジェット名
171 $localeText['label_config_id'] = $this->_('Config ID');// 定義ID
172 $localeText['label_visible'] = $this->_('Visible');// 表示
173 $localeText['label_shared'] = $this->_('Global');// グローバル属性
174 $localeText['label_operation'] = $this->_('Operation');// 操作
175 $localeText['label_shared_item'] = $this->_('Include global widgets.');// グローバル属性ウィジェット含む
176 $localeText['label_delete_all'] = $this->_('Delete all');// すべて削除
177 $this->setLocaleText($localeText);
179 $task = $request->trimValueOf('task');
180 if ($task == 'pagedef_detail'){ // 詳細設定画面
181 $this->createDetail($request);
183 $this->createView($request);
189 * @param RequestManager $request HTTPリクエスト処理クラス
192 function createView($request)
195 $task = $request->trimValueOf('task'); // 処理区分
196 $act = $request->trimValueOf('act');
197 $this->pageId = $request->trimValueOf('pageid'); // ページID
198 $this->pageSubId = $request->trimValueOf('pagesubid');// ページサブID
199 $layoutMode = $request->trimValueOf('layoutmode');// テンプレートモード(空=デザインテンプレート,plain=デザインなしテンプレート)
200 if (empty($this->pageId)){
202 case 'pagedef_mobile': // 携帯用設定画面のとき
203 $this->pageId = $this->gEnv->getDefaultMobilePageId(); // 携帯用デフォルト値取得
205 case 'pagedef_smartphone': // スマートフォン用設定画面のとき
206 $this->pageId = $this->gEnv->getDefaultSmartphonePageId(); // スマートフォン用デフォルト値取得
209 $this->pageId = $this->gEnv->getDefaultPageId(); // デフォルト値取得
213 if (empty($this->pageSubId)) $this->pageSubId = $this->gEnv->getDefaultPageSubIdByPageId($this->pageId);// デフォルト値取得
217 case 'pagedef_mobile': // 携帯用設定画面のとき
218 $this->templateId = $this->gSystem->defaultMobileTemplateId();
219 $deviceType = 1; // デバイスタイプ(携帯)
220 $taskStr = 'pagedef_mobile';
221 $previewWidth = '600px';
222 $this->tmpl->addVar("_widget", "preview_option_class", 'class="layout_top_border layout_side_border"'); // プレビューエリアにトップとサイドのボーダーラインを付加
223 $this->tmpl->addVar("_widget", "template_normal_disabled", 'disabled');
225 case 'pagedef_smartphone': // スマートフォン用設定画面
226 $this->templateId = $this->gSystem->defaultSmartphoneTemplateId();
227 $deviceType = 2; // デバイスタイプ(スマートフォン)
228 $taskStr = 'pagedef_smartphone';
229 $previewWidth = '600px';
230 $this->tmpl->addVar("_widget", "preview_option_class", 'class="layout_top_border layout_side_border"'); // プレビューエリアにトップとサイドのボーダーラインを付加
231 $this->tmpl->addVar("_widget", "template_normal_disabled", 'disabled');
234 $this->templateId = $this->gSystem->defaultTemplateId();
235 $this->subTemplateId = $this->gSystem->defaultSubTemplateId(); // サブテンプレートID
236 $deviceType = 0; // デバイスタイプ(PC)
237 $taskStr = 'pagedef';
238 $previewWidth = '100%';
239 $this->tmpl->addVar("_widget", "preview_option_class", 'class="layout_top_border"'); // プレビューエリアにトップのボーダーラインを付加
243 if ($act == 'changetemplate'){ // テンプレート変更のとき
244 $templateId = $request->trimValueOf('sel_template'); // テンプレートID
245 if (!empty($templateId)){
247 case 'pagedef_mobile': // 携帯用設定画面のとき
248 $this->gSystem->changeDefaultMobileTemplate($templateId);
250 case 'pagedef_smartphone': // スマートフォン用設定画面のとき
251 $this->gSystem->changeDefaultSmartphoneTemplate($templateId);
254 // Themlerテンプレートの場合はサブテンプレートIDを取得
255 $subTemplateId = $this->getDefaultSubTemplateId($templateId);
257 // 現在のテンプレート、サブテンプレートを変更
258 $this->gSystem->changeDefaultTemplate($templateId, $subTemplateId);
261 $request->setSessionValue(M3_SESSION_CURRENT_TEMPLATE, $templateId);
265 $this->gCache->clearAllCache();
268 $this->templateId = $templateId;
269 $this->subTemplateId = $subTemplateId;
271 // // デフォルトテンプレートを使用しているページのサブテンプレートIDは初期化
272 // // ページIDですべてのページ情報を取得
273 // $ret = $this->db->getPageInfoByPageId($this->pageId, ''/*言語*/, $pageInfoRows);
275 // for ($i = 0; $i < count($pageInfoRows); $i++){
276 // $pageInfo = $pageInfoRows[$i];
277 // $pageSubId = $pageInfo['pg_id'];
278 // $templateId = $pageInfo['pn_template_id'];
279 // if (!is_null($templateId)/*データ情報あり*/ && empty($templateId) && !empty($pageInfo['pn_sub_template_id'])){ // デフォルトテンプレートを使用、サブテンプレート設定ありの場合
280 // $ret = $this->db->getPageInfo($this->pageId, $pageSubId, $row);
281 // if ($ret) $this->db->updatePageInfo($this->pageId, $pageSubId, $row['pn_content_type'], $row['pn_template_id'], ''/*サブテンプレートID*/, $row['pn_auth_type'], $row['pn_use_ssl'], $row['pn_user_limited']);
286 } else if ($act == 'changepagetemplate'){ // 個別ページ用テンプレート選択
287 $templateId = $request->trimValueOf('sel_page_template'); // テンプレートID
290 // デフォルトと同じ場合はトグル切り替え
291 /* if ($templateId == $this->templateId){
292 $ret = $this->db->getPageInfo($this->pageId, $this->pageSubId, $row);
293 if ($ret && !is_null($row['pn_template_id'])){ // ページ情報レコードがある場合
294 if (empty($row['pn_template_id'])){
295 // 個別のテンプレート設定の場合はデフォルトのサブテンプレートIDを取得
296 $subTemplateId = $this->getDefaultSubTemplateId($templateId);
297 } else { // トグルオフの場合はテンプレートID、サブテンプレートIDを初期化
302 // 個別のテンプレート設定の場合はデフォルトのサブテンプレートIDを取得
303 $subTemplateId = $this->getDefaultSubTemplateId($templateId);
306 // 個別のテンプレート設定の場合はデフォルトのサブテンプレートIDを取得
307 $subTemplateId = $this->getDefaultSubTemplateId($templateId);
309 if (!empty($templateId)){
310 // 個別のテンプレート設定の場合はデフォルトのサブテンプレートIDを取得
311 $subTemplateId = $this->getDefaultSubTemplateId($templateId);
313 // 表示中のページについてページ情報更新
314 $ret = $this->db->getPageInfo($this->pageId, $this->pageSubId, $row);
316 if (is_null($row['pn_template_id'])){ // ページ情報レコードがない場合
317 $ret = $this->db->updatePageInfo($this->pageId, $this->pageSubId, ''/*コンテンツタイプ*/, $templateId, $subTemplateId);
319 // 既存の設定値と同じ場合はリセット(トグルオフ)
320 if ($templateId == $row['pn_template_id']){
325 $ret = $this->db->updatePageInfo($this->pageId, $this->pageSubId, $row['pn_content_type'], $templateId, $subTemplateId, $row['pn_auth_type'], $row['pn_use_ssl'], $row['pn_user_limited']);
329 } else if ($act == 'changesubtemplate'){ // サブテンプレート選択
330 $subTemplateId = $request->trimValueOf('subtemplateid'); // サブテンプレートID
331 // $ret = $this->db->getPageInfo($this->pageId, $this->pageSubId, $row);
333 // if (is_null($row['pn_content_type'])){ // ページ情報レコードがない場合
334 // $ret = $this->db->updatePageInfo($this->pageId, $this->pageSubId,''/*コンテンツタイプ*/, $row['pn_template_id'], $subTemplateId);
336 // $ret = $this->db->updatePageInfo($this->pageId, $this->pageSubId, $row['pn_content_type'], $row['pn_template_id'], $subTemplateId, $row['pn_auth_type'], $row['pn_use_ssl'], $row['pn_user_limited']);
339 $ret = $this->db->getPageInfo($this->pageId, $this->pageSubId, $row);
340 if ($ret){ // ページ情報レコードがある場合
341 if (is_null($row['pn_template_id'])){ // ページ情報部がない場合
343 $this->subTemplateId = $subTemplateId;
344 $this->gSystem->changeDefaultTemplate($this->templateId, $this->subTemplateId);
346 $templateId = $row['pn_template_id'];
347 if (empty($templateId)){ // 個別にテンプレートが設定されていない場合
349 $this->subTemplateId = $subTemplateId;
350 $this->gSystem->changeDefaultTemplate($this->templateId, $this->subTemplateId);
352 // 個別のページのサブテンプレートを変更
353 $ret = $this->db->updatePageInfo($this->pageId, $this->pageSubId, $row['pn_content_type'], $row['pn_template_id'], $subTemplateId, $row['pn_auth_type'], $row['pn_use_ssl'], $row['pn_user_limited']);
359 $ret = $this->db->getPageInfoByPageId($this->pageId, ''/*言語*/, $this->pageInfoRows);
362 $this->db->getPageIdList(array($this, 'pageIdLoop'), 0/*ページID*/, $deviceType);
364 // ページサブIDメニュー作成(ページメインIDを先に作成してから)。デバイスで共通。
365 $this->db->getPageIdList(array($this, 'pageSubIdLoop'), 1/*サブページID*/, -1/*デバイス関係なし*/, true/*メニューから選択可項目のみ*/);
368 /* $contentTypeStr = ''; // コンテンツ種別
369 $ret = $this->db->getPageInfo($this->pageId, $this->pageSubId, $row);
371 if (!empty($row['pn_content_type'])) $contentTypeStr = $this->_('Page Attribute:') . $row['pn_content_type']; // 「ページ属性:」
375 $this->db->getAllTemplateList($deviceType, array($this, 'templateIdLoop'));
378 $this->createSubTemplateMenu();
381 $this->tmpl->addVar("_widget", "page_title", $this->pageTitle); // ページタイトル(エスケープ済み)
382 $this->tmpl->addVar("_widget", "template_title", $this->templateTitle); // テンプレートタイトル(エスケープ済み)
386 $pathArray = explode('_', $this->pageId);
387 for ($i = 0; $i < count($pathArray); $i++){
388 $path .= '/' . $pathArray[$i];
390 $url = $this->gEnv->getRootUrlByPage($this->pageId, $this->pageSubId) . $path . '.php';
392 if ($this->pageSubId == $this->defaultPageSubId){
393 $urlWithSession = $url . '?' . $this->gAccess->getSessionIdUrlParam(); // セッションIDをURLに追加
395 $url .= '?sub=' . $this->pageSubId;
396 $dispUrl .= '?<strong>sub=' . $this->pageSubId . '</strong>';
397 $urlWithSession = $url . '&' . $this->gAccess->getSessionIdUrlParam(); // セッションIDをURLに追加
399 // デフォルトテンプレート、サブテンプレート
400 $defaultTemplate = $this->templateId;
401 if (!empty($this->subTemplateId)) $defaultTemplate .= '(' . $this->subTemplateId . ')'; // サブテンプレートがある場合は付加
403 $this->tmpl->addVar("_widget", "url", $url); // getUrl()は掛けない
404 $this->tmpl->addVar("_widget", "disp_url", $dispUrl); // 表示用URL
405 $this->tmpl->addVar("_widget", "url_with_session", $urlWithSession); // セッションID付きURL(携帯のみ使用)。getUrl()は掛けない
406 // $this->tmpl->addVar("_widget", "content_type", $contentTypeStr); // コンテンツ種別
407 $this->tmpl->addVar("_widget", "device_type", $deviceType); // デバイスタイプ
408 $this->tmpl->addVar("_widget", "preview_width", $previewWidth); // プレビュー幅
409 $this->tmpl->addVar("_widget", "task", $taskStr); // タスク
410 $this->tmpl->addVar("_widget", "default_template_id", $this->convertToDispString($defaultTemplate)); // デフォルトのテンプレートID
413 $adminUrl = $this->gEnv->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_DEF_PAGE_ID . '=' . $this->pageId . '&' . M3_REQUEST_PARAM_DEF_PAGE_SUB_ID . '=' . $this->pageSubId;
414 $this->tmpl->addVar("_widget", "admin_url", $this->getUrl($adminUrl));
417 $iconUrl = $this->gEnv->getRootUrl() . self::TEMPLATE_NORMAL_ICON_FILE;
418 $this->tmpl->addVar("_widget", "template_normal", $this->getUrl($iconUrl));
419 $iconUrl = $this->gEnv->getRootUrl() . self::TEMPLATE_PLAIN_ICON_FILE;
420 $this->tmpl->addVar("_widget", "template_plain", $this->getUrl($iconUrl));
421 $iconUrl = $this->gEnv->getRootUrl() . self::TEMPLATE_NORMAL32_ICON_FILE;
422 $this->tmpl->addVar("_widget", "template_normal32", $this->getUrl($iconUrl));
423 $iconUrl = $this->gEnv->getRootUrl() . self::TEMPLATE_PLAIN32_ICON_FILE;
424 $this->tmpl->addVar("_widget", "template_plain32", $this->getUrl($iconUrl));
426 // テンプレートモード(空=デザインテンプレート,plain=デザインなしテンプレート)を再設定
427 $this->tmpl->addVar("_widget", "layout_mode", $layoutMode);
428 if (empty($layoutMode)){
429 $this->tmpl->addVar("_widget", "template_normal_style", 'display:inline;');
430 $this->tmpl->addVar("_widget", "template_plain_style", 'display:none;');
431 $previewTemplateParam = '';
433 $this->tmpl->addVar("_widget", "template_normal_style", 'display:none;');
434 $this->tmpl->addVar("_widget", "template_plain_style", 'display:inline;');
435 $previewTemplateParam = '&' . M3_REQUEST_PARAM_TEMPLATE_ID . '=' . self::PLAIN_TEMPLATE_ID;// プレビュー用のテンプレートID
437 $this->tmpl->addVar("_widget", "plain_template_id", self::PLAIN_TEMPLATE_ID); // デザインなしテンプレートID
438 $this->tmpl->addVar("_widget", "preview_template_param", $previewTemplateParam); // プレビュー用のテンプレートID
440 if ($this->db->canDetailConfig()){ // 詳細設定可のときは、ページID選択を可にする
441 $this->tmpl->setAttribute('show_access_point', 'visibility', 'visible');// アクセスポイント選択メニュー
442 $this->tmpl->addVar('_widget', 'page_id_col', 'colspan="4"'); // カラム数を調整
444 $this->tmpl->addVar('_widget', 'page_id_col', 'colspan="2"'); // カラム数を調整
450 * @param RequestManager $request HTTPリクエスト処理クラス
453 function createDetail($request)
455 $act = $request->trimValueOf('act');
456 $this->serialNo = $request->trimValueOf('serial'); // 選択項目のシリアル番号
457 $this->pageId = $request->trimValueOf('pageid'); // ページID
458 $this->pageSubId = $request->trimValueOf('pagesubid');// ページサブID
459 if (empty($this->pageId)) $this->pageId = $this->gEnv->getDefaultPageId(); // デフォルト値取得
460 if (empty($this->pageSubId)) $this->pageSubId = $this->gEnv->getDefaultPageSubIdByPageId($this->pageId);// デフォルト値取得
461 $this->position = $request->trimValueOf('position'); // 表示ポジション
463 if ($act == 'updateline'){ // 更新のとき
465 $selectedItemNo = $request->trimValueOf('no'); // 処理対象の項目番号
466 $updateIndex = $request->trimValueOf('item' . $selectedItemNo . '_index'); // 表示インデックス
467 $instanceDefId = $request->trimValueOf('item' . $selectedItemNo . '_def_id'); // 定義ID
468 if ($instanceDefId == '') $instanceDefId = 0;
469 $updateVisible = ($request->trimValueOf('item' . $selectedItemNo . '_visible') == 'on') ? 1 : 0; // 表示状態
472 if ($this->db->getPageDef($this->serialNo, $row)){
473 //$updatePageSubId = $row['pd_sub_id'];
474 $updatePos = $row['pd_position_id'];
475 $updateWidgetId = $row['pd_widget_id'];
477 // 「グローバル」項目に合わせて、ページサブIDの修正
478 $updatePageSubId = '';// グローバル属性使用
479 if ($request->trimValueOf('item' . $selectedItemNo . '_shared') != 'on') $updatePageSubId = $this->pageSubId;
482 $this->checkNumeric($updateIndex, $this->_('Order')); // 表示順
485 if ($this->getMsgCount() == 0){
486 $ret = $this->db->updatePageDef($this->serialNo, $this->pageId, $updatePageSubId, $updatePos, $updateIndex, $updateWidgetId, $instanceDefId,
487 '', '', $updateVisible);
488 if ($ret){ // データ更新成功のとき
489 $this->setMsg(self::MSG_GUIDANCE, $this->_('Data updated.')); // データを更新しました
491 $this->setMsg(self::MSG_APP_ERR, $this->_('Failed in updating data.')); // データ更新に失敗しました
495 $this->setMsg(self::MSG_APP_ERR, $this->_('Failed in updating data.')); // データ更新に失敗しました
498 $this->gCache->clearAllCache();
499 } else if ($act == 'deleteline'){ // 削除のとき
500 $ret = $this->db->delPageDef($this->serialNo);
501 if ($ret){ // データ削除成功のとき
502 $this->setMsg(self::MSG_GUIDANCE, $this->_('Data deleted.')); // データを削除しました
504 $this->setMsg(self::MSG_APP_ERR, $this->_('Failed in deleting data.')); // データ削除に失敗しました
507 $this->gCache->clearAllCache();
508 } else if ($act == 'deleteall'){ // すべて削除のとき
509 $withCommon = ($request->trimValueOf('with_common') == 'on') ? 1 : 0; // グローバル属性項目も削除するかどうか
510 $ret = $this->db->delPageDefAll($this->pageId, $this->pageSubId, $this->position, $withCommon);
511 if ($ret){ // データ削除成功のとき
512 $this->setMsg(self::MSG_GUIDANCE, $this->_('Data deleted.')); // データを削除しました
514 $this->setMsg(self::MSG_APP_ERR, $this->_('Failed in deleting data.')); // データ削除に失敗しました
517 $this->gCache->clearAllCache();
521 $this->db->getPageDefList(array($this, 'pageListLoop'), $this->pageId, $this->pageSubId, $this->position);
522 if (!$this->isExistsDefItems) $this->tmpl->setAttribute('page_def_list', 'visibility', 'hidden');
525 $this->db->getPagePositionList(array($this, 'pagePositionLoop'));
528 $this->tmpl->addVar('_widget', 'pageid', $this->pageId); // ページID
529 $this->tmpl->addVar('_widget', 'pagesubid', $this->pageSubId); // ページサブID
533 $pathArray = explode('_', $this->pageId);
534 for ($i = 0; $i < count($pathArray); $i++){
535 $path .= '/' . $pathArray[$i];
537 //$url = $this->gEnv->getRootUrl() . $path . '.php';
538 $url = $this->gEnv->getRootUrlByPage($this->pageId, $this->pageSubId) . $path . '.php';
539 if ($this->pageSubId != $this->defaultPageSubId){
540 $url .= '?sub=' . $this->pageSubId;
542 $this->tmpl->addVar("_widget", "url", $url);// getUrl()は掛けない
545 * ページ定義、取得したデータをテンプレートに設定する
547 * @param int $index 行番号(0~)
548 * @param array $fetchedRow フェッチ取得した行
549 * @param object $param 未使用
550 * @return bool true=処理続行の場合、false=処理終了の場合
552 function pageListLoop($index, $fetchedRow, $param)
554 // サブIDが空のときは、グローバル属性ウィジェットとする
556 if (empty($fetchedRow['pd_sub_id'])){
557 $isSharedItem = 'checked';
559 // 編集不可項目のときは、ボタンを使用不可にする
561 if (!$fetchedRow['pd_editable']) $buttonEnabled = 'disabled';
563 // 設定画面がない場合はボタンを使用不可にする
564 $configButtonEnabled = '';
565 if (!$fetchedRow['wd_has_admin']) $configButtonEnabled = 'disabled';
569 if ($fetchedRow['pd_visible']) $itemVisible = 'checked';
572 $defId = $fetchedRow['pd_config_id'];
574 $sharedColorClass = ''; // ウィジェットの共有状態
575 if (empty($fetchedRow['pd_sub_id'])){
576 $sharedColorClass = 'class="danger"';
578 $sharedColorClass = 'class="success"';
582 'no' => $index + 1, // 行番号
583 'serial' => $this->convertToDispString($fetchedRow['pd_serial']), // シリアルNo
584 // 'id' => $this->convertToDispString($fetchedRow['wd_id']), // ウィジェットID
585 'name' => $this->convertToDispString($fetchedRow['wd_name']), // 名前
586 'position' => $this->convertToDispString($fetchedRow['pd_position_id']), // 表示ポジション
587 'shared_color' => $sharedColorClass, // ウィジェットの共有状態
588 'index' => $this->convertToDispString($fetchedRow['pd_index']), // 表示順
589 'widget_id' => $this->convertToDispString($fetchedRow['pd_widget_id']), // ウィジェットID
590 'widget_name' => $this->convertToDispString($fetchedRow['wd_name']), // ウィジェット名
591 'def_id' => $this->convertToDispString($defId), // 定義ID
592 'suffix' => $this->convertToDispString($fetchedRow['pd_suffix']), // サフィックス
593 'shared' => $isSharedItem, // グローバル属性ウィジェットかどうか
594 'visible' => $itemVisible, // 画面に表示するかどうか
595 'update_line' => $this->convertToDispString($this->_('Update line')), // 行を更新
596 'delete_line' => $this->convertToDispString($this->_('Delete line')), // 行を削除
597 'update_button' => $buttonEnabled, // 行更新ボタン
598 'delete_button' => $buttonEnabled, // 行削除ボタン
599 'config_button_disabled' => $configButtonEnabled, // 設定画面表示ボタン
600 'label_config_window' => $this->_('Show config window'), // 設定画面を表示
602 $this->tmpl->addVars('page_def_list', $row);
603 $this->tmpl->parseTemplate('page_def_list', 'a');
605 $this->isExistsDefItems = true; // ページ定義項目が存在するかどうか
609 * ページID、取得したデータをテンプレートに設定する
611 * @param int $index 行番号(0~)
612 * @param array $fetchedRow フェッチ取得した行
613 * @param object $param 未使用
614 * @return bool true=処理続行の場合、false=処理終了の場合
616 function pageIdLoop($index, $fetchedRow, $param)
619 if ($fetchedRow['pg_id'] == $this->pageId){
620 $selected = 'selected';
623 $this->defaultPageSubId = $fetchedRow['pg_default_sub_id']; // デフォルトのページID
625 $name = $this->convertToDispString($fetchedRow['pg_id']) . ' - ' . $this->convertToDispString($fetchedRow['pg_name']); // ページ名
627 'value' => $this->convertToDispString($fetchedRow['pg_id']), // ページID
628 'name' => $name, // ページ名
629 'selected' => $selected // 選択中かどうか
631 $this->tmpl->addVars('access_point_list', $row);
632 $this->tmpl->parseTemplate('access_point_list', 'a');
636 * ページサブID、取得したデータをテンプレートに設定する
638 * @param int $index 行番号(0~)
639 * @param array $fetchedRow フェッチ取得した行
640 * @param object $param 未使用
641 * @return bool true=処理続行の場合、false=処理終了の場合
643 function pageSubIdLoop($index, $fetchedRow, $param)
647 $value = $fetchedRow['pg_id'];
653 $useSsl = false; // SSL使用状況
654 $pageInfoCount = count($this->pageInfoRows);
655 for ($i = 0; $i < $pageInfoCount; $i++){
656 $pageInfo = $this->pageInfoRows[$i];
657 if ($pageInfo['pg_id'] == $value){
658 $contentType = strval($pageInfo['pn_content_type']); // NULL値あり
659 $templateId = $pageInfo['pn_template_id'];
660 $subTemplateId = $pageInfo['pn_sub_template_id'];
661 $useSsl = $pageInfo['pn_use_ssl'];
662 if ($value == $this->pageSubId){ // 表示中のページの場合
663 $this->pageTemplateId = $templateId; // 個別ページのテンプレートID
664 $this->pageSubTemplateId = $subTemplateId; // サブテンプレートID
671 $name = $this->convertToDispString($fetchedRow['pg_name']);
672 $nameWithAttr = $name . '(' . $this->convertToDispString($value) . ')';
677 if ($value == $this->defaultPageSubId) $preTitle .= self::TITLE_PRE_ICON_HOME; // デフォルトページ(homeアイコン)
678 if ($useSsl) $preTitle .= self::TITLE_PRE_ICON_LOCK; // SSL使用ページ(鍵アイコン)
679 if (!$fetchedRow['pg_active']) $preTitle .= self::TITLE_PRE_ICON_MINUS; // 非表示ページ(非表示アイコン)
680 $pageTitle = $preTitle . $name; // 選択ページのタイトル
683 if ($value == $this->pageSubId){
684 $selected = 'selected';
685 $checked = 'checked';
687 $this->pageTitle = $preTitle . $nameWithAttr; // 選択ページのタイトル
688 // if ($value == $this->defaultPageSubId) $this->pageTitle .= ' [' . $this->_('Default') . ']'; // デフォルトのページサブIDのときは、説明を付加
689 // if (!$fetchedRow['pg_active']) $this->pageTitle .= ' [' . $this->_('Unpublished') . ']'; // 非公開
693 if ($value == $this->defaultPageSubId) $nameWithAttr .= ' [' . $this->_('Default') . ']'; // デフォルトのページサブIDのときは、説明を付加
694 if (!$fetchedRow['pg_active']) $nameWithAttr .= ' [' . $this->_('Unpublished') . ']'; // 非公開
697 $dispTemplateId = $templateId;
698 if (!empty($subTemplateId)) $dispTemplateId .= '(' . $subTemplateId . ')';
701 'value' => $this->convertToDispString($value), // ページID
702 'name' => $nameWithAttr, // ページ名
703 'selected' => $selected, // 選択中かどうか
705 'col_title' => $pageTitle, // ページ名
706 'col_id' => $this->convertToDispString($value), // ページID
707 'col_content_type' => $this->convertToDispString($contentType), // コンテンツタイプ
708 // 'col_template_id' => $this->convertToDispString($templateId), // テンプレートID
709 'col_template_id' => $this->convertToDispString($dispTemplateId), // テンプレートID
710 'col_checked' => $checked // 選択状態
712 $this->tmpl->addVars('sub_id_list', $row);
713 $this->tmpl->parseTemplate('sub_id_list', 'a');
719 * @param int $index 行番号(0~)
720 * @param array $fetchedRow フェッチ取得した行
721 * @param object $param 未使用
722 * @return bool true=処理続行の場合、false=処理終了の場合
724 function templateIdLoop($index, $fetchedRow, $param)
726 $value = $fetchedRow['tm_id'];
727 $name = $fetchedRow['tm_name'];
728 $type = $fetchedRow['tm_type']; // テンプレートタイプ
729 $generator = $fetchedRow['tm_generator']; // テンプレート作成アプリケーション
733 if ($value == $this->templateId){ // デフォルトのテンプレート
734 $selected = 'selected';
735 $checked = 'checked';
737 if (empty($this->templateTitle)){
738 $this->templateTitle = $this->convertToDispString($name); // 選択テンプレートのタイトル
741 if (10 <= $type && $type < 20){ // Bootstrap型
742 $this->templateTitle .= self::TEMPLATE_TYPE_LABEL_BOOTSTRAP;
743 } else if ($type == 100){ // WordPress型
744 $this->templateTitle .= self::TEMPLATE_TYPE_LABEL_WORDPRESS;
745 } else if ($generator == M3_TEMPLATE_GENERATOR_THEMLER){ // Themler製テンプレートの場合
746 $this->templateTitle .= self::TEMPLATE_TYPE_LABEL_THEMLER;
751 if ($type == 100){ // WordPressテンプレートの場合
753 foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext){
754 $imgPath = $this->gEnv->getTemplatesPath() . '/' . $value . '/' . self::TEMPLATE_THUMBNAIL_FILENAME_WP . '.' . $ext;
755 if (file_exists($imgPath)){
756 $imageUrl = $this->gEnv->getTemplatesUrl() . '/' . $value . '/' . self::TEMPLATE_THUMBNAIL_FILENAME_WP . '.' . $ext;
761 $imageUrl = $this->gEnv->getTemplatesUrl() . '/' . $value . '/' . self::TEMPLATE_THUMBNAIL_FILENAME;
763 $imagetTag = '<img src="' . $imageUrl . '" name="templatepreview" border="1" width="70" height="45" />';
766 if ($value == $this->pageTemplateId){ // 個別ページのテンプレートID
767 $selectButtonIcon = self::BUTTON_ICON_TEMPLATE_CHECK;
768 $selectButtonHelp = self::HELP_SELECT_BUTTON;
770 // テンプレートのタイトルを個別ページのテンプレートに変更
771 $this->templateTitle = self::BUTTON_ICON_TEMPLATE_CHECK_WITH_HELP . $this->convertToDispString($this->pageTemplateId); // 選択テンプレートのタイトル
774 if (10 <= $type && $type < 20){ // Bootstrap型
775 $this->templateTitle .= self::TEMPLATE_TYPE_LABEL_BOOTSTRAP;
776 } else if ($type == 100){ // WordPress型
777 $this->templateTitle .= self::TEMPLATE_TYPE_LABEL_WORDPRESS;
778 } else if ($generator == M3_TEMPLATE_GENERATOR_THEMLER){ // Themler製テンプレートの場合
779 $this->templateTitle .= self::TEMPLATE_TYPE_LABEL_THEMLER;
782 $selectButtonIcon = self::BUTTON_ICON_TEMPLATE_UNCHECKED;
783 $selectButtonHelp = self::HELP_SELECT_BUTTON;
785 $selectTag = '<span ' . $selectButtonHelp . '><a class="btn btn-sm btn-default" onclick="changePageTemplate(\'' . $value . '\');return false;">' . $selectButtonIcon . '</a></span>';
788 'value' => $this->convertToDispString($value), // テンプレートID
789 'name' => $this->convertToDispString($name), // テンプレート名名
790 'selected' => $selected, // 選択中かどうか
792 'col_id' => $this->convertToDispString($value), // テンプレートID
793 'col_image' => $imagetTag, // テンプレート画像
794 'col_checked' => $checked, // 選択状態
795 'col_select' => $selectTag // 個別選択
797 $this->tmpl->addVars('sel_template_list', $row);
798 $this->tmpl->parseTemplate('sel_template_list', 'a');
802 * ページポジション、取得したデータをテンプレートに設定する
804 * @param int $index 行番号(0~)
805 * @param array $fetchedRow フェッチ取得した行
806 * @param object $param 未使用
807 * @return bool true=処理続行の場合、false=処理終了の場合
809 function pagePositionLoop($index, $fetchedRow, $param)
813 if ($fetchedRow['tp_id'] == $this->position){
814 $selected = 'selected';
817 'value' => $this->convertToDispString($fetchedRow['tp_id']), // ページID
818 'name' => $this->convertToDispString($fetchedRow['tp_name']), // ページ名
819 'selected' => $selected // 選択中かどうか
821 $this->tmpl->addVars('position_list', $row);
822 $this->tmpl->parseTemplate('position_list', 'a');
830 function createSubTemplateMenu()
833 $selectedTemplateId = $this->templateId;
834 if (!empty($this->pageTemplateId)) $selectedTemplateId = $this->pageTemplateId;// 個別ページのテンプレートが選択されている場合は優先
836 $ret = $this->db->getTemplate($selectedTemplateId, $row);
839 $generator = $row['tm_generator'];
840 $version = $row['tm_version']; // テンプレートバージョン
842 case M3_TEMPLATE_GENERATOR_THEMLER: // Themler
844 $this->tmpl->setAttribute('select_subtemplate', 'visibility', 'visible');
846 $subTemplateInfoFile = $this->gEnv->getTemplatesPath() . '/' . $selectedTemplateId . '/templates/list.php';
847 if (is_readable($subTemplateInfoFile)){
848 // サブテンプレート情報ファイル読み込み
849 require_once($subTemplateInfoFile);
850 if (!isset($this->subTemplateInfo)) $this->subTemplateInfo = $templatesInfo; // ローカル変数へコピー
855 'name' => $this->convertToDispString('-- ' . $this->_('No Select') . ' --'),
856 'selected' => '' // 選択中かどうか
858 $this->tmpl->addVars('subtemplate_list', $row);
859 $this->tmpl->parseTemplate('subtemplate_list', 'a');*/
861 foreach ($this->subTemplateInfo as $key => $templateInfo){
862 $subTemplateId = $templateInfo['fileName'];
863 $type = $templateInfo['kind'];
864 if (empty($subTemplateId)) continue;
865 if ($type == 'error404') continue; // エラーメッセージ表示用の404タイプのサブテンプレートは表示しない
868 if (empty($this->pageTemplateId)){ // ページ個別のテンプレートが設定されていない場合
869 if ($subTemplateId == $this->subTemplateId) $selected = 'selected'; // サブテンプレートID
871 if ($subTemplateId == $this->pageSubTemplateId) $selected = 'selected'; // サブテンプレートID
875 'value' => $this->convertToDispString($subTemplateId),
876 'name' => $this->convertToDispString($templateInfo['defaultTemplateCaption'] . '(' . $templateInfo['fileName'] . ')'),
877 'selected' => $selected // 選択中かどうか
879 $this->tmpl->addVars('subtemplate_list', $row);
880 $this->tmpl->parseTemplate('subtemplate_list', 'a');
887 * デフォルトのサブテンプレートIDを取得
889 * @param string $templateId テンプレートID
890 * @return string サブテンプレートID
892 function getDefaultSubTemplateId($templateId)
896 $ret = $this->db->getTemplate($templateId, $row);
897 if (!$ret) return $subTemplateId;
899 $generator = $row['tm_generator'];
900 $version = $row['tm_version']; // テンプレートバージョン
902 case M3_TEMPLATE_GENERATOR_THEMLER: // Themler
903 // デフォルトのサブテンプレートIDを取得
904 $subTemplateInfoFile = $this->gEnv->getTemplatesPath() . '/' . $templateId . '/templates/list.php';
905 if (is_readable($subTemplateInfoFile)){
906 // サブテンプレート情報ファイル読み込み
907 require_once($subTemplateInfoFile);
908 if (!isset($this->subTemplateInfo)) $this->subTemplateInfo = $templatesInfo; // ローカル変数へコピー
910 foreach ($this->subTemplateInfo as $key => $templateInfo){
911 $id = $templateInfo['fileName'];
912 $type = $templateInfo['kind'];
913 if (empty($id)) continue;
915 if ($type == 'default'){
916 $subTemplateId = $id;
923 return $subTemplateId;