diff --git a/code/administrator/manifests/files/files_koowa.xml b/code/administrator/manifests/files/files_koowa.xml index 4c6cbde83..e68227c86 100644 --- a/code/administrator/manifests/files/files_koowa.xml +++ b/code/administrator/manifests/files/files_koowa.xml @@ -7,7 +7,7 @@ GNU GPLv3 - http://www.gnu.org/licenses/gpl.html support@joomlatools.com www.joomlatools.com - 2.0.1 + 2.0.2 script.php diff --git a/code/libraries/koowa/components/com_koowa/dispatcher/request/request.php b/code/libraries/koowa/components/com_koowa/dispatcher/request/request.php index 0b8a285ab..a02d9bb6e 100644 --- a/code/libraries/koowa/components/com_koowa/dispatcher/request/request.php +++ b/code/libraries/koowa/components/com_koowa/dispatcher/request/request.php @@ -51,4 +51,23 @@ public function getFormat() return $format; } + + /** + * If PHP is on a secure connection always return 443 instead of 80 + * + * When PHP is behind a reverse proxy port information might not be forwarded correctly. + * Also, $_SERVER['SERVER_PORT'] is not configured correctly on some hosts and always returns 80. + * + * {@inheritdoc} + */ + public function getPort() + { + $port = parent::getPort(); + + if ($this->isSecure() && $port == '80') { + $port = '443'; + } + + return $port; + } } \ No newline at end of file diff --git a/code/libraries/koowa/components/com_koowa/dispatcher/router/route.php b/code/libraries/koowa/components/com_koowa/dispatcher/router/route.php index 2e4063440..df192990a 100644 --- a/code/libraries/koowa/components/com_koowa/dispatcher/router/route.php +++ b/code/libraries/koowa/components/com_koowa/dispatcher/router/route.php @@ -58,7 +58,7 @@ public function toString($parts = self::FULL, $escape = null) $query = array_merge(array('option' => null, 'view' => null), $query); //Let Joomla build the route - $route = JRoute::_('index.php?'.http_build_query($query), $escape); + $route = JRoute::_('index.php?'.http_build_query($query, '', '&'), $escape); // We had to change the format in the URL above so that .htaccess file can catch it if (isset($append_format)) { diff --git a/code/libraries/koowa/components/com_koowa/event/publisher/publisher.php b/code/libraries/koowa/components/com_koowa/event/publisher/publisher.php index 0695a0f6b..8383293d8 100644 --- a/code/libraries/koowa/components/com_koowa/event/publisher/publisher.php +++ b/code/libraries/koowa/components/com_koowa/event/publisher/publisher.php @@ -15,6 +15,34 @@ */ final class ComKoowaEventPublisher extends KEventPublisher { + /** + * Publish an event by calling all listeners that have registered to receive it. + * + * If an event target is specified try to import the plugin group based on the package name of the target + * before publishing the event. + * + * @param string|KEventInterface $event The event name or a KEventInterface object + * @param array|Traversable|KEventInterface $attributes An associative array, an object implementing the + * KEventInterface or a Traversable object + * @param mixed $target The event target + * + * @throws InvalidArgumentException If the event is not a string or does not implement the KEventInterface + * @return null|KEventInterface Returns the event object. If the chain is not enabled will return NULL. + */ + public function publishEvent($event, $attributes = array(), $target = null) + { + //Try to load the plugin group + if($target instanceof KObject) + { + $identifier = $target->getIdentifier()->toArray(); + $package = $identifier['package']; + + JPluginHelper::importPlugin($package, null, true); + } + + return parent::publishEvent($event, $attributes, $target); + } + /** * Publish an event by calling all listeners that have registered to receive it. * diff --git a/code/libraries/koowa/components/com_koowa/template/filter/module.php b/code/libraries/koowa/components/com_koowa/template/filter/module.php index 26f378654..0c6214ddc 100644 --- a/code/libraries/koowa/components/com_koowa/template/filter/module.php +++ b/code/libraries/koowa/components/com_koowa/template/filter/module.php @@ -99,6 +99,7 @@ protected function _parseModuleTags(&$text) $module->attribs = $attributes; $module->user = 0; $module->module = 'mod_koowa_injector'; + $module->name = 'mod_koowa_injector'; $modules = &ComKoowaModuleHelper::getModules(null); diff --git a/code/libraries/koowa/components/com_koowa/template/filter/version.php b/code/libraries/koowa/components/com_koowa/template/filter/version.php new file mode 100644 index 000000000..8e48ca2da --- /dev/null +++ b/code/libraries/koowa/components/com_koowa/template/filter/version.php @@ -0,0 +1,107 @@ + + * @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 + * @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 = '~ + + ~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); + } + } + } + } +} \ No newline at end of file diff --git a/code/libraries/koowa/components/com_koowa/template/helper/behavior.php b/code/libraries/koowa/components/com_koowa/template/helper/behavior.php index 2bd9acc4d..7be31c08d 100644 --- a/code/libraries/koowa/components/com_koowa/template/helper/behavior.php +++ b/code/libraries/koowa/components/com_koowa/template/helper/behavior.php @@ -66,7 +66,9 @@ public function jquery($config = array()) if (version_compare(JVERSION, '3.0', 'ge')) { JHtml::_('jquery.framework'); - JHtml::_('script', 'media/koowa/com_koowa/js/koowa.kquery.js', false, false, false, false, false); + // Can't use JHtml here as it makes a file_exists call on koowa.kquery.js?version + $path = JURI::root(true).'/media/koowa/com_koowa/js/koowa.kquery.js?'.substr(md5(Koowa::VERSION), 0, 8); + JFactory::getDocument()->addScript($path); } else $html .= parent::jquery($config); diff --git a/code/libraries/koowa/components/com_koowa/translator/catalogue/abstract.php b/code/libraries/koowa/components/com_koowa/translator/catalogue/abstract.php index 1e1f6441c..65abbfbbb 100644 --- a/code/libraries/koowa/components/com_koowa/translator/catalogue/abstract.php +++ b/code/libraries/koowa/components/com_koowa/translator/catalogue/abstract.php @@ -32,6 +32,12 @@ abstract class ComKoowaTranslatorCatalogueAbstract extends KTranslatorCatalogueA */ protected $_keys; + /** + * A list of key aliases. + * + * @var + */ + protected $_aliases; /** * @param KObjectConfig $config @@ -41,6 +47,7 @@ public function __construct(KObjectConfig $config) parent::__construct($config); $this->setPrefix($config->prefix); + $this->_aliases = $config->aliases; } /** @@ -56,7 +63,7 @@ protected function _initialize(KObjectConfig $config) $config->append(array( 'prefix' => 'KLS_', 'key_length' => 40, - 'data' => array( + 'aliases' => array( 'all' => 'JALL', 'title' => 'JGLOBAL_TITLE', 'alias' => 'JFIELD_ALIAS_LABEL', @@ -124,9 +131,14 @@ public function clear() */ public function get($string) { - if (!parent::has(strtolower($string))) + $lowercase = strtolower($string); + + if (!parent::has($lowercase)) { - if(!JFactory::getLanguage()->hasKey($string)) + if (isset($this->_aliases[$lowercase])) { + $key = $this->_aliases[$lowercase]; + } + else if(!JFactory::getLanguage()->hasKey($string)) { if (substr($string, 0, strlen($this->getPrefix())) === $this->getPrefix()) { $key = $string; @@ -134,17 +146,13 @@ public function get($string) //Gets a key from the catalogue and prefixes it $key = $this->getPrefix().$this->generateKey($string); } - - $translation = JFactory::getLanguage()->_($key); } - else $translation = JFactory::getLanguage()->_($string); - } - else $translation = JFactory::getLanguage()->_(parent::get(strtolower($string))); + else $key = $string; - //Set the translation to prevent it from being re-translated - $this->set($string, $translation); + $this->set($lowercase, JFactory::getLanguage()->_($key)); + } - return $translation; + return parent::get($lowercase); } /** @@ -155,20 +163,21 @@ public function get($string) */ public function has($string) { - if (!parent::has(strtolower($string))) - { - if(!JFactory::getLanguage()->hasKey($string)) - { - if (substr($string, 0, strlen($this->getPrefix())) === $this->getPrefix()) { - $key = $string; - } else { - //Gets a key from the catalogue and prefixes it - $key = $this->getPrefix().$this->generateKey($string); - } + $lowercase = strtolower($string); - $result = JFactory::getLanguage()->hasKey($key); + if (!parent::has($lowercase) && !JFactory::getLanguage()->hasKey($string)) + { + if (isset($this->_aliases[$lowercase])) { + $key = $this->_aliases[$lowercase]; } - else $result = true; + elseif (substr($string, 0, strlen($this->getPrefix())) === $this->getPrefix()) { + $key = $string; + } else { + //Gets a key from the catalogue and prefixes it + $key = $this->getPrefix().$this->generateKey($string); + } + + $result = JFactory::getLanguage()->hasKey($key); } else $result = true; diff --git a/code/libraries/koowa/components/com_koowa/views/html.php b/code/libraries/koowa/components/com_koowa/views/html.php index 4a5eda61a..04e88576f 100644 --- a/code/libraries/koowa/components/com_koowa/views/html.php +++ b/code/libraries/koowa/components/com_koowa/views/html.php @@ -15,5 +15,12 @@ */ class ComKoowaViewHtml extends KViewHtml { + protected function _initialize(KObjectConfig $config) + { + $config->append(array( + 'template_filters' => array('version') + )); + parent::_initialize($config); + } } diff --git a/code/libraries/koowa/components/com_koowa/views/page/tmpl/koowa.html.php b/code/libraries/koowa/components/com_koowa/views/page/tmpl/koowa.html.php index c9b9109bf..a7cf5ee20 100644 --- a/code/libraries/koowa/components/com_koowa/views/page/tmpl/koowa.html.php +++ b/code/libraries/koowa/components/com_koowa/views/page/tmpl/koowa.html.php @@ -23,11 +23,11 @@