/** * 唯一のインスタンスに対して設定を行う * * @static * @param array $opts */ public static function setOptions($opts) { $instance = Teeple_Smarty4Maple::getInstance(); foreach ($opts as $attr => $value) { if (array_key_exists($attr, $instance)) { $instance->{$attr} = $value; } } }
/** * エラーハンドリングを行ないます。 * * @param Exception $e 例外クラス */ public static function handle($e) { // ロギング self::handleLogging($e); // エラーページを出力 $display = $e->getMessage(); $template = 'common/exception.html'; $renderer = Teeple_Smarty4Maple::getInstance(); $renderer->assign('display', $display); $renderer->assign('stack', $e->__toString()); $result = $renderer->fetch($template); if ($result == "") { self::print_error($display); } print $result; return; }
/** * Viewの処理を実行 * **/ public function postfilter() { if ($this->isCompleteResponse()) { $this->log->info("CompleteResponseフラグが立っているため、Viewは実行されませんでした。"); return; } $view = $this->response->getView(); $this->log->debug("view: {$view}"); if ($view == "") { $view = Teeple_Util::getPathInfo(); } if ($view != "") { $template = preg_replace("/^\\//", "", $view); if ($template == "") { throw new Teeple_Exception("テンプレートの指定が不正です。({$template})"); } if (preg_match("/^location:/", $template)) { $url = preg_replace("/^location:/", "", $template); $url = trim($url); $this->response->setRedirect($url); } else { if (preg_match("/^redirect:/", $template)) { $url = preg_replace("/^redirect:/", "", $template); $url = trim($url); $url = Teeple_Util::getAbsoluteUrlFromActionName($url, $this->request->isHttps()); $this->request->setFilterError(NULL); // TODO 定数化 $this->session->setParameter("__REDIRECT_SCOPE_REQUEST", $this->request); $this->response->setRedirect($url); } else { $renderer = Teeple_Smarty4Maple::getInstance(); $action = $this->actionChain->getCurAction(); $renderer->setAction($action); if (is_object($this->token)) { $renderer->setToken($this->token); } if (is_object($this->session)) { $renderer->setSession($this->session); } if (is_object($this->request)) { $renderer->setRequest($this->request); } $renderer->setScriptName(Teeple_Util::getScriptName()); $result = $renderer->fetch($template); if ($result == "") { throw new Teeple_Exception("Viewのレンダリングに失敗しました。"); } $this->response->setResult($result); } } } $contentDisposition = $this->response->getContentDisposition(); $contentType = $this->response->getContentType(); $result = $this->response->getResult(); $redirect = $this->response->getRedirect(); if ($redirect) { $this->redirect($redirect); } else { if ($contentDisposition != "") { header("Content-disposition: {$contentDisposition}"); } if ($contentType != "") { header("Content-type: {$contentType}"); } print $result; } return; }
<?php /** * Teeple2 - PHP5 Web Application Framework inspired by Seasar2 * * PHP versions 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @package teeple * @author Mitsutaka Sato <*****@*****.**> * @license http://www.php.net/license/3_0.txt PHP License 3.0 */ include_once dirname(__FILE__) . '/teeple.inc.php'; // // Action自動生成機能のON/OFF // define('USE_DEVHELPER', false); // //Smartyテンプレートの設定 // Teeple_Smarty4Maple::setOptions(array("caching" => false, "cache_lifetime" => 5, "compile_check" => false, "force_compile" => true)); // // DataSourceの設定 // define('DEFAULT_DATASOURCE', 'default'); Teeple_DataSource::setDataSource(array('default' => array('dsn' => 'mysql:host=localhost;dbname=default;charset=utf8', 'user' => 'default', 'pass' => 'default')));
private function confirmPage($actionName) { list($className, $classfile, $templatefile) = $this->makeNames($actionName); $isClassfile = "新規作成"; $isTemplatefile = "新規作成"; if (@file_exists($classfile)) { $isClassfile = "存在します"; } if (@file_exists($templatefile)) { $isTemplatefile = "存在します"; } $renderer = Teeple_Smarty4Maple::getInstance(); $renderer->assign('actionName', $actionName); $renderer->assign('classfile', $classfile); $renderer->assign('templatefile', $templatefile); $renderer->assign('isClassfile', $isClassfile); $renderer->assign('isTemplatefile', $isTemplatefile); $result = $renderer->fetch('devhelper/confirm.html'); print $result; exit; }