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: g_qrcodeWidgetContainer.php 1803 2009-04-25 05:32:05Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
18 class g_qrcodeWidgetContainer extends BaseWidgetContainer
20 const DEFAULT_CONFIG_ID = 0;
21 const DEFAULT_QR_CODE_SIZE = 150; // デフォルトのQRコードサイズ
22 const DEFAULT_TITLE = 'QRコード'; // デフォルトのウィジェットタイトル
27 function __construct()
30 parent::__construct();
35 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
36 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
38 * @param RequestManager $request HTTPリクエスト処理クラス
39 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
40 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
42 function _setTemplate($request, &$param)
44 return 'index.tmpl.html';
49 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
51 * @param RequestManager $request HTTPリクエスト処理クラス
52 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
55 function _assign($request, &$param)
58 $configId = $this->gEnv->getCurrentWidgetConfigId();
59 if (empty($configId)) $configId = self::DEFAULT_CONFIG_ID;
62 $paramObj = $this->getWidgetParamObj();
66 for ($i = 0; $i < count($paramObj); $i++){
67 $targetObj = $paramObj[$i];
68 $id = $targetObj->id;// 定義ID
69 if ($id == $configId){
70 $name = $targetObj->name;// 定義名
71 $qrData = $targetObj->qrData; // QRコード化するデータ
72 $desc = $targetObj->desc; // 説明
73 $width = $targetObj->width; // QRコードサイズ
74 if (empty($width)) $width = self::DEFAULT_QR_CODE_SIZE;
78 if ($i < count($paramObj)){ // 該当する定義IDのデータが取得できたとき
79 $this->tmpl->setAttribute('show_html', 'visibility', 'visible');
83 $descString = '<tr><td>' . $desc . '</td></tr>';
84 $this->tmpl->addVar("show_html", "desc", $descString);
87 $qrData = urlencode($qrData);
88 $this->tmpl->addVar("show_html", "qr_data", $qrData);
89 $size = $width . 'x' . $width;
90 $this->tmpl->addVar("show_html", "size", $size);
96 * @param RequestManager $request HTTPリクエスト処理クラス
97 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
98 * @return string ウィジェットのタイトル名
100 function _setTitle($request, &$param)
102 return self::DEFAULT_TITLE;