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 /***************************************************************************************************
17 ### 複製元クラス admin_blog_mainEntryWidgetContainer ###
18 複製元クラスからblog_mainEntryWidgetContainerクラスを生成する
20 ・親クラスファイルの読み込み(require_once)
22 ****************************************************************************************************/
23 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/blog_mainBaseWidgetContainer.php');
24 require_once($gEnvManager->getCurrentWidgetDbPath() . '/blog_mainDb.php');
25 require_once($gEnvManager->getCommonPath() . '/valueCheck.php');
27 // このファイルはadmin_blog_mainEntryWidgetContainer.phpの内容と同じ。クラス名の定義のみ異なる。
28 //class admin_blog_mainEntryWidgetContainer extends admin_blog_mainBaseWidgetContainer
29 class blog_mainEntryWidgetContainer extends blog_mainBaseWidgetContainer
31 private $currentYear; // 現在の年号
32 private $serialNo; // 選択中の項目のシリアル番号
34 private $blogId; // 所属ブログ
35 private $langId; // 現在の選択言語
36 private $serialArray = array(); // 表示されている項目シリアル番号
37 private $categoryListData; // 全記事カテゴリー
38 private $categorySortInfo; // カテゴリーソート情報
39 private $categoryArray; // 選択中の記事カテゴリー
40 private $categoryCount; // カテゴリ数
41 private $isMultiLang; // 多言語対応画面かどうか
42 private $useMultiBlog;// マルチブログを使用するかどうか
43 private $useComment;// コメント機能を使用するかどうか
44 private $fieldValueArray; // ユーザ定義フィールド入力値
45 const ICON_SIZE = 32; // アイコンのサイズ
46 const SMALL_ICON_SIZE = 16; // アイコンのサイズ
47 const EYECATCH_IMAGE_SIZE = 40; // アイキャッチ画像サイズ
48 const DEFAULT_LIST_COUNT = 20; // 最大リスト表示数
49 const LINK_PAGE_COUNT = 10; // リンクページ数
50 const LINK_PAGE_COUNT_S = 5; // リンクページ数(小画面用)
51 const CATEGORY_NAME_SIZE = 20; // カテゴリー名の最大文字列長
52 const CALENDAR_ICON_FILE = '/images/system/calendar.png'; // カレンダーアイコン
53 const ACTIVE_ICON_FILE = '/images/system/active32.png'; // 公開中アイコン
54 const INACTIVE_ICON_FILE = '/images/system/inactive32.png'; // 非公開アイコン
55 const SEARCH_ICON_FILE = '/images/system/search16.png'; // 検索用アイコン
56 const SMALL_ACTIVE_ICON_FILE = '/images/system/active.png'; // 公開中アイコン
57 const SMALL_INACTIVE_ICON_FILE = '/images/system/inactive.png'; // 非公開アイコン
58 const FIELD_HEAD = 'item_'; // フィールド名の先頭文字列
59 const NO_BLOG_NAME = '所属なし'; // 所属ブログなし
60 const TAG_ID_ACTIVE_TERM = 'activeterm_button'; // 公開期間エリア表示用ボタンタグ
61 const TOOLTIP_ACTIVE_TERM = '公開期間を設定'; // 公開期間エリア表示用ボタンツールチップ
62 const DATETIME_FORMAT = 'Y年n月j日($1) H:i:s'; // 日付時間フォーマット
67 function __construct()
70 parent::__construct();
72 $this->currentYear = intval(date('Y'));
77 * 共通パラメータの初期化や、以下のパターンでウィジェット出力方法の変更を行う。
78 * ・組み込みの_setTemplate(),_assign()を使用
80 * @param RequestManager $request HTTPリクエスト処理クラス
83 function _init($request)
86 $this->isMultiLang = $this->gEnv->isMultiLanguageSite(); // 多言語対応画面かどうか
89 $this->useMultiBlog = self::$_configArray[blog_mainCommonDef::CF_USE_MULTI_BLOG];// マルチブログを使用するかどうか
90 $this->useComment = self::$_configArray[blog_mainCommonDef::CF_RECEIVE_COMMENT];// コメント機能を使用するかどうか
91 $this->categoryCount = self::$_configArray[blog_mainCommonDef::CF_CATEGORY_COUNT]; // カテゴリ数
92 if (empty($this->categoryCount)) $this->categoryCount = blog_mainCommonDef::DEFAULT_CATEGORY_COUNT;
94 self::$_mainDb->getAllCategory($this->_langId, $this->categoryListData); // カテゴリー情報
99 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
100 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
102 * @param RequestManager $request HTTPリクエスト処理クラス
103 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
104 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
106 function _setTemplate($request, &$param)
108 $task = $request->trimValueOf('task');
110 if ($task == 'entry_detail'){ // 詳細画面
111 if ($this->_isSmallDeviceOptimize){ // 小画面デバイス最適化の場合
112 return 'admin_entry_detail_small.tmpl.html';
114 return 'admin_entry_detail.tmpl.html';
117 if ($this->_isSmallDeviceOptimize){ // 小画面デバイス最適化の場合
118 return 'admin_entry_small.tmpl.html';
120 return 'admin_entry.tmpl.html';
127 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
129 * @param RequestManager $request HTTPリクエスト処理クラス
130 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
133 function _assign($request, &$param)
135 $task = $request->trimValueOf('task');
136 if ($task == 'entry_detail'){ // 詳細画面
137 return $this->createDetail($request);
139 return $this->createList($request);
143 * JavascriptファイルをHTMLヘッダ部に設定
145 * JavascriptファイルをHTMLのheadタグ内に追加出力する。
146 * _assign()よりも後に実行される。
148 * @param RequestManager $request HTTPリクエスト処理クラス
149 * @param object $param 任意使用パラメータ。
150 * @return string Javascriptファイル。出力しない場合は空文字列を設定。
152 function _addScriptFileToHead($request, &$param)
154 $scriptArray = array($this->getUrl($this->gEnv->getScriptsUrl() . self::CALENDAR_SCRIPT_FILE), // カレンダースクリプトファイル
155 $this->getUrl($this->gEnv->getScriptsUrl() . self::CALENDAR_LANG_FILE), // カレンダー言語ファイル
156 $this->getUrl($this->gEnv->getScriptsUrl() . self::CALENDAR_SETUP_FILE)); // カレンダーセットアップファイル
161 * CSSファイルをHTMLヘッダ部に設定
163 * CSSファイルをHTMLのheadタグ内に追加出力する。
164 * _assign()よりも後に実行される。
166 * @param RequestManager $request HTTPリクエスト処理クラス
167 * @param object $param 任意使用パラメータ。
168 * @return string CSS文字列。出力しない場合は空文字列を設定。
170 function _addCssFileToHead($request, &$param)
172 return $this->getUrl($this->gEnv->getScriptsUrl() . self::CALENDAR_CSS_FILE);
177 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
179 * @param RequestManager $request HTTPリクエスト処理クラス
182 function createList($request)
184 $act = $request->trimValueOf('act');
185 $this->langId = $request->trimValueOf('item_lang'); // 現在メニューで選択中の言語
186 if (empty($this->langId)) $this->langId = $this->gEnv->getDefaultLanguage(); // 言語が選択されていないときは、デフォルト言語を設定
187 if ($this->gEnv->isAdminDirAccess()){ // 管理画面へのアクセスの場合
188 $this->blogId = null; // デフォルトブログ(ブログID空)を含むすべてのブログ記事にアクセス可能
190 $this->blogId = $request->trimValueOf(M3_REQUEST_PARAM_BLOG_ID); // 所属ブログ
194 $pageNo = $request->trimIntValueOf(M3_REQUEST_PARAM_PAGE_NO, '1'); // ページ番号
197 $maxListCount = self::DEFAULT_LIST_COUNT;
198 $serializedParam = $this->_db->getWidgetParam($this->_widgetId);
199 if (!empty($serializedParam)){
200 $dispInfo = unserialize($serializedParam);
201 $maxListCount = $dispInfo->maxMemberListCountByAdmin; // 会員リスト最大表示数
204 $search_startDt = $request->trimValueOf('search_start'); // 検索範囲開始日付
205 if (!empty($search_startDt)) $search_startDt = $this->convertToProperDate($search_startDt);
206 $search_endDt = $request->trimValueOf('search_end'); // 検索範囲終了日付
207 if (!empty($search_endDt)) $search_endDt = $this->convertToProperDate($search_endDt);
208 $search_categoryId = $request->trimValueOf('search_category0'); // 検索カテゴリー
209 $search_keyword = $request->trimValueOf('search_keyword'); // 検索キーワード
212 $this->categoryArray = array();
213 if (!empty($search_categoryId)){ // 0以外の値を取得
214 $this->categoryArray[] = $search_categoryId;
217 if ($act == 'delete'){ // 項目削除の場合
218 $listedItem = explode(',', $request->trimValueOf('seriallist'));
220 for ($i = 0; $i < count($listedItem); $i++){
222 $itemName = 'item' . $i . '_selected';
223 $itemValue = ($request->trimValueOf($itemName) == 'on') ? 1 : 0;
225 if ($itemValue){ // チェック項目
226 $delItems[] = $listedItem[$i];
229 if (count($delItems) > 0){
231 $delEntryInfo = array();
232 for ($i = 0; $i < count($delItems); $i++){
233 $ret = self::$_mainDb->getEntryBySerial($delItems[$i], $row, $categoryRow);
235 $newInfoObj = new stdClass;
236 $newInfoObj->entryId = $row['be_id']; // 記事ID
237 $newInfoObj->name = $row['be_name']; // 記事タイトル
238 $newInfoObj->thumb = $row['be_thumb_filename']; // サムネール
239 $delEntryInfo[] = $newInfoObj;
243 $ret = self::$_mainDb->delEntryItem($delItems);
244 if ($ret){ // データ削除成功のとき
245 $this->setGuidanceMsg('データを削除しました');
247 // ##### サムネールの削除 #####
248 for ($i = 0; $i < count($delEntryInfo); $i++){
249 $infoObj = $delEntryInfo[$i];
250 // $ret = blog_mainCommonDef::removeThumbnail($infoObj->entryId);
252 if (!empty($infoObj->thumb)){
253 //$oldFiles = explode(';', $infoObj->thumb);
254 //$this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $oldFiles);
257 blog_mainCommonDef::removeEyecatchImage($infoObj->entryId);
262 for ($i = 0; $i < count($delItems); $i++){
263 $this->clearCacheBySerial($delItems[$i]);
267 $this->gPage->updateParentWindow();
270 for ($i = 0; $i < count($delEntryInfo); $i++){
271 $infoObj = $delEntryInfo[$i];
272 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
273 M3_EVENT_HOOK_PARAM_CONTENT_ID => $infoObj->entryId,
274 M3_EVENT_HOOK_PARAM_UPDATE_DT => date("Y/m/d H:i:s"));
275 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $infoObj->name, 2402, 'ID=' . $infoObj->entryId, $eventParam);
278 $this->setAppErrorMsg('データ削除に失敗しました');
281 } else if ($act == 'search'){ // 検索のとき
282 if (!empty($search_startDt) && !empty($search_endDt) && $search_startDt > $search_endDt){
283 $this->setUserErrorMsg('期間の指定範囲にエラーがあります。');
285 $pageNo = 1; // ページ番号初期化
286 } else if ($act == 'selpage'){ // ページ選択
288 // ###### 一覧の取得条件を作成 ######
289 if (!empty($search_endDt)) $endDt = $this->getNextDay($search_endDt);
292 $totalCount = self::$_mainDb->getEntryItemCount($search_startDt, $endDt, $this->categoryArray, $search_keyword, $this->langId, $this->blogId);
295 $this->calcPageLink($pageNo, $totalCount, $maxListCount);
298 if ($this->_isSmallDeviceOptimize){ // 小画面デバイス最適化の場合
299 $pageLink = $this->createPageLink($pageNo, self::LINK_PAGE_COUNT_S, ''/*リンク作成用(未使用)*/, 'selpage($1);return false;');
301 $pageLink = $this->createPageLink($pageNo, self::LINK_PAGE_COUNT, ''/*リンク作成用(未使用)*/, 'selpage($1);return false;');
305 self::$_mainDb->searchEntryItems($maxListCount, $pageNo, $search_startDt, $endDt, $this->categoryArray, $search_keyword, $this->langId, array($this, 'itemListLoop'), $this->blogId);
306 if (count($this->serialArray) <= 0) $this->tmpl->setAttribute('itemlist', 'visibility', 'hidden');// 投稿記事がないときは、一覧を表示しない
309 $this->createCategoryMenu(1); // メニューは1つだけ表示
312 $previewUrl = $this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $this->gEnv->getPageSubIdByContentType($this->gEnv->getDefaultPageId(), M3_VIEW_TYPE_BLOG);
313 $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_PREVIEW;
314 // if ($this->isMultiLang) $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_LANG . '=' . $this->langId; // 多言語対応の場合は言語IDを付加
315 $this->tmpl->addVar('_widget', 'preview_url', $previewUrl);// プレビュー用URL(フロント画面)
318 $this->tmpl->addVar("_widget", "page_link", $pageLink);
319 $this->tmpl->addVar("_widget", "total_count", $totalCount);
322 $this->tmpl->addVar("_widget", "search_start", $search_startDt); // 開始日付
323 $this->tmpl->addVar("_widget", "search_end", $search_endDt); // 終了日付
324 $this->tmpl->addVar("_widget", "search_keyword", $search_keyword); // 検索キーワード
327 $this->tmpl->addVar("_widget", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
328 $this->tmpl->addVar("_widget", "page", $pageNo); // ページ番号
329 $this->tmpl->addVar("_widget", "list_count", $maxListCount); // 一覧表示項目数
334 * @param RequestManager $request HTTPリクエスト処理クラス
337 function createDetail($request)
340 $contentLayout = array(self::$_configArray[blog_mainCommonDef::CF_LAYOUT_ENTRY_SINGLE], self::$_configArray[blog_mainCommonDef::CF_LAYOUT_ENTRY_LIST]);
341 $fieldInfoArray = blog_mainCommonDef::parseUserMacro($contentLayout);
344 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
345 $act = $request->trimValueOf('act');
346 $this->langId = $request->trimValueOf('item_lang'); // 現在メニューで選択中の言語
347 if (empty($this->langId)) $this->langId = $this->gEnv->getDefaultLanguage(); // 言語が選択されていないときは、デフォルト言語を設定
348 $this->entryId = $request->trimValueOf('entryid'); // 記事エントリーID
349 $this->serialNo = $request->trimValueOf('serial'); // 選択項目のシリアル番号
350 $this->blogId = $request->trimValueOf(M3_REQUEST_PARAM_BLOG_ID); // 所属ブログ
351 $name = $request->trimValueOf('item_name');
352 $entry_date = $request->trimValueOf('item_entry_date'); // 投稿日
353 $entry_time = $request->trimValueOf('item_entry_time'); // 投稿時間
354 $html = $request->valueOf('item_html');
355 $html2 = $request->valueOf('item_html2');
356 if (strlen($html2) <= 10){ // IE6のときFCKEditorのバグの対応(「続き」が空の場合でもpタグが送信される)
359 $desc = $request->trimValueOf('item_desc'); // 簡易説明
360 $metaDesc = $request->trimValueOf('item_meta_desc'); // ページ要約
361 $metaKeyword = $request->trimValueOf('item_meta_keyword'); // ページキーワード
362 $status = $request->trimValueOf('item_status'); // エントリー状態(0=未設定、1=編集中、2=公開、3=非公開)
363 $category = ''; // カテゴリー
364 $showComment = ($request->trimValueOf('show_comment') == 'on') ? 1 : 0; // コメントを表示するかどうか
365 $receiveComment = ($request->trimValueOf('receive_comment') == 'on') ? 1 : 0; // コメントを受け付けるかどうか
366 $relatedContent = $request->trimValueOf('item_related_content'); // 関連コンテンツ
367 if (!$this->useComment){ // コメント機能を使用しない場合のデフォルト値
368 $showComment = 1; // コメントを表示するかどうか
369 $receiveComment = 1; // コメントを受け付けるかどうか
373 $this->categoryArray = array();
374 for ($i = 0; $i < $this->categoryCount; $i++){
375 $itemName = 'item_category' . $i;
376 $itemValue = $request->trimValueOf($itemName);
377 if (!empty($itemValue)){ // 0以外の値を取得
378 $this->categoryArray[] = $itemValue;
382 $this->sortCategory($this->categoryArray);
385 $start_date = $request->trimValueOf('item_start_date'); // 公開期間開始日付
386 if (!empty($start_date)) $start_date = $this->convertToProperDate($start_date);
387 $start_time = $request->trimValueOf('item_start_time'); // 公開期間開始時間
388 if (empty($start_date)){
389 $start_time = ''; // 日付が空のときは時刻も空に設定する
391 if (empty($start_time)) $start_time = '00:00'; // 日付が入っているときは時間にデフォルト値を設定
393 if (!empty($start_time)) $start_time = $this->convertToProperTime($start_time, 1/*時分フォーマット*/);
395 $end_date = $request->trimValueOf('item_end_date'); // 公開期間終了日付
396 if (!empty($end_date)) $end_date = $this->convertToProperDate($end_date);
397 $end_time = $request->trimValueOf('item_end_time'); // 公開期間終了時間
398 if (empty($end_date)){
399 $end_time = ''; // 日付が空のときは時刻も空に設定する
401 if (empty($end_time)) $end_time = '00:00'; // 日付が入っているときは時間にデフォルト値を設定
403 if (!empty($end_time)) $end_time = $this->convertToProperTime($end_time, 1/*時分フォーマット*/);
406 $this->fieldValueArray = array(); // ユーザ定義フィールド入力値
407 $fieldKeys = array_keys($fieldInfoArray);
408 for ($i = 0; $i < count($fieldKeys); $i++){
409 $fieldKey = $fieldKeys[$i];
410 $itemName = self::FIELD_HEAD . $fieldKey;
411 $itemValue = $this->cleanMacroValue($request->trimValueOf($itemName));
412 if (!empty($itemValue)) $this->fieldValueArray[$fieldKey] = $itemValue;
415 $historyIndex = -1; // 履歴番号初期化(旧データの場合のみ有効)
416 $reloadData = false; // データの再ロード
417 if ($act == 'select'){ // 一覧から選択のとき
418 $reloadData = true; // データの再ロード
419 } else if ($act == 'new'){
421 $reloadData = true; // データの再読み込み
422 } else if ($act == 'selectlang'){ // 項目選択の場合
424 $this->serialNo = self::$_mainDb->getEntrySerialNoByContentId($this->entryId, $this->langId);
425 if (empty($this->serialNo)){
427 //$name = ''; // タイトル
428 //$html = ''; // HTML
429 //$status = 0; // エントリー状況
430 $status = 1; // エントリー状況(編集中)
431 $reg_user = ''; // 投稿者
432 $update_user = '';// 更新者
435 $reloadData = true; // データの再ロード
437 } else if ($act == 'add' || $act == 'addlang'){ // 項目追加の場合
439 $this->checkInput($name, 'タイトル');
440 $this->checkDate($entry_date, '投稿日付');
441 $this->checkTime($entry_time, '投稿時間');
444 if (!empty($start_date) && !empty($end_date)){
445 if (strtotime($start_date . ' ' . $start_time) >= strtotime($end_date . ' ' . $end_time)) $this->setUserErrorMsg('公開期間が不正です');
449 if (!empty($relatedContent)){
450 $contentIdArray = explode(',', $relatedContent);
451 if (!ValueCheck::isNumeric($contentIdArray)) $this->setUserErrorMsg('関連コンテンツにエラー値があります');// すべて数値であるかチェック
455 if ($this->getMsgCount() == 0){
457 if (empty($start_date)){
458 $startDt = $this->gEnv->getInitValueOfTimestamp();
460 $startDt = $start_date . ' ' . $start_time;
462 if (empty($end_date)){
463 $endDt = $this->gEnv->getInitValueOfTimestamp();
465 $endDt = $end_date . ' ' . $end_time;
467 $regDt = $this->convertToProperDate($entry_date) . ' ' . $this->convertToProperTime($entry_time); // 投稿日時
471 $thumbSrcPath = ''; // サムネール画像の元のファイル
472 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
474 $nextEntryId = self::$_mainDb->getNextEntryId();
476 if ($status == 2){ // 記事公開の場合のみアイキャッチ画像を作成
477 $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html);
478 if (empty($thumbPath) && !empty($html2)) $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html2); // 本文1に画像がないときは本文2を検索
479 if (!empty($thumbPath)){
480 $ret = $this->gInstance->getImageManager()->createSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $nextEntryId, $thumbPath, $destFilename);
481 if ($ret) $thumbFilename = implode(';', $destFilename);
485 $thumbSrcPath = str_replace($this->gEnv->getResourcePath(), '', $thumbPath);
490 $html = $this->gInstance->getTextConvManager()->convToContentMacro($html);
491 $html2 = $this->gInstance->getTextConvManager()->convToContentMacro($html2);
493 // 記事に含まれるすべての画像のパスを取得
494 $imagePathArray = $this->gInstance->getImageManager()->getSiteImagePath($html);
495 $imagePathArray2 = $this->gInstance->getImageManager()->getSiteImagePath($html2);
496 $imagePathArray = array_unique(array_merge($imagePathArray, $imagePathArray2));
499 $otherParams = array( 'be_description' => $desc, // 簡易説明
500 'be_meta_description' => $metaDesc, // ページ要約(METAタグ)
501 'be_meta_keywords' => $metaKeyword, // ページキーワード(METAタグ)
502 'be_thumb_filename' => $thumbFilename, // サムネールファイル名
503 'be_thumb_src' => $thumbSrcPath, // サムネール画像の元のファイル
504 'be_related_content' => $relatedContent, // 関連コンテンツ
505 'be_option_fields' => $this->serializeArray($this->fieldValueArray)); // ユーザ定義フィールド値
508 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // 多言語でデフォルト言語、または単一言語のとき
509 $ret = self::$_mainDb->addEntryItem($nextEntryId * (-1)/*次のコンテンツIDのチェック*/, $this->langId, $name, $html, $html2, $status, $this->categoryArray, $imagePathArray, $this->blogId,
510 $this->_userId, $regDt, $startDt, $endDt, $showComment, $receiveComment, $newSerial, $otherParams);
512 $ret = self::$_mainDb->addEntryItem($this->entryId, $this->langId, $name, $html, $html2, $status, $this->categoryArray, $imagePathArray, $this->blogId,
513 $this->_userId, $regDt, $startDt, $endDt, $showComment, $receiveComment, $newSerial, $otherParams);
516 $this->setGuidanceMsg('データを追加しました');
519 $this->serialNo = $newSerial;
520 $reloadData = true; // データの再ロード
522 // ##### サムネールの作成 #####
523 /* $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
525 $entryId = $row['be_id']; // 記事ID
526 $html = $row['be_html']; // HTML
527 $updateDt = $row['be_create_dt'];
528 $status = $row['be_status'];
530 if ($status == 2){ // 公開の場合
531 $ret = blog_mainCommonDef::createThumbnail($html, $entryId, $updateDt);
533 $ret = blog_mainCommonDef::removeThumbnail($entryId);
538 $this->clearCacheBySerial($this->serialNo);
541 $this->gPage->updateParentWindow();
545 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
547 $this->entryId = $row['be_id']; // 記事ID
548 $name = $row['be_name']; // コンテンツ名前
549 $updateDt = $row['be_create_dt']; // 作成日時
552 switch ($row['be_status']){
553 case 1: $statusStr = '編集中'; break;
554 case 2: $statusStr = '公開'; break;
555 case 3: $statusStr = '非公開'; break;
558 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
559 M3_EVENT_HOOK_PARAM_CONTENT_ID => $this->entryId,
560 M3_EVENT_HOOK_PARAM_UPDATE_DT => $updateDt);
561 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を追加(' . $statusStr . ')しました。タイトル: ' . $name, 2400, 'ID=' . $this->entryId, $eventParam);
563 $this->setAppErrorMsg('データ追加に失敗しました');
566 } else if ($act == 'update'){ // 項目更新の場合
568 $this->checkInput($name, 'タイトル');
569 $this->checkDate($entry_date, '投稿日付');
570 $this->checkTime($entry_time, '投稿時間');
573 if (!empty($start_date) && !empty($end_date)){
574 if (strtotime($start_date . ' ' . $start_time) >= strtotime($end_date . ' ' . $end_time)) $this->setUserErrorMsg('公開期間が不正です');
578 if (!empty($relatedContent)){
579 $contentIdArray = explode(',', $relatedContent);
580 if (!ValueCheck::isNumeric($contentIdArray)) $this->setUserErrorMsg('関連コンテンツにエラー値があります');// すべて数値であるかチェック
584 if ($this->getMsgCount() == 0){
586 if (empty($start_date)){
587 $startDt = $this->gEnv->getInitValueOfTimestamp();
589 $startDt = $start_date . ' ' . $start_time;
591 if (empty($end_date)){
592 $endDt = $this->gEnv->getInitValueOfTimestamp();
594 $endDt = $end_date . ' ' . $end_time;
596 $regDt = $this->convertToProperDate($entry_date) . ' ' . $this->convertToProperTime($entry_time); // 投稿日時
600 $thumbSrcPath = ''; // サムネール画像の元のファイル
601 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
602 if ($status == 2){ // 記事公開の場合のみアイキャッチ画像を作成
603 // コンテンツからアイキャッチ画像を作成
604 $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html);
605 if (empty($thumbPath) && !empty($html2)) $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html2); // 本文1に画像がないときは本文2を検索
606 if (!empty($thumbPath)){
607 $ret = $this->gInstance->getImageManager()->createSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $this->entryId, $thumbPath, $destFilename);
608 if ($ret) $thumbFilename = implode(';', $destFilename);
611 // 非公開ディレクトリのアイキャッチ画像をコピー
612 $ret = blog_mainCommonDef::copyEyecatchImageToPublicDir($this->entryId);
613 if ($ret){ // アイキャッチ画像をコピーした場合は、ファイル名を取得
615 list($destFilename, $formats) = $this->gInstance->getImageManager()->getSystemThumbFilename($this->entryId, 1/*クロップ画像のみ*/);
616 $thumbFilename = implode(';', $destFilename);
620 $thumbSrcPath = str_replace($this->gEnv->getResourcePath(), '', $thumbPath);
622 // 公開ディレクトリのアイキャッチ画像を削除
623 blog_mainCommonDef::removeEyecatchImageInPublicDir($this->entryId);
628 $html = $this->gInstance->getTextConvManager()->convToContentMacro($html);
629 $html2 = $this->gInstance->getTextConvManager()->convToContentMacro($html2);
631 // 記事に含まれるすべての画像のパスを取得
632 $imagePathArray = $this->gInstance->getImageManager()->getSiteImagePath($html);
633 $imagePathArray2 = $this->gInstance->getImageManager()->getSiteImagePath($html2);
634 $imagePathArray = array_unique(array_merge($imagePathArray, $imagePathArray2));
637 $otherParams = array( 'be_description' => $desc, // 簡易説明
638 'be_meta_description' => $metaDesc, // ページ要約(METAタグ)
639 'be_meta_keywords' => $metaKeyword, // ページキーワード(METAタグ)
640 'be_thumb_filename' => $thumbFilename, // サムネールファイル名
641 'be_thumb_src' => $thumbSrcPath, // サムネール画像の元のファイル
642 'be_related_content' => $relatedContent, // 関連コンテンツ
643 'be_option_fields' => $this->serializeArray($this->fieldValueArray)); // ユーザ定義フィールド値
645 // 履歴からのデータ取得の場合はシリアル番号を最新に変更
646 $mode = $request->trimValueOf('mode'); // データ更新モード
647 if ($mode == 'history'){ // 履歴データ表示モード
648 $this->serialNo = self::$_mainDb->getEntrySerialNoByContentId($this->entryId, $this->langId); // 最新のシリアル番号を取得
650 // ### 履歴データを再取得すべき? ###
654 $ret = self::$_mainDb->updateEntryItem($this->serialNo, $name, $html, $html2, $status, $this->categoryArray, $imagePathArray, $this->blogId,
655 ''/*投稿者そのまま*/, $regDt, $startDt, $endDt, $showComment, $receiveComment, $newSerial, $oldRecord, $otherParams);
657 // コンテンツに画像がなくなった場合は、サムネールを削除
658 if (empty($thumbFilename) && !empty($oldRecord['be_thumb_filename'])){
659 $oldFiles = explode(';', $oldRecord['be_thumb_filename']);
660 $this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $oldFiles);
665 $this->setGuidanceMsg('データを更新しました');
668 $this->serialNo = $newSerial;
669 $reloadData = true; // データの再ロード
671 /* // ##### サムネールの作成 #####
672 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
674 $entryId = $row['be_id']; // 記事ID
675 $html = $row['be_html']; // HTML
676 $updateDt = $row['be_create_dt'];
677 $status = $row['be_status'];
679 if ($status == 2){ // 公開の場合
680 $ret = blog_mainCommonDef::createThumbnail($html, $entryId, $updateDt);
682 $ret = blog_mainCommonDef::removeThumbnail($entryId);
687 $this->clearCacheBySerial($this->serialNo);
690 $this->gPage->updateParentWindow();
694 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
696 $this->entryId = $row['be_id']; // 記事ID
697 $name = $row['be_name']; // コンテンツ名前
698 $updateDt = $row['be_create_dt']; // 作成日時
701 switch ($row['be_status']){
702 case 1: $statusStr = '編集中'; break;
703 case 2: $statusStr = '公開'; break;
704 case 3: $statusStr = '非公開'; break;
707 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
708 M3_EVENT_HOOK_PARAM_CONTENT_ID => $this->entryId,
709 M3_EVENT_HOOK_PARAM_UPDATE_DT => $updateDt);
710 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を更新(' . $statusStr . ')しました。タイトル: ' . $name, 2401, 'ID=' . $this->entryId, $eventParam);
712 $this->setAppErrorMsg('データ更新に失敗しました');
715 } else if ($act == 'delete'){ // 項目削除の場合
716 if (empty($this->serialNo)){
717 $this->setUserErrorMsg('削除項目が選択されていません');
720 if ($this->getMsgCount() == 0){
722 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
724 $this->entryId = $row['be_id']; // 記事ID
725 $name = $row['be_name']; // コンテンツ名前
728 $ret = self::$_mainDb->delEntryItem(array($this->serialNo));
729 if ($ret){ // データ削除成功のとき
730 $this->setGuidanceMsg('データを削除しました');
732 // ##### サムネールの削除 #####
733 // $ret = blog_mainCommonDef::removeThumbnail($this->entryId);
736 if (!empty($row['be_thumb_filename'])){
737 // $oldFiles = explode(';', $row['be_thumb_filename']);
738 // $this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $oldFiles);
741 blog_mainCommonDef::removeEyecatchImage($this->entryId);
745 $this->clearCacheBySerial($this->serialNo);
748 $this->gPage->updateParentWindow();
751 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
752 M3_EVENT_HOOK_PARAM_CONTENT_ID => $this->entryId,
753 M3_EVENT_HOOK_PARAM_UPDATE_DT => date("Y/m/d H:i:s"));
754 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $name, 2402, 'ID=' . $this->entryId, $eventParam);
756 $this->setAppErrorMsg('データ削除に失敗しました');
759 } else if ($act == 'deleteid'){ // ID項目削除の場合
760 if (empty($this->serialNo)){
761 $this->setUserErrorMsg('削除項目が選択されていません');
764 if ($this->getMsgCount() == 0){
766 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
768 $this->entryId = $row['be_id']; // 記事ID
769 $name = $row['be_name']; // コンテンツ名前
772 $ret = self::$_mainDb->delEntryItemById($this->serialNo);
773 if ($ret){ // データ削除成功のとき
774 $this->setGuidanceMsg('データを削除しました');
776 // ##### サムネールの削除 #####
777 // $ret = blog_mainCommonDef::removeThumbnail($this->entryId);
780 blog_mainCommonDef::removeEyecatchImage($this->entryId);
783 $this->clearCacheBySerial($this->serialNo);
786 $this->gPage->updateParentWindow();
789 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
790 M3_EVENT_HOOK_PARAM_CONTENT_ID => $this->entryId,
791 M3_EVENT_HOOK_PARAM_UPDATE_DT => date("Y/m/d H:i:s"));
792 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $name, 2402, 'ID=' . $this->entryId, $eventParam);
794 $this->setAppErrorMsg('データ削除に失敗しました');
797 } else if ($act == 'preview'){ // プレビューデータ追加
798 // ##### ウィジェット出力処理中断 ######
799 $this->gPage->abortWidget();
802 if (empty($name)) $name = blog_mainCommonDef::DEFAULT_TITLE_NO_TITLE;
803 if (empty($entry_date) || empty($entry_time)){
804 $entry_date = date("Y/m/d"); // 投稿日
805 $entry_time = date("H:i:s"); // 投稿時間
809 $regDt = $this->convertToProperDate($entry_date) . ' ' . $this->convertToProperTime($entry_time); // 投稿日時
812 $ret = self::$_mainDb->getEntryItem($this->entryId, $this->langId, $row);
813 if ($ret){ // データありの場合
814 $userId = $row['be_regist_user_id']; // 最初の投稿者
816 $userId = $this->_userId; // 現在のユーザ
820 $otherParams = array();
821 $otherParams['be_name'] = $name;
822 $otherParams['be_blog_id'] = $this->blogId;
823 $otherParams['be_status'] = $status;
824 $otherParams['be_regist_user_id'] = $userId; // 投稿者
825 $otherParams['be_regist_dt'] = $regDt;
826 $otherParams['be_show_comment'] = $showComment;
827 $otherParams['be_receive_comment'] = $receiveComment;
828 $otherParams['be_description'] = $desc; // 簡易説明
829 $otherParams['be_meta_description'] = $metaDesc; // ページ要約(METAタグ)
830 $otherParams['be_meta_keywords'] = $metaKeyword; // ページキーワード(METAタグ)
831 $otherParams['be_thumb_filename'] = $thumbFilename; // サムネールファイル名
832 $otherParams['be_related_content'] = $relatedContent; // 関連コンテンツ
833 $otherParams['be_option_fields'] = $this->serializeArray($this->fieldValueArray); // ユーザ定義フィールド値
834 $ret = self::$_mainDb->updateEntryPreview($this->entryId, $this->langId, $html, $html2, $this->categoryArray, $otherParams, $serial);
837 $previewUrl = $this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $this->entryId . '-' . $this->_userId;
838 $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_PREVIEW;
839 if ($this->isMultiLang) $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_LANG . '=' . $this->langId; // 多言語対応の場合は言語IDを付加
840 $this->gInstance->getAjaxManager()->addData('url', $previewUrl);
843 } else if ($act == 'get_history'){ // 履歴データの取得のとき
844 $reloadData = true; // データの再読み込み
845 } else { // 初期画面表示のとき
846 // ##### ブログ記事IDが設定されているとき(他ウィジェットからの表示)は、データを取得 #####
847 if (empty($this->entryId)){
848 if (!empty($this->serialNo)){ // シリアル番号で指定の場合
849 $reloadData = true; // データの再読み込み
853 if ($this->isMultiLang){ // 多言語対応の場合
854 $langId = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_LANG); // lang値を取得
855 if (!empty($langId)) $this->langId = $langId;
859 $ret = self::$_mainDb->getEntryItem($this->entryId, $this->langId, $row);
861 $this->serialNo = $row['be_serial']; // シリアル番号
862 $reloadData = true; // データの再読み込み
867 if (empty($this->serialNo)){
869 // 所属ブログIDは親ウィンドウから引き継ぐ
870 //$this->blogId = ''; // 所属ブログ
871 $entry_date = date("Y/m/d"); // 投稿日
872 $entry_time = date("H:i:s"); // 投稿時間
873 $showComment = 1; // コメントを表示するかどうか
874 $receiveComment = 1; // コメントを受け付けるかどうか
879 if ($reloadData){ // データの再ロード
880 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
882 $this->entryId = $row['be_id']; // 記事ID
883 $this->blogId = $row['be_blog_id']; // 所属ブログ
884 $name = $row['be_name']; // タイトル
885 $html = $row['be_html']; // HTML
886 $html = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $html);// アプリケーションルートを変換
887 $html2 = $row['be_html_ext']; // HTML
888 $html2 = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $html2);// アプリケーションルートを変換
889 $desc = $row['be_description']; // 簡易説明
890 $metaDesc = $row['be_meta_description']; // ページ要約(METAタグ)
891 $metaKeyword = $row['be_meta_keywords']; // ページキーワード(METAタグ)
892 $status = $row['be_status']; // エントリー状況
893 $reg_user = $row['reg_user_name']; // 投稿者
894 $entry_date = $this->timestampToDate($row['be_regist_dt']); // 投稿日
895 $entry_time = $this->timestampToTime($row['be_regist_dt']); // 投稿時間
896 //$update_user = $this->convertToDispString($row['lu_name']);// 更新者
897 $update_user = $this->convertToDispString($row['update_user_name']);// 更新者
898 $update_dt = $this->convertToDispDateTime($row['be_create_dt']);
899 $start_date = $this->convertToDispDate($row['be_active_start_dt']); // 公開期間開始日
900 $start_time = $this->convertToDispTime($row['be_active_start_dt'], 1/*時分*/); // 公開期間開始時間
901 $end_date = $this->convertToDispDate($row['be_active_end_dt']); // 公開期間終了日
902 $end_time = $this->convertToDispTime($row['be_active_end_dt'], 1/*時分*/); // 公開期間終了時間
903 $showComment = $row['be_show_comment']; // コメントを表示するかどうか
904 $receiveComment = $row['be_receive_comment']; // コメントを受け付けるかどうか
905 $relatedContent = $row['be_related_content']; // 関連コンテンツ
908 $this->categoryArray = $this->getCategory($categoryRow);
911 if ($row['be_deleted']) $historyIndex = $row['be_history_index']; // 旧データの場合のみ有効
914 $this->fieldValueArray = $this->unserializeArray($row['be_option_fields']);
916 // 前後のエントリーのシリアル番号を取得
917 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
918 if ($this->gEnv->isAdminDirAccess()){ // 管理画面へのアクセスの場合
919 $blogId = null; // デフォルトブログ(ブログID空)を含むすべてのブログ記事にアクセス可能
921 $blogId = $this->blogId; // 所属ブログ
923 $ret = self::$_mainDb->getPrevNextEntryByDate($row['be_regist_dt'], $prevRow, $nextRow, $blogId);
925 if (!empty($prevRow)) $prevSerial = $prevRow['be_serial'];
926 if (!empty($nextRow)) $nextSerial = $nextRow['be_serial'];
931 $iconUrl = blog_mainCommonDef::getEyecatchImageUrl($row['be_thumb_filename'], self::$_configArray[blog_mainCommonDef::CF_ENTRY_DEFAULT_IMAGE], self::$_configArray[blog_mainCommonDef::CF_THUMB_TYPE], 's'/*sサイズ画像*/) . '?' . date('YmdHis');
932 if (empty($row['be_thumb_filename'])){
933 $iconTitle = 'アイキャッチ画像未設定';
935 $iconTitle = 'アイキャッチ画像';
937 $eyecatchImageTag = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::EYECATCH_IMAGE_SIZE . '" height="' . self::EYECATCH_IMAGE_SIZE . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
940 $this->entryId = '0'; // 記事ID
941 $this->blogId = ''; // 所属ブログ
946 $metaDesc = ''; // ページ要約(METAタグ)
947 $metaKeyword = ''; // ページキーワード(METAタグ)
948 //$status = 0; // エントリー状況
949 $status = 1; // エントリー状況(編集中)
950 $reg_user = ''; // 投稿者
951 $entry_date = date("Y/m/d"); // 投稿日
952 $entry_time = date("H:i:s"); // 投稿時間
953 $update_user = '';// 更新者
955 $start_date = ''; // 公開期間開始日
956 $start_time = ''; // 公開期間開始時間
957 $end_date = ''; // 公開期間終了日
958 $end_time = ''; // 公開期間終了時間
959 $showComment = 1; // コメントを表示するかどうか
960 $receiveComment = 1; // コメントを受け付けるかどうか
961 $relatedContent = ''; // 関連コンテンツ
964 $this->categoryArray = array();
970 $this->fieldValueArray = array();
974 $this->createCategoryMenu($this->categoryCount);
977 $this->createUserFields($fieldInfoArray);
980 if (empty($this->useMultiBlog)){
981 /* $this->tmpl->setAttribute('show_blogid_area', 'visibility', 'visible');
983 $blogName = $this->getBlogName($this->blogId);
984 $this->tmpl->addVar("show_blogid_area", "blog_id", $this->blogId); // 所属ブログID
985 $this->tmpl->addVar("show_blogid_area", "blog_name", $blogName); // 所属ブログ名
987 } else { // マルチブログを使用するとき
988 $this->tmpl->setAttribute('select_blogid_area', 'visibility', 'visible');
991 $this->createBlogIdMenu();
995 if ($this->useComment){
996 $this->tmpl->setAttribute('show_comment_area', 'visibility', 'visible');
998 $this->tmpl->addVar("show_comment_area", "show_comment", $this->convertToCheckedString($showComment));// コメントを表示するかどうか
999 $this->tmpl->addVar("show_comment_area", "receive_comment", $this->convertToCheckedString($receiveComment));// コメントを受け付けるかどうか
1003 $previewUrl = $this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $this->entryId;
1004 if ($historyIndex >= 0) $previewUrl .= '&' . M3_REQUEST_PARAM_HISTORY . '=' . $historyIndex; // 履歴番号(旧データの場合のみ有効)
1005 $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_PREVIEW;
1006 if ($this->isMultiLang) $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_LANG . '=' . $this->langId; // 多言語対応の場合は言語IDを付加
1007 $this->tmpl->addVar('_widget', 'preview_url', $previewUrl);// プレビュー用URL(フロント画面)
1009 // CKEditor用のCSSファイルを読み込む
1010 $this->loadCKEditorCssFiles($previewUrl);
1013 $this->tmpl->addVar('_widget', 'entryid', $this->entryId);
1014 $this->tmpl->addVar("_widget", "item_name", $this->convertToDispString($name)); // 名前
1015 $this->tmpl->addVar("_widget", "item_html", $html); // HTML
1016 $this->tmpl->addVar("_widget", "item_html2", $html2); // HTML(続き)
1017 $this->tmpl->addVar("_widget", "desc", $desc); // 簡易説明
1018 $this->tmpl->addVar("_widget", "meta_desc", $this->convertToDispString($metaDesc)); // ページ要約(METAタグ)
1019 $this->tmpl->addVar("_widget", "meta_keyword", $this->convertToDispString($metaKeyword)); // ページキーワード(METAタグ)
1020 if ($this->_isSmallDeviceOptimize){ // 小画面デバイス最適化の場合
1022 case 1: $this->tmpl->addVar("_widget", "checked_edit", 'checked'); break;
1023 case 2: $this->tmpl->addVar("_widget", "checked_public", 'checked'); break;
1024 case 3: $this->tmpl->addVar("_widget", "checked_closed", 'checked'); break;
1028 case 1: $this->tmpl->addVar("_widget", "selected_edit", 'selected'); break;
1029 case 2: $this->tmpl->addVar("_widget", "selected_public", 'selected'); break;
1030 case 3: $this->tmpl->addVar("_widget", "selected_closed", 'selected'); break;
1033 $this->tmpl->addVar("_widget", "entry_user", $this->convertToDispString($reg_user)); // 投稿者
1034 $this->tmpl->addVar("_widget", "entry_date", $entry_date); // 投稿日
1035 $this->tmpl->addVar("_widget", "entry_time", $entry_time); // 投稿時
1036 $this->tmpl->addVar("_widget", "update_user", $update_user); // 更新者
1037 $this->tmpl->addVar("_widget", "update_dt", $update_dt); // 更新日時
1038 $this->tmpl->addVar("_widget", "start_date", $start_date); // 公開期間開始日
1039 $this->tmpl->addVar("_widget", "start_time", $start_time); // 公開期間開始時間
1040 $this->tmpl->addVar("_widget", "end_date", $end_date); // 公開期間終了日
1041 $this->tmpl->addVar("_widget", "end_time", $end_time); // 公開期間終了時間
1042 $this->tmpl->addVar("_widget", "related_content", $relatedContent); // 関連コンテンツ
1043 $this->tmpl->addVar("_widget", "eyecatch_image", $eyecatchImageTag); // アイキャッチ画像
1046 $this->tmpl->addVar("_widget", "serial", $this->serialNo); // シリアル番号
1047 $this->tmpl->addVar('_widget', 'calendar_img', $this->getUrl($this->gEnv->getRootUrl() . self::CALENDAR_ICON_FILE)); // カレンダーアイコン
1048 $this->tmpl->addVar('_widget', 'current_widget', $this->_widgetId); // AJAX用ウィジェットID
1051 if ($this->_isSmallDeviceOptimize){ // 小画面デバイス最適化の場合
1052 $resistDtTimestamp = strtotime($row['be_regist_dt']);
1053 $weekTypeArray = array('日', '月', '火', '水', '木', '金', '土');// 曜日表示名
1054 $datetimeStr = $date = date(self::DATETIME_FORMAT, $resistDtTimestamp);
1055 $datetimeStr = str_replace('$1', $weekTypeArray[intval(date('w', $resistDtTimestamp))], $datetimeStr);
1056 $this->tmpl->addVar("_widget", "entry_datetime_text", '<div class="form-control-static m3config_item">' . $datetimeStr . '</div>');
1060 if ($this->_isSmallDeviceOptimize){ // 小画面デバイス最適化の場合
1061 $statusLabelTag = '';
1064 $statusLabelTag = ' <span id="status_label" class="label label-warning">編集中</span>';
1065 $statusPanelTitle = '編集中'; // 記事状態パネルのタイトル
1066 $statusPanelColor = 'panel-warning'; // 記事状態パネルのカラー
1069 $statusLabelTag = ' <span id="status_label" class="label label-success">公開</span>';
1070 $statusPanelTitle = '公開'; // 記事状態パネルのタイトル
1071 $statusPanelColor = 'panel-success'; // 記事状態パネルのカラー
1074 $statusLabelTag = ' <span id="status_label" class="label label-warning">非公開</span>';
1075 $statusPanelTitle = '非公開'; // 記事状態パネルのタイトル
1076 $statusPanelColor = 'panel-warning'; // 記事状態パネルのカラー
1079 $this->tmpl->addVar("_widget", "status_label", $statusLabelTag);
1080 $this->tmpl->addVar("_widget", "status_panel_color", $statusPanelColor);
1081 $this->tmpl->addVar("_widget", "status_panel_title", $statusPanelTitle);
1085 $activeTermButton = $this->gDesign->createTermButton(''/*同画面*/, self::TOOLTIP_ACTIVE_TERM, self::TAG_ID_ACTIVE_TERM);
1086 $this->tmpl->addVar("_widget", "active_term_button", $activeTermButton);
1087 $this->tmpl->addVar("_widget", "tagid_active_term", self::TAG_ID_ACTIVE_TERM);
1088 if (!empty($start_date) || !empty($start_time) || !empty($end_date) || !empty($end_time)){
1089 $this->tmpl->addVar('_widget', 'show_active_term_area', 'true'); // 公開期間エリアの初期の表示状態
1091 $this->tmpl->addVar('_widget', 'show_active_term_area', 'false'); // 公開期間エリアの初期の表示状態
1095 if (!empty($prevSerial)){
1096 $this->tmpl->setAttribute('show_prev_button', 'visibility', 'visible');
1097 $this->tmpl->addVar('show_prev_button', 'serial', $prevSerial);
1099 if (!empty($nextSerial)){
1100 $this->tmpl->setAttribute('show_next_button', 'visibility', 'visible');
1101 $this->tmpl->addVar('show_next_button', 'serial', $nextSerial);
1104 // 入力フィールドの設定、共通項目のデータ設定
1105 if (empty($this->entryId)){ // 記事IDが0のときは、新規追加モードにする
1107 $this->tmpl->addVar('_widget', 'id', '新規');
1109 $this->tmpl->setAttribute('add_button', 'visibility', 'visible');
1110 // $this->tmpl->addVar('_widget', 'preview_btn_disabled', 'disabled');// プレビューボタン使用不可
1111 $this->tmpl->addVar('_widget', 'history_btn_disabled', 'disabled');// 履歴ボタン使用不可
1112 $this->tmpl->addVar('_widget', 'image_btn_disabled', 'disabled');// 画像ボタン使用不可
1113 $this->tmpl->addVar('_widget', 'schedule_btn_disabled', 'disabled');// 記事予約ボタン使用不可
1114 $this->tmpl->addVar('cancel_button', 'new_btn_disabled', 'disabled'); // 「新規」ボタン使用不可
1117 //$this->tmpl->addVar("default_lang", "default_lang", $defaultLangName);
1118 //$this->tmpl->setAttribute('default_lang', 'visibility', 'visible');
1121 $itemId = $this->entryId;
1122 if ($historyIndex >= 0) $itemId .= '(' . ($historyIndex +1) . ')';// 履歴番号(旧データの場合のみ有効)
1123 $this->tmpl->addVar('_widget', 'id', $itemId);
1126 if (empty($this->serialNo)){ // 未登録データのとき
1128 $this->tmpl->setAttribute('add_button', 'visibility', 'visible');
1130 if ($historyIndex >= 0){ // 履歴データの場合
1131 $this->tmpl->setAttribute('update_history_button', 'visibility', 'visible'); // 「履歴データで更新」ボタン
1134 $this->tmpl->setAttribute('delete_button', 'visibility', 'visible');// デフォルト言語以外はデータ削除
1135 $this->tmpl->setAttribute('update_button', 'visibility', 'visible');
1139 //if (!empty($this->entryId)){ // コンテンツが選択されているとき
1140 // self::$_mainDb->getAllLang(array($this, 'langLoop'));
1141 // $this->tmpl->setAttribute('select_lang', 'visibility', 'visible');
1146 if ($openBy == 'simple') $this->tmpl->setAttribute('cancel_button', 'visibility', 'hidden'); // 詳細画面のみの表示のときは戻るボタンを隠す
1149 * 取得したデータをテンプレートに設定する
1151 * @param int $index 行番号(0~)
1152 * @param array $fetchedRow フェッチ取得した行
1153 * @param object $param 未使用
1154 * @return bool true=処理続行の場合、false=処理終了の場合
1156 function itemListLoop($index, $fetchedRow, $param)
1159 $serial = $fetchedRow['be_serial'];
1160 $id = $fetchedRow['be_id'];
1163 $categoryArray = array();
1164 $ret = self::$_mainDb->getEntryBySerial($serial, $row, $categoryRow);
1166 for ($i = 0; $i < count($categoryRow); $i++){
1167 if (function_exists('mb_strimwidth')){
1168 $categoryArray[] = mb_strimwidth($categoryRow[$i]['bc_name'], 0, self::CATEGORY_NAME_SIZE, '…');
1170 $categoryArray[] = substr($categoryRow[$i]['bc_name'], 0, self::CATEGORY_NAME_SIZE) . '...';
1174 $category = implode(',', $categoryArray);
1177 switch ($fetchedRow['be_status']){
1178 case 1: $status = '<font color="orange">編集中</font>'; break;
1179 case 2: $status = '<font color="green">公開</font>'; break;
1180 case 3: $status = '非公開'; break;
1183 $updateViewCount = $this->gInstance->getAnalyzeManager()->getTotalContentViewCount(blog_mainCommonDef::VIEW_CONTENT_TYPE, $serial); // 更新後からの参照数
1184 $totalViewCount = $this->gInstance->getAnalyzeManager()->getTotalContentViewCount(blog_mainCommonDef::VIEW_CONTENT_TYPE, 0, $id); // 新規作成からの参照数
1185 $viewCountStr = $updateViewCount;
1186 if ($totalViewCount > $updateViewCount) $viewCountStr .= '(' . $totalViewCount . ')'; // 新規作成からの参照数がない旧仕様に対応
1189 $now = date("Y/m/d H:i:s"); // 現在日時
1190 $startDt = $fetchedRow['be_active_start_dt'];
1191 $endDt = $fetchedRow['be_active_end_dt'];
1193 $isActive = false; // 公開状態
1194 if ($fetchedRow['be_status'] == 2) $isActive = $this->_isActive($startDt, $endDt, $now);// 表示可能
1196 if ($this->_isSmallDeviceOptimize){ // 小画面デバイス最適化の場合
1197 if ($isActive){ // コンテンツが公開状態のとき
1198 $iconUrl = $this->gEnv->getRootUrl() . self::SMALL_ACTIVE_ICON_FILE; // 公開中アイコン
1201 $iconUrl = $this->gEnv->getRootUrl() . self::SMALL_INACTIVE_ICON_FILE; // 非公開アイコン
1204 $statusImg = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::SMALL_ICON_SIZE . '" height="' . self::SMALL_ICON_SIZE . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1206 if ($isActive){ // コンテンツが公開状態のとき
1207 $iconUrl = $this->gEnv->getRootUrl() . self::ACTIVE_ICON_FILE; // 公開中アイコン
1210 $iconUrl = $this->gEnv->getRootUrl() . self::INACTIVE_ICON_FILE; // 非公開アイコン
1213 $statusImg = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1217 $iconUrl = blog_mainCommonDef::getEyecatchImageUrl($fetchedRow['be_thumb_filename'], self::$_configArray[blog_mainCommonDef::CF_ENTRY_DEFAULT_IMAGE], self::$_configArray[blog_mainCommonDef::CF_THUMB_TYPE], 's'/*sサイズ画像*/) . '?' . date('YmdHis');
1218 if (empty($fetchedRow['be_thumb_filename'])){
1219 $iconTitle = 'アイキャッチ画像未設定';
1221 $iconTitle = 'アイキャッチ画像';
1223 $eyecatchImageTag = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::EYECATCH_IMAGE_SIZE . '" height="' . self::EYECATCH_IMAGE_SIZE . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1226 $outputDate = $fetchedRow['be_regist_dt'];
1227 if ($this->_isSmallDeviceOptimize){ // 小画面デバイス最適化の場合
1228 if (intval(date('Y', strtotime($outputDate))) == $this->currentYear){ // 年号が今日の年号のとき
1229 $dispDate = $this->convertToDispDate($outputDate, 11/*年省略,0なし年月*/) . '<br />' . $this->convertToDispTime($outputDate, 1/*時分*/);
1231 $dispDate = $this->convertToDispDate($outputDate, 3/*短縮年,0なし年月*/) . '<br />' . $this->convertToDispTime($outputDate, 1/*時分*/);
1234 $dispDate = $this->convertToDispDateTime($outputDate, 0/*ロングフォーマット*/, 10/*時分*/);
1238 'index' => $index, // 項目番号
1239 'no' => $index + 1, // 行番号
1240 'serial' => $serial, // シリアル番号
1241 'id' => $this->convertToDispString($id), // 記事ID
1242 'name' => $this->convertToDispString($fetchedRow['be_name']), // 名前
1243 'lang' => $lang, // 対応言語
1244 'eyecatch_image' => $eyecatchImageTag, // アイキャッチ画像
1245 'status_img' => $statusImg, // 公開状態
1246 'status' => $status, // 公開状況
1247 'category' => $category, // 記事カテゴリー
1248 //'view_count' => $totalViewCount, // 参照数
1249 'view_count' => $this->convertToDispString($viewCountStr), // 参照数
1250 'reg_user' => $this->convertToDispString($fetchedRow['lu_name']), // 投稿者
1251 // 'reg_date' => $this->convertToDispDateTime($fetchedRow['be_regist_dt'], 0/*ロングフォーマット*/, 10/*時分*/) // 投稿日時
1252 'reg_date' => $dispDate
1254 $this->tmpl->addVars('itemlist', $row);
1255 $this->tmpl->parseTemplate('itemlist', 'a');
1258 $this->serialArray[] = $serial;
1262 * 取得した言語をテンプレートに設定する
1264 * @param int $index 行番号(0~)
1265 * @param array $fetchedRow フェッチ取得した行
1266 * @param object $param 未使用
1267 * @return bool true=処理続行の場合、false=処理終了の場合
1269 function langLoop($index, $fetchedRow, $param)
1272 if ($fetchedRow['ln_id'] == $this->langId){
1273 $selected = 'selected';
1275 if ($this->gEnv->getCurrentLanguage() == 'ja'){ // 日本語表示の場合
1276 $name = $this->convertToDispString($fetchedRow['ln_name']);
1278 $name = $this->convertToDispString($fetchedRow['ln_name_en']);
1282 'value' => $this->convertToDispString($fetchedRow['ln_id']), // 言語ID
1283 'name' => $name, // 言語名
1284 'selected' => $selected // 選択中かどうか
1286 $this->tmpl->addVars('lang_list', $row);
1287 $this->tmpl->parseTemplate('lang_list', 'a');
1293 * @param array $srcRows 取得行
1294 * @return array 取得した行
1296 function getCategory($srcRows)
1298 $destArray = array();
1300 for ($i = 0; $i < count($srcRows); $i++){
1301 if (!empty($srcRows[$i]['bw_category_id'])){
1302 $destArray[] = $srcRows[$i]['bw_category_id'];
1304 if ($itemCount >= $this->categoryCount) break;
1312 * @param int $size メニューの表示数
1315 function createCategoryMenu($size)
1317 for ($j = 0; $j < $size; $j++){
1319 $this->tmpl->clearTemplate('category_list');
1320 for ($i = 0; $i < count($this->categoryListData); $i++){
1321 $categoryId = $this->categoryListData[$i]['bc_id'];
1323 if ($j < count($this->categoryArray) && $this->categoryArray[$j] == $categoryId){
1324 $selected = 'selected';
1327 'value' => $categoryId, // カテゴリーID
1328 'name' => $this->categoryListData[$i]['bc_name'], // カテゴリー名
1329 'selected' => $selected // 選択中かどうか
1331 $this->tmpl->addVars('category_list', $menurow);
1332 $this->tmpl->parseTemplate('category_list', 'a');
1335 'index' => $j // 項目番号
1337 $this->tmpl->addVars('category', $itemRow);
1338 $this->tmpl->parseTemplate('category', 'a');
1344 * @param string $blogId ブログID
1345 * @return string ブログ名
1347 function getBlogName($blogId)
1349 $ret = self::$_mainDb->getBlogInfoById($blogId, $row);
1351 return $row['bl_name'];
1353 return self::NO_BLOG_NAME;
1361 function createBlogIdMenu()
1363 if ($this->gEnv->isSystemManageUser()){ // システム運用ユーザのみ「ブログ選択なし」が利用可能
1365 if (empty($this->blogId)) $selected ='selected';
1367 'value' => $this->convertToDispString(''), // ブログID
1368 'name' => $this->convertToDispString(self::NO_BLOG_NAME), // ブログ選択なし
1369 'selected' => $selected // 選択中かどうか
1371 $this->tmpl->addVars('blogid_list', $row);
1372 $this->tmpl->parseTemplate('blogid_list', 'a');
1375 $ret = self::$_mainDb->getAvailableBlogId($rows);
1377 for ($i = 0; $i < count($rows); $i++){
1379 if ($rows[$i]['bl_id'] == $this->blogId) $selected = 'selected';
1381 'value' => $this->convertToDispString($rows[$i]['bl_id']), // ブログID
1382 'name' => $this->convertToDispString($rows[$i]['bl_name']), // ブログ名
1383 'selected' => $selected // 選択中かどうか
1385 $this->tmpl->addVars('blogid_list', $row);
1386 $this->tmpl->parseTemplate('blogid_list', 'a');
1393 * @param timestamp $startDt 公開開始日時
1394 * @param timestamp $endDt 公開終了日時
1395 * @param timestamp $now 基準日時
1396 * @return bool true=公開可能、false=公開不可
1398 function _isActive($startDt, $endDt, $now)
1400 $isActive = false; // 公開状態
1402 if ($startDt == $this->gEnv->getInitValueOfTimestamp() && $endDt == $this->gEnv->getInitValueOfTimestamp()){
1403 $isActive = true; // 公開状態
1404 } else if ($startDt == $this->gEnv->getInitValueOfTimestamp()){
1405 if (strtotime($now) < strtotime($endDt)) $isActive = true; // 公開状態
1406 } else if ($endDt == $this->gEnv->getInitValueOfTimestamp()){
1407 if (strtotime($now) >= strtotime($startDt)) $isActive = true; // 公開状態
1409 if (strtotime($startDt) <= strtotime($now) && strtotime($now) < strtotime($endDt)) $isActive = true; // 公開状態
1416 * @param int $serial 削除対象のコンテンツシリアル番号
1419 function clearCacheBySerial($serial)
1421 $ret = self::$_mainDb->getEntryBySerial($serial, $row, $categoryRow);// 記事ID取得
1423 $entryId = $row['be_id']; // 記事ID
1424 $urlParam = array();
1425 $urlParam[] = M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $entryId; // 記事ID
1426 $urlParam[] = M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT . '=' . $entryId; // 記事ID略式
1427 $this->clearCache($urlParam);
1433 * @param array $fields フィールドID
1434 * @return bool true=成功、false=失敗
1436 function createUserFields($fields)
1438 if (count($fields) == 0) return true;
1440 $this->tmpl->setAttribute('user_fields', 'visibility', 'visible');
1441 $keys = array_keys($fields);
1442 $fieldCount = count($keys);
1443 for ($i = 0; $i < $fieldCount; $i++){
1444 if ($i == 0) $this->tmpl->addVar('user_fields', 'type', 'first'); // 最初の行の場合
1448 $value = $this->fieldValueArray[$key];
1449 if (!isset($value)) $value = '';
1452 'row_count' => $fieldCount,
1453 'field_id' => $this->convertToDispString($key),
1454 'value' => $this->convertToDispString($value)
1456 $this->tmpl->addVars('user_fields', $row);
1457 $this->tmpl->parseTemplate('user_fields', 'a');
1464 * @param array $categoryArray ソート対象のカテゴリー
1465 * @return bool true=成功、false=失敗
1467 function sortCategory(&$categoryArray)
1470 $categoryArray = array_unique($categoryArray);
1473 $this->categorySortInfo = array();
1474 $categoryCount = count($this->categoryListData);
1475 for ($i = 0; $i < $categoryCount; $i++){
1476 $key = $this->categoryListData[$i]['bc_id'];
1477 $this->categorySortInfo[$key] = $i;
1481 usort($categoryArray, array($this, 'sortCategoryCompare'));
1491 function sortCategoryCompare($a, $b)
1493 if ($this->categorySortInfo[$a] == $this->categorySortInfo[$b]) return 0;
1494 return ($this->categorySortInfo[$a] < $this->categorySortInfo[$b]) ? -1 : 1;