OSDN Git Service

DB更新スクリプト更新。
[magic3/magic3.git] / widgets / m / bbs_2ch / include / container / admin_m_bbs_2chOtherWidgetContainer.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-2011 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_m_bbs_2chOtherWidgetContainer.php 4028 2011-03-11 04:11:33Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/admin_m_bbs_2chBaseWidgetContainer.php');
17
18 class admin_m_bbs_2chOtherWidgetContainer extends admin_m_bbs_2chBaseWidgetContainer
19 {
20         /**
21          * コンストラクタ
22          */
23         function __construct()
24         {
25                 // 親クラスを呼び出す
26                 parent::__construct();
27         }
28         /**
29          * テンプレートファイルを設定
30          *
31          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
32          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
33          *
34          * @param RequestManager $request               HTTPリクエスト処理クラス
35          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
36          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
37          */
38         function _setTemplate($request, &$param)
39         {
40                 return 'admin_other.tmpl.html';
41         }
42         /**
43          * テンプレートにデータ埋め込む
44          *
45          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
46          *
47          * @param RequestManager $request               HTTPリクエスト処理クラス
48          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
49          * @param                                                               なし
50          */
51         function _assign($request, &$param)
52         {
53                 $defaultLang    = $this->gEnv->getDefaultLanguage();
54                 $act = $request->trimValueOf('act');
55                 
56                 $bbsTitle = $request->trimValueOf('bbs_title');                                 // 掲示板タイトル
57                 $topLink = $request->trimValueOf('title_link');                         // トップ画像のリンク先
58                 $topImage = $request->trimValueOf('top_image');                         // トップ画像
59                 $bgImage = $request->trimValueOf('bg_image');                           // 背景画像
60                 $bbsGuide = $request->valueOf('bbs_guide');                             // 掲示板規則(HTML許可)
61                 $bottomMessage = $request->valueOf('bottom_message');                           // トップ画面下部メッセージ(HTML許可)
62                 $textColor = $request->valueOf('text_color');                           // 文字色
63                 $bgColor = $request->valueOf('bg_color');                               // 背景色
64                 //$titleColor = $request->valueOf('title_color');                               // タイトルカラー
65                 $menuColor = $request->valueOf('menu_color');                           // メニュー背景色
66                 $threadColor = $request->valueOf('thread_color');                       // スレッド表示部背景色
67                 $makeThreadColor = $request->valueOf('makethread_color');       // スレッド作成部背景色
68                 $linkColor = $request->valueOf('link_color');   // リンク色
69                 $alinkColor = $request->valueOf('alink_color'); // リンク色(アクティブ)
70                 $vlinkColor = $request->valueOf('vlink_color'); // リンク色(アクセス済み)
71                 $subjectColor = $request->valueOf('subject_color');     // 件名文字色
72                 $nameColor = $request->valueOf('name_color');   // 投稿者名文字色
73                 $errMessageColor = $request->valueOf('err_message_color');      // エラーメッセージ文字色
74                 $subjectLength = $request->valueOf('subject_length');   // 件名最大長
75                 $nameLength = $request->valueOf('name_length'); // 投稿者名最大長
76                 $emailLength = $request->valueOf('email_length');       // emailアドレス最大長
77                 $messageLength = $request->valueOf('message_length');   // 投稿文最大長
78                 $lineLength = $request->valueOf('line_length'); // 投稿文行長
79                 $lineCount = $request->valueOf('line_count');   // 投稿文行数
80                 $resAnchorLinkCount = $request->valueOf('res_anchor_link_count');       // レスアンカーリンク数
81                 $threadCount = $request->valueOf('thread_count');       // トップ画面のスレッド最大数
82                 $resCount = $request->valueOf('res_count');     // トップ画面のレス最大数
83                 $threadRes = $request->valueOf('thread_res');   // 投稿可能なレス数の上限
84                 $menuThreadCount = $request->valueOf('menu_thread_count');      // メニューのスレッド最大数
85                 $nonameName = $request->valueOf('noname_name'); // 名前未設定時の表示名
86                 $adminName = $request->valueOf('admin_name');   // サイト運営者名
87                 $threadEndMessage = $request->valueOf('thread_end_message');    // スレッド終了メッセージ
88                 
89                 $reloadData = false;            // データの再読み込み
90                 if ($act == 'update'){          // 設定更新のとき
91                         // 入力値のエラーチェック
92                         
93                         if ($this->getMsgCount() == 0){                 // エラーのないとき
94                                 // パスの修正
95                                 if (!empty($topImage)) $topImage = $this->gEnv->getMacroPath($topImage);
96                                 if (!empty($bgImage)) $bgImage = $this->gEnv->getMacroPath($bgImage);
97                                                         
98                                 $ret = $this->_db->updateConfig(self::CF_BBS_TITLE, $bbsTitle);         // 掲示板タイトル
99                                 if ($ret) $this->_db->updateConfig(self::CF_TOP_LINK, $topLink);        // トップ画像のリンク先
100                                 if ($ret) $this->_db->updateConfig(self::CF_TOP_IMAGE, $topImage);      // トップ画像
101                                 if ($ret) $this->_db->updateConfig(self::CF_BG_IMAGE, $bgImage);        // 背景画像
102                                 if ($ret) $this->_db->updateConfig(self::CF_BBS_GUIDE, $bbsGuide);      // 掲示板規則
103                                 if ($ret) $this->_db->updateConfig(self::CF_BOTTOM_MESSAGE, $bottomMessage);    // トップ画面下部メッセージ
104                                 if ($ret) $this->_db->updateConfig(self::CF_TEXT_COLOR, $textColor);    // 文字色
105                                 if ($ret) $this->_db->updateConfig(self::CF_BG_COLOR, $bgColor);        // 背景色
106                                 //if ($ret) $this->_db->updateConfig(self::CF_TITLE_COLOR, $titleColor);        // タイトルカラー
107                                 if ($ret) $this->_db->updateConfig(self::CF_MENU_COLOR, $menuColor);    // メニュー背景色
108                                 if ($ret) $this->_db->updateConfig(self::CF_THREAD_COLOR, $threadColor);        // スレッド表示部背景色
109                                 if ($ret) $this->_db->updateConfig(self::CF_MAKE_THREAD_COLOR, $makeThreadColor);       // スレッド作成部背景色
110                                 if ($ret) $this->_db->updateConfig(self::CF_LINK_COLOR, $linkColor);    // リンク色
111                                 if ($ret) $this->_db->updateConfig(self::CF_ALINK_COLOR, $alinkColor);  // リンク色(アクティブ)
112                                 if ($ret) $this->_db->updateConfig(self::CF_VLINK_COLOR, $vlinkColor);  // リンク色(アクセス済み)
113                                 if ($ret) $this->_db->updateConfig(self::CF_SUBJECT_COLOR, $subjectColor);      // 件名文字色
114                                 if ($ret) $this->_db->updateConfig(self::CF_NAME_COLOR, $nameColor);    // 投稿者名文字色
115                                 if ($ret) $this->_db->updateConfig(self::CF_ERR_MESSAGE_COLOR, $errMessageColor);       // エラーメッセージ文字色
116                                 if ($ret) $this->_db->updateConfig(self::CF_SUBJECT_LENGTH, $subjectLength);    // 件名最大長
117                                 if ($ret) $this->_db->updateConfig(self::CF_NAME_LENGTH, $nameLength);  // 投稿者名最大長
118                                 if ($ret) $this->_db->updateConfig(self::CF_EMAIL_LENGTH, $emailLength);        // emailアドレス最大長
119                                 if ($ret) $this->_db->updateConfig(self::CF_MESSAGE_LENGTH, $messageLength);    // 投稿文最大長
120                                 if ($ret) $this->_db->updateConfig(self::CF_LINE_LENGTH, $lineLength);  // 投稿文行長
121                                 if ($ret) $this->_db->updateConfig(self::CF_LINE_COUNT, $lineCount);    // 投稿文行数
122                                 if ($ret) $this->_db->updateConfig(self::CF_RES_ANCHOR_LINK_COUNT, $resAnchorLinkCount);        // レスアンカーリンク数
123                                 if ($ret) $this->_db->updateConfig(self::CF_THREAD_COUNT, $threadCount);        // トップ画面のスレッド最大数
124                                 if ($ret) $this->_db->updateConfig(self::CF_RES_COUNT, $resCount);      // トップ画面のレス最大数
125                                 if ($ret) $this->_db->updateConfig(self::CF_THREAD_RES, $threadRes);    // 投稿可能なレス数の上限
126                                 if ($ret) $this->_db->updateConfig(self::CF_MENU_THREAD_COUNT, $menuThreadCount);       // メニューのスレッド最大数
127                                 if ($ret) $this->_db->updateConfig(self::CF_NONAME_NAME, $nonameName);  // 名前未設定時の表示名
128                                 if ($ret) $this->_db->updateConfig(self::CF_ADMIN_NAME, $adminName);    // サイト運営者名
129                                 if ($ret) $this->_db->updateConfig(self::CF_THREAD_END_MESSAGE, $threadEndMessage);             // スレッド終了メッセージ
130                                 
131                                 if ($ret){
132                                         $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
133                                         
134                                         // BBS定義を再読み込み
135                                         $this->_loadConfig();
136                                         $reloadData = true;             // データの再読み込み
137                                 } else {
138                                         $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
139                                 }
140                                 $this->gPage->updateParentWindow();// 親ウィンドウを更新
141                         }
142                 } else {                // 初期表示の場合
143                         $reloadData = true;             // データの再読み込み
144                 }
145                 if ($reloadData){
146                         $bbsTitle = $this->_configArray[self::CF_BBS_TITLE];            // 掲示板タイトル
147                         $topLink = $this->_configArray[self::CF_TOP_LINK];                                      // トップ画像のリンク先
148                         $topImage = $this->_configArray[self::CF_TOP_IMAGE];            // トップ画像
149                         $bgImage = $this->_configArray[self::CF_BG_IMAGE];                                      // 背景画像
150                         $bbsGuide = $this->_configArray[self::CF_BBS_GUIDE];    // 掲示板規則
151                         $bottomMessage = $this->_configArray[self::CF_BOTTOM_MESSAGE];  // トップ画面下部メッセージ
152                         if (is_null($bottomMessage)) $bottomMessage = self::DEFAULT_BOTTOM_MESSAGE;
153                         $textColor = $this->_configArray[self::CF_TEXT_COLOR];  // 文字色
154                         $bgColor = $this->_configArray[self::CF_BG_COLOR];      // 背景色
155                         //$titleColor = $this->_configArray[self::CF_TITLE_COLOR];      // タイトルカラー
156                         $menuColor = $this->_configArray[self::CF_MENU_COLOR];  // メニュー背景色
157                         $threadColor = $this->_configArray[self::CF_THREAD_COLOR];      // スレッド表示部背景色
158                         $makeThreadColor = $this->_configArray[self::CF_MAKE_THREAD_COLOR];     // スレッド作成部背景色
159                         $linkColor = $this->_configArray[self::CF_LINK_COLOR];  // リンク色
160                         $alinkColor = $this->_configArray[self::CF_ALINK_COLOR];        // リンク色(アクティブ)
161                         $vlinkColor = $this->_configArray[self::CF_VLINK_COLOR];        // リンク色(アクセス済み)
162                         $subjectColor = $this->_configArray[self::CF_SUBJECT_COLOR];    // 件名文字色
163                         $nameColor = $this->_configArray[self::CF_NAME_COLOR];  // 投稿者名文字色
164                         $errMessageColor = $this->_configArray[self::CF_ERR_MESSAGE_COLOR];     // エラーメッセージ文字色
165                         $subjectLength = $this->_configArray[self::CF_SUBJECT_LENGTH];  // 件名最大長
166                         $nameLength = $this->_configArray[self::CF_NAME_LENGTH];        // 投稿者名最大長
167                         $emailLength = $this->_configArray[self::CF_EMAIL_LENGTH];      // emailアドレス最大長
168                         $messageLength = $this->_configArray[self::CF_MESSAGE_LENGTH];  // 投稿文最大長
169                         $lineLength = $this->_configArray[self::CF_LINE_LENGTH];        // 投稿文行長
170                         $lineCount = $this->_configArray[self::CF_LINE_COUNT];  // 投稿文行数
171                         $resAnchorLinkCount = $this->_configArray[self::CF_RES_ANCHOR_LINK_COUNT];      // レスアンカーリンク数
172                         $threadCount = $this->_configArray[self::CF_THREAD_COUNT];      // トップ画面のスレッド最大数
173                         $resCount = $this->_configArray[self::CF_RES_COUNT];    // トップ画面のレス最大数
174                         $threadRes = $this->_configArray[self::CF_THREAD_RES];  // 投稿可能なレス数の上限
175                         $menuThreadCount = $this->_configArray[self::CF_MENU_THREAD_COUNT];     // メニューのスレッド最大数
176                         $nonameName = $this->_configArray[self::CF_NONAME_NAME];        // 名前未設定時の表示名
177                         $adminName = $this->_configArray[self::CF_ADMIN_NAME];  // サイト運営者名
178                         if (empty($adminName)) $adminName = self::DEFAULT_ADMIN_NAME;
179                         $threadEndMessage = $this->_configArray[self::CF_THREAD_END_MESSAGE];           // スレッド終了メッセージ
180                         if (empty($threadEndMessage)) $threadEndMessage = self::DEFAULT_THREAD_END_MESSAGE;
181                         
182                         // パスの修正
183                         $topImage = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->gEnv->getRootUrl(), $topImage);
184                         $bgImage = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->gEnv->getRootUrl(), $bgImage);
185                 }
186                 // 画面に書き戻す
187                 $this->tmpl->addVar("_widget", "bbs_title", $bbsTitle);         // 掲示板タイトル
188                 $this->tmpl->addVar("_widget", "top_link", $topLink);           // トップ画像のリンク先
189                 $this->tmpl->addVar("_widget", "top_image", $topImage);         // トップ画像
190                 $this->tmpl->addVar("_widget", "bg_image", $bgImage);           // 背景画像
191                 $this->tmpl->addVar("_widget", "bbs_guide", $bbsGuide);         // 掲示板規則
192                 $this->tmpl->addVar("_widget", "bottom_message", $bottomMessage);       // トップ画面下部メッセージ
193                 $this->tmpl->addVar("_widget", "text_color", $textColor);               // 文字色
194                 $this->tmpl->addVar("_widget", "bg_color", $bgColor);           // 背景色
195                 //$this->tmpl->addVar("_widget", "title_color", $titleColor);           // タイトルカラー
196                 $this->tmpl->addVar("_widget", "menu_color", $menuColor);               // メニュー背景色
197                 $this->tmpl->addVar("_widget", "thread_color", $threadColor);           // スレッド表示部背景色
198                 $this->tmpl->addVar("_widget", "makethread_color", $makeThreadColor);           // スレッド作成部背景色
199                 $this->tmpl->addVar("_widget", "link_color", $linkColor);       // リンク色
200                 $this->tmpl->addVar("_widget", "alink_color", $alinkColor);     // リンク色(アクティブ)
201                 $this->tmpl->addVar("_widget", "vlink_color", $vlinkColor);     // リンク色(アクセス済み)
202                 $this->tmpl->addVar("_widget", "subject_color", $subjectColor); // 件名文字色
203                 $this->tmpl->addVar("_widget", "name_color", $nameColor);       // 投稿者名文字色
204                 $this->tmpl->addVar("_widget", "err_message_color", $errMessageColor);  // エラーメッセージ文字色
205                 $this->tmpl->addVar("_widget", "subject_length", $subjectLength);       // 件名最大長
206                 $this->tmpl->addVar("_widget", "name_length", $nameLength);     // 投稿者名最大長
207                 $this->tmpl->addVar("_widget", "email_length", $emailLength);   // emailアドレス最大長
208                 $this->tmpl->addVar("_widget", "message_length", $messageLength);       // 投稿文最大長
209                 $this->tmpl->addVar("_widget", "line_length", $lineLength);     // 投稿文行長
210                 $this->tmpl->addVar("_widget", "line_count", $lineCount);       // 投稿文行数
211                 $this->tmpl->addVar("_widget", "res_anchor_link_count", $resAnchorLinkCount);   // レスアンカーリンク数
212                 $this->tmpl->addVar("_widget", "thread_count", $threadCount);   // トップ画面のスレッド最大数
213                 $this->tmpl->addVar("_widget", "res_count", $resCount); // トップ画面のレス最大数
214                 $this->tmpl->addVar("_widget", "thread_res", $threadRes);       // 投稿可能なレス数の上限
215                 $this->tmpl->addVar("_widget", "menu_thread_count", $menuThreadCount);  // メニューのスレッド最大数
216                 $this->tmpl->addVar("_widget", "noname_name", $nonameName);     // 名前未設定時の表示名
217                 $this->tmpl->addVar("_widget", "admin_name", $adminName);       // サイト運営者名
218                 $this->tmpl->addVar("_widget", "thread_end_message", $threadEndMessage);                // スレッド終了メッセージ
219         }
220 }
221 ?>