Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
 /**
  * Forward the user to a different URL
  * 
  * @param string $url the url to forward to
  * @param integer $code HTTP status code
  */
 public function headerRedirect($url, $code = 302)
 {
     Logging::log('Running header redirect function');
     $this->clearHeaders();
     $this->setHttpStatus($code);
     if (Caspar::getRequest()->isAjaxCall() || Caspar::getRequest()->getRequestedFormat() == 'json') {
         $this->renderHeaders();
     } else {
         $this->addHeader("Location: {$url}");
         $this->renderHeaders();
     }
     exit;
 }
Ejemplo n.º 3
0
 /**
  * Returns the current route action
  *
  * @return string The current route action
  */
 public function getCurrentRouteAction()
 {
     if ($this->current_route_module === null) {
         $this->getRouteFromUrl(Caspar::getRequest()->getParameter('url', null, false));
     }
     return $this->current_route_action;
 }
Ejemplo n.º 4
0
 /**
  * Sets the response to 404 and shows an error, with an optional message
  * 
  * @param string $message[optional] The message
  */
 public function return404($message = null)
 {
     if (Caspar::getRequest()->isAjaxCall() || Caspar::getRequest()->getRequestedFormat() == 'json') {
         $this->getResponse()->ajaxResponseText(404, $message);
     }
     $this->message = $message;
     $this->getResponse()->setHttpStatus(404);
     $this->getResponse()->setTemplate('main/notfound');
     return false;
 }
Ejemplo n.º 5
0
 /**
  * Returns the request object
  *
  * @return Request
  */
 protected function getRequest()
 {
     return Caspar::getRequest();
 }