当前位置: 首页>>代码示例>>PHP>>正文


PHP TBGContext::visitPartial方法代码示例

本文整理汇总了PHP中TBGContext::visitPartial方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGContext::visitPartial方法的具体用法?PHP TBGContext::visitPartial怎么用?PHP TBGContext::visitPartial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TBGContext的用法示例。


在下文中一共展示了TBGContext::visitPartial方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: includeTemplate

 /**
  * Include a template from a module
  *
  * @param string $template
  * @param array $params
  */
 public static function includeTemplate($template, $params = array())
 {
     $debug = TBGContext::isDebugMode();
     if ($debug) {
         $time = explode(' ', microtime());
         $pretime = $time[1] + $time[0];
     }
     $template_name = self::getFinalTemplateName($template);
     self::presentTemplate($template_name, $params);
     if ($debug) {
         $time = explode(' ', microtime());
         $posttime = $time[1] + $time[0];
         TBGContext::visitPartial($template, $posttime - $pretime);
     }
 }
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:21,代码来源:TBGActionComponent.class.php

示例2: performAction

 /**
  * Performs an action
  * 
  * @param string $action Name of the action
  * @param string $method Name of the action method to run
  */
 public static function performAction($action, $method)
 {
     // Set content variable
     $content = null;
     // Set the template to be used when rendering the html (or other) output
     $templatePath = THEBUGGENIE_MODULES_PATH . $action . DS . 'templates' . DS;
     // Construct the action class and method name, including any pre- action(s)
     $actionClassName = $action . 'Actions';
     $actionToRunName = 'run' . ucfirst($method);
     $preActionToRunName = 'pre' . ucfirst($method);
     // Set up the response object, responsible for controlling any output
     self::getResponse()->setPage(self::getRouting()->getCurrentRouteName());
     self::getResponse()->setTemplate(strtolower($method) . '.' . TBGContext::getRequest()->getRequestedFormat() . '.php');
     self::getResponse()->setupResponseContentType(self::getRequest()->getRequestedFormat());
     self::setCurrentProject(null);
     // Set up the action object
     $actionObject = new $actionClassName();
     // Run the specified action method set if it exists
     if (method_exists($actionObject, $actionToRunName)) {
         // Turning on output buffering
         ob_start();
         ob_implicit_flush(0);
         if (self::getRouting()->isCurrentRouteCSRFenabled()) {
             // If the csrf check fails, don't proceed
             if (!self::checkCSRFtoken(true)) {
                 return true;
             }
         }
         if (self::$debug_mode) {
             $time = explode(' ', microtime());
             $pretime = $time[1] + $time[0];
         }
         if ($content === null) {
             TBGLogging::log('Running main pre-execute action');
             // Running any overridden preExecute() method defined for that module
             // or the default empty one provided by TBGAction
             if ($pre_action_retval = $actionObject->preExecute(self::getRequest(), $method)) {
                 $content = ob_get_clean();
                 TBGLogging::log('preexecute method returned something, skipping further action');
                 if (self::$debug_mode) {
                     $visited_templatename = "{$actionClassName}::preExecute()";
                 }
             }
         }
         if ($content === null) {
             $action_retval = null;
             if (self::getResponse()->getHttpStatus() == 200) {
                 // Checking for and running action-specific preExecute() function if
                 // it exists
                 if (method_exists($actionObject, $preActionToRunName)) {
                     TBGLogging::log('Running custom pre-execute action');
                     $actionObject->{$preActionToRunName}(self::getRequest(), $method);
                 }
                 // Running main route action
                 TBGLogging::log('Running route action ' . $actionToRunName . '()');
                 if (self::$debug_mode) {
                     $time = explode(' ', microtime());
                     $action_pretime = $time[1] + $time[0];
                 }
                 $action_retval = $actionObject->{$actionToRunName}(self::getRequest());
                 if (self::$debug_mode) {
                     $time = explode(' ', microtime());
                     $action_posttime = $time[1] + $time[0];
                     TBGContext::visitPartial("{$actionClassName}::{$actionToRunName}", $action_posttime - $action_pretime);
                 }
             }
             if (self::getResponse()->getHttpStatus() == 200 && $action_retval) {
                 // If the action returns *any* output, we're done, and collect the
                 // output to a variable to be outputted in context later
                 $content = ob_get_clean();
                 TBGLogging::log('...done');
             } elseif (!$action_retval) {
                 // If the action doesn't return any output (which it usually doesn't)
                 // we continue on to rendering the template file for that specific action
                 TBGLogging::log('...done');
                 TBGLogging::log('Displaying template');
                 // Check to see if we have a translated version of the template
                 if (($templateName = self::getI18n()->hasTranslatedTemplate(self::getResponse()->getTemplate())) === false) {
                     // Check to see if the template has been changed, and whether it's in a
                     // different module, specified by "module/templatename"
                     if (strpos(self::getResponse()->getTemplate(), '/')) {
                         $newPath = explode('/', self::getResponse()->getTemplate());
                         $templateName = THEBUGGENIE_MODULES_PATH . $newPath[0] . DS . 'templates' . DS . $newPath[1] . '.' . TBGContext::getRequest()->getRequestedFormat() . '.php';
                     } else {
                         $templateName = $templatePath . self::getResponse()->getTemplate();
                     }
                 }
                 // Check to see if the template exists and throw an exception otherwise
                 if (!file_exists($templateName)) {
                     TBGLogging::log('The template file for the ' . $method . ' action ("' . self::getResponse()->getTemplate() . '") does not exist', 'core', TBGLogging::LEVEL_FATAL);
                     throw new TBGTemplateNotFoundException('The template file for the ' . $method . ' action ("' . self::getResponse()->getTemplate() . '") does not exist');
                 }
                 self::loadLibrary('common');
                 // Present template for current action
//.........这里部分代码省略.........
开发者ID:ronaldbroens,项目名称:thebuggenie,代码行数:101,代码来源:TBGContext.class.php

示例3: performAction

 /**
  * Performs an action
  * 
  * @param string $module Name of the action module
  * @param string $method Name of the action method to run
  */
 public static function performAction($action, $module, $method)
 {
     // Set content variable
     $content = null;
     // Set the template to be used when rendering the html (or other) output
     $templatePath = THEBUGGENIE_MODULES_PATH . $module . DS . 'templates' . DS;
     $actionClassName = get_class($action);
     $actionToRunName = 'run' . ucfirst($method);
     $preActionToRunName = 'pre' . ucfirst($method);
     // Set up the response object, responsible for controlling any output
     self::getResponse()->setPage(self::getRouting()->getCurrentRouteName());
     self::getResponse()->setTemplate(mb_strtolower($method) . '.' . TBGContext::getRequest()->getRequestedFormat() . '.php');
     self::getResponse()->setupResponseContentType(self::getRequest()->getRequestedFormat());
     self::setCurrentProject(null);
     // Run the specified action method set if it exists
     if (method_exists($action, $actionToRunName)) {
         // Turning on output buffering
         ob_start('mb_output_handler');
         ob_implicit_flush(0);
         if (self::getRouting()->isCurrentRouteCSRFenabled()) {
             // If the csrf check fails, don't proceed
             if (!self::checkCSRFtoken(true)) {
                 return true;
             }
         }
         if (self::$_debug_mode) {
             $time = explode(' ', microtime());
             $pretime = $time[1] + $time[0];
         }
         if ($content === null) {
             TBGLogging::log('Running main pre-execute action');
             // Running any overridden preExecute() method defined for that module
             // or the default empty one provided by TBGAction
             if ($pre_action_retval = $action->preExecute(self::getRequest(), $method)) {
                 $content = ob_get_clean();
                 TBGLogging::log('preexecute method returned something, skipping further action');
                 if (self::$_debug_mode) {
                     $visited_templatename = "{$actionClassName}::preExecute()";
                 }
             }
         }
         if ($content === null) {
             $action_retval = null;
             if (self::getResponse()->getHttpStatus() == 200) {
                 // Checking for and running action-specific preExecute() function if
                 // it exists
                 if (method_exists($action, $preActionToRunName)) {
                     TBGLogging::log('Running custom pre-execute action');
                     $action->{$preActionToRunName}(self::getRequest(), $method);
                 }
                 // Running main route action
                 TBGLogging::log('Running route action ' . $actionToRunName . '()');
                 if (self::$_debug_mode) {
                     $time = explode(' ', microtime());
                     $action_pretime = $time[1] + $time[0];
                 }
                 $action_retval = $action->{$actionToRunName}(self::getRequest());
                 if (self::$_debug_mode) {
                     $time = explode(' ', microtime());
                     $action_posttime = $time[1] + $time[0];
                     TBGContext::visitPartial("{$actionClassName}::{$actionToRunName}", $action_posttime - $action_pretime);
                 }
             }
             if (self::getResponse()->getHttpStatus() == 200 && $action_retval) {
                 // If the action returns *any* output, we're done, and collect the
                 // output to a variable to be outputted in context later
                 $content = ob_get_clean();
                 TBGLogging::log('...done');
             } elseif (!$action_retval) {
                 // If the action doesn't return any output (which it usually doesn't)
                 // we continue on to rendering the template file for that specific action
                 TBGLogging::log('...done');
                 TBGLogging::log('Displaying template');
                 // Check to see if we have a translated version of the template
                 if ($method != 'notFound' && (!self::isReadySetup() || ($templateName = self::getI18n()->hasTranslatedTemplate(self::getResponse()->getTemplate())) === false)) {
                     // Check to see if any modules provide an alternate template
                     $event = TBGEvent::createNew('core', "TBGContext::performAction::renderTemplate")->triggerUntilProcessed(array('class' => $actionClassName, 'action' => $actionToRunName));
                     if ($event->isProcessed()) {
                         $templateName = $event->getReturnValue();
                     }
                     // Check to see if the template has been changed, and whether it's in a
                     // different module, specified by "module/templatename"
                     if (mb_strpos(self::getResponse()->getTemplate(), '/')) {
                         $newPath = explode('/', self::getResponse()->getTemplate());
                         $templateName = THEBUGGENIE_MODULES_PATH . $newPath[0] . DS . 'templates' . DS . $newPath[1] . '.' . TBGContext::getRequest()->getRequestedFormat() . '.php';
                     } else {
                         $templateName = $templatePath . self::getResponse()->getTemplate();
                     }
                 }
                 // Check to see if the template exists and throw an exception otherwise
                 if (!file_exists($templateName)) {
                     TBGLogging::log('The template file for the ' . $method . ' action ("' . self::getResponse()->getTemplate() . '") does not exist', 'core', TBGLogging::LEVEL_FATAL);
                     throw new TBGTemplateNotFoundException('The template file for the ' . $method . ' action ("' . self::getResponse()->getTemplate() . '") does not exist');
                 }
//.........这里部分代码省略.........
开发者ID:oparoz,项目名称:thebuggenie,代码行数:101,代码来源:TBGContext.class.php


注:本文中的TBGContext::visitPartial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。