7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
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: newsWidgetContainer.php 2261 2009-08-28 01:57:12Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/newsDb.php');
19 class newsWidgetContainer extends BaseWidgetContainer
21 private $db; // DB接続オブジェクト
22 private $langId; // 現在の言語
23 const DEFAULT_CONFIG_ID = 0;
24 const CONTENT_TYPE = 'news'; // コンテンツタイプ
29 function __construct()
32 parent::__construct();
35 $this->db = new newsDb();
40 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
41 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
43 * @param RequestManager $request HTTPリクエスト処理クラス
44 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
45 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
47 function _setTemplate($request, &$param)
49 return 'main.tmpl.html';
54 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
56 * @param RequestManager $request HTTPリクエスト処理クラス
57 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
60 function _assign($request, &$param)
62 $this->langId = $this->gEnv->getCurrentLanguage();
65 $configId = $this->gEnv->getCurrentWidgetConfigId();
66 if (empty($configId)) $configId = self::DEFAULT_CONFIG_ID;
69 $paramObj = $this->getWidgetParamObj();
74 for ($i = 0; $i < count($paramObj); $i++){
75 $targetObj = $paramObj[$i];
76 $id = $targetObj->id;// 定義ID
77 if ($id == $configId){
78 $contentId = $targetObj->contentId;
79 $name = $targetObj->name;// 定義名
85 $ret = $this->db->getContentByContentId(self::CONTENT_TYPE, $contentId, $this->langId, $row);
87 $html = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->getUrl($this->gEnv->getRootUrl()), $row['cn_html']);// アプリケーションルートを変換
91 $this->tmpl->addVar("_widget", "content", $html);