OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / youtube2 / include / container / youtube2WidgetContainer.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-2009 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: youtube2WidgetContainer.php 1825 2009-05-02 12:52:51Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17
18 class youtube2WidgetContainer extends BaseWidgetContainer
19 {
20         private $langId;                // 現在の言語
21         const DEFAULT_CONFIG_ID = 0;
22         const DEFAULT_TITLE = 'YouTube';                        // デフォルトのウィジェットタイトル
23         
24         /**
25          * コンストラクタ
26          */
27         function __construct()
28         {
29                 // 親クラスを呼び出す
30                 parent::__construct();
31         }
32         /**
33          * テンプレートファイルを設定
34          *
35          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
36          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
37          *
38          * @param RequestManager $request               HTTPリクエスト処理クラス
39          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
40          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
41          */
42         function _setTemplate($request, &$param)
43         {
44                 return 'index.tmpl.html';
45         }
46         /**
47          * テンプレートにデータ埋め込む
48          *
49          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
50          *
51          * @param RequestManager $request               HTTPリクエスト処理クラス
52          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
53          * @param                                                               なし
54          */
55         function _assign($request, &$param)
56         {
57                 $this->langId = $this->gEnv->getCurrentLanguage();
58                 
59                 // 定義ID取得
60                 $configId = $this->gEnv->getCurrentWidgetConfigId();
61                 if (empty($configId)) $configId = self::DEFAULT_CONFIG_ID;
62                 
63                 // パラメータオブジェクトを取得
64                 $targetObj = $this->getWidgetParamObjByConfigId($configId);
65                 if (!empty($targetObj)){                // 定義データが取得できたとき
66                         $name = $targetObj->name;// 定義名
67                         $width  = $targetObj->width;            // 幅
68                         $height = $targetObj->height;           // 高さ
69                         $movieId = $targetObj->movieId;         // YouTubeの動画ID
70                         
71                         // 表示データ埋め込み
72                         $this->tmpl->setAttribute('show_html', 'visibility', 'visible');// 画像を表示
73                         $this->tmpl->addVar("show_html", "width",       $width);
74                         $this->tmpl->addVar("show_html", "height",      $height);
75                         $this->tmpl->addVar("show_html", "movie_id",    $movieId);
76                 }
77         }
78         /**
79          * ウィジェットのタイトルを設定
80          *
81          * @param RequestManager $request               HTTPリクエスト処理クラス
82          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
83          * @return string                                               ウィジェットのタイトル名
84          */
85         function _setTitle($request, &$param)
86         {
87                 return self::DEFAULT_TITLE;
88         }
89 }
90 ?>