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-2018 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getWidgetContainerPath('default_content') . '/admin_default_contentBaseWidgetContainer.php');
17 require_once($gEnvManager->getLibPath() . '/qqFileUploader/fileuploader.php');
18 require_once($gEnvManager->getCommonPath() . '/valueCheck.php');
20 class admin_default_contentContentWidgetContainer extends admin_default_contentBaseWidgetContainer
22 private $serialNo; // 選択中の項目のシリアル番号
23 private $serialArray = array(); // 表示されているコンテンツシリアル番号
24 private $selectedItem = array(); // 選択中の項目
25 private $attachFileInfoArray; // 添付ファイルの情報
26 private $fieldValueArray; // ユーザ定義フィールド入力値
27 private $completed; // データ登録完了かどうか
28 private $isExistsContent; // コンテンツ項目が存在するかどうか
29 private $isMultiLang; // 多言語対応画面かどうか
30 private $isOpenOptionArea; // 拡張エリアを開くかどうか
31 private $pluginIdArray = array(); // jQueryプラグインのID
32 private $selectedPlugin = array(); // 選択しているjQueryプラグイン
33 private $addLib = array(); // 追加スクリプトライブラリ
34 private $templateId; // テンプレートID
35 private $subTemplateId; // サブテンプレートID
36 private $subTemplateInfo; // サブテンプレート情報
37 private $isExistsSubTemplate; // サブテンプレートが存在するかどうか
38 const ICON_SIZE = 32; // アイコンのサイズ
39 const PANEL_BUTTON_SIZE = 32; // 拡張エリア制御ボタンサイズ
40 const INC_INDEX = 1; // メニュー項目表示順の増加分
41 const ADMIN_WIDGET_ID = 'admin_main'; // 管理ウィジェットのウィジェットID
42 const CALENDAR_ICON_FILE = '/images/system/calendar.png'; // カレンダーアイコン
43 const ACTIVE_ICON_FILE = '/images/system/active32.png'; // 公開中アイコン
44 const INACTIVE_ICON_FILE = '/images/system/inactive32.png'; // 非公開アイコン
45 const ADD_TO_MENU_ICON_FILE = '/images/system/addtomenu32.png'; // メニューに追加用アイコン
46 const PREVIEW_ICON_FILE = '/images/system/window32.png'; // プレビュー用アイコン
47 const OPEN_PANEL_ICON_FILE = '/images/system/plus32.png'; // 拡張エリア表示用アイコン
48 const CLOSE_PANEL_ICON_FILE = '/images/system/minus32.png'; // 拡張エリア非表示用アイコン
49 const DELETE_ICON_FILE = '/images/system/delete32.png'; // 行削除用アイコン
50 const LANG_ICON_PATH = '/images/system/flag/'; // 言語アイコンパス
51 const MSG_UPDATE_CONTENT = 'コンテンツを更新しました'; // コンテンツ更新メッセージ
52 const DEFAULT_SEARCH_KEY = '1'; // デフォルトの検索キー(更新日時)
53 const DEFAULT_SEARCH_ORDER = '1'; // デフォルトの検索ソート順(降順)
54 const DEFAULT_LIST_COUNT = 20; // 最大リスト表示数
55 const LINK_PAGE_COUNT = 20; // リンクページ数
56 const DEFAULT_PASSWORD = '********'; // 設定済みを示すパスワード
57 const LOG_MSG_ADD_CONTENT = '汎用コンテンツ(%s)を追加しました。タイトル: %s';
58 const LOG_MSG_UPDATE_CONTENT = '汎用コンテンツ(%s)を更新しました。タイトル: %s';
59 const LOG_MSG_DEL_CONTENT = '汎用コンテンツ(%s)を削除しました。タイトル: %s';
60 const FIELD_HEAD = 'item_'; // フィールド名の先頭文字列
61 const LIB_ITEM_HEAD = 'item_lib_'; // 選択ライブラリの項目名ヘッダ
62 const LIB_CODEMIRROR_JAVASCRIPT = 'codemirror.javascript'; // CodeMirror Javascript
63 const TAG_ID_ACTIVE_TERM = 'activeterm_button'; // 公開期間エリア表示用ボタンタグ
64 const TOOLTIP_ACTIVE_TERM = '公開期間を設定'; // 公開期間エリア表示用ボタンツールチップ
65 const CHANGE_URL_TAG_ID = 'changeurl'; // URL変更ボタンタグID
70 function __construct()
73 parent::__construct();
75 $this->isMultiLang = $this->gEnv->isMultiLanguageSite(); // 多言語対応画面かどうか
80 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
81 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
83 * @param RequestManager $request HTTPリクエスト処理クラス
84 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
85 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
87 function _setTemplate($request, &$param)
90 $task = $request->trimValueOf('task');
92 case self::TASK_CONTENT: // コンテンツ管理
94 $filename = 'admin.tmpl.html';
96 case self::TASK_CONTENT_DETAIL: // 詳細画面
97 $filename = 'admin_detail.tmpl.html';
105 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
107 * @param RequestManager $request HTTPリクエスト処理クラス
108 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
111 function _assign($request, &$param)
113 $task = $request->trimValueOf('task');
115 case self::TASK_CONTENT: // コンテンツ管理
117 $this->createList($request);
119 case self::TASK_CONTENT_DETAIL: // 詳細画面
120 $this->createDetail($request);
127 * @param RequestManager $request HTTPリクエスト処理クラス
130 function createList($request)
133 $userId = $this->gEnv->getCurrentUserId();
134 $this->langId = $this->gEnv->getDefaultLanguage();
137 $maxListCount = self::DEFAULT_LIST_COUNT;
140 $pageNo = $request->trimIntValueOf(M3_REQUEST_PARAM_PAGE_NO, '1'); // ページ番号
141 $searchKeyword = $request->trimValueOf('search_keyword'); // 検索キーワード
142 $searchKey = $request->trimValueOf('search_key'); // 検索ソートキー
143 if ($searchKey == '') $searchKey = self::DEFAULT_SEARCH_KEY;
144 $searchOrder = $request->trimValueOf('search_order'); // 検索ソート順
145 if ($searchOrder == '') $searchOrder = self::DEFAULT_SEARCH_ORDER;
147 $act = $request->trimValueOf('act');
148 if ($act == 'delete'){ // 項目削除の場合
149 $listedItem = explode(',', $request->trimValueOf('seriallist'));
151 for ($i = 0; $i < count($listedItem); $i++){
153 $itemName = 'item' . $i . '_selected';
154 $itemValue = ($request->trimValueOf($itemName) == 'on') ? 1 : 0;
156 if ($itemValue){ // チェック項目
157 $delItems[] = $listedItem[$i];
160 if (count($delItems) > 0){
162 $delContentInfo = array();
163 for ($i = 0; $i < count($delItems); $i++){
164 $ret = self::$_mainDb->getContentBySerial($delItems[$i], $row);
166 $newInfoObj = new stdClass;
167 $newInfoObj->contentId = $row['cn_id']; // コンテンツID
168 $newInfoObj->name = $row['cn_name']; // コンテンツ名前
169 $newInfoObj->thumb = $row['cn_thumb_filename']; // サムネール
170 $delContentInfo[] = $newInfoObj;
174 // 多言語対応状態に関わらずコンテンツIDで削除
175 //if ($this->isMultiLang){ // 多言語対応のとき
176 $ret = self::$_mainDb->delContentItemById($delItems);
178 // $ret = self::$_mainDb->delContentItem($delItems);
182 for ($i = 0; $i < count($delContentInfo); $i++){
183 $infoObj = $delContentInfo[$i];
186 if (!empty($infoObj->thumb)){
187 $oldFiles = explode(';', $infoObj->thumb);
188 $this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_CONTENT, default_contentCommonDef::$_deviceType, $oldFiles);
192 $ret = $this->gInstance->getFileManager()->delAttachFileInfoByContentId(default_contentCommonDef::$_viewContentType,
193 $infoObj->contentId, default_contentCommonDef::getAttachFileDir());
198 if ($ret){ // データ削除成功のとき
199 // ##### アクセスキー情報を削除 #####
200 for ($i = 0; $i < count($delContentInfo); $i++){
201 $infoObj = $delContentInfo[$i];
202 $this->gAccess->unegistAllSessionAccessKey($infoObj->contentId); // 一旦すべて削除
205 $this->setGuidanceMsg('データを削除しました');
208 for ($i = 0; $i < count($delItems); $i++){
209 $this->clearCacheBySerial($delItems[$i]);
213 for ($i = 0; $i < count($delContentInfo); $i++){
214 $infoObj = $delContentInfo[$i];
215 $contentAttr = default_contentCommonDef::$_deviceTypeName;
216 //$this->gOpeLog->writeUserInfo(__METHOD__, sprintf(self::LOG_MSG_DEL_CONTENT, $contentAttr, $infoObj->name), 2100, 'ID=' . $infoObj->contentId);
217 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_CONTENT,
218 M3_EVENT_HOOK_PARAM_CONTENT_ID => $infoObj->contentId,
219 M3_EVENT_HOOK_PARAM_UPDATE_DT => date("Y/m/d H:i:s"));
220 $this->writeUserInfoEvent(__METHOD__, sprintf(self::LOG_MSG_DEL_CONTENT, $contentAttr, $infoObj->name), 2402, 'ID=' . $infoObj->contentId, $eventParam);
223 $this->setAppErrorMsg('データ削除に失敗しました');
226 } else if ($act == 'search'){ // 検索のとき
227 $pageNo = 1; // ページ番号初期化
228 } else if ($act == 'selpage'){ // ページ選択
231 $totalCount = self::$_mainDb->getContentCount(default_contentCommonDef::$_contentType, $this->langId, $searchKeyword, $searchKey, $searchOrder);
234 $this->calcPageLink($pageNo, $totalCount, $maxListCount);
237 $currentBaseUrl = ''; // POST用のリンク作成
238 $pageLink = $this->createPageLink($pageNo, self::LINK_PAGE_COUNT, $currentBaseUrl, 'selpage($1);return false;');
241 if ($this->isMultiLang){ // 多言語対応の場合
242 $this->tmpl->setAttribute('show_multilang', 'visibility', 'visible');
244 $this->tmpl->setAttribute('show_singlelang', 'visibility', 'visible');
248 self::$_mainDb->searchContent(default_contentCommonDef::$_contentType, $this->langId, $maxListCount, $pageNo, $searchKeyword, $searchKey, $searchOrder, array($this, 'itemListLoop'));
249 if (!$this->isExistsContent) $this->tmpl->setAttribute('itemlist', 'visibility', 'hidden');// コンテンツ項目がないときは、一覧を表示しない
253 if (empty($searchKey)){ // コンテンツIDをキーにする場合
254 $this->tmpl->addVar('_widget', 'search_content_id_checked', 'checked');
256 $this->tmpl->addVar('_widget', 'search_update_dt_checked', 'checked');
258 if (empty($searchOrder)){ // 昇順にソートするとき
259 $this->tmpl->addVar('_widget', 'search_asc_checked', 'checked');
261 $this->tmpl->addVar('_widget', 'search_desc_checked', 'checked');
265 $this->tmpl->addVar("_widget", "page", $pageNo); // ページ番号
266 $this->tmpl->addVar("_widget", "page_link", $pageLink);
267 $this->tmpl->addVar("_widget", "total_count", $totalCount);
268 $this->tmpl->addVar("_widget", "search_keyword", $searchKeyword); // 検索キーワード
271 $this->tmpl->addVar("_widget", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
272 $this->tmpl->addVar("_widget", "target_widget", $this->gEnv->getCurrentWidgetId());// メニュー選択ウィンドウ表示用
273 $this->tmpl->addVar("_widget", "device_type", default_contentCommonDef::$_deviceType); // デバイスタイプ
278 * @param RequestManager $request HTTPリクエスト処理クラス
281 function createDetail($request)
284 $this->langId = $this->gEnv->getDefaultLanguage();
287 $openby = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY);
290 if ($this->isMultiLang){ // 多言語対応の場合
291 $langId = $request->trimValueOf('item_lang'); // 現在メニューで選択中の言語
292 if (!empty($langId)) $this->langId = $langId;
295 $contentLayout = self::$_configArray[default_contentCommonDef::$CF_LAYOUT_VIEW_DETAIL];
296 $fieldInfoArray = default_contentCommonDef::parseUserMacro($contentLayout);
299 $useJQuery = self::$_configArray[default_contentCommonDef::$CF_USE_JQUERY]; // jQueryスクリプト作成するかどうか
300 if ($useJQuery){ // jQueryスクリプト作成機能を使用する場合
301 $this->pluginIdArray = $this->gPage->getScriptLibId(2/*jQueryプラグインのみ*/);
303 $pluginCount = count($this->pluginIdArray);
304 for ($i = 0; $i < $pluginCount; $i++){
305 $itemPluginId = str_replace('.', '_', $this->pluginIdArray[$i]);
306 $itemName = self::LIB_ITEM_HEAD . $itemPluginId;
307 $itemValue = ($request->trimValueOf($itemName) == 'on') ? 1 : 0;
308 if ($itemValue) $this->selectedPlugin[] = $this->pluginIdArray[$i];
311 $useContentTemplate = self::$_configArray[default_contentCommonDef::$CF_USE_CONTENT_TEMPLATE];// コンテンツ単位のテンプレート設定を行うかどうか
314 $act = $request->trimValueOf('act');
315 $this->serialNo = $request->trimValueOf('serial'); // 選択項目のシリアル番号
316 $contentId = $request->trimValueOf('contentid'); // コンテンツID
317 $name = $request->trimValueOf('item_name');
318 $html = $request->valueOf('item_html'); // HTMLタグを可能とする
319 $desc = $request->trimValueOf('item_desc'); // 簡易説明
320 $key = $request->trimValueOf('item_key'); // 外部参照用キー
321 $visible = ($request->trimValueOf('item_visible') == 'on') ? 1 : 0; // チェックボックス
322 $limited = ($request->trimValueOf('item_limited') == 'on') ? 1 : 0; // チェックボックス
323 // $default = ($request->trimValueOf('item_default') == 'on') ? 1 : 0; // チェックボックス
324 $searchTarget = $request->trimCheckedValueOf('item_search_target'); // 検索対象かどうか
325 $metaTitle = $request->trimValueOf('item_meta_title'); // ページタイトル名
326 $metaDesc = $request->trimValueOf('item_meta_desc'); // ページ要約
327 $metaKeyword = $request->trimValueOf('item_meta_keyword'); // ページキーワード
328 $headOthers = $request->valueOf('item_head_others'); // ヘッダ部その他
329 $password = $request->trimValueOf('password');
330 $relatedContent = $request->trimValueOf('item_related_content'); // 関連コンテンツ
331 $jQueryScript = $request->valueOf('item_jquery_script'); // jQueryスクリプト
332 $this->templateId = $request->trimValueOf('templateid'); // テンプレートID
333 $this->subTemplateId = $request->trimValueOf('subtemplateid'); // サブテンプレートID
334 $accessKey = $request->trimValueOf('item_access_key'); // アクセスキー
335 $accessUrl = $request->trimValueOf('item_access_url'); // アクセスキー取得用URL
336 $accessUrl = str_replace($this->gEnv->getRootUrl(), M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $accessUrl);// マクロ変換
338 $start_date = $request->trimValueOf('item_start_date'); // 公開期間開始日付
339 if (!empty($start_date)) $start_date = $this->convertToProperDate($start_date);
340 $start_time = $request->trimValueOf('item_start_time'); // 公開期間開始時間
341 if (empty($start_date)){
342 $start_time = ''; // 日付が空のときは時刻も空に設定する
344 if (empty($start_time)) $start_time = '00:00'; // 日付が入っているときは時間にデフォルト値を設定
346 if (!empty($start_time)) $start_time = $this->convertToProperTime($start_time, 1/*時分フォーマット*/);
348 $end_date = $request->trimValueOf('item_end_date'); // 公開期間終了日付
349 if (!empty($end_date)) $end_date = $this->convertToProperDate($end_date);
350 $end_time = $request->trimValueOf('item_end_time'); // 公開期間終了時間
351 if (empty($end_date)){
352 $end_time = ''; // 日付が空のときは時刻も空に設定する
354 if (empty($end_time)) $end_time = '00:00'; // 日付が入っているときは時間にデフォルト値を設定
356 if (!empty($end_time)) $end_time = $this->convertToProperTime($end_time, 1/*時分フォーマット*/);
359 $this->fieldValueArray = array(); // ユーザ定義フィールド入力値
360 $fieldKeys = array_keys($fieldInfoArray);
361 for ($i = 0; $i < count($fieldKeys); $i++){
362 $fieldKey = $fieldKeys[$i];
363 $itemName = self::FIELD_HEAD . $fieldKey;
364 $itemValue = $this->cleanMacroValue($request->trimValueOf($itemName));
365 if (!empty($itemValue)) $this->fieldValueArray[$fieldKey] = $itemValue;
369 $attachFileCount = $request->trimValueOf('attachfilecount'); // 添付ファイル数
370 $fileTitles = $request->trimValueOf('item_filetitle'); // 添付ファイルタイトル
371 $filenames = $request->trimValueOf('item_filename'); // 添付ファイルファイル名
372 $fileIds = $request->trimValueOf('item_fileid'); // 添付ファイルファイルID
373 $this->attachFileInfoArray = array();
374 for ($i = 0; $i < $attachFileCount; $i++){
375 $newInfoObj = new stdClass;
376 $newInfoObj->title = $fileTitles[$i];
377 $newInfoObj->filename = $filenames[$i];
378 $newInfoObj->fileId = $fileIds[$i];
379 $this->attachFileInfoArray[] = $newInfoObj;
382 $reloadData = false; // データの再読み込み
383 $hasPassword = false; // パスワードが設定されているかどうか
384 $historyIndex = -1; // 履歴番号(旧データの場合のみ有効)
387 $reloadData = true; // データの再読み込み
388 } else if ($act == 'add'){ // 項目追加の場合。多言語対応の場合はデフォルト言語が最初に追加される。
390 $this->checkInput($name, '名前');
393 if (!empty($start_date) && !empty($end_date)){
394 if (strtotime($start_date . ' ' . $start_time) >= strtotime($end_date . ' ' . $end_time)) $this->setUserErrorMsg('公開期間が不正です');
398 if (!empty($relatedContent)){
399 $contentIdArray = explode(',', $relatedContent);
400 if (!ValueCheck::isNumeric($contentIdArray)) $this->setUserErrorMsg('関連コンテンツにエラー値があります');// すべて数値であるかチェック
404 $this->checkSingleByte($accessKey, 'アクセスキー', true);
407 if ($this->getMsgCount() == 0){
409 if (empty($start_date)){
410 $startDt = $this->gEnv->getInitValueOfTimestamp();
412 $startDt = $start_date . ' ' . $start_time;
414 if (empty($end_date)){
415 $endDt = $this->gEnv->getInitValueOfTimestamp();
417 $endDt = $end_date . ' ' . $end_time;
422 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
424 $nextContentId = self::$_mainDb->getNextContentId(default_contentCommonDef::$_contentType);
426 $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html);
427 if (!empty($thumbPath)){
428 $ret = $this->gInstance->getImageManager()->createSystemDefaultThumb(M3_VIEW_TYPE_CONTENT, default_contentCommonDef::$_deviceType, $nextContentId, $thumbPath, $destFilename);
429 if ($ret) $thumbFilename = implode(';', $destFilename);
434 $otherParams = array( 'cn_thumb_filename' => $thumbFilename, // サムネールファイル名
435 'cn_related_content' => $relatedContent, // 関連コンテンツ
436 'cn_option_fields' => $this->serializeArray($this->fieldValueArray), // ユーザ定義フィールド値
437 'cn_script' => $jQueryScript, // jQueryスクリプト
438 'cn_script_lib' => implode(',', $this->selectedPlugin),// jQueryプラグイン
439 'cn_template_id' => $this->templateId, // テンプレートID
440 'cn_sub_template_id' => $this->subTemplateId, // サブテンプレートID
441 'cn_attach_access_key' => $accessKey, // アクセスキー
442 'cn_attach_access_url' => $accessUrl, // アクセスキー取得用URL
443 'cn_search_target' => $searchTarget // 検索対象かどうか
446 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // 多言語でデフォルト言語、または単一言語のとき
447 $ret = self::$_mainDb->addContentItem(default_contentCommonDef::$_contentType, $nextContentId * (-1)/*次のコンテンツIDのチェック*/,
448 $this->langId, $name, $desc, $html, $visible, 0/*未使用(デフォルトかどうか)*/, $limited, $key, $password,
449 $metaTitle, $metaDesc, $metaKeyword, $headOthers, $startDt, $endDt, $newSerial, $otherParams);
451 $ret = self::$_mainDb->addContentItem(default_contentCommonDef::$_contentType, $contentId,
452 $this->langId, $name, $desc, $html, $visible, 0/*未使用(デフォルトかどうか)*/, $limited, $key, $password,
453 $metaTitle, $metaDesc, $metaKeyword, $headOthers, $startDt, $endDt, $newSerial, $otherParams);
455 // ##### 添付ファイル情報を更新 #####
457 $ret = self::$_mainDb->getContentBySerial($newSerial, $row);
459 $contentId = $row['cn_id']; // コンテンツID
460 $name = $row['cn_name']; // コンテンツ名前
461 $updateDt = $row['cn_create_dt']; // コンテンツ作成日時
462 $attachFileDir = default_contentCommonDef::getAttachFileDir();
464 $ret = $this->gInstance->getFileManager()->updateAttachFileInfo(default_contentCommonDef::$_viewContentType, $contentId, 0, $newSerial,
465 $this->attachFileInfoArray, $attachFileDir);
470 // ##### アクセスキー情報を登録 #####
471 $this->gAccess->unegistAllSessionAccessKey($contentId); // 一旦すべて削除
472 if (!empty($accessKey)) $this->gAccess->registSessionAccessKey($accessKey, $contentId, 0/*参照*/);
474 $this->setGuidanceMsg('データを追加しました');
477 $this->serialNo = $newSerial;
478 $reloadData = true; // データの再読み込み
481 $this->gPage->updateParentWindow($this->serialNo);
484 $ret = $this->registContentInfoBySerial($this->serialNo, true/*新規*/);
485 if ($ret) $this->setGuidanceMsg('更新情報をサーバへアップしました');
488 $contentAttr = default_contentCommonDef::$_deviceTypeName;
489 if ($this->isMultiLang) $contentAttr .= $this->getLangName($this->langId); // 多言語対応の場合
490 //$this->gOpeLog->writeUserInfo(__METHOD__, sprintf(self::LOG_MSG_ADD_CONTENT, $contentAttr, $name), 2100, 'ID=' . $contentId);
491 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_CONTENT,
492 M3_EVENT_HOOK_PARAM_CONTENT_ID => $contentId,
493 M3_EVENT_HOOK_PARAM_UPDATE_DT => $updateDt);
494 $this->writeUserInfoEvent(__METHOD__, sprintf(self::LOG_MSG_ADD_CONTENT, $contentAttr, $name), 2400, 'ID=' . $contentId, $eventParam);
496 $this->setAppErrorMsg('データ追加に失敗しました');
499 } else if ($act == 'update'){ // 項目更新の場合
501 $this->checkInput($name, '名前');
504 if (!empty($start_date) && !empty($end_date)){
505 if (strtotime($start_date . ' ' . $start_time) >= strtotime($end_date . ' ' . $end_time)) $this->setUserErrorMsg('公開期間が不正です');
509 if (!empty($relatedContent)){
510 $contentIdArray = explode(',', $relatedContent);
511 if (!ValueCheck::isNumeric($contentIdArray)) $this->setUserErrorMsg('関連コンテンツにエラー値があります');// すべて数値であるかチェック
515 $this->checkSingleByte($accessKey, 'アクセスキー', true);
518 if ($this->getMsgCount() == 0){
520 if (empty($start_date)){
521 $startDt = $this->gEnv->getInitValueOfTimestamp();
523 $startDt = $start_date . ' ' . $start_time;
525 if (empty($end_date)){
526 $endDt = $this->gEnv->getInitValueOfTimestamp();
528 $endDt = $end_date . ' ' . $end_time;
533 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
534 $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html);
535 if (!empty($thumbPath)){
536 $ret = $this->gInstance->getImageManager()->createSystemDefaultThumb(M3_VIEW_TYPE_CONTENT, default_contentCommonDef::$_deviceType, $contentId, $thumbPath, $destFilename);
537 if ($ret) $thumbFilename = implode(';', $destFilename);
542 $otherParams = array( 'cn_thumb_filename' => $thumbFilename, // サムネールファイル名
543 'cn_related_content' => $relatedContent, // 関連コンテンツ
544 'cn_option_fields' => $this->serializeArray($this->fieldValueArray), // ユーザ定義フィールド値
545 'cn_script' => $jQueryScript, // jQueryスクリプト
546 'cn_script_lib' => implode(',', $this->selectedPlugin), // jQueryプラグイン
547 'cn_template_id' => $this->templateId, // テンプレートID
548 'cn_sub_template_id' => $this->subTemplateId, // サブテンプレートID
549 'cn_attach_access_key' => $accessKey, // アクセスキー
550 'cn_attach_access_url' => $accessUrl, // アクセスキー取得用URL
551 'cn_search_target' => $searchTarget // 検索対象かどうか
554 // 履歴からのデータ取得の場合はシリアル番号を最新に変更
555 $mode = $request->trimValueOf('mode'); // データ更新モード
556 if ($mode == 'history'){ // 履歴データ表示モード
558 $ret = self::$_mainDb->getContentByContentId(default_contentCommonDef::$_contentType, $contentId, $this->langId, $row);
559 if ($ret) $this->serialNo = $row['cn_serial']; // コンテンツシリアル番号
561 // ### 履歴データを再取得すべき? ###
564 $ret = self::$_mainDb->updateContentItem($this->serialNo, $name, $desc, $html, $visible, 0/*未使用(デフォルトかどうか)*/, $limited, $key, $password,
565 $metaTitle, $metaDesc, $metaKeyword, $headOthers, $startDt, $endDt, $newSerial, $oldRecord, $otherParams);
567 // コンテンツに画像がなくなった場合は、サムネールを削除
568 if (empty($thumbFilename) && !empty($oldRecord['cn_thumb_filename'])){
569 $oldFiles = explode(';', $oldRecord['cn_thumb_filename']);
570 $this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_CONTENT, default_contentCommonDef::$_deviceType, $oldFiles);
573 // ##### 添付ファイル情報を更新 #####
574 $ret = self::$_mainDb->getContentBySerial($newSerial, $row);
576 $contentId = $row['cn_id']; // コンテンツID
577 $name = $row['cn_name']; // コンテンツ名前
578 $updateDt = $row['cn_create_dt']; // コンテンツ作成日時
579 $attachFileDir = default_contentCommonDef::getAttachFileDir();
581 $ret = $this->gInstance->getFileManager()->updateAttachFileInfo(default_contentCommonDef::$_viewContentType, $contentId, $this->serialNo, $newSerial,
582 $this->attachFileInfoArray, $attachFileDir);
587 // ##### アクセスキー情報を登録 #####
588 $this->gAccess->unegistAllSessionAccessKey($contentId); // 一旦すべて削除
589 if (!empty($accessKey)) $this->gAccess->registSessionAccessKey($accessKey, $contentId, 0/*参照*/);
591 $this->setGuidanceMsg('データを更新しました');
594 $this->serialNo = $newSerial;
595 $reloadData = true; // データの再読み込み
598 $this->clearCacheBySerial($this->serialNo);
601 $this->gPage->updateParentWindow($this->serialNo);
604 $ret = $this->registContentInfoBySerial($this->serialNo);
605 if ($ret) $this->setGuidanceMsg('更新情報をサーバへアップしました');
608 $contentAttr = default_contentCommonDef::$_deviceTypeName;
609 if ($this->isMultiLang) $contentAttr .= $this->getLangName($this->langId); // 多言語対応の場合
610 //$this->gOpeLog->writeUserInfo(__METHOD__, sprintf(self::LOG_MSG_UPDATE_CONTENT, $contentAttr, $name), 2100, 'ID=' . $contentId);
611 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_CONTENT,
612 M3_EVENT_HOOK_PARAM_CONTENT_ID => $contentId,
613 M3_EVENT_HOOK_PARAM_UPDATE_DT => $updateDt);
614 $this->writeUserInfoEvent(__METHOD__, sprintf(self::LOG_MSG_UPDATE_CONTENT, $contentAttr, $name), 2401, 'ID=' . $contentId, $eventParam);
616 $this->setAppErrorMsg('データ更新に失敗しました');
619 } else if ($act == 'delete'){ // 項目削除の場合
620 if (empty($this->serialNo)){
621 $this->setUserErrorMsg('削除項目が選択されていません');
624 if ($this->getMsgCount() == 0){
626 $ret = self::$_mainDb->getContentBySerial($this->serialNo, $row);
628 $contentId = $row['cn_id']; // コンテンツID
629 $name = $row['cn_name']; // コンテンツ名前
632 $delByContentId = true; // コンテンツをコンテンツIDで削除するかどうか
633 if ($this->isMultiLang){ // 多言語対応のとき
634 if ($this->langId == $this->gEnv->getDefaultLanguage()){ // デフォルト言語のときは全削除
635 $ret = self::$_mainDb->delContentItemById(array($this->serialNo));
637 $ret = self::$_mainDb->delContentItem(array($this->serialNo));
638 $delByContentId = false; // コンテンツをコンテンツIDで削除するかどうか
641 // 多言語対応状態に関わらずコンテンツIDで削除
642 $ret = self::$_mainDb->delContentItemById(array($this->serialNo));
646 if ($delByContentId){ // コンテンツIDで削除のとき
648 if (!empty($row['cn_thumb_filename'])){
649 $oldFiles = explode(';', $row['cn_thumb_filename']);
650 $this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_CONTENT, default_contentCommonDef::$_deviceType, $oldFiles);
654 $ret = $this->gInstance->getFileManager()->delAttachFileInfoByContentId(default_contentCommonDef::$_viewContentType,
655 $contentId, default_contentCommonDef::getAttachFileDir());
658 $ret = $this->gInstance->getFileManager()->delAttachFileInfo(default_contentCommonDef::$_viewContentType,
659 $this->serialNo, default_contentCommonDef::getAttachFileDir());
663 if ($ret){ // データ削除成功のとき
664 // ##### アクセスキー情報を削除 #####
665 $this->gAccess->unegistAllSessionAccessKey($contentId); // 一旦すべて削除
667 $this->setGuidanceMsg('データを削除しました');
668 $reloadData = true; // データの再読み込み
671 $this->clearCacheBySerial($this->serialNo);
674 $this->gPage->updateParentWindow();
677 $contentAttr = default_contentCommonDef::$_deviceTypeName;
678 if ($this->isMultiLang && $this->langId != $this->gEnv->getDefaultLanguage()) $contentAttr .= $this->getLangName($this->langId); // 多言語対応の場合
679 //$this->gOpeLog->writeUserInfo(__METHOD__, sprintf(self::LOG_MSG_DEL_CONTENT, $contentAttr, $name), 2100, 'ID=' . $contentId);
680 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_CONTENT,
681 // M3_EVENT_HOOK_PARAM_CONTENT_ID => $infoObj->contentId,
682 M3_EVENT_HOOK_PARAM_CONTENT_ID => $contentId,
683 M3_EVENT_HOOK_PARAM_UPDATE_DT => date("Y/m/d H:i:s"));
684 $this->writeUserInfoEvent(__METHOD__, sprintf(self::LOG_MSG_DEL_CONTENT, $contentAttr, $name), 2402, 'ID=' . $contentId, $eventParam);
686 $this->setAppErrorMsg('データ削除に失敗しました');
689 } else if ($act == 'get_history'){ // 履歴データの取得のとき
690 $reloadData = true; // データの再読み込み
691 } else if ($act == 'selectlang'){ // 言語選択
693 //$contentId = $request->trimValueOf('contentid'); // コンテンツID
696 $ret = self::$_mainDb->getContentByContentId(default_contentCommonDef::$_contentType, $contentId, $this->langId, $row);
698 $this->serialNo = $row['cn_serial']; // コンテンツシリアル番号
699 $reloadData = true; // データの再読み込み
703 } else if ($act == 'uploadfile'){ // 添付ファイルアップロード
704 $uploader = new qqFileUploader(array());
705 $resultObj = $uploader->handleUpload(default_contentCommonDef::getAttachFileDir());
707 if ($resultObj['success']){
708 $fileInfo = $resultObj['file'];
709 $ret = $this->gInstance->getFileManager()->addAttachFileInfo(default_contentCommonDef::$_viewContentType, $fileInfo['fileid'], $fileInfo['path'], $fileInfo['filename']);
710 if (!$ret){ // エラーの場合はファイルを添付ファイルを削除
711 unlink($fileInfo['path']);
712 $resultObj = array('error' => 'Could not create file information.');
715 // ##### 添付ファイルアップロード結果を返す #####
717 $this->gPage->abortPage();
720 if (function_exists('json_encode')){
721 $destStr = json_encode($resultObj);
723 $destStr = $this->gInstance->getAjaxManager()->createJsonString($resultObj);
725 //$destStr = htmlspecialchars($destStr, ENT_NOQUOTES);// 「&」が「&」に変換されるので使用しない
726 //header('Content-type: application/json; charset=utf-8');
727 header('Content-Type: text/html; charset=UTF-8'); // JSONタイプを指定するとIE8で動作しないのでHTMLタイプを指定
731 $this->gPage->exitSystem();
732 } else if ($act == 'getmenu'){ // メニュー定義取得
733 // ##### ウィジェット出力処理中断 ######
734 $this->gPage->abortWidget();
736 $menuList = $this->getParsedTemplateData('default_menulist.tmpl.html', array($this, 'makeMenuList'), $contentId);// メニュー定義一覧
737 $this->gInstance->getAjaxManager()->addDataToBody($menuList);
739 } else if ($act == 'getsubtemplate'){ // サブテンプレート取得
740 // ##### ウィジェット出力処理中断 ######
741 $this->gPage->abortWidget();
744 $this->subTemplateId = $this->getDefaultSubTemplateId($this->templateId);
746 // $subTemplateMenu = $this->getParsedTemplateData('sub_template_menu.tmpl.html', array($this, 'makeSubTemplateMenu'), $this->templateId);// サブテンプレートメニュー取得
747 $subTemplateMenu = $this->getParsedTemplateData('sub_template_menu.tmpl.html', array($this, 'createSubTemplateMenu'), $this->templateId);// サブテンプレートメニュー取得
748 if (!$this->isExistsSubTemplate) $subTemplateMenu = ''; // サブテンプレートが存在しない場合は空で返す
749 $this->gInstance->getAjaxManager()->addDataToBody($subTemplateMenu);
751 } else if ($act == 'addtomenu'){ // メニューに項目を追加
752 $serialList = $request->trimValueOf('seriallist');
753 if (!empty($serialList)){
754 $listedItem = explode(',', $serialList);
755 for ($i = 0; $i < count($listedItem); $i++){
757 $itemName = 'item' . $i . '_selected';
758 $itemValue = ($request->trimValueOf($itemName) == 'on') ? 1 : 0;
759 if ($itemValue) $this->selectedItem[] = $listedItem[$i];// チェック項目
764 switch (default_contentCommonDef::$_deviceType){ // デバイスごとの処理
767 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . $this->gEnv->getDefaultPageId() . '.php?contentid=' . $contentId;
770 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . M3_DIR_NAME_MOBILE . '/' . $this->gEnv->getDefaultPageId() . '.php?contentid=' . $contentId;
773 $url = M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END . '/' . M3_DIR_NAME_SMARTPHONE . '/' . $this->gEnv->getDefaultPageId() . '.php?contentid=' . $contentId;
779 $ret = self::$_mainDb->getContentByContentId(default_contentCommonDef::$_contentType, $contentId, $this->langId, $row);
780 if ($ret) $menutItemName = $row['cn_name']; // 名前は取得値を設定
783 for ($i = 0; $i < count($this->selectedItem); $i++){
784 $ret = self::$_mainDb->addMenuItem($this->selectedItem[$i], $menutItemName, $url);
788 $this->gInstance->getAjaxManager()->addData('status', 'OK');
789 $this->gInstance->getAjaxManager()->addData('message', '<div class="alert alert-success">メニューにリンクを追加しました</div>');
791 $this->gInstance->getAjaxManager()->addData('status', 'NG');
792 $this->gInstance->getAjaxManager()->addData('message', '<div class="alert alert-error">メニューのリンク追加に失敗しました</div>');
796 // ##### コンテンツIDが設定されているとき(他ウィジェットからの表示)は、データを取得 #####
797 if (empty($contentId)){
798 if (empty($this->serialNo)){ // 新規項目追加のとき
799 $visible = 1; // 非公開で登録されてしまうので、初期状態は表示に設定
801 $reloadData = true; // データの再読み込み
805 if ($this->isMultiLang){ // 多言語対応の場合
806 $langId = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_LANG); // lang値を取得
807 if (!empty($langId)) $this->langId = $langId;
811 $ret = self::$_mainDb->getContentByContentId(default_contentCommonDef::$_contentType, $contentId, $this->langId, $row);
813 $this->serialNo = $row['cn_serial']; // コンテンツシリアル番号
814 $reloadData = true; // データの再読み込み
816 $visible = 1; // 非公開で登録されてしまうので、初期状態は表示に設定
820 // ##### 初期表示時は仮登録の添付ファイルを削除 #####
821 $this->gInstance->getFileManager()->cleanAttachFileInfo(default_contentCommonDef::$_viewContentType, default_contentCommonDef::getAttachFileDir());
823 if ($reloadData){ // データの再読み込み
824 $ret = self::$_mainDb->getContentBySerial($this->serialNo, $row);
826 $contentId = $row['cn_id']; // コンテンツID
827 $name = $row['cn_name']; // コンテンツ名前
828 $html = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $row['cn_html']); // HTML
829 $desc = $row['cn_description']; // 簡易説明
830 $key = $row['cn_key']; // 外部参照用キー
831 $update_user = $row['lu_name'];// 更新者
832 $update_dt = $row['cn_create_dt'];
834 // 項目表示、デフォルト値チェックボックス
835 $visible = $row['cn_visible'];
836 $default = '0'; // 未使用(デフォルトかどうか)
837 $limited = $row['cn_user_limited']; // ユーザ制限
838 $searchTarget = $row['cn_search_target']; // 検索対象かどうか
839 $metaTitle = $row['cn_meta_title']; // ページタイトル名(METAタグ)
840 $metaDesc = $row['cn_meta_description']; // ページ要約(METAタグ)
841 $metaKeyword = $row['cn_meta_keywords']; // ページキーワード(METAタグ)
842 $headOthers = $row['cn_head_others']; // ヘッダ部その他
843 $start_date = $this->convertToDispDate($row['cn_active_start_dt']); // 公開期間開始日
844 $start_time = $this->convertToDispTime($row['cn_active_start_dt'], 1/*時分*/); // 公開期間開始時間
845 $end_date = $this->convertToDispDate($row['cn_active_end_dt']); // 公開期間終了日
846 $end_time = $this->convertToDispTime($row['cn_active_end_dt'], 1/*時分*/); // 公開期間終了時間
847 $relatedContent = $row['cn_related_content']; // 関連コンテンツ
848 $jQueryScript = $row['cn_script']; // jQueryスクリプト
849 if (!empty($row['cn_script_lib'])) $this->selectedPlugin = explode(',', $row['cn_script_lib']); // jQueryプラグイン
850 $this->templateId = $row['cn_template_id']; // テンプレートID
851 $this->subTemplateId = $row['cn_sub_template_id']; // サブテンプレートID
852 $accessKey = $row['cn_attach_access_key']; // アクセスキー
853 $accessUrl = $row['cn_attach_access_url']; // アクセスキー取得用URL
856 if (!empty($row['cn_password'])) $hasPassword = true; // パスワードが設定されている
859 if ($row['cn_deleted']) $historyIndex = $row['cn_history_index'];// 旧データの場合のみ有効
862 $this->fieldValueArray = $this->unserializeArray($row['cn_option_fields']);
864 // ##### 添付ファイル情報を取得 #####
865 // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
866 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){
867 $ret = $this->gInstance->getFileManager()->getAttachFileInfo(default_contentCommonDef::$_viewContentType, $this->serialNo, $rows);
869 $this->attachFileInfoArray = array();
870 for ($i = 0; $i < count($rows); $i++){
871 $attachFileRow = $rows[$i];
872 $newInfoObj = new stdClass;
873 $newInfoObj->title = $attachFileRow['af_title'];
874 $newInfoObj->filename = $attachFileRow['af_filename'];
875 $newInfoObj->fileId = $attachFileRow['af_file_id'];
876 $this->attachFileInfoArray[] = $newInfoObj;
882 if ($hasPassword || !empty($headOthers) || !empty($limited) || !empty($key) || !empty($relatedContent) || count($this->attachFileInfoArray) > 0) $this->isOpenOptionArea = true;
886 $contentId = '0'; // コンテンツID
887 $name = ''; // コンテンツ名前
890 $key = ''; // 外部参照用キー
891 $update_user = '';// 更新者
894 // 項目表示、デフォルト値チェックボックス
896 $default = '0'; // 未使用(デフォルトかどうか)
897 $limited = '0'; // ユーザ制限
898 $searchTarget = '1'; // 検索対象かどうか
899 $metaTitle = ''; // ページタイトル名(METAタグ)
900 $metaDesc = ''; // ページ要約(METAタグ)
901 $metaKeyword = ''; // ページキーワード(METAタグ)
902 $headOthers = ''; // ヘッダ部その他
903 $start_date = ''; // 公開期間開始日
904 $start_time = ''; // 公開期間開始時間
905 $end_date = ''; // 公開期間終了日
906 $end_time = ''; // 公開期間終了時間
907 $relatedContent = ''; // 関連コンテンツ
908 $jQueryScript = ''; // jQueryスクリプト
909 $this->selectedPlugin = array(); // jQueryプラグイン
910 $this->templateId = ''; // テンプレートID
911 $this->subTemplateId = ''; // サブテンプレートID
912 $accessKey = ''; // アクセスキー
913 $accessUrl = ''; // アクセスキー取得用URL
916 $hasPassword = false; // パスワードが設定されている
922 $this->fieldValueArray = array();
925 $this->attachFileInfoArray = array();
928 $this->isOpenOptionArea = false;
932 if ($this->isMultiLang){ // 多言語対応の場合
933 $this->tmpl->setAttribute('show_multilang', 'visibility', 'visible');
934 $this->tmpl->addVar("show_multilang", "sel_item_name", $name); // 名前
936 if (empty($contentId)){ // 新規追加の場合
937 $defaultLangName = $this->gEnv->getDefaultLanguageNameByCurrentLanguage(); // デフォルト言語の現在の表示名を取得
938 $this->tmpl->addVar("default_lang", "default_lang", $defaultLangName);
939 $this->tmpl->setAttribute('default_lang', 'visibility', 'visible');
940 } else { // コンテンツが選択されているとき
942 self::$_mainDb->getAvailableLang(array($this, 'langLoop'));
943 $this->tmpl->setAttribute('select_lang', 'visibility', 'visible');
945 // デフォルト言語のみ入力可能フィールド
946 if ($this->langId != $this->gEnv->getDefaultLanguage()){
947 $this->tmpl->addVar("_widget", "password_disabled", "disabled");// パスワード
948 $this->tmpl->addVar("_widget", "key_disabled", "disabled"); // 外部参照用キー
949 $this->tmpl->addVar("_widget", "related_content_disabled", "disabled");// 関連コンテンツ
954 $langImage = $this->createLangImage($contentId);
955 $this->tmpl->addVar("show_multilang", "lang", $langImage);
957 $this->tmpl->setAttribute('show_singlelang', 'visibility', 'visible');
958 $this->tmpl->addVar("show_singlelang", "sel_item_name", $name); // 名前
962 $activeTermButton = $this->gDesign->createTermButton(''/*同画面*/, self::TOOLTIP_ACTIVE_TERM, self::TAG_ID_ACTIVE_TERM);
963 $this->tmpl->addVar("_widget", "active_term_button", $activeTermButton);
964 $this->tmpl->addVar("_widget", "tagid_active_term", self::TAG_ID_ACTIVE_TERM);
965 if (!empty($start_date) || !empty($start_time) || !empty($end_date) || !empty($end_time)){
966 $this->tmpl->addVar('_widget', 'show_active_term_area', 'true'); // 公開期間エリアの初期の表示状態
968 $this->tmpl->addVar('_widget', 'show_active_term_area', 'false'); // 公開期間エリアの初期の表示状態
972 $this->createUserFields($fieldInfoArray);
975 $this->createAttachFileList();
976 if (count($this->attachFileInfoArray) == 0) $this->tmpl->setAttribute('attach_file_list', 'visibility', 'hidden');// 添付ファイル一覧を表示
979 $uploadUrl = $this->gEnv->getDefaultAdminUrl() . '?' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_CONFIG_WIDGET; // ウィジェット設定画面
980 $uploadUrl .= '&' . M3_REQUEST_PARAM_WIDGET_ID . '=' . $this->gEnv->getCurrentWidgetId(); // ウィジェットID
981 $uploadUrl .= '&' . M3_REQUEST_PARAM_OPERATION_TASK . '=' . 'content_detail';
982 $uploadUrl .= '&' . M3_REQUEST_PARAM_OPERATION_ACT . '=' . 'uploadfile';
983 // $uploadUrl .= '&path=' . $this->adaptWindowsPath($path); // アップロードディレクトリ
984 $this->tmpl->addVar("_widget", "upload_url", $this->getUrl($uploadUrl));
986 // アクセスキー取得用URLを実URLに変換
987 $accessUrl = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->gEnv->getRootUrl(), $accessUrl); // マクロ展開
989 // jQueryスクリプト、プラグイン一覧作成
992 if ($this->langId == $this->gEnv->getDefaultLanguage()){
993 $this->tmpl->setAttribute('show_jquery', 'visibility', 'visible');
994 $this->createpluginIdList();
997 $this->addLib[] = self::LIB_CODEMIRROR_JAVASCRIPT; // CodeMirror Javascript
999 // コンテンツ単位のテンプレート設定を行うかどうか
1000 if ($useContentTemplate){
1002 if ($this->langId == $this->gEnv->getDefaultLanguage()){
1003 $this->tmpl->setAttribute('show_template', 'visibility', 'visible');
1006 self::$_mainDb->getAllTemplateList(default_contentCommonDef::$_deviceType, array($this, 'templateIdLoop'));
1009 $this->createSubTemplateMenu($this->tmpl, $this->templateId);
1011 // サブテンプレートが設定されている場合は拡張エリアを開く
1012 if (!empty($this->templateId)) $this->isOpenOptionArea = true;
1017 $this->tmpl->addVar("_widget", "sel_item_html", $this->convertToDispString($html)); // HTML
1018 $this->tmpl->addVar("_widget", "desc", $this->convertToDispString($desc)); // 簡易説明
1019 $this->tmpl->addVar("_widget", "sel_item_key", $this->convertToDispString($key)); // 外部参照用キー
1020 $this->tmpl->addVar("_widget", "meta_title", $this->convertToDispString($metaTitle)); // ページタイトル名(METAタグ)
1021 $this->tmpl->addVar("_widget", "meta_desc", $this->convertToDispString($metaDesc)); // ページ要約(METAタグ)
1022 $this->tmpl->addVar("_widget", "meta_keyword", $this->convertToDispString($metaKeyword)); // ページキーワード(METAタグ)
1023 $this->tmpl->addVar("_widget", "head_others", $this->convertToDispString($headOthers)); // ヘッダ部その他
1024 $this->tmpl->addVar("_widget", "update_user", $this->convertToDispString($update_user)); // 更新者
1025 $this->tmpl->addVar("_widget", "update_dt", $this->convertToDispDateTime($update_dt)); // 更新日時
1026 $this->tmpl->addVar("_widget", "start_date", $start_date); // 公開期間開始日
1027 $this->tmpl->addVar("_widget", "start_time", $start_time); // 公開期間開始時間
1028 $this->tmpl->addVar("_widget", "end_date", $end_date); // 公開期間終了日
1029 $this->tmpl->addVar("_widget", "end_time", $end_time); // 公開期間終了時間
1030 if ($hasPassword) $this->tmpl->addVar("_widget", "password", self::DEFAULT_PASSWORD);// 入力済みを示すパスワードの設定
1031 $this->tmpl->addVar("_widget", "related_content", $this->convertToDispString($relatedContent)); // 関連コンテンツ
1032 $this->tmpl->addVar("show_jquery", "jquery_script", $this->convertToDispString($jQueryScript)); // jQueryスクリプト
1033 $this->tmpl->addVar('_widget', 'access_key', $this->convertToDispString($accessKey)); // アクセスキー
1034 $this->tmpl->addVar('_widget', 'access_url', $this->convertToDispString($accessUrl)); // アクセスキー取得用URL
1036 // 項目表示、項目利用可否チェックボックス
1037 /* $visibleStr = '';
1038 if ($visible) $visibleStr = 'checked';
1039 $this->tmpl->addVar("_widget", "sel_item_visible", $visibleStr);
1040 // $defaultStr = '';
1041 // if ($default) $defaultStr = 'checked';
1042 // $this->tmpl->addVar("_widget", "sel_item_default", $defaultStr);
1044 if ($limited) $limitedStr = 'checked';
1045 $this->tmpl->addVar("_widget", "sel_item_limited", $limitedStr);
1047 $this->tmpl->addVar("_widget", "sel_item_visible", $this->convertToCheckedString($visible)); // コンテンツ公開
1048 $this->tmpl->addVar("_widget", "sel_item_limited", $this->convertToCheckedString($limited)); // ユーザ制限
1049 $this->tmpl->addVar("_widget", "search_target_checked", $this->convertToCheckedString($searchTarget)); // 検索対象かどうか
1051 $this->tmpl->addVar("_widget", "serial", $this->serialNo); // 選択中のシリアル番号
1052 $this->tmpl->addVar("_widget", "target_widget", $this->gEnv->getCurrentWidgetId());// メニュー選択ウィンドウ表示用
1053 $this->tmpl->addVar("_widget", "device_type", default_contentCommonDef::$_deviceType); // デバイスタイプ
1054 $this->tmpl->addVar('_widget', 'tag_start', M3_TAG_START . M3_TAG_MACRO_ITEM_KEY); // 置換タグ(前)
1055 $this->tmpl->addVar('_widget', 'tag_end', M3_TAG_END); // 置換タグ(後)
1058 $this->tmpl->addVar('_widget', 'admin_url', $this->getUrl($this->gEnv->getDefaultAdminUrl()));// 管理者URL
1061 switch (default_contentCommonDef::$_deviceType){ // デバイスごとの処理
1064 $previewUrl = $this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId;
1067 $previewUrl = $this->gEnv->getDefaultMobileUrl() . '?' . M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId;
1070 $previewUrl = $this->gEnv->getDefaultSmartphoneUrl() . '?' . M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId;
1073 if ($historyIndex >= 0) $previewUrl .= '&' . M3_REQUEST_PARAM_HISTORY . '=' . $historyIndex;
1074 $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_PREVIEW;
1075 if ($this->isMultiLang) $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_LANG . '=' . $this->langId; // 多言語対応の場合は言語IDを付加
1076 $this->tmpl->addVar('_widget', 'preview_url', $previewUrl);// プレビュー用URL(フロント画面)
1078 $this->tmpl->addVar('_widget', 'custom_value_task', 'usercustom'); // ユーザ定義値参照用
1079 $this->tmpl->addVar('_widget', 'admin_widget_id', self::ADMIN_WIDGET_ID);// ユーザ定義値参照用(管理ウィジェットのウィジェットID)
1080 $this->tmpl->addVar('_widget', 'calendar_img', $this->getUrl($this->gEnv->getRootUrl() . self::CALENDAR_ICON_FILE)); // カレンダーアイコン
1082 $iconUrl = $this->gEnv->getRootUrl() . self::DELETE_ICON_FILE; // 行削除アイコン
1084 $iconTag = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1085 $this->tmpl->addVar('_widget', 'delete_icon', $iconTag);
1087 // CKEditor用のCSSファイルを読み込む
1088 $this->loadCKEditorCssFiles($previewUrl);
1091 $buttonTag = $this->gDesign->createEditButton(''/*同画面*/, 'URL作成', self::CHANGE_URL_TAG_ID);
1092 $this->tmpl->addVar("_widget", "change_url_button", $buttonTag);
1093 $this->tmpl->addVar("_widget", "tagid_change_url", self::CHANGE_URL_TAG_ID); // URL変更タグ
1096 if ($this->isOpenOptionArea){
1097 $this->tmpl->addVar('_widget', 'option_area_open', 'true');
1099 $this->tmpl->addVar('_widget', 'option_area_open', 'false');
1101 $iconUrl = $this->gEnv->getRootUrl() . self::OPEN_PANEL_ICON_FILE; // 拡張エリア表示用アイコン
1102 $iconTitle = 'オプションを表示';
1103 $openButton = '<a id="button_open" href="javascript:void(0);" class="btn btn-sm btn-warning" role="button" rel="m3help" data-container="body" title="' . $iconTitle . '"><i class="glyphicon glyphicon-plus"></i></a>';
1104 //$openButton = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::PANEL_BUTTON_SIZE . '" height="' . self::PANEL_BUTTON_SIZE . '" border="0" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1105 $this->tmpl->addVar('_widget', 'open_button', $openButton);
1106 $iconUrl = $this->gEnv->getRootUrl() . self::CLOSE_PANEL_ICON_FILE; // 拡張エリア非表示用アイコン
1107 $iconTitle = 'オプションを非表示';
1108 $closeButton = '<a id="button_close" href="javascript:void(0);" class="btn btn-sm btn-warning" role="button" rel="m3help" data-container="body" title="' . $iconTitle . '"><i class="glyphicon glyphicon-minus"></i></a>';
1109 //$closeButton = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::PANEL_BUTTON_SIZE . '" height="' . self::PANEL_BUTTON_SIZE . '" border="0" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1110 $this->tmpl->addVar('_widget', 'close_button', $closeButton);
1113 if (empty($this->serialNo)){ // 新規追加項目を選択しているとき
1114 if ($this->isMultiLang){ // 多言語対応の場合
1115 if (empty($contentId)){
1116 $this->tmpl->addVar("_widget", "sel_item_id", ''); // コンテンツID
1117 $this->tmpl->addVar("_widget", "item_id", '新規'); // コンテンツID
1119 $this->tmpl->addVar('cancel_button', 'new_btn_disabled', 'disabled'); // 「新規」ボタン使用不可
1121 $this->tmpl->addVar("_widget", "sel_item_id", $contentId); // コンテンツID
1122 $this->tmpl->addVar("_widget", "item_id", $contentId); // コンテンツID
1125 $this->tmpl->addVar("_widget", "sel_item_id", ''); // コンテンツID
1126 $this->tmpl->addVar("_widget", "item_id", '新規'); // コンテンツID
1128 $this->tmpl->addVar('cancel_button', 'new_btn_disabled', 'disabled'); // 「新規」ボタン使用不可
1130 $this->tmpl->setAttribute('add_button', 'visibility', 'visible');// 「新規追加」ボタン
1131 $this->tmpl->addVar('_widget', 'preview_btn_disabled', 'disabled');// プレビューボタン使用不可
1132 $this->tmpl->addVar('_widget', 'history_btn_disabled', 'disabled');// 履歴ボタン使用不可
1135 $itemId = $contentId; // コンテンツID
1136 if ($historyIndex >= 0) $itemId .= '(' . ($historyIndex +1) . ')';
1138 $this->tmpl->addVar("_widget", "sel_item_id", $contentId); // コンテンツID
1139 $this->tmpl->addVar("_widget", "item_id", $itemId); // コンテンツID
1141 if ($historyIndex >= 0){ // 履歴データの場合
1142 $this->tmpl->setAttribute('update_history_button', 'visibility', 'visible'); // 「履歴データで更新」ボタン
1144 $this->tmpl->setAttribute('del_button', 'visibility', 'visible');// 「更新」「削除」ボタン
1148 if ($openby == 'simple' || $openby == 'tabs') $this->tmpl->setAttribute('cancel_button', 'visibility', 'hidden'); // 詳細画面のみの表示またはタブ表示のときは戻るボタンを隠す
1151 * JavascriptライブラリをHTMLヘッダ部に設定
1153 * JavascriptライブラリをHTMLのheadタグ内に追加出力する。
1154 * _assign()よりも後に実行される。
1156 * @param RequestManager $request HTTPリクエスト処理クラス
1157 * @param object $param 任意使用パラメータ。
1158 * @return string,array Javascriptライブラリ。出力しない場合は空文字列を設定。
1160 function _addScriptLibToHead($request, &$param)
1162 return $this->addLib;
1165 * 取得したデータをテンプレートに設定する
1167 * @param int $index 行番号(0~)
1168 * @param array $fetchedRow フェッチ取得した行
1169 * @param object $param 未使用
1170 * @return bool true=処理続行の場合、false=処理終了の場合
1172 function itemListLoop($index, $fetchedRow, $param)
1174 $serial = $this->convertToDispString($fetchedRow['cn_serial']);
1175 $contentId = $fetchedRow['cn_id']; // コンテンツID
1179 if ($fetchedRow['cn_user_limited']) $limited = 'checked';
1183 if ($this->isMultiLang){ // 多言語対応の場合
1184 $lang = $this->createLangImage($contentId);
1187 $updateViewCount = $this->gInstance->getAnalyzeManager()->getTotalContentViewCount(default_contentCommonDef::$_viewContentType, $serial); // 更新後からの参照数
1188 $totalViewCount = $this->gInstance->getAnalyzeManager()->getTotalContentViewCount(default_contentCommonDef::$_viewContentType, 0, $contentId); // 新規作成からの参照数
1189 $viewCountStr = $updateViewCount;
1190 if ($totalViewCount > $updateViewCount) $viewCountStr .= '(' . $totalViewCount . ')'; // 新規作成からの参照数がない旧仕様に対応
1193 $now = date("Y/m/d H:i:s"); // 現在日時
1194 $startDt = $fetchedRow['cn_active_start_dt'];
1195 $endDt = $fetchedRow['cn_active_end_dt'];
1197 $isActive = false; // 公開状態
1198 if ($fetchedRow['cn_visible']) $isActive = $this->isActive($startDt, $endDt, $now);// 表示可能
1200 if ($isActive){ // コンテンツが公開状態のとき
1201 $iconUrl = $this->gEnv->getRootUrl() . self::ACTIVE_ICON_FILE; // 公開中アイコン
1204 $iconUrl = $this->gEnv->getRootUrl() . self::INACTIVE_ICON_FILE; // 非公開アイコン
1207 $statusImg = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1210 $addToMenuImg = $this->getUrl($this->gEnv->getRootUrl() . self::ADD_TO_MENU_ICON_FILE); // メニューに追加用アイコン
1211 $addToMenuStr = 'メニューに追加';
1212 $statusUrl = $this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId;// 現在の表示画面用URL
1215 switch (default_contentCommonDef::$_deviceType){ // デバイスごとの処理
1218 $previewUrl = $this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId;
1221 $previewUrl = $this->gEnv->getDefaultMobileUrl() . '?' . M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId;
1224 $previewUrl = $this->gEnv->getDefaultSmartphoneUrl() . '?' . M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId;
1227 $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_PREVIEW;// プレビュー用URL
1228 // if ($this->isMultiLang) $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_LANG . '=' . $this->langId; // 多言語対応の場合は言語IDを付加
1229 $previewImg = $this->getUrl($this->gEnv->getRootUrl() . self::PREVIEW_ICON_FILE);
1230 $previewStr = 'プレビュー';
1233 'index' => $index, // 項目番号
1234 'serial' => $serial, // シリアル番号
1235 'id' => $this->convertToDispString($contentId), // ID
1236 'name' => $this->convertToDispString($fetchedRow['cn_name']), // 名前
1237 'lang' => $lang, // 対応言語
1238 //'view_count' => $totalViewCount, // 参照数
1239 'view_count' => $this->convertToDispString($viewCountStr), // 参照数
1240 'status' => $statusImg, // 公開状況
1241 'update_user' => $this->convertToDispString($fetchedRow['lu_name']), // 更新者
1242 'update_dt' => $this->convertToDispDateTime($fetchedRow['cn_create_dt'], 0/*ロングフォーマット*/, 10/*時分*/), // 更新日時
1243 'limited' => $limited, // ユーザ制限
1244 'add_to_menu_img' => $addToMenuImg, // メニューに追加用の画像
1245 'add_to_menu_str' => $addToMenuStr, // メニューに追加用の文字列
1246 'status_url' => $statusUrl, // 現在の表示画面用URL
1247 'preview_url' => $previewUrl, // プレビュー用のURL
1248 'preview_img' => $previewImg, // プレビュー用の画像
1249 'preview_str' => $previewStr // プレビュー文字列
1251 if ($this->isMultiLang){ // 多言語対応のとき
1252 $this->tmpl->addVars('itemlist2', $row);
1253 $this->tmpl->parseTemplate('itemlist2', 'a');
1255 $this->tmpl->addVars('itemlist', $row);
1256 $this->tmpl->parseTemplate('itemlist', 'a');
1260 $this->serialArray[] = $fetchedRow['cn_serial'];
1262 $this->isExistsContent = true; // コンテンツ項目が存在するかどうか
1266 * 取得した言語をテンプレートに設定する
1268 * @param int $index 行番号(0~)
1269 * @param array $fetchedRow フェッチ取得した行
1270 * @param object $param 未使用
1271 * @return bool true=処理続行の場合、false=処理終了の場合
1273 function langLoop($index, $fetchedRow, $param)
1276 if ($fetchedRow['ln_id'] == $this->langId){
1277 $selected = 'selected';
1279 if ($this->gEnv->getCurrentLanguage() == 'ja'){ // 日本語表示の場合
1280 $name = $this->convertToDispString($fetchedRow['ln_name']);
1282 $name = $this->convertToDispString($fetchedRow['ln_name_en']);
1286 'value' => $this->convertToDispString($fetchedRow['ln_id']), // 言語ID
1287 'name' => $name, // 言語名
1288 'selected' => $selected // 選択中かどうか
1290 $this->tmpl->addVars('lang_list', $row);
1291 $this->tmpl->parseTemplate('lang_list', 'a');
1295 * 取得したデータをテンプレートに設定する
1297 * @param int $index 行番号(0~)
1298 * @param array $fetchedRow フェッチ取得した行
1299 * @param object $param 未使用
1300 * @return bool true=処理続行の場合、false=処理終了の場合
1302 function menuIdListLoop($index, $fetchedRow, $tmpl)
1304 $id = $fetchedRow['mn_id'];
1307 if (in_array($id, $this->selectedItem)) $checkStr = 'checked ';
1308 if ($this->completed) $checkStr .= 'disabled '; // 追加完了のとき
1311 'index' => $index, // 項目番号
1312 'serial' => $this->convertToDispString($id), // シリアル番号
1313 'id' => $this->convertToDispString($id), // ID
1314 'name' => $this->convertToDispString($fetchedRow['mn_name']), // 名前
1315 'check' => $checkStr // チェック状態
1317 $tmpl->addVars('itemlist', $row);
1318 $tmpl->parseTemplate('itemlist', 'a');
1321 $this->serialArray[] = $id;
1322 $this->isExistsContent = true; // コンテンツ項目が存在するかどうか
1328 * @param int $serial 削除対象のコンテンツシリアル番号
1331 function clearCacheBySerial($serial)
1333 $ret = self::$_mainDb->getContentBySerial($serial, $row); // コンテンツID取得
1335 $contentId = $row['cn_id']; // コンテンツID
1336 $urlParam = array();
1337 $urlParam[] = M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId; // コンテンツID
1338 $urlParam[] = M3_REQUEST_PARAM_CONTENT_ID_SHORT . '=' . $contentId; // コンテンツID略式
1339 $this->clearCache($urlParam);
1345 * @param timestamp $startDt 公開開始日時
1346 * @param timestamp $endDt 公開終了日時
1347 * @param timestamp $now 基準日時
1348 * @return bool true=公開可能、false=公開不可
1350 function isActive($startDt, $endDt, $now)
1352 $isActive = false; // 公開状態
1354 if ($startDt == $this->gEnv->getInitValueOfTimestamp() && $endDt == $this->gEnv->getInitValueOfTimestamp()){
1355 $isActive = true; // 公開状態
1356 } else if ($startDt == $this->gEnv->getInitValueOfTimestamp()){
1357 if (strtotime($now) < strtotime($endDt)) $isActive = true; // 公開状態
1358 } else if ($endDt == $this->gEnv->getInitValueOfTimestamp()){
1359 if (strtotime($now) >= strtotime($startDt)) $isActive = true; // 公開状態
1361 if (strtotime($startDt) <= strtotime($now) && strtotime($now) < strtotime($endDt)) $isActive = true; // 公開状態
1368 * @param int $serial コンテンツシリアル番号
1369 * @param bool $isNew 新規または更新
1372 function registContentInfoBySerial($serial, $isNew=false)
1374 $ret = self::$_mainDb->getContentBySerial($serial, $row); // コンテンツID取得
1376 $contentId = $row['cn_id']; // コンテンツID
1377 $contentTitle = $row['cn_name']; // コンテンツタイトル
1378 $contentLink = $url = $this->gEnv->getDefaultUrl() . '?contentid=' . $contentId; // コンテンツリンク先
1379 $contentDt = $row['cn_create_dt']; // コンテンツ更新日時
1381 $ret = $this->gInstance->getConnectManager()->registUpdateInfo(''/*汎用コンテンツ*/, ''/*送信先はデフォルトURL*/, ''/*デフォルトウィジェットに送信*/,
1382 $this->gEnv->getCurrentWidgetId(), self::MSG_UPDATE_CONTENT, $contentTitle, $contentLink, $contentDt);
1389 * @param int $contentId コンテンツID
1390 * @return atring 言語アイコンタグ
1392 function createLangImage($contentId)
1395 $ret = self::$_mainDb->getLangByContentId(default_contentCommonDef::$_contentType, $contentId, $rows);
1397 $count = count($rows);
1398 for ($i = 0; $i < $count; $i++){
1399 if ($this->gEnv->getCurrentLanguage() == 'ja'){ // 日本語の場合
1400 $langName = $rows[$i]['ln_name'];
1402 $langName = $rows[$i]['ln_name_en'];
1405 $iconTitle = $langName;
1406 $iconUrl = $this->gEnv->getRootUrl() . self::LANG_ICON_PATH . $rows[$i]['ln_image_filename']; // 画像ファイル
1407 $iconTag = '<img src="' . $this->getUrl($iconUrl) . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1408 $imageTag .= $iconTag;
1416 * @param string $langId 言語ID
1417 * @return atring 表示名
1419 function getLangName($langId)
1421 $ret = self::$_mainDb->getLang($langId, $row);
1422 if ($this->gEnv->getCurrentLanguage() == 'ja'){ // 日本語表示の場合
1423 $name = $this->convertToDispString($row['ln_name']);
1425 $name = $this->convertToDispString($row['ln_name_en']);
1434 function createAttachFileList()
1437 $iconUrl = $this->gEnv->getRootUrl() . self::DELETE_ICON_FILE; // 行削除アイコン
1439 $iconTag = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1441 $fileCount = count($this->attachFileInfoArray);
1442 for ($i = 0; $i < $fileCount; $i++){
1443 $infoObj = $this->attachFileInfoArray[$i];
1444 $title = $infoObj->title; // タイトル
1445 $filename = $infoObj->filename; // ファイル名
1446 $fileId = $infoObj->fileId; // ファイルID
1449 'title' => $this->convertToDispString($title),
1450 'filename' => $this->convertToDispString($filename),
1451 'file_id' => $this->convertToDispString($fileId),
1452 'delete_icon' => $iconTag
1454 $this->tmpl->addVars('attach_file_list', $row);
1455 $this->tmpl->parseTemplate('attach_file_list', 'a');
1461 * @param array $fields フィールドID
1462 * @return bool true=成功、false=失敗
1464 function createUserFields($fields)
1466 if (count($fields) == 0) return true;
1468 $this->tmpl->setAttribute('user_fields', 'visibility', 'visible');
1469 $keys = array_keys($fields);
1470 $fieldCount = count($keys);
1471 for ($i = 0; $i < $fieldCount; $i++){
1472 if ($i == 0) $this->tmpl->addVar('user_fields', 'type', 'first'); // 最初の行の場合
1476 $value = $this->fieldValueArray[$key];
1477 if (!isset($value)) $value = '';
1480 'row_count' => $fieldCount,
1481 'field_id' => $this->convertToDispString($key),
1482 'value' => $this->convertToDispString($value)
1484 $this->tmpl->addVars('user_fields', $row);
1485 $this->tmpl->parseTemplate('user_fields', 'a');
1494 function createpluginIdList()
1496 for ($i = 0; $i < count($this->pluginIdArray); $i++){
1497 $itemPluginId = str_replace('.', '_', $this->pluginIdArray[$i]);
1498 $id = $this->pluginIdArray[$i];
1502 $libInfo = $this->gPage->getScriptLibInfo($id);
1503 if (!empty($libInfo)){
1504 $url = $libInfo['url'];
1505 if (!empty($url)) $name = '<a href="' . $this->convertUrlToHtmlEntity($url) . '" target="_blank">' . $name . '</a>';
1509 if (in_array($id, $this->selectedPlugin)) $checked = 'checked';
1512 'id' => $itemPluginId, // 値
1513 'name' => $name, // 名前
1514 'id_checked' => $checked // 選択中かどうか
1516 $this->tmpl->addVars('plugin_list', $row);
1517 $this->tmpl->parseTemplate('plugin_list', 'a');
1523 * @param int $index 行番号(0~)
1524 * @param array $fetchedRow フェッチ取得した行
1525 * @param object $param 未使用
1526 * @return bool true=処理続行の場合、false=処理終了の場合
1528 function templateIdLoop($index, $fetchedRow, $param)
1531 if ($fetchedRow['tm_id'] == $this->templateId) $selected = 'selected';
1534 'value' => $this->convertToDispString($fetchedRow['tm_id']), // テンプレートID
1535 'name' => $this->convertToDispString($fetchedRow['tm_name']), // テンプレート名名
1536 'selected' => $selected // 選択中かどうか
1538 $this->tmpl->addVars('template_list', $row);
1539 $this->tmpl->parseTemplate('template_list', 'a');
1545 * @param object $tmpl テンプレートオブジェクト
1546 * @param string $templateId テンプレートID
1549 function createSubTemplateMenu($tmpl, $templateId)
1551 if (empty($templateId)) return;
1554 $ret = self::$_mainDb->getTemplate($templateId, $row);
1557 $generator = $row['tm_generator'];
1558 $version = $row['tm_version']; // テンプレートバージョン
1559 if ($generator != M3_TEMPLATE_GENERATOR_THEMLER) return; // Themler
1562 $tmpl->setAttribute('select_subtemplate', 'visibility', 'visible');
1564 $subTemplateInfoFile = $this->gEnv->getTemplatesPath() . '/' . $templateId . '/templates/list.php';
1565 if (is_readable($subTemplateInfoFile)){
1566 // サブテンプレート情報ファイル読み込み
1567 require_once($subTemplateInfoFile);
1569 // $templatesInfoにサブテンプレートの情報が設定されているので取得
1570 if (!isset($this->subTemplateInfo)) $this->subTemplateInfo = array();
1571 if (!empty($templatesInfo)) $this->subTemplateInfo = $templatesInfo;
1573 foreach ($this->subTemplateInfo as $key => $templateInfo){
1574 $subTemplateId = $templateInfo['fileName'];
1575 $type = $templateInfo['kind'];
1576 if (empty($subTemplateId)) continue;
1577 if ($type == 'error404') continue; // エラーメッセージ表示用の404タイプのサブテンプレートは表示しない
1580 if ($subTemplateId == $this->subTemplateId) $selected = 'selected'; // サブテンプレートID
1583 'value' => $this->convertToDispString($subTemplateId),
1584 'name' => $this->convertToDispString($templateInfo['defaultTemplateCaption'] . '(' . $templateInfo['fileName'] . ')'),
1585 'selected' => $selected // 選択中かどうか
1587 $tmpl->addVars('subtemplate_list', $row);
1588 $tmpl->parseTemplate('subtemplate_list', 'a');
1590 $this->isExistsSubTemplate = true; // サブテンプレートが存在するかどうか
1595 * メニュー定義一覧データ作成処理コールバック
1597 * @param object $tmpl テンプレートオブジェクト
1598 * @param object $param 任意パラメータ(コンテンツID)
1601 function makeMenuList($tmpl, $param)
1604 self::$_mainDb->getMenuIdList(default_contentCommonDef::$_deviceType, array($this, 'menuIdListLoop'), $tmpl);
1605 if (!$this->isExistsContent) $tmpl->setAttribute('itemlist', 'visibility', 'hidden');// 一覧項目がないときは、一覧を表示しない
1607 $tmpl->addVar("_tmpl", "content_id", $param);// コンテンツID
1608 $tmpl->addVar("_tmpl", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
1611 * デフォルトのサブテンプレートIDを取得
1613 * @param string $templateId テンプレートID
1614 * @return string サブテンプレートID
1616 function getDefaultSubTemplateId($templateId)
1618 $subTemplateId = '';
1620 $ret = self::$_mainDb->getTemplate($templateId, $row);
1621 if (!$ret) return $subTemplateId;
1623 $generator = $row['tm_generator'];
1624 $version = $row['tm_version']; // テンプレートバージョン
1625 switch ($generator){
1626 case M3_TEMPLATE_GENERATOR_THEMLER: // Themler
1627 // デフォルトのサブテンプレートIDを取得
1628 $subTemplateInfoFile = $this->gEnv->getTemplatesPath() . '/' . $templateId . '/templates/list.php';
1629 if (is_readable($subTemplateInfoFile)){
1630 // サブテンプレート情報ファイル読み込み
1631 require_once($subTemplateInfoFile);
1633 // $templatesInfoにサブテンプレートの情報が設定されているので取得
1634 if (!isset($this->subTemplateInfo)) $this->subTemplateInfo = array();
1635 if (!empty($templatesInfo)) $this->subTemplateInfo = $templatesInfo;
1637 foreach ($this->subTemplateInfo as $key => $templateInfo){
1638 $id = $templateInfo['fileName'];
1639 $type = $templateInfo['kind'];
1640 if (empty($id)) continue;
1642 if ($type == 'default'){
1643 $subTemplateId = $id;
1650 return $subTemplateId;