OSDN Git Service

DB更新スクリプト更新。
[magic3/magic3.git] / widgets / m / blog / include / container / admin_m_blogBaseWidgetContainer.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_blogBaseWidgetContainer.php 3836 2010-11-17 06:05:07Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/blogDb.php');
18
19 class admin_m_blogBaseWidgetContainer extends BaseAdminWidgetContainer
20 {
21         protected $_db;                 // DB接続オブジェクト
22         protected $_blogId;     // ブログID
23         const DEFAULT_TOP_PAGE = 'config';              // デフォルトのトップページ
24         const WIDGET_TITLE_NAME = 'ブログ(携帯)';                          // ウィジェットタイトル名
25         const CF_ENTRY_VIEW_COUNT               = 'm:entry_view_count';                 // 記事表示数
26         const CF_ENTRY_VIEW_ORDER               = 'm:entry_view_order';                 // 記事表示方向
27         const CF_TITLE_COLOR                    = 'm:title_color';                      // タイトルの背景色
28         
29         /**
30          * コンストラクタ
31          */
32         function __construct()
33         {
34                 // 親クラスを呼び出す
35                 parent::__construct();
36                 
37                 // サブウィジェット起動のときだけ初期処理実行
38                 if ($this->gEnv->getIsSubWidget()){
39                         // DBオブジェクト作成
40                         $this->_db = new blogDb();
41                 
42                         $this->_blogId = '';
43                 
44                         // ブログ定義を読み込む
45                         $this->_loadConfig($this->_blogId);
46                 }
47         }
48         /**
49          * テンプレートにデータ埋め込む
50          *
51          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
52          *
53          * @param RequestManager $request               HTTPリクエスト処理クラス
54          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
55          * @return                                                              なし
56          */
57         function _postAssign($request, &$param)
58         {
59                 // ウィンドウオープンタイプ取得
60                 $openBy = $request->trimValueOf(M3_REQUEST_PARAM_OPEN_BY);              // ウィンドウオープンタイプ
61                 if (!empty($openBy)) $this->addOptionUrlParam(M3_REQUEST_PARAM_OPEN_BY, $openBy);
62                 
63                 // 表示画面を決定
64                 $task = $request->trimValueOf(M3_REQUEST_PARAM_OPERATION_TASK);
65                 if (empty($task)) $task = self::DEFAULT_TOP_PAGE;
66                 
67                 // パンくずリストを作成
68                 switch ($task){
69                         case 'config':          // 基本設定
70                                 $linkList = ' &gt;&gt; 基本設定';// パンくずリスト
71                                 break;
72                 }
73                 // ####### 上段メニューの作成 #######
74                 $menuText = '<div id="configmenu-upper">' . M3_NL;
75                 $menuText .= '<ul>' . M3_NL;
76                 $baseUrl = $this->getAdminUrlWithOptionParam(true);// 画面定義ID付き
77
78                 // その他設定
79                 $current = '';
80                 $link = $baseUrl . '&task=config';
81                 if ($task == 'config'){         
82                         $current = 'id="current"';
83                 }
84                 $menuText .= '<li ' . $current . '><a href="'. $this->getUrl($link, true) .'"><span>基本設定</span></a></li>' . M3_NL;
85                 
86                 // 上段メニュー終了
87                 $menuText .= '</ul>' . M3_NL;
88                 $menuText .= '</div>' . M3_NL;
89                 
90                 // 作成データの埋め込み
91                 $linkList = '<div id="configmenu-top"><label>' . self::WIDGET_TITLE_NAME . $linkList . '</div>';
92                 $outputText .= '<table width="90%"><tr><td>' . $linkList . $menuText . '</td></tr></table>' . M3_NL;
93                 $this->tmpl->addVar("_widget", "menu_items", $outputText);
94         }
95         /**
96          * ブログ定義値をDBから取得
97          *
98          * @param string $blogId        ブログID
99          * @return bool                         true=取得成功、false=取得失敗
100          */
101         function _loadConfig($blogId)
102         {
103                 $this->_configArray = array();
104
105                 // BBS定義を読み込み
106                 $ret = $this->_db->getAllConfig($rows, $blogId);
107                 if ($ret){
108                         // 取得データを連想配列にする
109                         $configCount = count($rows);
110                         for ($i = 0; $i < $configCount; $i++){
111                                 $key = $rows[$i]['bg_id'];
112                                 $value = $rows[$i]['bg_value'];
113                                 $this->_configArray[$key] = $value;
114                         }
115                 }
116                 return $ret;
117         }
118 }
119 ?>