示例#1
0
 /**
  * @return TemplatePathsController
  */
 function createControllerFor($action_name, $mime_type = 'html')
 {
     $controller_class_name = AkInflector::camelize($this->controller_name) . 'Controller';
     $controller = new $controller_class_name();
     $Request = $this->createGetRequest($action_name, $mime_type);
     $Response = $this->getMock('AkResponse', array('outputResults'));
     $controller->setRequestAndResponse($Request, $Response);
     $this->Template = $controller->Template = $this->getMock('AkActionView', array('renderFile'), array(AK_VIEWS_DIR . DS . $this->controller_name));
     $this->Template->_registerTemplateHandler('tpl', 'AkPhpTemplateHandler');
     $this->Template->_registerTemplateHandler('html.tpl', 'AkPhpTemplateHandler');
     $this->action_name = $action_name;
     return $this->Controller = $controller;
 }
示例#2
0
 /**
  * Render detailed diagnostics for unhandled exceptions rescued from
  *  a controller action.
  */
 public function rescueActionLocally($Exception)
 {
     $exception_class_name = get_class($Exception);
     if (!isset($this->rescue_templates[$exception_class_name])) {
         AkError::handle($Exception);
     }
     AkConfig::rebaseApp(AK_ACTION_PACK_DIR . DS . 'rescues');
     $Template = new AkActionView();
     $Template->registerTemplateHandler('tpl', 'AkPhpTemplateHandler');
     $Template->Request = $this->Request;
     $file = $this->rescue_templates[$exception_class_name];
     $body = $Template->render(array('file' => $file, 'layout' => 'layouts/exception', 'locals' => array('Exception' => $Exception, 'Template' => $Template, 'Request' => $this->Request)));
     AkConfig::leaveBase();
     $this->render($this->getStatusCode($Exception), $body);
 }
示例#3
0
 function test_content_for()
 {
     $str = "test CaptureHelper content_for";
     $this->capture_helper->content_for('content_for');
     echo $str;
     $this->assertEqual($this->capture_helper->end(), $str);
     $globals = AkActionView::_getGlobals();
     $this->assertEqual($globals['content_for_content_for'], $str);
 }
示例#4
0
 public function test_concatenation()
 {
     $this->capture_helper->content_for('concatenation');
     echo 'A';
     $this->assertEqual($this->capture_helper->end(), 'A');
     $this->capture_helper->content_for('concatenation');
     echo 'B';
     $this->assertEqual($this->capture_helper->end(), 'B');
     $globals = AkActionView::_getGlobals();
     $this->assertEqual($globals['content_for_concatenation'], 'AB');
 }
示例#5
0
 public function &_initializeTemplateClass($assigns)
 {
     require_once AK_LIB_DIR . DS . 'AkActionView.php';
     $TemplateInstance = new AkActionView($this->getTemplatePath(), $assigns, $this);
     require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'AkPhpTemplateHandler.php';
     $TemplateInstance->_registerTemplateHandler('tpl', 'AkPhpTemplateHandler');
     return $TemplateInstance;
 }
示例#6
0
 /**
  * @static 
  */
 function _getGlobals()
 {
     return AkActionView::_addGlobalVar(null, null, true);
 }
示例#7
0
 function _addVarToView($var_name, $content)
 {
     AkActionView::_addGlobalVar($var_name, $content);
 }
示例#8
0
文件: base.php 项目: bermi/akelos
 protected function &_initializeTemplateClass($assigns)
 {
     $TemplateInstance = new AkActionView($this->getTemplatePath(), $assigns, $this);
     $TemplateInstance->registerTemplateHandler('tpl', 'AkPhpTemplateHandler');
     $TemplateInstance->setHelperLoader($this->getHelperLoader());
     return $TemplateInstance;
 }
示例#9
0
 static function getGlobals()
 {
     return AkActionView::addGlobalVar(null, null, true);
 }
示例#10
0
 /**
  * @return AkActionView
  */
 public function createView()
 {
     $View = new AkActionView(AkConfig::getDir('views') . DS . $this->controller_name);
     $View->registerTemplateHandler('tpl', 'AkPhpTemplateHandler');
     return $this->Template = $View;
 }