Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:joomla/joomla-cms into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Jan 22, 2017
2 parents 81127c3 + f0d9270 commit f38dfcb
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 31 deletions.
2 changes: 1 addition & 1 deletion administrator/language/en-GB/en-GB.com_languages.sys.ini
Expand Up @@ -10,5 +10,5 @@ COM_LANGUAGES_INSTALLED_VIEW_DEFAULT_DESC="Displays language packs installed int
COM_LANGUAGES_INSTALLED_VIEW_DEFAULT_TITLE="Installed Languages"
COM_LANGUAGES_LANGUAGES_VIEW_DEFAULT_DESC="Create or manage content languages for your Joomla! website."
COM_LANGUAGES_LANGUAGES_VIEW_DEFAULT_TITLE="Content Languages"
COM_LANGUAGES_OVERRIDE_VIEW_DEFAULT_DESC="Here you assign custom text for a language key that you want to used instead of language pack default text."
COM_LANGUAGES_OVERRIDE_VIEW_DEFAULT_DESC="Here you assign custom text for a language key that you want to use instead of language pack default text."
COM_LANGUAGES_OVERRIDE_VIEW_DEFAULT_TITLE="Language Overrides"
17 changes: 10 additions & 7 deletions components/com_tags/views/tag/view.html.php
Expand Up @@ -132,6 +132,9 @@ public function display($tpl = null)
$active = $app->getMenu()->getActive();
$temp = clone $this->params;

// Convert item params to a Registry object
$item[0]->params = new Registry($item[0]->params);

// Check to see which parameters should take priority
if ($active)
{
Expand All @@ -140,9 +143,9 @@ public function display($tpl = null)
// If the current view is the active item and an tag view for one tag, then the menu item params take priority
if (strpos($currentLink, 'view=tag') && strpos($currentLink, '&id[0]=' . (string) $item[0]->id))
{
// $item->params are the article params, $temp are the menu item params
// $item[0]->params are the tag params, $temp are the menu item params
// Merge so that the menu item params take priority
$this->params->merge($temp);
$item[0]->params->merge($temp);

// Load layout from active query (in case it is an alternative menu item)
if (isset($active->query['layout']))
Expand All @@ -152,14 +155,14 @@ public function display($tpl = null)
}
else
{
// Current view is not tags, so the global params take priority since tags is not an item.
// Merge the menu item params with the global params so that the article params take priority
$temp->merge($this->state->params);
$this->params = $temp;
// Current menuitem is not a single tag view, so the tag params take priority.
// Merge the menu item params with the tag params so that the tag params take priority
$temp->merge($item[0]->params);
$item[0]->params = $temp;

// Check for alternative layouts (since we are not in a single-article menu item)
// Single-article menu item layout takes priority over alt layout for an article
if ($layout = $this->params->get('tags_layout'))
if ($layout = $item[0]->params->get('tag_layout'))
{
$this->setLayout($layout);
}
Expand Down
5 changes: 2 additions & 3 deletions libraries/legacy/controller/form.php
Expand Up @@ -381,7 +381,7 @@ public function edit($key = null, $urlVar = null)

// Get the previous record id (if any) and the current record id.
$recordId = (int) (count($cid) ? $cid[0] : $this->input->getInt($urlVar));
$checkin = property_exists($table, 'checked_out');
$checkin = property_exists($table, $table->getColumnAlias('checked_out'));

// Access check.
if (!$this->allowEdit(array($key => $recordId), $key))
Expand Down Expand Up @@ -622,11 +622,10 @@ public function save($key = null, $urlVar = null)
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

$app = JFactory::getApplication();
$lang = JFactory::getLanguage();
$model = $this->getModel();
$table = $model->getTable();
$data = $this->input->post->get('jform', array(), 'array');
$checkin = property_exists($table, 'checked_out');
$checkin = property_exists($table, $table->getColumnAlias('checked_out'));
$context = "$this->option.edit.$this->context";
$task = $this->getTask();

Expand Down
13 changes: 8 additions & 5 deletions libraries/legacy/model/admin.php
Expand Up @@ -11,6 +11,7 @@

use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;

/**
* Prototype admin model.
Expand Down Expand Up @@ -190,7 +191,7 @@ public function batch($commands, $pks, $contexts)
{
// Sanitize ids.
$pks = array_unique($pks);
JArrayHelper::toInteger($pks);
$pks = ArrayHelper::toInteger($pks);

// Remove any values of zero.
if (array_search(0, $pks, true))
Expand Down Expand Up @@ -225,7 +226,7 @@ public function batch($commands, $pks, $contexts)

if ($this->batch_copymove && !empty($commands[$this->batch_copymove]))
{
$cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
$cmd = ArrayHelper::getValue($commands, 'move_copy', 'c');

if ($cmd == 'c')
{
Expand Down Expand Up @@ -694,12 +695,14 @@ public function checkin($pks = array())
$pks = array((int) $this->getState($this->getName() . '.id'));
}

$checkedOutField = $table->getColumnAlias('checked_out');

// Check in all items.
foreach ($pks as $pk)
{
if ($table->load($pk))
{
if ($table->checked_out > 0)
if ($table->{$checkedOutField} > 0)
{
if (!parent::checkin($pk))
{
Expand Down Expand Up @@ -904,7 +907,7 @@ public function getItem($pk = null)

// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$item = JArrayHelper::toObject($properties, 'JObject');
$item = ArrayHelper::toObject($properties, 'JObject');

if (property_exists($item, 'params'))
{
Expand Down Expand Up @@ -1210,7 +1213,7 @@ public function save($data)
$associations = $data['associations'];

// Unset any invalid associations
$associations = Joomla\Utilities\ArrayHelper::toInteger($associations);
$associations = ArrayHelper::toInteger($associations);

// Unset any invalid associations
foreach ($associations as $tag => $id)
Expand Down
6 changes: 4 additions & 2 deletions libraries/legacy/model/list.php
Expand Up @@ -9,6 +9,8 @@

defined('JPATH_PLATFORM') or die;

use Joomla\Utilities\ArrayHelper;

/**
* Model class for handling lists of items.
*
Expand Down Expand Up @@ -375,7 +377,7 @@ public function getFilterForm($data = array(), $loadData = true)
protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = false)
{
// Handle the optional arguments.
$options['control'] = JArrayHelper::getValue($options, 'control', false);
$options['control'] = ArrayHelper::getValue((array) $options, 'control', false);

// Create a signature hash.
$hash = md5($source . serialize($options));
Expand Down Expand Up @@ -640,7 +642,7 @@ protected function preprocessForm(JForm $form, $data, $group = 'content')
JPluginHelper::importPlugin($group);

// Get the dispatcher.
$dispatcher = JDispatcher::getInstance();
$dispatcher = JEventDispatcher::getInstance();

// Trigger the form preparation event.
$results = $dispatcher->trigger('onContentPrepareForm', array($form, $data));
Expand Down
102 changes: 89 additions & 13 deletions libraries/loader.php
Expand Up @@ -62,7 +62,7 @@ abstract class JLoader
* @var array
* @since 12.3
*/
protected static $namespaces = array();
protected static $namespaces = array('psr0' => array(), 'psr4' => array());

/**
* Holds a reference for all deprecated aliases (mainly for use by a logging platform).
Expand Down Expand Up @@ -152,13 +152,20 @@ public static function getDeprecatedAliases()
/**
* Method to get the list of registered namespaces.
*
* @param string $type Defines the type of namespace, can be prs0 or psr4.
*
* @return array The array of namespace => path values for the autoloader.
*
* @since 12.3
*/
public static function getNamespaces()
public static function getNamespaces($type = 'psr0')
{
return self::$namespaces;
if ($type !== 'psr0' && $type !== 'psr4')
{
throw new InvalidArgumentException('Type needs to be prs0 or psr4!');
}

return self::$namespaces[$type];
}

/**
Expand All @@ -178,10 +185,10 @@ public static function import($key, $base = null)
{
// Setup some variables.
$success = false;
$parts = explode('.', $key);
$class = array_pop($parts);
$base = (!empty($base)) ? $base : __DIR__;
$path = str_replace('.', DIRECTORY_SEPARATOR, $key);
$parts = explode('.', $key);
$class = array_pop($parts);
$base = (!empty($base)) ? $base : __DIR__;
$path = str_replace('.', DIRECTORY_SEPARATOR, $key);

// Handle special case for helper classes.
if ($class == 'helper')
Expand Down Expand Up @@ -384,15 +391,22 @@ public static function registerAlias($alias, $original, $version = false)
* @param string $path A case sensitive absolute file path to the library root where classes of the given namespace can be found.
* @param boolean $reset True to reset the namespace with only the given lookup path.
* @param boolean $prepend If true, push the path to the beginning of the namespace lookup paths array.
* @param string $type Defines the type of namespace, can be prs0 or psr4.
*
* @return void
*
* @throws RuntimeException
*
* @note The default argument of $type will be changed in J4 to be 'psr4'
* @since 12.3
*/
public static function registerNamespace($namespace, $path, $reset = false, $prepend = false)
public static function registerNamespace($namespace, $path, $reset = false, $prepend = false, $type = 'psr0')
{
if ($type !== 'psr0' && $type !== 'psr4')
{
throw new InvalidArgumentException('Type needs to be prs0 or psr4!');
}

// Verify the library path exists.
if (!file_exists($path))
{
Expand All @@ -402,21 +416,21 @@ public static function registerNamespace($namespace, $path, $reset = false, $pre
}

// If the namespace is not yet registered or we have an explicit reset flag then set the path.
if (!isset(self::$namespaces[$namespace]) || $reset)
if (!isset(self::$namespaces[$type][$namespace]) || $reset)
{
self::$namespaces[$namespace] = array($path);
self::$namespaces[$type][$namespace] = array($path);
}

// Otherwise we want to simply add the path to the namespace.
else
{
if ($prepend)
{
array_unshift(self::$namespaces[$namespace], $path);
array_unshift(self::$namespaces[$type][$namespace], $path);
}
else
{
self::$namespaces[$namespace][] = $path;
self::$namespaces[$type][$namespace][] = $path;
}
}
}
Expand Down Expand Up @@ -457,10 +471,70 @@ public static function setup($enablePsr = true, $enablePrefixes = true, $enableC
{
// Register the PSR-0 based autoloader.
spl_autoload_register(array('JLoader', 'loadByPsr0'));
spl_autoload_register(array('JLoader', 'loadByPsr4'));
spl_autoload_register(array('JLoader', 'loadByAlias'));
}
}

/**
* Method to autoload classes that are namespaced to the PSR-4 standard.
*
* @param string $class The fully qualified class name to autoload.
*
* @return boolean True on success, false otherwise.
*
* @since __DEPLOY_VERSION__
*/
public static function loadByPsr4($class)
{
// Remove the root backslash if present.
if ($class[0] == '\\')
{
$class = substr($class, 1);
}

// Find the location of the last NS separator.
$pos = strrpos($class, '\\');

// If one is found, we're dealing with a NS'd class.
if ($pos !== false)
{
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
$className = substr($class, $pos + 1);
}
// If not, no need to parse path.
else
{
$classPath = null;
$className = $class;
}

$classPath .= $className . '.php';

// Loop through registered namespaces until we find a match.
foreach (self::$namespaces['psr4'] as $ns => $paths)
{
$nsPath = trim(str_replace('\\', DIRECTORY_SEPARATOR, $ns), DIRECTORY_SEPARATOR);

if (strpos($class, $ns) === 0)
{
// Loop through paths registered to this namespace until we find a match.
foreach ($paths as $path)
{
$classFilePath = $path . DIRECTORY_SEPARATOR . str_replace($nsPath, '', $classPath);

// We check for class_exists to handle case-sensitive file systems
if (file_exists($classFilePath) && !class_exists($class, false))
{
return (bool) include_once $classFilePath;
}
}
}
}

return false;
}

/**
* Method to autoload classes that are namespaced to the PSR-0 standard.
*
Expand All @@ -469,6 +543,8 @@ public static function setup($enablePsr = true, $enablePrefixes = true, $enableC
* @return boolean True on success, false otherwise.
*
* @since 13.1
*
* @deprecated 4.0 this method will be removed
*/
public static function loadByPsr0($class)
{
Expand Down Expand Up @@ -497,7 +573,7 @@ public static function loadByPsr0($class)
$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

// Loop through registered namespaces until we find a match.
foreach (self::$namespaces as $ns => $paths)
foreach (self::$namespaces['psr0'] as $ns => $paths)
{
if (strpos($class, $ns) === 0)
{
Expand Down

0 comments on commit f38dfcb

Please sign in to comment.