OSDN Git Service

DB更新スクリプト更新。
[magic3/magic3.git] / widgets / m / chacha / include / container / admin_m_chachaBaseWidgetContainer.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    マイクロブログ
10  * @author     株式会社 毎日メディアサービス
11  * @copyright  Copyright 2010 株式会社 毎日メディアサービス.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_m_chachaBaseWidgetContainer.php 3282 2010-06-23 05:58:43Z fishbone $
14  * @link       http://www.m-media.co.jp
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/chachaDb.php');
18
19 class admin_m_chachaBaseWidgetContainer extends BaseAdminWidgetContainer
20 {
21         protected $_db;                 // DB接続オブジェクト
22         protected $_boardId;    // 掲示板ID
23         const DEFAULT_BBS_ID_HEAD = 'board';            // デフォルトの掲示板ID
24         const DEFAULT_TOP_PAGE = 'other';               // デフォルトのトップページ
25         const WIDGET_TITLE_NAME = 'マイクロブログ(携帯)';                              // ウィジェットタイトル名
26         const CF_TEXT_COLOR = 'text_color';     // 文字色
27         const CF_BG_COLOR = 'bg_color';         // 背景色
28         const CF_INNER_BG_COLOR = 'inner_bg_color';     // 内枠背景色
29         const CF_PROFILE_COLOR = 'profile_color';               // プロフィール背景色
30         const CF_ERR_MESSAGE_COLOR = 'err_message_color';               // エラーメッセージ文字色
31         const CF_MESSAGE_LENGTH = 'message_length';     // 最大メッセージ長
32         const CF_TOP_CONTENTS = 'm:top_contents';               // トップコンテンツ(携帯)
33         
34         /**
35          * コンストラクタ
36          */
37         function __construct()
38         {
39                 // 親クラスを呼び出す
40                 parent::__construct();
41                 
42                 // サブウィジェット起動のときだけ初期処理実行
43                 if ($this->gEnv->getIsSubWidget()){
44                         // DBオブジェクト作成
45                         $this->_db = new chachaDb();
46                 
47                         $this->_boardId = self::DEFAULT_BBS_ID_HEAD . '0';
48                 
49                         // BBS定義を読み込む
50                         $this->_loadConfig($this->_boardId);
51                 }
52         }
53         /**
54          * テンプレートにデータ埋め込む
55          *
56          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
57          *
58          * @param RequestManager $request               HTTPリクエスト処理クラス
59          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
60          * @return                                                              なし
61          */
62         function _postAssign($request, &$param)
63         {
64                 // ウィンドウオープンタイプ取得
65                 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY);              // ウィンドウオープンタイプ
66                 if (!empty($openBy)) $this->addOptionUrlParam(M3_REQUEST_PARAM_OPEN_BY, $openBy);
67                 
68                 // 表示画面を決定
69                 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
70                 if (empty($task)) $task = self::DEFAULT_TOP_PAGE;
71                 
72                 // パンくずリストを作成
73                 switch ($task){
74                         case 'other':           // その他設定
75                                 $linkList = ' &gt;&gt; 基本設定';// パンくずリスト
76                                 break;
77                 }
78                 // ####### 上段メニューの作成 #######
79                 $menuText = '<div id="configmenu-upper">' . M3_NL;
80                 $menuText .= '<ul>' . M3_NL;
81                 $baseUrl = $this->getAdminUrlWithOptionParam(true);// 画面定義ID付き
82
83                 // その他設定
84                 $current = '';
85                 $link = $baseUrl . '&task=other';
86                 if ($task == 'other'){          
87                         $current = 'id="current"';
88                 }
89                 $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link, true) .'"><span>基本設定</span></a></li>' . M3_NL;
90                 
91                 // 上段メニュー終了
92                 $menuText .= '</ul>' . M3_NL;
93                 $menuText .= '</div>' . M3_NL;
94                 
95                 // 作成データの埋め込み
96                 $linkList = '<div id="configmenu-top"><label>' . self::WIDGET_TITLE_NAME . $linkList . '</div>';
97                 $outputText .= '<table width="90%"><tr><td>' . $linkList . $menuText . '</td></tr></table>' . M3_NL;
98                 $this->tmpl->addVar("_widget", "menu_items", $outputText);
99         }
100         /**
101          * ブログ定義値をDBから取得
102          *
103          * @param string $boardId       掲示板ID
104          * @return bool                         true=取得成功、false=取得失敗
105          */
106         function _loadConfig($boardId)
107         {
108                 $this->_configArray = array();
109
110                 // BBS定義を読み込み
111                 $ret = $this->_db->getAllConfig($rows, $boardId);
112                 if ($ret){
113                         // 取得データを連想配列にする
114                         $configCount = count($rows);
115                         for ($i = 0; $i < $configCount; $i++){
116                                 $key = $rows[$i]['mc_id'];
117                                 $value = $rows[$i]['mc_value'];
118                                 $this->_configArray[$key] = $value;
119                         }
120                 }
121                 return $ret;
122         }
123 }
124 ?>