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: image2WidgetContainer.php 2268 2009-08-31 03:29:18Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/image2Db.php');
19 class image2WidgetContainer extends BaseWidgetContainer
21 private $db; // DB接続オブジェクト
22 private $langId; // 現在の言語
23 private $paramObj; // 定義取得用
24 private $headCss; // ヘッダ出力用CSS
25 const DEFAULT_CONFIG_ID = 0;
30 function __construct()
33 parent::__construct();
36 $this->db = new image2Db();
41 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
42 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
44 * @param RequestManager $request HTTPリクエスト処理クラス
45 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
46 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
48 function _setTemplate($request, &$param)
50 return 'index.tmpl.html';
55 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
57 * @param RequestManager $request HTTPリクエスト処理クラス
58 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
61 function _assign($request, &$param)
63 $this->langId = $this->gEnv->getCurrentLanguage();
66 $configId = $this->gEnv->getCurrentWidgetConfigId();
67 if (empty($configId)) $configId = self::DEFAULT_CONFIG_ID;
70 $targetObj = $this->getWidgetParamObjByConfigId($configId);
71 if (!empty($targetObj)){ // 定義データが取得できたとき
72 $menuId = $targetObj->menuId; // メニューID
73 $name = $targetObj->name;// 定義名
74 $imageUrl = $targetObj->imageUrl; // 画像へのパス
75 $linkUrl = $targetObj->linkUrl; // リンク先
76 $align = $targetObj->align; // 表示位置
77 $bgcolor = $targetObj->bgcolor; // 画像バックグランドカラー
78 $width = $targetObj->width; // 画像の幅
79 $height = $targetObj->height; // 画像の高さ
80 $margin = $targetObj->margin; // 画像マージン
81 $widthType = $targetObj->widthType; // 画像の幅単位
82 $heightType = $targetObj->heightType; // 画像の高さ単位
83 $posx = $targetObj->posx; // x座標
84 $posy = $targetObj->posy; // y座標
85 $posxType = $targetObj->posxType; // x座標単位
86 $posyType = $targetObj->posyType; // y座標単位
87 $posType = $targetObj->posType; // 座標指定方法(相対座標)
88 $usePos = $targetObj->usePos; // 座標指定を可能とするかどうか
89 $useLink = $targetObj->useLink; // 画像にリンクを付けるかどうか
92 if (!empty($imageUrl)){
93 $imageUrl = str_replace(M3_TAG_START . M3_TAG_MACRO_ROOT_URL . M3_TAG_END, $this->gEnv->getRootUrl(), $imageUrl);
95 if (!empty($imageUrl)){
99 $align = 'align="' . $align . '"';
100 $this->tmpl->addVar("_widget", "align", $align);
102 if (!empty($bgcolor)) $divStyle .= 'background:' . $bgcolor . ';';
103 $divStyle .= 'margin:0;';
104 if (!empty($divStyle)){
105 $divStyle = 'style="' . $divStyle . '"';
106 $this->tmpl->addVar("_widget", "div_style", $divStyle);
110 $imgStyle = 'border:0;';
111 $destImg = '<img src="' . $this->getUrl($imageUrl) . '"';
114 $destImg .= ' width="' . $width;
115 if ($widthType == 0){
122 $destImg .= ' height="' . $height;
123 if ($heightType == 0){
130 if (!empty($margin)) $imgStyle .= 'margin:' . $margin . 'px;';
134 if ($posType == 'absolute'){
135 $imgStyle .= 'position:absolute;';
137 $imgStyle .= 'position:relative;';
139 $imgStyle .= 'left:' . $posx;
145 $imgStyle .= 'top:' . $posy;
153 if (!empty($imgStyle)){
154 $destImg .= ' style="'. $imgStyle . '"';
158 if ($useLink){ // リンクありのとき
159 $destImg = '<a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '">' . $destImg . '</a>';
161 $this->tmpl->addVar("_widget", "image", $destImg);