OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / user_content / include / container / user_contentBaseWidgetContainer.php
1 <?php
2 /**
3  * index.php用コンテナクラス
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: user_contentBaseWidgetContainer.php 3011 2010-04-08 04:06:37Z fishbone $
14  * @link       http://www.m-media.co.jp
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/user_contentDb.php');
18
19 class user_contentBaseWidgetContainer extends BaseWidgetContainer
20 {
21         protected $_localDb;                    // DB接続オブジェクト
22         protected $_headCss;            // ヘッダに設定するCSS
23         protected static $_canEditContent;      // コンテンツが編集可能かどうか
24         protected static $_paramObj;            // ウィジェットパラメータオブジェクト
25         
26         // 画面
27         const TASK_TOP = 'top';                 // トップ画面
28         const TASK_CONTENT = 'content';                 // コンテンツ編集画面
29         const TASK_CONTENT_DETAIL = 'content_detail';                   // コンテンツ編集画面詳細
30         
31         /**
32          * コンストラクタ
33          */
34         function __construct()
35         {
36                 // 親クラスを呼び出す
37                 parent::__construct();
38                 
39                 // DBオブジェクト作成
40                 $this->_localDb = new user_contentDb();
41         }
42         /**
43          * テンプレートにデータ埋め込む
44          *
45          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
46          *
47          * @param RequestManager $request               HTTPリクエスト処理クラス
48          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
49          * @return                                                              なし
50          */
51         function _postAssign($request, &$param)
52         {
53                 // タブ用CSSを取得
54                 if (!empty(self::$_paramObj)){
55                         $this->_headCss = self::$_paramObj->css;                                        // タブ用CSS
56                 }
57                 
58                 // ヘッダ用CSSが作成されていないときは、デフォルトのCSSを取得
59                 if (empty($this->_headCss)){
60                         $this->_headCss = $this->getParsedTemplateData('default.tmpl.css', array($this, 'makeCss'));// デフォルト用のCSSを取得
61                 }
62         }
63         /**
64          * CSSデータをHTMLヘッダ部に設定
65          *
66          * CSSデータをHTMLのheadタグ内に追加出力する。
67          * _assign()よりも後に実行される。
68          *
69          * @param RequestManager $request               HTTPリクエスト処理クラス
70          * @param object         $param                 任意使用パラメータ。
71          * @return string                                               CSS文字列。出力しない場合は空文字列を設定。
72          */
73         function _addCssToHead($request, &$param)
74         {
75                 return $this->_headCss;
76         }
77         /**
78          * BBS定義値をDBから取得
79          *
80          * @return bool                 true=取得成功、false=取得失敗
81          */
82         function _loadConfig()
83         {
84                 $this->_configArray = array();
85
86                 // BBS定義を読み込み
87                 $ret = $this->_localDb->getAllConfig($rows);
88                 if ($ret){
89                         // 取得データを連想配列にする
90                         $configCount = count($rows);
91                         for ($i = 0; $i < $configCount; $i++){
92                                 $key = $rows[$i]['tg_id'];
93                                 $value = $rows[$i]['tg_value'];
94                                 $this->_configArray[$key] = $value;
95                         }
96                 }
97                 return $ret;
98         }
99         /**
100          * CSSデータ作成処理コールバック
101          *
102          * @param object         $tmpl                  テンプレートオブジェクト
103          * @param                                                               なし
104          */
105         function makeCss($tmpl)
106         {
107                 $tmpl->addVar("_tmpl", "widget_url",    $this->gEnv->getCurrentWidgetRootUrl());                // ウィジェットのURL
108         }
109 }
110 ?>