Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/joomla/joomla-platform into…
Browse files Browse the repository at this point in the history
… meta
  • Loading branch information
jamesdurrant committed Jan 3, 2012
2 parents 7a89d3d + 694c346 commit 70f382a
Show file tree
Hide file tree
Showing 21 changed files with 321 additions and 80 deletions.
2 changes: 1 addition & 1 deletion libraries/joomla/application/component/helper.php
Expand Up @@ -357,7 +357,7 @@ public static function renderComponent($option, $params = array())
$contents = self::executeComponent($path);

// Build the component toolbar
if ($path = JApplicationHelper::getPath('toolbar'))
if ($path = JApplicationHelper::getPath('toolbar') && $app->isAdmin())
{
// Get the task again, in case it has changed
$task = JRequest::getString('task');
Expand Down
12 changes: 1 addition & 11 deletions libraries/joomla/application/component/model.php
Expand Up @@ -435,28 +435,18 @@ public function getState($property = null, $default = null)
*
* @since 11.1
*/
public function getTable($name = '', $prefix = '', $options = array())
public function getTable($name = '', $prefix = 'Table', $options = array())
{
if (empty($name))
{
$name = $this->getName();
}

if (empty($prefix))
{
$prefix = $this->getName() . 'Table';
}

if ($table = $this->_createTable($name, $prefix, $options))
{
return $table;
}

if ($table = $this->_createTable($name, 'Table', $options))
{
return $table;
}

JError::raiseError(0, JText::sprintf('JLIB_APPLICATION_ERROR_TABLE_NAME_NOT_SUPPORTED', $name));

return null;
Expand Down
60 changes: 53 additions & 7 deletions libraries/joomla/database/database.php
Expand Up @@ -1240,28 +1240,74 @@ public function quote($text, $escape = true)
* Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection
* risks and reserved word conflicts.
*
* @param mixed $name The identifier name to wrap in quotes, or an array of parts to quote with dot-notation.
* @param mixed $name The identifier name to wrap in quotes, or an array of identifier names to wrap in quotes.
* Each type supports dot-notation name.
* @param mixed $as The AS query part associated to $name. It can be string or array, in latter case it has to be
* same length of $name; if is null there will not be any AS part for string or array element.
*
* @return string The quote wrapped name.
* @return mixed The quote wrapped name, same type of $name.
*
* @since 11.1
*/
public function quoteName($name)
public function quoteName($name, $as = null)
{
if (is_string($name))
{
$name = explode('.', $name);
$quotedName = $this->quoteNameStr(explode('.', $name));

$quotedAs = '';
if (!is_null($as))
{
settype($as, 'array');
$quotedAs .= ' AS ' . $this->quoteNameStr($as);
}

return $quotedName . $quotedAs;
}
elseif (!is_array($name))
else
{
settype($name, 'array');
$fin = array();

if (is_null($as))
{
foreach ($name as $str)
{
$fin[] = $this->quoteName($str);
}
}
elseif (is_array($name) && (count($name) == count($as)))
{
for ($i = 0; $i < count($name); $i++)
{
$fin[] = $this->quoteName($name[$i], $as[$i]);
}
}

return $fin;
}
}

/**
* Quote strings coming from quoteName call.
*
* @param array $strArr Array of strings coming from quoteName dot-explosion.
*
* @return string Dot-imploded string of quoted parts.
*
* @since 11.3
*/
protected function quoteNameStr($strArr)
{
$parts = array();
$q = $this->nameQuote;

foreach ($name as $part)
foreach ($strArr as $part)
{
if (is_null($part))
{
continue;
}

if (strlen($q) == 1)
{
$parts[] = $q . $part . $q;
Expand Down
17 changes: 14 additions & 3 deletions libraries/joomla/database/table.php
Expand Up @@ -524,10 +524,21 @@ public function load($keys = null, $reset = true)
}

$this->_db->setQuery($query);
$row = $this->_db->loadAssoc();

// Check for a database error.
if ($this->_db->getErrorNum())
try
{
$row = $this->_db->loadAssoc();
}
catch (JDatabaseException $e)
{
$je = new JException($e->getMessage());
$this->setError($je);
return false;
}

// Legacy error handling switch based on the JError::$legacy switch.
// @deprecated 12.1
if (JError::$legacy && $this->_db->getErrorNum())
{
$e = new JException($this->_db->getErrorMsg());
$this->setError($e);
Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/database/tablenested.php
Expand Up @@ -872,7 +872,7 @@ public function store($updateNulls = false)
* not allow you to set a publishing state on a node with a checked out child.
*
* @param mixed $pks An optional array of primary key values to update. If not
* set the instance property value is used.
* set the instance property value is used.
* @param integer $state The publishing state. eg. [0 = unpublished, 1 = published]
* @param integer $userId The user id of the user performing the operation.
*
Expand Down Expand Up @@ -974,7 +974,7 @@ public function publish($pks = null, $state = 1, $userId = 0)

// Update and cascade the publishing state.
$query = $this->_db->getQuery(true)->update($this->_db->quoteName($this->_tbl))->set('published = ' . (int) $state)
->where('(lft > ' . (int) $this->lft . ' AND rgt < ' . (int) $this->rgt . ')' . ' OR ' . $k . ' = ' . (int) $pk);
->where('(lft > ' . (int) $node->lft . ' AND rgt < ' . (int) $node->rgt . ')' . ' OR ' . $k . ' = ' . (int) $pk);
$this->_db->setQuery($query);

// Check for a database error.
Expand Down
16 changes: 8 additions & 8 deletions libraries/joomla/filter/output.php
Expand Up @@ -85,20 +85,20 @@ public static function linkXHTMLSafe($input)
*/
public static function stringURLSafe($string)
{
//remove any '-' from the string since they will be used as concatenaters
// remove any '-' from the string since they will be used as concatenaters
$str = str_replace('-', ' ', $string);

$lang = JFactory::getLanguage();
$str = $lang->transliterate($str);

// Convert certain symbols to letter representation
$str = str_replace(array('&', '"', '<', '>'), array('a', 'q', 'l', 'g'), $str);

// Lowercase and trim
$str = trim(strtolower($str));
// Trim white spaces at beginning and end of alias and make lowercase
$str = trim(JString::strtolower($str));

// Remove any duplicate whitespace, and ensure all characters are alphanumeric
$str = preg_replace(array('/\s+/', '/[^A-Za-z0-9\-]/'), array('-', ''), $str);
$str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $str);

// Trim dashes at beginning and end of alias
$str = trim($str, '-');

return $str;
}
Expand All @@ -123,7 +123,7 @@ public static function stringURLUnicodeSlug($string)
$str = str_replace('-', ' ', $str);

// Replace forbidden characters by whitespaces
$str = preg_replace('#[:\#\*"@+=;!&\.%()\]\/\'\\\\|\[]#', "\x20", $str);
$str = preg_replace('#[:\#\*"@+=;!><&\.%()\]\/\'\\\\|\[]#', "\x20", $str);

// Delete all '?'
$str = str_replace('?', '', $str);
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/form/form.php
Expand Up @@ -1264,7 +1264,7 @@ protected function filterField($element, $value)

// Otherwise we treat it is an external link.
// Put the url back together.
$value = $protocol . '://' . ltrim($value, $protocol);
$value = $protocol . '://' . $value;
}

// If relative URLS are allowed we assume that URLs without protocols are internal.
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/html/html/behavior.php
Expand Up @@ -777,7 +777,7 @@ public static function highlighter(array $terms, $start = 'highlighter-start', $
window.addEvent('domready', function () {
var start = document.id('" . $start . "');
var end = document.id('" . $end . "');
if (!start || !end || !window.highlight) {
if (!start || !end || !Joomla.Highlighter) {
return true;
}
highlighter = new Joomla.Highlighter({
Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/html/html/grid.php
Expand Up @@ -86,7 +86,7 @@ public static function sort($title, $order, $direction = 'asc', $selected = 0, $
$direction = ($direction == 'desc') ? 'asc' : 'desc';
}

$html = '<a href="javascript:tableOrdering(\'' . $order . '\',\'' . $direction . '\',\'' . $task . '\');" title="'
$html = '<a href="#" onclick="Joomla.tableOrdering(\'' . $order . '\',\'' . $direction . '\',\'' . $task . '\');" title="'
. JText::_('JGLOBAL_CLICK_TO_SORT_THIS_COLUMN') . '">';
$html .= JText::_($title);

Expand Down Expand Up @@ -119,7 +119,7 @@ public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid')
else
{
return '<input type="checkbox" id="cb' . $rowNum . '" name="' . $name . '[]" value="' . $recId
. '" onclick="isChecked(this.checked);" title="' . JText::sprintf('JGRID_CHECKBOX_ROW_N', ($rowNum + 1)) . '" />';
. '" onclick="Joomla.isChecked(this.checked);" title="' . JText::sprintf('JGRID_CHECKBOX_ROW_N', ($rowNum + 1)) . '" />';
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/html/html/user.php
Expand Up @@ -32,7 +32,7 @@ public static function groups()
$query->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level');
$query->from($db->quoteName('#__usergroups') . ' AS a');
$query->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
$query->group('a.id, a.title, a.lft, b.lft, a.rgt');
$query->group('a.id, a.title, a.lft, a.rgt');
$query->order('a.lft ASC');
$db->setQuery($query);
$options = $db->loadObjectList();
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/html/toolbar/button/help.php
Expand Up @@ -83,7 +83,7 @@ protected function _getCommand($ref, $com, $override, $component)
jimport('joomla.language.help');
$url = JHelp::createURL($ref, $com, $override, $component);
$url = htmlspecialchars($url, ENT_QUOTES);
$cmd = "popupWindow('$url', '" . JText::_('JHELP', true) . "', 700, 500, 1)";
$cmd = "Joomla.popupWindow('$url', '" . JText::_('JHELP', true) . "', 700, 500, 1)";

return $cmd;
}
Expand Down

0 comments on commit 70f382a

Please sign in to comment.