-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
360 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
<license>GNU GPLv3 - http://www.gnu.org/licenses/gpl.html</license> | ||
<authorEmail>[email protected]</authorEmail> | ||
<authorUrl>www.joomlatools.com</authorUrl> | ||
<version>2.0.1</version> | ||
<version>2.0.2</version> | ||
<description></description> | ||
|
||
<scriptfile>script.php</scriptfile> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
code/libraries/koowa/components/com_koowa/template/filter/version.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
/** | ||
* Nooku Framework - http://nooku.org/framework | ||
* | ||
* @copyright Copyright (C) 2007 - 2014 Johan Janssens and Timble CVBA. (http://www.timble.net) | ||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> | ||
* @link https://github.com/nooku/nooku-framework for the canonical source repository | ||
*/ | ||
|
||
/** | ||
* Url Template Filter | ||
* | ||
* Filter allows to create url schemes that are replaced on compile and render. | ||
* | ||
* @author Johan Janssens <https://github.com/johanjanssens> | ||
* @package Koowa\Component\Koowa\Template\Filter | ||
*/ | ||
class ComKoowaTemplateFilterVersion extends KTemplateFilterAbstract | ||
{ | ||
/** | ||
* A component => version map | ||
* | ||
* @var array | ||
*/ | ||
protected static $_versions = array(); | ||
|
||
/** | ||
* Initializes the options for the object | ||
* | ||
* Called from {@link __construct()} as a first step of object instantiation. | ||
* | ||
* @param KObjectConfig $config Configuration options | ||
* @return void | ||
*/ | ||
protected function _initialize(KObjectConfig $config) | ||
{ | ||
$config->append(array( | ||
'priority' => KTemplateFilterInterface::PRIORITY_HIGH | ||
)); | ||
|
||
parent::_initialize($config); | ||
} | ||
|
||
|
||
/** | ||
* Returns the version information of a component | ||
* | ||
* @param $component | ||
* @return string|null | ||
*/ | ||
protected function _getVersion($component) | ||
{ | ||
if (!isset(self::$_versions[$component])) | ||
{ | ||
try | ||
{ | ||
if ($component === 'koowa') { | ||
$version = Koowa::VERSION; | ||
} | ||
else $version = $this->getObject('com://admin/' . $component.'.version')->getVersion(); | ||
} | ||
catch (Exception $e) { | ||
$version = null; | ||
} | ||
|
||
self::$_versions[$component] = $version; | ||
} | ||
|
||
return self::$_versions[$component]; | ||
} | ||
|
||
/** | ||
* Adds version suffixes to stylesheets and scripts | ||
* | ||
* {@inheritdoc} | ||
*/ | ||
public function filter(&$text) | ||
{ | ||
$pattern = '~ | ||
<ktml:(?:script|style) # match ktml:script and ktml:style tags | ||
[^(?:src=)]+ # anything before src= | ||
src=" # match the link | ||
(media:// # starts with media:// | ||
(?:koowa/)? # may or may not be in koowa/ folder | ||
com_([^/]+)/ # match the com_foo part | ||
[^"]+)" # match the rest of the link | ||
(.*)/> | ||
~siUx'; | ||
|
||
if(preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) | ||
{ | ||
foreach ($matches as $match) | ||
{ | ||
$version = $this->_getVersion($match[2]); | ||
|
||
if ($version) | ||
{ | ||
$url = $match[1]; | ||
$version = substr(md5($version), 0, 8); | ||
$suffix = strpos($url, '?') === false ? '?'.$version : '&'.$version; | ||
|
||
$text = str_replace($url, $url.$suffix, $text); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.