OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / ec_product_header / include / container / ec_product_headerWidgetContainer.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    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2008 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: ec_product_headerWidgetContainer.php 2266 2009-08-28 08:25:59Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getContainerPath()           . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/ec_product_headerDb.php');
18
19 class ec_product_headerWidgetContainer extends BaseWidgetContainer
20 {
21         private $db;    // DB接続オブジェクト
22         const CONTENT_TYPE = 'ec_menu';                 // コンテンツタイプ
23         const PARAM_CONTENT_ID = 'pcontent';    // コンテンツIDキー
24                 
25         /**
26          * コンストラクタ
27          */
28         function __construct()
29         {
30                 // 親クラスを呼び出す
31                 parent::__construct();
32                 
33                 // DBオブジェクト作成
34                 $this->db = new ec_product_headerDb();
35         }
36         /**
37          * テンプレートファイルを設定
38          *
39          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
40          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
41          *
42          * @param RequestManager $request               HTTPリクエスト処理クラス
43          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
44          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
45          */
46         function _setTemplate($request, &$param)
47         {       
48                 return 'index.tmpl.html';
49         }
50         /**
51          * テンプレートにデータ埋め込む
52          *
53          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
54          *
55          * @param RequestManager $request               HTTPリクエスト処理クラス
56          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
57          * @param                                                               なし
58          */
59         function _assign($request, &$param)
60         {
61                 $this->lang = $this->gEnv->getCurrentLanguage();
62                 
63                 // コンテンツを取得
64                 $contentId = $request->trimValueOf(self::PARAM_CONTENT_ID);
65                 if (empty($contentId)) $contentId = 0;
66
67                 $ret = $this->db->getContentByContentId(self::CONTENT_TYPE, $contentId, $this->lang, $row);
68                 if ($ret){
69                         $html = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $row['cn_html']);// アプリケーションルートを変換
70                 }
71                 
72                 // コンテンツを設定
73                 $this->tmpl->addVar("_widget", "content", $html);
74         }
75 }
76 ?>