Exemple #1
0
 /**
  * Attaches files to the header.
  *
  * @since	1.0
  * @access	public
  * @param	string	The path to the javascript file
  * @return
  */
 public function attach($path = null)
 {
     // Import joomla's filesystem library.
     jimport('joomla.filesystem.file');
     // Keep original file value
     if (!is_null($path)) {
         $_file = $this->file;
         $this->file = FD::resolve($path . '.' . $this->extension);
         if (!$this->file) {
             $this->file = FD::resolve($path);
         }
     }
     // Keep current value
     $_scriptTag = $this->scriptTag;
     $_CDATA = $this->CDATA;
     // Reset to false
     $this->scriptTag = false;
     $this->CDATA = false;
     $output = $this->parse();
     FD::page()->addInlineScript($output);
     // Restore current value
     $this->scriptTag = $_scriptTag;
     $this->CDATA = $_CDATA;
     // Restore original file value
     if (!is_null($path)) {
         $this->file = $_file;
     }
 }
Exemple #2
0
 public function attach($path = null)
 {
     // Keep current value
     $_styleTag = $this->styleTag;
     $_CDATA = $this->CDATA;
     // Keep original file value
     if (!is_null($path)) {
         $_file = $this->file;
         $this->file = FD::resolve($path . '.' . $this->extension);
     }
     // Reset to false
     $this->styleTag = false;
     $this->CDATA = false;
     $output = $this->parse();
     FD::page()->addInlineStylesheet($output);
     // Restore current value
     $this->styleTag = $_styleTag;
     $this->CDATA = $_CDATA;
     // Restore original file value
     if (!is_null($path)) {
         $this->file = $_file;
     }
 }
Exemple #3
0
 public function getResourcesSettings()
 {
     $config = FD::config();
     $assets = FD::get('Assets');
     $themes = FD::get('Themes');
     $locations = $assets->locations();
     // Build a deterministic cache
     $settings = array("language" => JFactory::getLanguage()->getTag(), "template" => array("site" => $config->get('theme.site', 'wireframe'), "admin" => $config->get('theme.admin', 'default')), "view" => array(), "modified" => filemtime($this->resourceManifestFile));
     // Determine if there are template overrides
     if (JFolder::exists($locations['site_override'])) {
         $settings["template"]["site_override"] = FD::call('Assets', 'getJoomlaTemplate', array('site'));
     }
     if (JFolder::exists($locations['admin_override'])) {
         $settings["template"]["admin_override"] = FD::call('Assets', 'getJoomlaTemplate', array('admin'));
     }
     // Get manifest
     $manifest = $this->getResourcesManifest();
     if (isset($manifest[0]->view) && $manifest[0]->view) {
         foreach ($manifest[0]->view as $view) {
             $original = $view;
             $view = 'themes:/' . $view;
             $path = FD::resolve($view . '.ejs');
             // If the file still does not exist, we'll skip this
             if (!JFile::exists($path)) {
                 continue;
             }
             $settings["view"][] = array("path" => str_ireplace(JPATH_ROOT, '', $path), "modified" => filemtime($path));
         }
     }
     // Build hash
     $settings["id"] = md5(serialize($settings));
     return $settings;
 }
Exemple #4
0
 /**
  * Processes an ajax call that is passed to the server. It is smart enough to decide which
  * file would be responsible to keep these codes.
  *
  * @since	1.0
  * @access	public
  *
  * @author	Mark Lee <*****@*****.**>
  */
 public function listen()
 {
     $doc = JFactory::getDocument();
     $ajax = FD::getInstance('Ajax');
     // Do not proceed if the request is not in ajax format.
     if ($doc->getType() != 'ajax') {
         return;
     }
     // Namespace format should be POSIX format.
     $namespace = JRequest::getVar('namespace');
     $parts = explode(':/', $namespace);
     // Detect if the user passed in a protocol.
     $hasProtocol = count($parts) > 1;
     if (!$hasProtocol) {
         $namespace = 'ajax:/' . $namespace;
     }
     return FD::resolve($namespace);
 }
 /**
  * Outputs the data from a template file.
  *
  * @since	1.0
  * @access	public
  * @param	string		Path to template.
  * @param	Array		An array of arguments.
  *
  * @return	string		The output of the theme file.
  *
  * @author	Mark Lee <*****@*****.**>
  */
 public function output($path = null, $vars = null)
 {
     // Keep original file value
     if (!is_null($path)) {
         $_file = $this->file;
         $this->file = FD::resolve($path . '.' . $this->extension);
     }
     // Let's try to extract the data.
     $output = $this->parse($vars);
     // Restore original file value
     if (!is_null($path)) {
         $this->file = $_file;
     }
     // Free up some memory
     unset($_file);
     return $output;
 }