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: baseTemplateContainer.php 1653 2009-03-27 05:24:28Z fishbone $
14 * @link http://www.magic3.org
17 require_once($gEnvManager->getLibPath() . '/patTemplate/patTemplate.php');
18 require_once($gEnvManager->getLibPath() . '/patTemplate/patError.php');
19 require_once($gEnvManager->getLibPath() . '/patTemplate/patErrorManager.php');
21 class BaseTemplateContainer
23 protected $tmpl; // テンプレートオブジェクト
24 private $errorMessage = array(); // アプリケーションのエラー
25 private $warningMessage = array(); // ユーザ操作の誤り
26 private $guidanceMessage = array(); // ガイダンス
31 function __construct()
34 parent::__construct();
38 * 起動マネージャから呼ばれる唯一のメソッド
40 * @param RequestManager $request HTTPリクエスト処理クラス
42 function process($request)
45 $this->_preBuffer($request);
47 if (method_exists($this, '_setTemplate')){
48 $templateFile = $this->_setTemplate();
50 // テンプレートファイル名が空文字列のときは、テンプレートライブラリを使用しない
51 if ($templateFile != ''){
53 //$mode = self::valueOf('_mode');
54 $mode = $request->valueOf('_mode');
57 self::__setTemplate();
60 $this->tmpl->readTemplatesFromFile($templateFile);
65 // 各ウィジェットごとののテンプレート処理
66 if (method_exists($this, '_assign')) $this->_assign($mode);
74 } else { // メソッドが存在しないときはエラーメッセージを出力
75 echo 'method not found: BaseTemplateContainer::_setTemplate()';
79 $this->_postBuffer($request);
85 private function __setTemplate()
88 $this->tmpl = new PatTemplate();
92 $this->tmpl->setRoot($gEnvManager->getTemplatesPath());
94 // エラーメッセージテンプレートを埋め込む
95 $this->tmpl->applyInputFilter('ErrorMessage');
98 //$this->tmpl->applyInputFilter('FunctionTag');
101 //$this->tmpl->applyInputFilter('StripComments');
104 //$this->tmpl->readTemplatesFromFile($filename);
112 private function __assign()
115 $now = date("Y/m/d H:i:s");
116 $this->tmpl->addVar("_page", "DATE", "created $now");
119 //$this->tmpl->addVar("_page", "RES", M3_SYSTEM_RES_DIR);
120 //$this->tmpl->addVar("_page_body", "RES", M3_SYSTEM_RES_DIR);
123 //$this->tmpl->addVar("_page", "POST_NAME", M3_COMPONENT_POST_NAME);
124 //$this->tmpl->addVar("_page_body", "POST_NAME", M3_COMPONENT_POST_NAME);
130 private function __parse()
132 echo $this->tmpl->getParsedTemplate('_page');