OSDN Git Service

DB更新スクリプト更新。
[magic3/magic3.git] / widgets / m / blog / include / container / admin_m_blogConfigWidgetContainer.php
1 <?php
2 /**
3  * コンテナクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2010 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_m_blogConfigWidgetContainer.php 3836 2010-11-17 06:05:07Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/admin_m_blogBaseWidgetContainer.php');
17
18 class admin_m_blogConfigWidgetContainer extends admin_m_blogBaseWidgetContainer
19 {
20         const DEFAULT_VIEW_COUNT        = 3;                            // デフォルトの表示記事数
21         
22         /**
23          * コンストラクタ
24          */
25         function __construct()
26         {
27                 // 親クラスを呼び出す
28                 parent::__construct();
29         }
30         /**
31          * テンプレートファイルを設定
32          *
33          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
34          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
35          *
36          * @param RequestManager $request               HTTPリクエスト処理クラス
37          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
38          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
39          */
40         function _setTemplate($request, &$param)
41         {
42                 return 'admin_config.tmpl.html';
43         }
44         /**
45          * テンプレートにデータ埋め込む
46          *
47          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
48          *
49          * @param RequestManager $request               HTTPリクエスト処理クラス
50          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
51          * @param                                                               なし
52          */
53         function _assign($request, &$param)
54         {
55                 $defaultLang    = $this->gEnv->getDefaultLanguage();
56                 
57                 $act = $request->trimValueOf('act');
58                 $entryViewCount = $request->trimValueOf('item_entry_view_count');               // 記事表示数
59                 $entryViewOrder = $request->trimValueOf('item_entry_view_order');               // 記事表示順
60                 $titleColor = $request->trimValueOf('item_title_color');                                        // タイトルの背景色
61                 
62                 $reloadData = false;            // データの再読み込み
63                 if ($act == 'update'){          // 設定更新のとき
64                         // 入力値のエラーチェック
65                         $this->checkNumeric($entryViewCount, '記事表示順');
66                         
67                         if ($this->getMsgCount() == 0){                 // エラーのないとき
68                                 $isErr = false;
69                                 
70                                 if (!$isErr){
71                                         if (!$this->_db->updateConfig(self::CF_ENTRY_VIEW_COUNT, $entryViewCount)) $isErr = true;// 記事表示数
72                                 }
73                                 if (!$isErr){
74                                         if (!$this->_db->updateConfig(self::CF_ENTRY_VIEW_ORDER, $entryViewOrder)) $isErr = true;// 記事表示順
75                                 }
76                                 if (!$isErr){
77                                         if (!$this->_db->updateConfig(self::CF_TITLE_COLOR, $titleColor)) $isErr = true;// タイトルの背景色
78                                 }
79
80                                 if ($isErr){
81                                         $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
82                                 } else {
83                                         $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
84                                         
85                                         // ブログ定義を読み込む
86                                         $this->_loadConfig($this->_blogId);
87                                         $reloadData = true;             // データの再読み込み
88                                 }
89                         }
90                 } else {                // 初期表示の場合
91                         $reloadData = true;             // データの再読み込み
92                 }
93                 // データ再取得
94                 if ($reloadData){
95                         $entryViewCount = $this->_configArray[self::CF_ENTRY_VIEW_COUNT];// 記事表示数
96                         $entryViewOrder = $this->_configArray[self::CF_ENTRY_VIEW_ORDER];// 記事表示順
97                         $titleColor = $this->_configArray[self::CF_TITLE_COLOR];                // タイトルの背景色
98                 }
99                 // 画面に書き戻す
100                 $this->tmpl->addVar("_widget", "view_count", $entryViewCount);// 記事表示数
101                 if (empty($entryViewOrder)){    // 順方向
102                         $this->tmpl->addVar("_widget", "view_order_inc_selected", 'selected');// 記事表示順
103                 } else {
104                         $this->tmpl->addVar("_widget", "view_order_dec_selected", 'selected');// 記事表示順
105                 }
106                 $this->tmpl->addVar("_widget", "title_color", $titleColor);// タイトルの背景色
107         }
108 }
109 ?>