Skip to content

Commit

Permalink
Merge branch 'release/2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ercanozkaya committed Oct 28, 2014
2 parents f4aa84c + aebf453 commit 17a0b3d
Show file tree
Hide file tree
Showing 43 changed files with 360 additions and 172 deletions.
2 changes: 1 addition & 1 deletion code/administrator/manifests/files/files_koowa.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
107 changes: 107 additions & 0 deletions code/libraries/koowa/components/com_koowa/template/filter/version.php
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);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ abstract class ComKoowaTranslatorCatalogueAbstract extends KTranslatorCatalogueA
*/
protected $_keys;

/**
* A list of key aliases.
*
* @var
*/
protected $_aliases;

/**
* @param KObjectConfig $config
Expand All @@ -41,6 +47,7 @@ public function __construct(KObjectConfig $config)
parent::__construct($config);

$this->setPrefix($config->prefix);
$this->_aliases = $config->aliases;
}

/**
Expand All @@ -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',
Expand Down Expand Up @@ -124,27 +131,28 @@ 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;
} else {
//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);
}

/**
Expand All @@ -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;

Expand Down
7 changes: 7 additions & 0 deletions code/libraries/koowa/components/com_koowa/views/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@
*/
class ComKoowaViewHtml extends KViewHtml
{
protected function _initialize(KObjectConfig $config)
{
$config->append(array(
'template_filters' => array('version')
));

parent::_initialize($config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

<script>
// Add a "joomla_modal" class to the HTML element if we are rendering inside a Squeezebox modal
if (window.parent && window.parent != window) {
if (window.parent && window.parent != window && window.frameElement && window.frameElement.className.match('mfp-iframe')) {
document.documentElement.className += " inside_modal";
}
if (window.parent.SqueezeBox && window.parent.SqueezeBox.isOpen) {
document.documentElement.className += " joomla_modal";
document.documentElement.className += " inside_modal joomla_modal";
}
if (navigator.userAgent.match(/Trident|MSIE/)) {
document.documentElement.className += " old-ie-html";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function getStream()

if(!$this->getObject('filter.path')->validate($content))
{
$stream = $factory->createStream('buffer://memory', 'w+b');
$stream = $factory->createStream('koowa-buffer://memory', 'w+b');
$stream->write($content);
}
else $stream = $factory->createStream($content, 'rb');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,19 @@ public function send(KDispatcherResponseInterface $response)
}
}

//Add file related information if we are serving a file
// IIS does not like it when you have a Location header in a non-redirect request
// http://stackoverflow.com/questions/12074730/w7-pro-iis-7-5-overwrites-php-location-header-solved
if ($response->headers->has('Location') && !$response->isRedirect())
{
$server = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : getenv('SERVER_SOFTWARE');

if ($server && strpos(strtolower($server), 'microsoft-iis') !== false) {
$response->headers->remove('Location');
}
}


//Add file related information if we are serving a file
if($response->isDownloadable())
{
//Last-Modified header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ public function sendContent(KDispatcherResponseInterface $response)
}

//Make sure the output buffers are cleared
while(ob_get_level()) {
$level = ob_get_level();
while($level > 0) {
ob_end_clean();
$level--;
};

$stream = $response->getStream();
Expand Down
Loading

0 comments on commit 17a0b3d

Please sign in to comment.