Пример #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);
 }
Пример #2
0
 /**
  * Gets the active theme name
  *
  * @return	string
  */
 public static function getTheme()
 {
     // theme nama has not yet been saved, fetch and save it
     if (!self::$theme) {
         self::$theme = FrontendModel::getModuleSetting('core', 'theme', null);
     }
     // return theme name
     return self::$theme;
 }
Пример #3
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();
 }
Пример #4
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;
 }
Пример #5
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();
 }
Пример #6
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;
 }
Пример #7
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);
 }
Пример #8
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);
 }
Пример #9
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);
     }
 }
Пример #10
0
 /**
  * Parse Facebook related header-data
  */
 private function parseFacebook()
 {
     $parseFacebook = false;
     // check if facebook admins are set
     if (FrontendModel::getModuleSetting('core', 'facebook_admin_ids', null) !== null) {
         $this->addMetaData(array('property' => 'fb:admins', 'content' => FrontendModel::getModuleSetting('core', 'facebook_admin_ids', null)), true, array('property'));
         $parseFacebook = true;
     }
     // check if no facebook admin is set but an app is configured we use the application as an admin
     if (FrontendModel::getModuleSetting('core', 'facebook_admin_ids', null) == '' && FrontendModel::getModuleSetting('core', 'facebook_app_id', null) !== null) {
         $this->addMetaData(array('property' => 'fb:app_id', 'content' => FrontendModel::getModuleSetting('core', 'facebook_app_id', null)), true, array('property'));
         $parseFacebook = true;
     }
     // should we add extra open-graph data?
     if ($parseFacebook) {
         // build correct locale
         switch (FRONTEND_LANGUAGE) {
             case 'en':
                 $locale = 'en_US';
                 break;
             case 'cn':
                 $locale = 'zh-CN';
                 break;
             default:
                 $locale = strtolower(FRONTEND_LANGUAGE) . '_' . strtoupper(FRONTEND_LANGUAGE);
         }
         // add the locale property
         $this->addOpenGraphData('locale', $locale);
         // if a default image has been set for facebook, assign it
         $this->addOpenGraphImage('/frontend/themes/' . FrontendTheme::getTheme() . '/facebook.png');
         $this->addOpenGraphImage('/facebook.png');
     }
 }