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-2015 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/admin_blog_mainBaseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/blog_mainDb.php');
18 require_once($gEnvManager->getCommonPath() . '/valueCheck.php');
20 // このファイルはadmin_blog_mainEntryWidgetContainer.phpの内容と同じ。クラス名の定義のみ異なる。
21 //class admin_blog_mainEntryWidgetContainer extends admin_blog_mainBaseWidgetContainer
22 class blog_mainEntryWidgetContainer extends blog_mainBaseWidgetContainer
24 private $serialNo; // 選択中の項目のシリアル番号
26 private $blogId; // 所属ブログ
27 private $langId; // 現在の選択言語
28 private $serialArray = array(); // 表示されている項目シリアル番号
29 private $categoryListData; // 全記事カテゴリー
30 private $categoryArray; // 選択中の記事カテゴリー
31 private $categoryCount; // カテゴリ数
32 private $isMultiLang; // 多言語対応画面かどうか
33 private $fieldValueArray; // ユーザ定義フィールド入力値
34 const ICON_SIZE = 32; // アイコンのサイズ
35 const CONTENT_TYPE = 'bg'; // 記事参照数取得用
36 const DEFAULT_LIST_COUNT = 20; // 最大リスト表示数
37 const LINK_PAGE_COUNT = 20; // リンクページ数
38 const CATEGORY_NAME_SIZE = 20; // カテゴリー名の最大文字列長
39 const CALENDAR_ICON_FILE = '/images/system/calendar.png'; // カレンダーアイコン
40 const ACTIVE_ICON_FILE = '/images/system/active32.png'; // 公開中アイコン
41 const INACTIVE_ICON_FILE = '/images/system/inactive32.png'; // 非公開アイコン
42 const SEARCH_ICON_FILE = '/images/system/search16.png'; // 検索用アイコン
43 const NO_BLOG_NAME = '所属なし'; // 所属ブログなし
44 const FIELD_HEAD = 'item_'; // フィールド名の先頭文字列
49 function __construct()
52 parent::__construct();
54 $this->isMultiLang = $this->gEnv->isMultiLanguageSite(); // 多言語対応画面かどうか
59 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
60 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
62 * @param RequestManager $request HTTPリクエスト処理クラス
63 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
64 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
66 function _setTemplate($request, &$param)
68 $task = $request->trimValueOf('task');
70 if ($task == 'entry_detail'){ // 詳細画面
71 return 'admin_entry_detail.tmpl.html';
73 return 'admin_entry.tmpl.html';
79 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
81 * @param RequestManager $request HTTPリクエスト処理クラス
82 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
85 function _assign($request, &$param)
87 $task = $request->trimValueOf('task');
88 if ($task == 'entry_detail'){ // 詳細画面
89 return $this->createDetail($request);
91 return $this->createList($request);
95 * JavascriptファイルをHTMLヘッダ部に設定
97 * JavascriptファイルをHTMLのheadタグ内に追加出力する。
98 * _assign()よりも後に実行される。
100 * @param RequestManager $request HTTPリクエスト処理クラス
101 * @param object $param 任意使用パラメータ。
102 * @return string Javascriptファイル。出力しない場合は空文字列を設定。
104 function _addScriptFileToHead($request, &$param)
106 $scriptArray = array($this->getUrl($this->gEnv->getScriptsUrl() . self::CALENDAR_SCRIPT_FILE), // カレンダースクリプトファイル
107 $this->getUrl($this->gEnv->getScriptsUrl() . self::CALENDAR_LANG_FILE), // カレンダー言語ファイル
108 $this->getUrl($this->gEnv->getScriptsUrl() . self::CALENDAR_SETUP_FILE)); // カレンダーセットアップファイル
113 * CSSファイルをHTMLヘッダ部に設定
115 * CSSファイルをHTMLのheadタグ内に追加出力する。
116 * _assign()よりも後に実行される。
118 * @param RequestManager $request HTTPリクエスト処理クラス
119 * @param object $param 任意使用パラメータ。
120 * @return string CSS文字列。出力しない場合は空文字列を設定。
122 function _addCssFileToHead($request, &$param)
124 return $this->getUrl($this->gEnv->getScriptsUrl() . self::CALENDAR_CSS_FILE);
129 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
131 * @param RequestManager $request HTTPリクエスト処理クラス
134 function createList($request)
137 $defaultLangId = $this->gEnv->getDefaultLanguage();
139 $act = $request->trimValueOf('act');
140 $this->langId = $request->trimValueOf('item_lang'); // 現在メニューで選択中の言語
141 if (empty($this->langId)) $this->langId = $defaultLangId; // 言語が選択されていないときは、デフォルト言語を設定
142 if ($this->gEnv->isAdminDirAccess()){ // 管理画面へのアクセスの場合
143 $this->blogId = null; // デフォルトブログ(ブログID空)を含むすべてのブログ記事にアクセス可能
145 $this->blogId = $request->trimValueOf(M3_REQUEST_PARAM_BLOG_ID); // 所属ブログ
149 $pageNo = $request->trimIntValueOf(M3_REQUEST_PARAM_PAGE_NO, '1'); // ページ番号
152 $maxListCount = self::DEFAULT_LIST_COUNT;
153 $serializedParam = $this->_db->getWidgetParam($this->gEnv->getCurrentWidgetId());
154 if (!empty($serializedParam)){
155 $dispInfo = unserialize($serializedParam);
156 $maxListCount = $dispInfo->maxMemberListCountByAdmin; // 会員リスト最大表示数
159 $search_startDt = $request->trimValueOf('search_start'); // 検索範囲開始日付
160 if (!empty($search_startDt)) $search_startDt = $this->convertToProperDate($search_startDt);
161 $search_endDt = $request->trimValueOf('search_end'); // 検索範囲終了日付
162 if (!empty($search_endDt)) $search_endDt = $this->convertToProperDate($search_endDt);
163 $search_categoryId = $request->trimValueOf('search_category0'); // 検索カテゴリー
164 $search_keyword = $request->trimValueOf('search_keyword'); // 検索キーワード
167 $this->categoryArray = array();
168 if (!empty($search_categoryId)){ // 0以外の値を取得
169 $this->categoryArray[] = $search_categoryId;
172 if ($act == 'delete'){ // 項目削除の場合
173 $listedItem = explode(',', $request->trimValueOf('seriallist'));
175 for ($i = 0; $i < count($listedItem); $i++){
177 $itemName = 'item' . $i . '_selected';
178 $itemValue = ($request->trimValueOf($itemName) == 'on') ? 1 : 0;
180 if ($itemValue){ // チェック項目
181 $delItems[] = $listedItem[$i];
184 if (count($delItems) > 0){
186 $delEntryInfo = array();
187 for ($i = 0; $i < count($delItems); $i++){
188 $ret = self::$_mainDb->getEntryBySerial($delItems[$i], $row, $categoryRow);
190 $newInfoObj = new stdClass;
191 $newInfoObj->entryId = $row['be_id']; // 記事ID
192 $newInfoObj->name = $row['be_name']; // 記事タイトル
193 $newInfoObj->thumb = $row['be_thumb_filename']; // サムネール
194 $delEntryInfo[] = $newInfoObj;
198 $ret = self::$_mainDb->delEntryItem($delItems);
199 if ($ret){ // データ削除成功のとき
200 $this->setGuidanceMsg('データを削除しました');
202 // ##### サムネールの削除 #####
203 for ($i = 0; $i < count($delEntryInfo); $i++){
204 $infoObj = $delEntryInfo[$i];
205 // $ret = blog_mainCommonDef::removeThumbnail($infoObj->entryId);
207 if (!empty($infoObj->thumb)){
208 //$oldFiles = explode(';', $infoObj->thumb);
209 //$this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $oldFiles);
212 blog_mainCommonDef::removerEyecatchImage($infoObj->entryId);
217 for ($i = 0; $i < count($delItems); $i++){
218 $this->clearCacheBySerial($delItems[$i]);
222 $this->gPage->updateParentWindow();
225 for ($i = 0; $i < count($delEntryInfo); $i++){
226 $infoObj = $delEntryInfo[$i];
227 //$this->gOpeLog->writeUserInfo(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $infoObj->name, 2100, 'ID=' . $infoObj->entryId);
228 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
229 M3_EVENT_HOOK_PARAM_CONTENT_ID => $infoObj->entryId,
230 M3_EVENT_HOOK_PARAM_UPDATE_DT => date("Y/m/d H:i:s"));
231 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $infoObj->name, 2402, 'ID=' . $infoObj->entryId, $eventParam);
234 $this->setAppErrorMsg('データ削除に失敗しました');
237 } else if ($act == 'search'){ // 検索のとき
238 if (!empty($search_startDt) && !empty($search_endDt) && $search_startDt > $search_endDt){
239 $this->setUserErrorMsg('期間の指定範囲にエラーがあります。');
241 $pageNo = 1; // ページ番号初期化
242 } else if ($act == 'selpage'){ // ページ選択
244 // ###### 一覧の取得条件を作成 ######
245 if (!empty($search_endDt)) $endDt = $this->getNextDay($search_endDt);
248 $totalCount = self::$_mainDb->getEntryItemCount($search_startDt, $endDt, $this->categoryArray, $search_keyword, $this->langId, $this->blogId);
251 $this->calcPageLink($pageNo, $totalCount, $maxListCount);
254 $pageLink = $this->createPageLink($pageNo, self::LINK_PAGE_COUNT, ''/*リンク作成用(未使用)*/, 'selpage($1);return false;');
257 self::$_mainDb->searchEntryItems($maxListCount, $pageNo, $search_startDt, $endDt, $this->categoryArray, $search_keyword, $this->langId, array($this, 'itemListLoop'), $this->blogId);
258 if (count($this->serialArray) <= 0) $this->tmpl->setAttribute('itemlist', 'visibility', 'hidden');// 投稿記事がないときは、一覧を表示しない
261 self::$_mainDb->getAllCategory($this->langId, $this->categoryListData);
262 $this->createCategoryMenu(1); // メニューは1つだけ表示
265 $previewUrl = $this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_PAGE_SUB_ID . '=' . $this->gEnv->getPageSubIdByContentType($this->gEnv->getDefaultPageId(), M3_VIEW_TYPE_BLOG);
266 $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_PREVIEW;
267 // if ($this->isMultiLang) $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_LANG . '=' . $this->langId; // 多言語対応の場合は言語IDを付加
268 $this->tmpl->addVar('_widget', 'preview_url', $previewUrl);// プレビュー用URL(一般画面)
271 $this->tmpl->addVar("_widget", "page_link", $pageLink);
272 $this->tmpl->addVar("_widget", "total_count", $totalCount);
275 $this->tmpl->addVar("_widget", "search_start", $search_startDt); // 開始日付
276 $this->tmpl->addVar("_widget", "search_end", $search_endDt); // 終了日付
277 $this->tmpl->addVar("_widget", "search_keyword", $search_keyword); // 検索キーワード
280 $this->tmpl->addVar("_widget", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
281 $this->tmpl->addVar("_widget", "page", $pageNo); // ページ番号
282 $this->tmpl->addVar("_widget", "list_count", $maxListCount); // 一覧表示項目数
287 * @param RequestManager $request HTTPリクエスト処理クラス
290 function createDetail($request)
293 $defaultLangId = $this->gEnv->getDefaultLanguage();
294 $regUserId = $this->gEnv->getCurrentUserId(); // 記事投稿ユーザ
295 //$regDt = date("Y/m/d H:i:s"); // 投稿日時
298 $useMultiBlog = self::$_configArray[blog_mainCommonDef::CF_USE_MULTI_BLOG];// マルチブログを使用するかどうか
299 $useComment = self::$_configArray[blog_mainCommonDef::CF_RECEIVE_COMMENT];// コメント機能を使用するかどうか
300 $this->categoryCount = self::$_configArray[blog_mainCommonDef::CF_CATEGORY_COUNT]; // カテゴリ数
301 if (empty($this->categoryCount)) $this->categoryCount = self::DEFAULT_CATEGORY_COUNT;
304 $contentLayout = array(self::$_configArray[blog_mainCommonDef::CF_LAYOUT_ENTRY_SINGLE], self::$_configArray[blog_mainCommonDef::CF_LAYOUT_ENTRY_LIST]);
305 $fieldInfoArray = blog_mainCommonDef::parseUserMacro($contentLayout);
308 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY); // ウィンドウオープンタイプ
309 $act = $request->trimValueOf('act');
310 $this->langId = $request->trimValueOf('item_lang'); // 現在メニューで選択中の言語
311 if (empty($this->langId)) $this->langId = $defaultLangId; // 言語が選択されていないときは、デフォルト言語を設定
312 $this->entryId = $request->trimValueOf('entryid'); // 記事エントリーID
313 $this->serialNo = $request->trimValueOf('serial'); // 選択項目のシリアル番号
314 // if (empty($this->serialNo)) $this->serialNo = 0;
315 $this->blogId = $request->trimValueOf(M3_REQUEST_PARAM_BLOG_ID); // 所属ブログ
316 $name = $request->trimValueOf('item_name');
317 $entry_date = $request->trimValueOf('item_entry_date'); // 投稿日
318 $entry_time = $request->trimValueOf('item_entry_time'); // 投稿時間
319 $html = $request->valueOf('item_html');
320 $html2 = $request->valueOf('item_html2');
321 if (strlen($html2) <= 10){ // IE6のときFCKEditorのバグの対応(「続き」が空の場合でもpタグが送信される)
324 $desc = $request->trimValueOf('item_desc'); // 簡易説明
325 $status = $request->trimValueOf('item_status'); // エントリー状態(0=未設定、1=編集中、2=公開、3=非公開)
326 $category = ''; // カテゴリー
327 $showComment = ($request->trimValueOf('show_comment') == 'on') ? 1 : 0; // コメントを表示するかどうか
328 $receiveComment = ($request->trimValueOf('receive_comment') == 'on') ? 1 : 0; // コメントを受け付けるかどうか
329 $relatedContent = $request->trimValueOf('item_related_content'); // 関連コンテンツ
330 if (!$useComment){ // コメント機能を使用しない場合のデフォルト値
331 $showComment = 1; // コメントを表示するかどうか
332 $receiveComment = 1; // コメントを受け付けるかどうか
336 $this->categoryArray = array();
337 for ($i = 0; $i < $this->categoryCount; $i++){
338 $itemName = 'item_category' . $i;
339 $itemValue = $request->trimValueOf($itemName);
340 if (!empty($itemValue)){ // 0以外の値を取得
341 $this->categoryArray[] = $itemValue;
346 $start_date = $request->trimValueOf('item_start_date'); // 公開期間開始日付
347 if (!empty($start_date)) $start_date = $this->convertToProperDate($start_date);
348 $start_time = $request->trimValueOf('item_start_time'); // 公開期間開始時間
349 if (empty($start_date)){
350 $start_time = ''; // 日付が空のときは時刻も空に設定する
352 if (empty($start_time)) $start_time = '00:00'; // 日付が入っているときは時間にデフォルト値を設定
354 if (!empty($start_time)) $start_time = $this->convertToProperTime($start_time, 1/*時分フォーマット*/);
356 $end_date = $request->trimValueOf('item_end_date'); // 公開期間終了日付
357 if (!empty($end_date)) $end_date = $this->convertToProperDate($end_date);
358 $end_time = $request->trimValueOf('item_end_time'); // 公開期間終了時間
359 if (empty($end_date)){
360 $end_time = ''; // 日付が空のときは時刻も空に設定する
362 if (empty($end_time)) $end_time = '00:00'; // 日付が入っているときは時間にデフォルト値を設定
364 if (!empty($end_time)) $end_time = $this->convertToProperTime($end_time, 1/*時分フォーマット*/);
367 $this->fieldValueArray = array(); // ユーザ定義フィールド入力値
368 $fieldKeys = array_keys($fieldInfoArray);
369 for ($i = 0; $i < count($fieldKeys); $i++){
370 $fieldKey = $fieldKeys[$i];
371 $itemName = self::FIELD_HEAD . $fieldKey;
372 $itemValue = $this->cleanMacroValue($request->trimValueOf($itemName));
373 if (!empty($itemValue)) $this->fieldValueArray[$fieldKey] = $itemValue;
376 $historyIndex = -1; // 履歴番号初期化(旧データの場合のみ有効)
377 $reloadData = false; // データの再ロード
378 if ($act == 'select'){ // 一覧から選択のとき
379 $reloadData = true; // データの再ロード
380 } else if ($act == 'new'){
382 $reloadData = true; // データの再読み込み
383 } else if ($act == 'selectlang'){ // 項目選択の場合
385 $this->serialNo = self::$_mainDb->getEntrySerialNoByContentId($this->entryId, $this->langId);
386 if (empty($this->serialNo)){
388 //$name = ''; // タイトル
389 //$html = ''; // HTML
390 $status = 0; // エントリー状況
391 $reg_user = ''; // 投稿者
392 $update_user = '';// 更新者
395 $reloadData = true; // データの再ロード
397 } else if ($act == 'add' || $act == 'addlang'){ // 項目追加の場合
399 $this->checkInput($name, 'タイトル');
400 $this->checkDate($entry_date, '投稿日付');
401 $this->checkTime($entry_time, '投稿時間');
404 if (!empty($start_date) && !empty($end_date)){
405 if (strtotime($start_date . ' ' . $start_time) >= strtotime($end_date . ' ' . $end_time)) $this->setUserErrorMsg('公開期間が不正です');
409 if (!empty($relatedContent)){
410 $contentIdArray = explode(',', $relatedContent);
411 if (!ValueCheck::isNumeric($contentIdArray)) $this->setUserErrorMsg('関連コンテンツにエラー値があります');// すべて数値であるかチェック
415 if ($this->getMsgCount() == 0){
417 if (empty($start_date)){
418 $startDt = $this->gEnv->getInitValueOfTimestamp();
420 $startDt = $start_date . ' ' . $start_time;
422 if (empty($end_date)){
423 $endDt = $this->gEnv->getInitValueOfTimestamp();
425 $endDt = $end_date . ' ' . $end_time;
427 $regDt = $this->convertToProperDate($entry_date) . ' ' . $this->convertToProperTime($entry_time); // 投稿日時
431 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
433 $nextEntryId = self::$_mainDb->getNextEntryId();
435 if ($status == 2){ // 記事公開の場合のみアイキャッチ画像を作成
436 $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html);
437 if (empty($thumbPath) && !empty($html2)) $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html2); // 本文1に画像がないときは本文2を検索
438 if (!empty($thumbPath)){
439 $ret = $this->gInstance->getImageManager()->createSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $nextEntryId, $thumbPath, $destFilename);
440 if ($ret) $thumbFilename = implode(';', $destFilename);
446 $otherParams = array( 'be_description' => $desc, // 簡易説明
447 'be_thumb_filename' => $thumbFilename, // サムネールファイル名
448 'be_related_content' => $relatedContent, // 関連コンテンツ
449 'be_option_fields' => $this->serializeArray($this->fieldValueArray)); // ユーザ定義フィールド値
450 //if ($act == 'add'){
451 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // 多言語でデフォルト言語、または単一言語のとき
452 $ret = self::$_mainDb->addEntryItem($nextEntryId * (-1)/*次のコンテンツIDのチェック*/, $this->langId, $name, $html, $html2, $status, $this->categoryArray, $this->blogId,
453 $regUserId, $regDt, $startDt, $endDt, $showComment, $receiveComment, $newSerial, $otherParams);
455 $ret = self::$_mainDb->addEntryItem($this->entryId, $this->langId, $name, $html, $html2, $status, $this->categoryArray, $this->blogId,
456 $regUserId, $regDt, $startDt, $endDt, $showComment, $receiveComment, $newSerial, $otherParams);
459 $this->setGuidanceMsg('データを追加しました');
462 $this->serialNo = $newSerial;
463 $reloadData = true; // データの再ロード
465 // ##### サムネールの作成 #####
466 /* $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
468 $entryId = $row['be_id']; // 記事ID
469 $html = $row['be_html']; // HTML
470 $updateDt = $row['be_create_dt'];
471 $status = $row['be_status'];
473 if ($status == 2){ // 公開の場合
474 $ret = blog_mainCommonDef::createThumbnail($html, $entryId, $updateDt);
476 $ret = blog_mainCommonDef::removeThumbnail($entryId);
481 $this->clearCacheBySerial($this->serialNo);
484 $this->gPage->updateParentWindow();
488 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
490 $this->entryId = $row['be_id']; // 記事ID
491 $name = $row['be_name']; // コンテンツ名前
492 $updateDt = $row['be_create_dt']; // 作成日時
495 switch ($row['be_status']){
496 case 1: $statusStr = '編集中'; break;
497 case 2: $statusStr = '公開'; break;
498 case 3: $statusStr = '非公開'; break;
501 //$this->gOpeLog->writeUserInfo(__METHOD__, 'ブログ記事を追加(' . $statusStr . ')しました。タイトル: ' . $name, 2100, 'ID=' . $this->entryId);
502 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
503 M3_EVENT_HOOK_PARAM_CONTENT_ID => $this->entryId,
504 M3_EVENT_HOOK_PARAM_UPDATE_DT => $updateDt);
505 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を追加(' . $statusStr . ')しました。タイトル: ' . $name, 2400, 'ID=' . $this->entryId, $eventParam);
507 $this->setAppErrorMsg('データ追加に失敗しました');
510 } else if ($act == 'update'){ // 項目更新の場合
512 $this->checkInput($name, 'タイトル');
513 $this->checkDate($entry_date, '投稿日付');
514 $this->checkTime($entry_time, '投稿時間');
517 if (!empty($start_date) && !empty($end_date)){
518 if (strtotime($start_date . ' ' . $start_time) >= strtotime($end_date . ' ' . $end_time)) $this->setUserErrorMsg('公開期間が不正です');
522 if (!empty($relatedContent)){
523 $contentIdArray = explode(',', $relatedContent);
524 if (!ValueCheck::isNumeric($contentIdArray)) $this->setUserErrorMsg('関連コンテンツにエラー値があります');// すべて数値であるかチェック
528 if ($this->getMsgCount() == 0){
530 if (empty($start_date)){
531 $startDt = $this->gEnv->getInitValueOfTimestamp();
533 $startDt = $start_date . ' ' . $start_time;
535 if (empty($end_date)){
536 $endDt = $this->gEnv->getInitValueOfTimestamp();
538 $endDt = $end_date . ' ' . $end_time;
540 $regDt = $this->convertToProperDate($entry_date) . ' ' . $this->convertToProperTime($entry_time); // 投稿日時
544 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
545 if ($status == 2){ // 記事公開の場合のみアイキャッチ画像を作成
546 // コンテンツからアイキャッチ画像を作成
547 $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html);
548 if (empty($thumbPath) && !empty($html2)) $thumbPath = $this->gInstance->getImageManager()->getFirstImagePath($html2); // 本文1に画像がないときは本文2を検索
549 if (!empty($thumbPath)){
550 $ret = $this->gInstance->getImageManager()->createSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $this->entryId, $thumbPath, $destFilename);
551 if ($ret) $thumbFilename = implode(';', $destFilename);
554 // 非公開ディレクトリのアイキャッチ画像をコピー
555 $ret = blog_mainCommonDef::copyEyecatchImageToPublicDir($this->entryId);
556 if ($ret){ // アイキャッチ画像をコピーした場合は、ファイル名を取得
558 list($destFilename, $formats) = $this->gInstance->getImageManager()->getSystemDefaultThumbFilename($this->entryId, 1/*クロップ画像のみ*/);
559 $thumbFilename = implode(';', $destFilename);
562 // 公開ディレクトリのアイキャッチ画像を削除
563 blog_mainCommonDef::removerEyecatchImageInPublicDir($this->entryId);
568 $otherParams = array( 'be_description' => $desc, // 簡易説明
569 'be_thumb_filename' => $thumbFilename, // サムネールファイル名
570 'be_related_content' => $relatedContent, // 関連コンテンツ
571 'be_option_fields' => $this->serializeArray($this->fieldValueArray)); // ユーザ定義フィールド値
573 // 履歴からのデータ取得の場合はシリアル番号を最新に変更
574 $mode = $request->trimValueOf('mode'); // データ更新モード
575 if ($mode == 'history'){ // 履歴データ表示モード
576 $this->serialNo = self::$_mainDb->getEntrySerialNoByContentId($this->entryId, $this->langId); // 最新のシリアル番号を取得
578 // ### 履歴データを再取得すべき? ###
581 $ret = self::$_mainDb->updateEntryItem($this->serialNo, $name, $html, $html2, $status, $this->categoryArray, $this->blogId,
582 ''/*投稿者そのまま*/, $regDt, $startDt, $endDt, $showComment, $receiveComment, $newSerial, $oldRecord, $otherParams);
584 // コンテンツに画像がなくなった場合は、サムネールを削除
585 if (empty($thumbFilename) && !empty($oldRecord['be_thumb_filename'])){
586 $oldFiles = explode(';', $oldRecord['be_thumb_filename']);
587 $this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $oldFiles);
592 $this->setGuidanceMsg('データを更新しました');
595 $this->serialNo = $newSerial;
596 $reloadData = true; // データの再ロード
598 /* // ##### サムネールの作成 #####
599 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
601 $entryId = $row['be_id']; // 記事ID
602 $html = $row['be_html']; // HTML
603 $updateDt = $row['be_create_dt'];
604 $status = $row['be_status'];
606 if ($status == 2){ // 公開の場合
607 $ret = blog_mainCommonDef::createThumbnail($html, $entryId, $updateDt);
609 $ret = blog_mainCommonDef::removeThumbnail($entryId);
614 $this->clearCacheBySerial($this->serialNo);
617 $this->gPage->updateParentWindow();
621 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
623 $this->entryId = $row['be_id']; // 記事ID
624 $name = $row['be_name']; // コンテンツ名前
625 $updateDt = $row['be_create_dt']; // 作成日時
628 switch ($row['be_status']){
629 case 1: $statusStr = '編集中'; break;
630 case 2: $statusStr = '公開'; break;
631 case 3: $statusStr = '非公開'; break;
634 //$this->gOpeLog->writeUserInfo(__METHOD__, 'ブログ記事を更新(' . $statusStr . ')しました。タイトル: ' . $name, 2100, 'ID=' . $this->entryId);
635 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
636 M3_EVENT_HOOK_PARAM_CONTENT_ID => $this->entryId,
637 M3_EVENT_HOOK_PARAM_UPDATE_DT => $updateDt);
638 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を更新(' . $statusStr . ')しました。タイトル: ' . $name, 2401, 'ID=' . $this->entryId, $eventParam);
640 $this->setAppErrorMsg('データ更新に失敗しました');
643 } else if ($act == 'delete'){ // 項目削除の場合
644 if (empty($this->serialNo)){
645 $this->setUserErrorMsg('削除項目が選択されていません');
648 if ($this->getMsgCount() == 0){
650 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
652 $this->entryId = $row['be_id']; // 記事ID
653 $name = $row['be_name']; // コンテンツ名前
656 $ret = self::$_mainDb->delEntryItem(array($this->serialNo));
657 if ($ret){ // データ削除成功のとき
658 $this->setGuidanceMsg('データを削除しました');
660 // ##### サムネールの削除 #####
661 // $ret = blog_mainCommonDef::removeThumbnail($this->entryId);
664 if (!empty($row['be_thumb_filename'])){
665 // $oldFiles = explode(';', $row['be_thumb_filename']);
666 // $this->gInstance->getImageManager()->delSystemDefaultThumb(M3_VIEW_TYPE_BLOG, blog_mainCommonDef::$_deviceType, $oldFiles);
669 blog_mainCommonDef::removerEyecatchImage($this->entryId);
673 $this->clearCacheBySerial($this->serialNo);
676 $this->gPage->updateParentWindow();
679 //$this->gOpeLog->writeUserInfo(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $name, 2100, 'ID=' . $this->entryId);
680 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
681 M3_EVENT_HOOK_PARAM_CONTENT_ID => $this->entryId,
682 M3_EVENT_HOOK_PARAM_UPDATE_DT => date("Y/m/d H:i:s"));
683 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $name, 2402, 'ID=' . $this->entryId, $eventParam);
685 $this->setAppErrorMsg('データ削除に失敗しました');
688 } else if ($act == 'deleteid'){ // ID項目削除の場合
689 if (empty($this->serialNo)){
690 $this->setUserErrorMsg('削除項目が選択されていません');
693 if ($this->getMsgCount() == 0){
695 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
697 $this->entryId = $row['be_id']; // 記事ID
698 $name = $row['be_name']; // コンテンツ名前
701 $ret = self::$_mainDb->delEntryItemById($this->serialNo);
702 if ($ret){ // データ削除成功のとき
703 $this->setGuidanceMsg('データを削除しました');
705 // ##### サムネールの削除 #####
706 // $ret = blog_mainCommonDef::removeThumbnail($this->entryId);
709 blog_mainCommonDef::removerEyecatchImage($this->entryId);
712 $this->clearCacheBySerial($this->serialNo);
715 $this->gPage->updateParentWindow();
718 //$this->gOpeLog->writeUserInfo(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $name, 2100, 'ID=' . $this->entryId);
719 $eventParam = array( M3_EVENT_HOOK_PARAM_CONTENT_TYPE => M3_VIEW_TYPE_BLOG,
720 M3_EVENT_HOOK_PARAM_CONTENT_ID => $this->entryId,
721 M3_EVENT_HOOK_PARAM_UPDATE_DT => date("Y/m/d H:i:s"));
722 $this->writeUserInfoEvent(__METHOD__, 'ブログ記事を削除しました。タイトル: ' . $name, 2402, 'ID=' . $this->entryId, $eventParam);
724 $this->setAppErrorMsg('データ削除に失敗しました');
727 } else if ($act == 'get_history'){ // 履歴データの取得のとき
728 $reloadData = true; // データの再読み込み
729 } else { // 初期画面表示のとき
730 // ##### ブログ記事IDが設定されているとき(他ウィジェットからの表示)は、データを取得 #####
731 if (empty($this->entryId)){
732 if (!empty($this->serialNo)){ // シリアル番号で指定の場合
733 $reloadData = true; // データの再読み込み
737 if ($this->isMultiLang){ // 多言語対応の場合
738 $langId = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_LANG); // lang値を取得
739 if (!empty($langId)) $this->langId = $langId;
743 $ret = self::$_mainDb->getEntryItem($this->entryId, $this->langId, $row);
745 $this->serialNo = $row['be_serial']; // シリアル番号
746 $reloadData = true; // データの再読み込み
751 if (empty($this->serialNo)){
753 // 所属ブログIDは親ウィンドウから引き継ぐ
754 //$this->blogId = ''; // 所属ブログ
755 $entry_date = date("Y/m/d"); // 投稿日
756 $entry_time = date("H:i:s"); // 投稿時間
757 $showComment = 1; // コメントを表示するかどうか
758 $receiveComment = 1; // コメントを受け付けるかどうか
763 if ($reloadData){ // データの再ロード
764 $ret = self::$_mainDb->getEntryBySerial($this->serialNo, $row, $categoryRow);
766 $this->entryId = $row['be_id']; // 記事ID
767 $this->blogId = $row['be_blog_id']; // 所属ブログ
768 $name = $row['be_name']; // タイトル
769 $html = $row['be_html']; // HTML
770 $html = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $html);// アプリケーションルートを変換
771 $html2 = $row['be_html_ext']; // HTML
772 $html2 = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $html2);// アプリケーションルートを変換
773 $desc = $row['be_description']; // 簡易説明
774 $status = $row['be_status']; // エントリー状況
775 $reg_user = $row['reg_user_name']; // 投稿者
776 $entry_date = $this->timestampToDate($row['be_regist_dt']); // 投稿日
777 $entry_time = $this->timestampToTime($row['be_regist_dt']); // 投稿時間
778 $update_user = $this->convertToDispString($row['lu_name']);// 更新者
779 $update_dt = $this->convertToDispDateTime($row['be_create_dt']);
780 $start_date = $this->convertToDispDate($row['be_active_start_dt']); // 公開期間開始日
781 $start_time = $this->convertToDispTime($row['be_active_start_dt'], 1/*時分*/); // 公開期間開始時間
782 $end_date = $this->convertToDispDate($row['be_active_end_dt']); // 公開期間終了日
783 $end_time = $this->convertToDispTime($row['be_active_end_dt'], 1/*時分*/); // 公開期間終了時間
784 $showComment = $row['be_show_comment']; // コメントを表示するかどうか
785 $receiveComment = $row['be_receive_comment']; // コメントを受け付けるかどうか
786 $relatedContent = $row['be_related_content']; // 関連コンテンツ
789 $this->categoryArray = $this->getCategory($categoryRow);
792 if ($row['be_deleted']) $historyIndex = $row['be_history_index']; // 旧データの場合のみ有効
795 $this->fieldValueArray = $this->unserializeArray($row['be_option_fields']);
797 // 前後のエントリーのシリアル番号を取得
798 if (($this->isMultiLang && $this->langId == $this->gEnv->getDefaultLanguage()) || !$this->isMultiLang){ // // 多言語対応の場合はデフォルト言語が選択されている場合のみ処理を行う
799 if ($this->gEnv->isAdminDirAccess()){ // 管理画面へのアクセスの場合
800 $blogId = null; // デフォルトブログ(ブログID空)を含むすべてのブログ記事にアクセス可能
802 $blogId = $this->blogId; // 所属ブログ
804 $ret = self::$_mainDb->getPrevNextEntryByDate($row['be_regist_dt'], $prevRow, $nextRow, $blogId);
806 if (!empty($prevRow)) $prevSerial = $prevRow['be_serial'];
807 if (!empty($nextRow)) $nextSerial = $nextRow['be_serial'];
812 $this->entryId = '0'; // 記事ID
813 $this->blogId = ''; // 所属ブログ
818 $status = 0; // エントリー状況
819 $reg_user = ''; // 投稿者
820 $entry_date = date("Y/m/d"); // 投稿日
821 $entry_time = date("H:i:s"); // 投稿時間
822 $update_user = '';// 更新者
824 $start_date = ''; // 公開期間開始日
825 $start_time = ''; // 公開期間開始時間
826 $end_date = ''; // 公開期間終了日
827 $end_time = ''; // 公開期間終了時間
828 $showComment = 1; // コメントを表示するかどうか
829 $receiveComment = 1; // コメントを受け付けるかどうか
830 $relatedContent = ''; // 関連コンテンツ
833 $this->categoryArray = array();
839 $this->fieldValueArray = array();
843 self::$_mainDb->getAllCategory($this->langId, $this->categoryListData);
844 $this->createCategoryMenu($this->categoryCount);
847 $this->createUserFields($fieldInfoArray);
850 if (empty($useMultiBlog)){
851 /* $this->tmpl->setAttribute('show_blogid_area', 'visibility', 'visible');
853 $blogName = $this->getBlogName($this->blogId);
854 $this->tmpl->addVar("show_blogid_area", "blog_id", $this->blogId); // 所属ブログID
855 $this->tmpl->addVar("show_blogid_area", "blog_name", $blogName); // 所属ブログ名
857 } else { // マルチブログを使用するとき
858 $this->tmpl->setAttribute('select_blogid_area', 'visibility', 'visible');
861 $this->createBlogIdMenu();
866 $this->tmpl->setAttribute('show_comment_area', 'visibility', 'visible');
868 $this->tmpl->addVar("show_comment_area", "show_comment", $this->convertToCheckedString($showComment));// コメントを表示するかどうか
869 $this->tmpl->addVar("show_comment_area", "receive_comment", $this->convertToCheckedString($receiveComment));// コメントを受け付けるかどうか
873 $previewUrl = $this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $this->entryId;
874 if ($historyIndex >= 0) $previewUrl .= '&' . M3_REQUEST_PARAM_HISTORY . '=' . $historyIndex; // 履歴番号(旧データの場合のみ有効)
875 $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_COMMAND . '=' . M3_REQUEST_CMD_PREVIEW;
876 if ($this->isMultiLang) $previewUrl .= '&' . M3_REQUEST_PARAM_OPERATION_LANG . '=' . $this->langId; // 多言語対応の場合は言語IDを付加
877 $this->tmpl->addVar('_widget', 'preview_url', $previewUrl);// プレビュー用URL(一般画面)
879 // CKEditor用のCSSファイルを読み込む
880 $this->loadCKEditorCssFiles($previewUrl);
883 $this->tmpl->addVar('_widget', 'entryid', $this->entryId);
884 $this->tmpl->addVar("_widget", "item_name", $this->convertToDispString($name)); // 名前
885 $this->tmpl->addVar("_widget", "item_html", $html); // HTML
886 $this->tmpl->addVar("_widget", "item_html2", $html2); // HTML(続き)
887 $this->tmpl->addVar("_widget", "desc", $desc); // 簡易説明
889 case 1: $this->tmpl->addVar("_widget", "selected_edit", 'selected'); break;
890 case 2: $this->tmpl->addVar("_widget", "selected_public", 'selected'); break;
891 case 3: $this->tmpl->addVar("_widget", "selected_closed", 'selected'); break;
893 $this->tmpl->addVar("_widget", "entry_user", $reg_user); // 投稿者
894 $this->tmpl->addVar("_widget", "entry_date", $entry_date); // 投稿日
895 $this->tmpl->addVar("_widget", "entry_time", $entry_time); // 投稿時
896 $this->tmpl->addVar("_widget", "update_user", $update_user); // 更新者
897 $this->tmpl->addVar("_widget", "update_dt", $update_dt); // 更新日時
898 $this->tmpl->addVar("_widget", "start_date", $start_date); // 公開期間開始日
899 $this->tmpl->addVar("_widget", "start_time", $start_time); // 公開期間開始時間
900 $this->tmpl->addVar("_widget", "end_date", $end_date); // 公開期間終了日
901 $this->tmpl->addVar("_widget", "end_time", $end_time); // 公開期間終了時間
902 $this->tmpl->addVar("_widget", "related_content", $relatedContent); // 関連コンテンツ
905 if (!empty($prevSerial)){
906 $this->tmpl->setAttribute('show_prev_button', 'visibility', 'visible');
907 $this->tmpl->addVar('show_prev_button', 'serial', $prevSerial);
909 if (!empty($nextSerial)){
910 $this->tmpl->setAttribute('show_next_button', 'visibility', 'visible');
911 $this->tmpl->addVar('show_next_button', 'serial', $nextSerial);
915 $this->tmpl->addVar("_widget", "serial", $this->serialNo); // シリアル番号
917 // 入力フィールドの設定、共通項目のデータ設定
918 if (empty($this->entryId)){ // 記事IDが0のときは、新規追加モードにする
920 $this->tmpl->addVar('_widget', 'id', '新規');
922 $this->tmpl->setAttribute('add_button', 'visibility', 'visible');
923 $this->tmpl->addVar('_widget', 'preview_btn_disabled', 'disabled');// プレビューボタン使用不可
924 $this->tmpl->addVar('_widget', 'history_btn_disabled', 'disabled');// 履歴ボタン使用不可
925 $this->tmpl->addVar('_widget', 'image_btn_disabled', 'disabled');// 画像ボタン使用不可
926 $this->tmpl->addVar('cancel_button', 'new_btn_disabled', 'disabled'); // 「新規」ボタン使用不可
929 //$this->tmpl->addVar("default_lang", "default_lang", $defaultLangName);
930 //$this->tmpl->setAttribute('default_lang', 'visibility', 'visible');
933 $itemId = $this->entryId;
934 if ($historyIndex >= 0) $itemId .= '(' . ($historyIndex +1) . ')';// 履歴番号(旧データの場合のみ有効)
935 $this->tmpl->addVar('_widget', 'id', $itemId);
938 if ($this->serialNo == 0){ // 未登録データのとき
940 $this->tmpl->setAttribute('add_button', 'visibility', 'visible');
942 if ($historyIndex >= 0){ // 履歴データの場合
943 $this->tmpl->setAttribute('update_history_button', 'visibility', 'visible'); // 「履歴データで更新」ボタン
946 $this->tmpl->setAttribute('delete_button', 'visibility', 'visible');// デフォルト言語以外はデータ削除
947 $this->tmpl->setAttribute('update_button', 'visibility', 'visible');
951 //if (!empty($this->entryId)){ // コンテンツが選択されているとき
952 // self::$_mainDb->getAllLang(array($this, 'langLoop'));
953 // $this->tmpl->setAttribute('select_lang', 'visibility', 'visible');
958 $this->tmpl->addVar('_widget', 'calendar_img', $this->getUrl($this->gEnv->getRootUrl() . self::CALENDAR_ICON_FILE)); // カレンダーアイコン
961 if ($openBy == 'simple') $this->tmpl->setAttribute('cancel_button', 'visibility', 'hidden'); // 詳細画面のみの表示のときは戻るボタンを隠す
964 * 取得したデータをテンプレートに設定する
966 * @param int $index 行番号(0~)
967 * @param array $fetchedRow フェッチ取得した行
968 * @param object $param 未使用
969 * @return bool true=処理続行の場合、false=処理終了の場合
971 function itemListLoop($index, $fetchedRow, $param)
974 $serial = $fetchedRow['be_serial'];
977 $categoryArray = array();
978 $ret = self::$_mainDb->getEntryBySerial($serial, $row, $categoryRow);
980 for ($i = 0; $i < count($categoryRow); $i++){
981 if (function_exists('mb_strimwidth')){
982 $categoryArray[] = mb_strimwidth($categoryRow[$i]['bc_name'], 0, self::CATEGORY_NAME_SIZE, '…');
984 $categoryArray[] = substr($categoryRow[$i]['bc_name'], 0, self::CATEGORY_NAME_SIZE) . '...';
988 $category = implode(',', $categoryArray);
991 switch ($fetchedRow['be_status']){
992 case 1: $status = '<font color="orange">編集中</font>'; break;
993 case 2: $status = '<font color="green">公開</font>'; break;
994 case 3: $status = '非公開'; break;
997 $totalViewCount = $this->gInstance->getAnalyzeManager()->getTotalContentViewCount(self::CONTENT_TYPE, $serial);
1000 $now = date("Y/m/d H:i:s"); // 現在日時
1001 $startDt = $fetchedRow['be_active_start_dt'];
1002 $endDt = $fetchedRow['be_active_end_dt'];
1004 $isActive = false; // 公開状態
1005 if ($fetchedRow['be_status'] == 2) $isActive = $this->isActive($startDt, $endDt, $now);// 表示可能
1007 if ($isActive){ // コンテンツが公開状態のとき
1008 $iconUrl = $this->gEnv->getRootUrl() . self::ACTIVE_ICON_FILE; // 公開中アイコン
1011 $iconUrl = $this->gEnv->getRootUrl() . self::INACTIVE_ICON_FILE; // 非公開アイコン
1014 $statusImg = '<img src="' . $this->getUrl($iconUrl) . '" width="' . self::ICON_SIZE . '" height="' . self::ICON_SIZE . '" rel="m3help" alt="' . $iconTitle . '" title="' . $iconTitle . '" />';
1017 'index' => $index, // 項目番号
1018 'no' => $index + 1, // 行番号
1019 'serial' => $serial, // シリアル番号
1020 'id' => $this->convertToDispString($fetchedRow['be_id']), // ID
1021 'name' => $this->convertToDispString($fetchedRow['be_name']), // 名前
1022 'lang' => $lang, // 対応言語
1023 'status_img' => $statusImg, // ユーザからの参照状況
1024 'status' => $status, // 公開状況
1025 'category' => $category, // 記事カテゴリー
1026 'view_count' => $totalViewCount, // 総参照数
1027 'reg_user' => $this->convertToDispString($fetchedRow['lu_name']), // 投稿者
1028 'reg_date' => $this->convertToDispDateTime($fetchedRow['be_regist_dt']), // 投稿日時
1029 'update_user' => $this->convertToDispString($fetchedRow['lu_name']), // 更新者
1030 'update_date' => $this->convertToDispDateTime($fetchedRow['be_create_dt']) // 更新日時
1032 $this->tmpl->addVars('itemlist', $row);
1033 $this->tmpl->parseTemplate('itemlist', 'a');
1036 $this->serialArray[] = $serial;
1040 * 取得した言語をテンプレートに設定する
1042 * @param int $index 行番号(0~)
1043 * @param array $fetchedRow フェッチ取得した行
1044 * @param object $param 未使用
1045 * @return bool true=処理続行の場合、false=処理終了の場合
1047 function langLoop($index, $fetchedRow, $param)
1050 if ($fetchedRow['ln_id'] == $this->langId){
1051 $selected = 'selected';
1053 if ($this->gEnv->getCurrentLanguage() == 'ja'){ // 日本語表示の場合
1054 $name = $this->convertToDispString($fetchedRow['ln_name']);
1056 $name = $this->convertToDispString($fetchedRow['ln_name_en']);
1060 'value' => $this->convertToDispString($fetchedRow['ln_id']), // 言語ID
1061 'name' => $name, // 言語名
1062 'selected' => $selected // 選択中かどうか
1064 $this->tmpl->addVars('lang_list', $row);
1065 $this->tmpl->parseTemplate('lang_list', 'a');
1071 * @param array $srcRows 取得行
1072 * @return array 取得した行
1074 function getCategory($srcRows)
1076 $destArray = array();
1078 for ($i = 0; $i < count($srcRows); $i++){
1079 if (!empty($srcRows[$i]['bw_category_id'])){
1080 $destArray[] = $srcRows[$i]['bw_category_id'];
1082 if ($itemCount >= $this->categoryCount) break;
1090 * @param int $size メニューの表示数
1093 function createCategoryMenu($size)
1095 for ($j = 0; $j < $size; $j++){
1097 $this->tmpl->clearTemplate('category_list');
1098 for ($i = 0; $i < count($this->categoryListData); $i++){
1099 $categoryId = $this->categoryListData[$i]['bc_id'];
1101 if ($j < count($this->categoryArray) && $this->categoryArray[$j] == $categoryId){
1102 $selected = 'selected';
1105 'value' => $categoryId, // カテゴリーID
1106 'name' => $this->categoryListData[$i]['bc_name'], // カテゴリー名
1107 'selected' => $selected // 選択中かどうか
1109 $this->tmpl->addVars('category_list', $menurow);
1110 $this->tmpl->parseTemplate('category_list', 'a');
1113 'index' => $j // 項目番号
1115 $this->tmpl->addVars('category', $itemRow);
1116 $this->tmpl->parseTemplate('category', 'a');
1122 * @param string $blogId ブログID
1123 * @return string ブログ名
1125 function getBlogName($blogId)
1127 $ret = self::$_mainDb->getBlogInfoById($blogId, $row);
1129 return $row['bl_name'];
1131 return self::NO_BLOG_NAME;
1139 function createBlogIdMenu()
1141 if ($this->gEnv->isSystemManageUser()){ // システム運用ユーザのみ「ブログ選択なし」が利用可能
1143 if (empty($this->blogId)) $selected ='selected';
1145 'value' => $this->convertToDispString(''), // ブログID
1146 'name' => $this->convertToDispString(self::NO_BLOG_NAME), // ブログ選択なし
1147 'selected' => $selected // 選択中かどうか
1149 $this->tmpl->addVars('blogid_list', $row);
1150 $this->tmpl->parseTemplate('blogid_list', 'a');
1153 $ret = self::$_mainDb->getAvailableBlogId($rows);
1155 for ($i = 0; $i < count($rows); $i++){
1157 if ($rows[$i]['bl_id'] == $this->blogId) $selected = 'selected';
1159 'value' => $this->convertToDispString($rows[$i]['bl_id']), // ブログID
1160 'name' => $this->convertToDispString($rows[$i]['bl_name']), // ブログ名
1161 'selected' => $selected // 選択中かどうか
1163 $this->tmpl->addVars('blogid_list', $row);
1164 $this->tmpl->parseTemplate('blogid_list', 'a');
1171 * @param timestamp $startDt 公開開始日時
1172 * @param timestamp $endDt 公開終了日時
1173 * @param timestamp $now 基準日時
1174 * @return bool true=公開可能、false=公開不可
1176 function isActive($startDt, $endDt, $now)
1178 $isActive = false; // 公開状態
1180 if ($startDt == $this->gEnv->getInitValueOfTimestamp() && $endDt == $this->gEnv->getInitValueOfTimestamp()){
1181 $isActive = true; // 公開状態
1182 } else if ($startDt == $this->gEnv->getInitValueOfTimestamp()){
1183 if (strtotime($now) < strtotime($endDt)) $isActive = true; // 公開状態
1184 } else if ($endDt == $this->gEnv->getInitValueOfTimestamp()){
1185 if (strtotime($now) >= strtotime($startDt)) $isActive = true; // 公開状態
1187 if (strtotime($startDt) <= strtotime($now) && strtotime($now) < strtotime($endDt)) $isActive = true; // 公開状態
1194 * @param int $serial 削除対象のコンテンツシリアル番号
1197 function clearCacheBySerial($serial)
1199 $ret = self::$_mainDb->getEntryBySerial($serial, $row, $categoryRow);// 記事ID取得
1201 $entryId = $row['be_id']; // 記事ID
1202 $urlParam = array();
1203 $urlParam[] = M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $entryId; // 記事ID
1204 $urlParam[] = M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT . '=' . $entryId; // 記事ID略式
1205 $this->clearCache($urlParam);
1211 * @param array $fields フィールドID
1212 * @return bool true=成功、false=失敗
1214 function createUserFields($fields)
1216 if (count($fields) == 0) return true;
1218 $this->tmpl->setAttribute('user_fields', 'visibility', 'visible');
1219 $keys = array_keys($fields);
1220 $fieldCount = count($keys);
1221 for ($i = 0; $i < $fieldCount; $i++){
1222 if ($i == 0) $this->tmpl->addVar('user_fields', 'type', 'first'); // 最初の行の場合
1226 $value = $this->fieldValueArray[$key];
1227 if (!isset($value)) $value = '';
1230 'row_count' => $fieldCount,
1231 'field_id' => $this->convertToDispString($key),
1232 'value' => $this->convertToDispString($value)
1234 $this->tmpl->addVars('user_fields', $row);
1235 $this->tmpl->parseTemplate('user_fields', 'a');