Esempio n. 1
0
 /**
  * Prints the HTML for JS resources
  *
  * @param string $collectionName the name of the collection
  *
  * @return string the result of the collection
  **/
 public function outputJs($collectionName = null)
 {
     $collection = $this->collection($collectionName);
     if ($collection->getJoin()) {
         $filename = $collection->getTargetPath();
         if (file_exists($filename)) {
             $time = 0;
             foreach ($collection->getResources() as $resource) {
                 $tmp = filemtime($resource->getRealTargetPath());
                 if ($tmp > $time) {
                     $time = $tmp;
                 }
             }
             // If created
             if (filemtime($filename) > $time) {
                 $collection->setTargetUri($collection->getTargetUri() . '?' . filemtime($filename));
                 return Tag::javascriptInclude($collection->getTargetUri());
             }
         }
         // Else CREATE
         $res = parent::outputJs($collectionName);
         return $res;
     }
     return parent::outputJs($collectionName);
 }
Esempio n. 2
0
 /**
  * Print output Js
  *
  * @param string $name
  */
 public function outputJs($name = null)
 {
     parent::outputJs($name);
     if ($name == null) {
         echo implode("", $this->jsDeclaration);
     } else {
         if (method_exists($this->_collections["{$name}"], "outputJs")) {
             $this->_collections["{$name}"]->outputJs();
         }
     }
 }
Esempio n. 3
0
 /**
  * Prints the HTML for JS resources.
  *
  * @param string $collectionName the name of the collection
  *
  * @return string
  **/
 public function outputJs($collectionName = self::DEFAULT_COLLECTION_JS)
 {
     $remote = $this->_config->application->assets->get('remote');
     $collection = $this->collection($collectionName);
     if (!$remote && $collection->getJoin()) {
         $local = $this->_config->application->assets->get('local');
         $lifetime = $this->_config->application->assets->get('lifetime', 0);
         $filepath = $local . self::GENERATED_STORAGE_PATH . ($filename = $filename = $this->getCollectionFileName($collection, self::FILENAME_PATTERN_JS));
         $collection->setTargetPath($filepath)->setTargetUri($filepath);
         if ($this->_cache->exists($filename)) {
             return Tag::javascriptInclude($collection->getTargetUri());
         }
         $res = parent::outputJs($collectionName);
         $this->_cache->save($filename, true, $lifetime);
         return $res;
     }
     return parent::outputJs($collectionName);
 }
Esempio n. 4
0
 public function outputJs($collectionName = null)
 {
     return parent::outputJs($collectionName);
 }