Ejemplo n.º 1
0
 public function __construct()
 {
     // if the application wasn't defined before we will define it
     if (!defined('NAMED_APPLICATION')) {
         define('NAMED_APPLICATION', 'frontend');
     }
     // set the module
     $this->setModule(SpoonFilter::getGetValue('module', null, ''));
     // set the requested file
     $this->setFile(SpoonFilter::getGetValue('file', null, ''));
     // set the language
     $this->setLanguage(SpoonFilter::getGetValue('language', FrontendLanguage::getActiveLanguages(), SITE_DEFAULT_LANGUAGE));
     // create a new template instance (this will handle all stuff for us)
     $tpl = new FrontendTemplate();
     // enable addslashes on each locale
     $tpl->setAddSlashes(true);
     // set correct headers
     SpoonHTTP::setHeaders('content-type: application/javascript');
     // fetch the template path
     if ($this->module == 'core') {
         $file = FRONTEND_CORE_PATH . '/js/' . $this->getFile();
     } else {
         $file = FRONTEND_MODULES_PATH . '/' . $this->getModule() . '/js/' . $this->getFile();
     }
     // output the template
     $tpl->display(FrontendTheme::getPath($file), true);
 }
Ejemplo n.º 2
0
 /**
  * Execute the extra
  */
 public function execute()
 {
     parent::execute();
     $this->loadData();
     $widgetTemplatesPath = FRONTEND_MODULES_PATH . '/pages/layout/widgets';
     // check if the given template exists
     try {
         $template = FrontendTheme::getPath($widgetTemplatesPath . '/' . $this->data['template']);
     } catch (FrontendException $e) {
         $template = FrontendTheme::getPath($widgetTemplatesPath . '/subpages_default.tpl');
     }
     $this->loadTemplate($template);
     $this->parse();
 }
Ejemplo n.º 3
0
 /**
  * Assign the template path
  *
  * @return string
  */
 private function assignTemplate()
 {
     $template = FrontendTheme::getPath(FRONTEND_MODULES_PATH . '/content_blocks/layout/widgets/default.tpl');
     // is the content block visible?
     if (!empty($this->item)) {
         // check if the given template exists
         try {
             $template = FrontendTheme::getPath(FRONTEND_MODULES_PATH . '/content_blocks/layout/widgets/' . $this->item['template']);
         } catch (FrontendException $e) {
             // do nothing
         }
     } else {
         $this->item['text'] = '';
     }
     return $template;
 }
Ejemplo n.º 4
0
 /**
  * Execute the extra
  *
  * @return	void
  */
 public function execute()
 {
     // parent execute
     parent::execute();
     // load data
     $this->loadData();
     // check if the given template exists
     try {
         $template = FrontendTheme::getPath(FRONTEND_MODULES_PATH . '/content_blocks/layout/widgets/' . $this->item['template']);
     } catch (FrontendException $e) {
         $template = FrontendTheme::getPath(FRONTEND_MODULES_PATH . '/content_blocks/layout/widgets/default.tpl');
     }
     // load template
     $this->loadTemplate($template);
     // parse
     $this->parse();
 }
Ejemplo n.º 5
0
 /**
  * Execute the extra
  */
 public function execute()
 {
     parent::execute();
     $this->loadTemplate();
     /*
      * A bit dirty this; we overwrite the navigation template path of the FrontendNavigation
      * by a separate template for the sitemap.
      */
     $widgetLayoutPath = FRONTEND_MODULES_PATH . '/pages/layout';
     $originalTemplatePath = FrontendNavigation::getTemplatePath();
     FrontendNavigation::setTemplatePath(FrontendTheme::getPath($widgetLayoutPath . '/templates/sitemap.tpl'));
     /*
      * Because the scope of the template is now changed to the new sitemap.tpl, we can
      * store the HTML of the new, parsed scope. Afterwards we reset to the original
      * template (FrontendNavigation might be used again after this).
      */
     $sitemapNavigationHTML = $this->tpl->getContent(FrontendTheme::getPath($widgetLayoutPath . '/widgets/sitemap.tpl'));
     FrontendNavigation::setTemplatePath($originalTemplatePath);
     return $sitemapNavigationHTML;
 }
Ejemplo n.º 6
0
 /**
  * Set the path for the template
  *
  * @return	void
  * @param	string $path	The path to set.
  */
 private function setTemplatePath($path)
 {
     $this->templatePath = FrontendTheme::getPath($path);
 }
Ejemplo n.º 7
0
 /**
  * Fetch the path for an include (theme file if available, core file otherwise)
  * 	syntax: {$var|getpath:file}
  *
  * @param string $var The variable.
  * @param string $file The base path.
  * @return string
  */
 public static function getPath($var, $file)
 {
     // trick codensiffer
     $var = (string) $var;
     return FrontendTheme::getPath($file);
 }
Ejemplo n.º 8
0
 /**
  * Add a javascript file into the array
  *
  * @return	void
  * @param 	string $file						The path to the javascript-file that should be loaded.
  * @param	bool[optional] $minify				Should the file be minified?
  * @param	bool[optional] $parseThroughPHP		Should the file be parsed through PHP?
  * @param	bool[optional] $addTimestamp		May we add a timestamp for caching purposes?
  */
 public function addJS($file, $minify = true, $parseThroughPHP = false, $addTimestamp = null)
 {
     // redefine
     $file = (string) $file;
     $minify = (bool) $minify;
     // get file path
     if (substr($file, 0, 4) != 'http') {
         $file = FrontendTheme::getPath($file);
     }
     // no minifying when debugging
     if (SPOON_DEBUG) {
         $minify = false;
     }
     // no minifying when parsing through PHP
     if ($parseThroughPHP) {
         $minify = false;
     }
     // if parse through PHP we should alter the path
     if ($parseThroughPHP) {
         // process the path
         $chunks = explode('/', str_replace(array('/frontend/modules/', '/frontend/core'), '', $file));
         // validate
         if (!isset($chunks[count($chunks) - 3])) {
             throw new FrontendException('Invalid file (' . $file . ').');
         }
         // fetch values
         $module = $chunks[count($chunks) - 3];
         $file = $chunks[count($chunks) - 1];
         // reset module for core
         if ($module == '') {
             $module = 'core';
         }
         // alter the file
         $file = '/frontend/js.php?module=' . $module . '&file=' . $file . '&language=' . FRONTEND_LANGUAGE;
     }
     // try to minify
     if ($minify) {
         $file = $this->minifyJavascript($file);
     }
     // already in array?
     if (!in_array(array('file' => $file, 'add_timestamp' => $addTimestamp), $this->javascriptFiles)) {
         // add to files
         $this->javascriptFiles[] = array('file' => $file, 'add_timestamp' => $addTimestamp);
     }
 }