示例#1
0
 /**
  * Return the routing object
  *
  * @return Routing
  */
 protected function getRouting()
 {
     return Caspar::getRouting();
 }
示例#2
0
 public function hasTranslatedTemplate($template, $is_component = false)
 {
     if (mb_strpos($template, '/')) {
         $templateinfo = explode('/', $template);
         $module = $templateinfo[0];
         $templatefile = $is_component ? '_' . $templateinfo[1] . '.inc.php' : $templateinfo[1] . '.' . Caspar::getRequest()->getRequestedFormat() . '.php';
     } else {
         $module = Caspar::getRouting()->getCurrentRouteModule();
         $templatefile = $is_component ? '_' . $template . '.inc.php' : $template . '.' . Caspar::getRequest()->getRequestedFormat() . '.php';
     }
     if (file_exists(CASPAR_MODULES_PATH . $module . DS . 'i18n' . DS . $this->_language . DS . 'templates' . DS . $templatefile)) {
         return CASPAR_MODULES_PATH . $module . DS . 'i18n' . DS . $this->_language . DS . 'templates' . DS . $templatefile;
     } elseif (file_exists(CASPAR_CORE_PATH . 'i18n' . DS . $this->getCurrentLanguage() . DS . 'templates' . DS . $module . DS . $templatefile)) {
         return CASPAR_CORE_PATH . 'i18n' . DS . $this->getCurrentLanguage() . DS . 'templates' . DS . $module . DS . $templatefile;
     }
     return false;
 }
示例#3
0
 /**
  * Present a template
  * @param string $template_file
  * @param array $params
  */
 public static function presentTemplate($template_file, $params = array())
 {
     Logging::log("configuring template variables for template {$template_file}");
     foreach ($params as $key => $val) {
         ${$key} = $val;
     }
     if (array_key_exists('key', $params)) {
         $key = $params['key'];
     }
     if (array_key_exists('val', $params)) {
         $val = $params['val'];
     }
     /**
      * @global Request The request object
      */
     $csp_request = Caspar::getRequest();
     /**
      * @global Response The response object
      */
     $csp_response = Caspar::getResponse();
     /**
      * @global Request The request object
      */
     $csp_routing = Caspar::getRouting();
     /**
      * @global User The user object
      */
     $csp_user = Caspar::getUser();
     Caspar::loadLibrary('common');
     Caspar::loadLibrary('ui');
     Logging::log('rendering template output');
     $___vars = Event::createNew('core', 'loadTemplateVariables')->trigger()->getReturnList();
     foreach ($___vars as $k => $v) {
         ${$k} = $v;
     }
     require $template_file;
 }