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-2012 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: admin_s_photoConfigWidgetContainer.php 4716 2012-02-26 02:19:15Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/admin_s_photoBaseWidgetContainer.php');
18 class admin_s_photoConfigWidgetContainer extends admin_s_photoBaseWidgetContainer
20 private $sortKeyTypeArray; // ソートキータイプ
21 private $sortKey; // ソートキー
26 function __construct()
29 parent::__construct();
32 $this->sortKeyTypeArray = array( array( 'name' => '画像表示順', 'value' => 'index'),
33 array( 'name' => '日付', 'value' => 'date'),
34 array( 'name' => '評価', 'value' => 'rate'),
35 array( 'name' => '参照数', 'value' => 'ref'));
40 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
41 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
43 * @param RequestManager $request HTTPリクエスト処理クラス
44 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
45 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
47 function _setTemplate($request, &$param)
49 return 'admin_config.tmpl.html';
54 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
56 * @param RequestManager $request HTTPリクエスト処理クラス
57 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
60 function _assign($request, &$param)
62 $act = $request->trimValueOf('act');
63 $listViewCount = $request->trimValueOf('item_view_count'); // 画像一覧表示数
64 $listViewOrder = $request->trimValueOf('item_view_order'); // 画像一覧表示順
65 $this->sortKey = $request->trimValueOf('item_sort_key'); // ソートキー
66 $titleLength = $request->trimValueOf('item_title_length'); // 画像タイトル文字数
68 $imageSize = $request->trimValueOf('item_image_size'); // 公開画像サイズ
69 $thumbnailSize = $request->trimValueOf('item_thumbnail_size'); // サムネール画像サイズ
70 $defaultImageSize = $request->trimValueOf('item_default_image_size'); // デフォルト公開画像サイズ
71 $defaultThumbnailSize = $request->trimValueOf('item_default_thumbnail_size'); // デフォルトサムネール画像サイズ
73 if ($act == 'update'){ // 設定更新のとき
75 $this->checkNumeric($listViewCount, '画像一覧表示数');
76 $this->checkNumeric($titleLength, '画像タイトル文字数');
77 $this->checkNumeric($defaultImageSize, 'デフォルト公開画像サイズ');
78 $this->checkNumeric($defaultThumbnailSize, 'デフォルトサムネール画像サイズ');
80 if ($this->getMsgCount() == 0){ // エラーのないとき
84 if (!self::$_mainDb->updateConfig(photoCommonDef::CF_PHOTO_LIST_ITEM_COUNT, $listViewCount)) $isErr = true;// 画像一覧表示数
87 if (!self::$_mainDb->updateConfig(photoCommonDef::CF_PHOTO_LIST_ORDER, $listViewOrder)) $isErr = true;// 画像一覧表示順
90 if (!self::$_mainDb->updateConfig(photoCommonDef::CF_PHOTO_LIST_SORT_KEY, $this->sortKey)) $isErr = true;// 画像一覧ソートキー
93 if (!self::$_mainDb->updateConfig(photoCommonDef::CF_PHOTO_TITLE_SHORT_LENGTH, $titleLength)) $isErr = true;// 画像タイトル文字数
96 if (!self::$_mainDb->updateConfig(photoCommonDef::CF_IMAGE_SIZE, $imageSize)) $isErr = true; // 公開画像サイズ
99 if (!self::$_mainDb->updateConfig(photoCommonDef::CF_THUMBNAIL_SIZE, $thumbnailSize)) $isErr = true; // サムネール画像サイズ
102 if (!self::$_mainDb->updateConfig(photoCommonDef::CF_DEFAULT_IMAGE_SIZE, $defaultImageSize)) $isErr = true; // デフォルト公開画像サイズ
105 if (!self::$_mainDb->updateConfig(photoCommonDef::CF_DEFAULT_THUMBNAIL_SIZE, $defaultThumbnailSize)) $isErr = true; // デフォルトサムネール画像サイズ
108 $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
110 $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
113 $listViewCount = self::$_mainDb->getConfig(photoCommonDef::CF_PHOTO_LIST_ITEM_COUNT); // 画像一覧表示数
114 $listViewOrder = self::$_mainDb->getConfig(photoCommonDef::CF_PHOTO_LIST_ORDER); // 画像一覧表示順
115 if (!in_array($listViewOrder, array('0', '1'))) $listViewOrder = photoCommonDef::DEFAULT_PHOTO_LIST_ORDER; // デフォルトの画像一覧並び順(昇順)
116 $this->sortKey = self::$_mainDb->getConfig(photoCommonDef::CF_PHOTO_LIST_SORT_KEY);// 画像一覧ソートキー
117 if (empty($this->sortKey)) $this->sortKey = photoCommonDef::DEFAULT_PHOTO_LIST_SORT_KEY;
118 $titleLength = self::$_mainDb->getConfig(photoCommonDef::CF_PHOTO_TITLE_SHORT_LENGTH);// 画像タイトル文字数
119 $imageSize = self::$_mainDb->getConfig(photoCommonDef::CF_IMAGE_SIZE); // 公開画像サイズ
120 $thumbnailSize = self::$_mainDb->getConfig(photoCommonDef::CF_THUMBNAIL_SIZE); // サムネール画像サイズ
121 $defaultImageSize = self::$_mainDb->getConfig(photoCommonDef::CF_DEFAULT_IMAGE_SIZE); // デフォルト公開画像サイズ
122 $defaultThumbnailSize = self::$_mainDb->getConfig(photoCommonDef::CF_DEFAULT_THUMBNAIL_SIZE); // デフォルトサムネール画像サイズ
125 $listViewCount = self::$_mainDb->getConfig(photoCommonDef::CF_PHOTO_LIST_ITEM_COUNT);// 画像一覧表示数
126 if (intval($listViewCount) <= 0) $listViewCount = photoCommonDef::DEFAULT_PHOTO_LIST_VIEW_COUNT;
127 $listViewOrder = self::$_mainDb->getConfig(photoCommonDef::CF_PHOTO_LIST_ORDER);// 画像一覧表示順
128 if (!in_array($listViewOrder, array('0', '1'))) $listViewOrder = photoCommonDef::DEFAULT_PHOTO_LIST_ORDER; // デフォルトの画像一覧並び順(昇順)
129 $this->sortKey = self::$_mainDb->getConfig(photoCommonDef::CF_PHOTO_LIST_SORT_KEY);// 画像一覧ソートキー
130 if (empty($this->sortKey)) $this->sortKey = photoCommonDef::DEFAULT_PHOTO_LIST_SORT_KEY;
131 $titleLength = self::$_mainDb->getConfig(photoCommonDef::CF_PHOTO_TITLE_SHORT_LENGTH);// 画像タイトル文字数
132 if (intval($titleLength) <= 0) $titleLength = photoCommonDef::DEFAULT_PHOTO_TITLE_SHORT_LENGTH;
133 $imageSize = self::$_mainDb->getConfig(photoCommonDef::CF_IMAGE_SIZE); // 公開画像サイズ
134 if (empty($imageSize)) $imageSize = photoCommonDef::DEFAULT_IMAGE_SIZE;
135 $thumbnailSize = self::$_mainDb->getConfig(photoCommonDef::CF_THUMBNAIL_SIZE); // サムネール画像サイズ
136 if (empty($thumbnailSize)) $thumbnailSize = photoCommonDef::DEFAULT_THUMBNAIL_SIZE;
137 $defaultImageSize = self::$_mainDb->getConfig(photoCommonDef::CF_DEFAULT_IMAGE_SIZE); // デフォルト公開画像サイズ
138 if (empty($defaultImageSize)) $defaultImageSize = photoCommonDef::DEFAULT_IMAGE_SIZE;
139 $defaultThumbnailSize = self::$_mainDb->getConfig(photoCommonDef::CF_DEFAULT_THUMBNAIL_SIZE); // デフォルトサムネール画像サイズ
140 if (empty($defaultThumbnailSize)) $defaultThumbnailSize = photoCommonDef::DEFAULT_THUMBNAIL_SIZE;
143 $this->createSortKeyMenu();
146 $this->tmpl->addVar("_widget", "view_count", $listViewCount);// 画像一覧表示数
147 if (empty($listViewOrder)){ // 順方向
148 $this->tmpl->addVar("_widget", "view_order_dec_selected", 'selected');// 降順
150 $this->tmpl->addVar("_widget", "view_order_inc_selected", 'selected');// 昇順
152 $this->tmpl->addVar("_widget", "title_length", $titleLength);// 画像タイトル文字数
153 $this->tmpl->addVar("_widget", "image_size", $imageSize);// 公開画像サイズ
154 $this->tmpl->addVar("_widget", "thumbnail_size", $thumbnailSize);// サムネール画像サイズ
155 $this->tmpl->addVar("_widget", "default_image_size", $defaultImageSize); // デフォルト公開画像サイズ
156 $this->tmpl->addVar("_widget", "default_thumbnail_size", $defaultThumbnailSize); // デフォルトサムネール画像サイズ
163 function createSortKeyMenu()
165 for ($i = 0; $i < count($this->sortKeyTypeArray); $i++){
166 $value = $this->sortKeyTypeArray[$i]['value'];
167 $name = $this->sortKeyTypeArray[$i]['name'];
170 if ($value == $this->sortKey) $selected = 'selected';
173 'value' => $value, // ソートキーID
174 'name' => $name, // 名前
175 'selected' => $selected // 選択中かどうか
177 $this->tmpl->addVars('item_sort_key_type_list', $row);
178 $this->tmpl->parseTemplate('item_sort_key_type_list', 'a');