Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'joomla/master' into phpmailer

  • Loading branch information...
commit e63a694f67785a887d149a4a50b35ff1afd951e2 2 parents 1b0d846 + a3a9975
@mbabker mbabker authored
Showing with 1,670 additions and 375 deletions.
  1. +19 −4 libraries/joomla/application/component/helper.php
  2. +9 −9 libraries/joomla/application/module/helper.php
  3. +4 −1 libraries/joomla/application/router.php
  4. +0 −25 libraries/joomla/client/ftp.php
  5. +1 −1  libraries/joomla/database/database.php
  6. +8 −0 libraries/joomla/form/fields/databaseconnection.php
  7. +7 −4 libraries/joomla/form/fields/media.php
  8. +106 −53 libraries/joomla/html/html.php
  9. +50 −118 libraries/joomla/html/html/behavior.php
  10. +4 −4 libraries/joomla/html/html/sliders.php
  11. +1 −1  libraries/joomla/user/authentication.php
  12. 0  media/system/css/mooRainbow.css
  13. 0  media/system/images/mooRainbow/blank.gif
  14. 0  media/system/images/mooRainbow/moor_arrows.gif
  15. 0  media/system/images/mooRainbow/moor_boverlay.png
  16. 0  media/system/images/mooRainbow/moor_cursor.gif
  17. 0  media/system/images/mooRainbow/moor_slider.png
  18. 0  media/system/images/mooRainbow/moor_woverlay.png
  19. 0  media/system/js/mooRainbow-uncompressed.js
  20. 0  media/system/js/mooRainbow.js
  21. +3 −3 media/system/js/multiselect.js
  22. 0  media/system/swf/uploader.swf
  23. +877 −94 tests/suite/joomla/html/JHtmlTest.php
  24. +581 −58 tests/suite/joomla/html/html/JHtmlBehaviorTest.php
View
23 libraries/joomla/application/component/helper.php
@@ -165,10 +165,7 @@ public static function renderComponent($option, $params = array())
$contents = null;
// Execute the component.
- ob_start();
- require_once $path;
- $contents = ob_get_contents();
- ob_end_clean();
+ $contents = self::executeComponent($path);
// Build the component toolbar
jimport('joomla.application.helper');
@@ -189,6 +186,24 @@ public static function renderComponent($option, $params = array())
}
/**
+ * Execute the component.
+ *
+ * @param string $path The component path.
+ *
+ * @return string The component output
+ *
+ * @since 11.3
+ */
+ protected static function executeComponent($path)
+ {
+ ob_start();
+ require_once $path;
+ $contents = ob_get_contents();
+ ob_end_clean();
+ return $contents;
+ }
+
+ /**
* Load the installed components into the _components property.
*
* @param string $option The element value for the extension
View
18 libraries/joomla/application/module/helper.php
@@ -54,16 +54,16 @@ public static function &getModule($name, $title = null)
// If we didn't find it, and the name is mod_something, create a dummy object
if (is_null($result) && substr($name, 0, 4) == 'mod_')
{
- $result = new stdClass;
- $result->id = 0;
- $result->title = '';
- $result->module = $name;
- $result->position = '';
- $result->content = '';
+ $result = new stdClass;
+ $result->id = 0;
+ $result->title = '';
+ $result->module = $name;
+ $result->position = '';
+ $result->content = '';
$result->showtitle = 0;
- $result->control = '';
- $result->params = '';
- $result->user = 0;
+ $result->control = '';
+ $result->params = '';
+ $result->user = 0;
}
return $result;
View
5 libraries/joomla/application/router.php
@@ -46,7 +46,10 @@ class JRouter extends JObject
* @var array
* @since 11.1
*/
- protected $_rules = array('build' => array(), 'parse' => array());
+ protected $_rules = array(
+ 'build' => array(),
+ 'parse' => array()
+ );
/**
* @var array JRouter instances container.
View
25 libraries/joomla/client/ftp.php
@@ -154,10 +154,8 @@ class JFTP
*
* @since 11.1
*/
-
public function __construct($options = array())
{
-
// If default transfer type is not set, set it to autoascii detect
if (!isset($options['type']))
{
@@ -259,7 +257,6 @@ public function getInstance($host = '127.0.0.1', $port = '21', $options = null,
*/
public function setOptions($options)
{
-
if (isset($options['type']))
{
$this->_type = $options['type'];
@@ -283,7 +280,6 @@ public function setOptions($options)
*/
public function connect($host = '127.0.0.1', $port = 21)
{
-
// Initialise variables.
$errno = null;
$err = null;
@@ -353,7 +349,6 @@ public function isConnected()
*/
public function login($user = 'anonymous', $pass = 'jftp@joomla.org')
{
-
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
@@ -397,7 +392,6 @@ public function login($user = 'anonymous', $pass = 'jftp@joomla.org')
*/
public function quit()
{
-
// If native FTP support is enabled lets use it...
if (FTP_NATIVE)
{
@@ -421,7 +415,6 @@ public function quit()
*/
public function pwd()
{
-
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
@@ -459,7 +452,6 @@ public function pwd()
*/
public function syst()
{
-
// If native FTP support is enabled lets use it...
if (FTP_NATIVE)
{
@@ -509,7 +501,6 @@ public function syst()
*/
public function chdir($path)
{
-
// If native FTP support is enabled lets use it...
if (FTP_NATIVE)
{
@@ -542,7 +533,6 @@ public function chdir($path)
*/
public function reinit()
{
-
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
@@ -576,7 +566,6 @@ public function reinit()
*/
public function rename($from, $to)
{
-
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
@@ -617,7 +606,6 @@ public function rename($from, $to)
*/
public function chmod($path, $mode)
{
-
// If no filename is given, we assume the current directory is the target
if ($path == '')
{
@@ -667,7 +655,6 @@ public function chmod($path, $mode)
*/
public function delete($path)
{
-
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
@@ -705,7 +692,6 @@ public function delete($path)
*/
public function mkdir($path)
{
-
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
@@ -737,7 +723,6 @@ public function mkdir($path)
*/
public function restart($point)
{
-
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
@@ -770,7 +755,6 @@ public function restart($point)
*/
public function create($path)
{
-
// If native FTP support is enabled let's use it...
if (FTP_NATIVE)
{
@@ -830,7 +814,6 @@ public function create($path)
*/
public function read($remote, &$buffer)
{
-
// Determine file type
$mode = $this->_findMode($remote);
@@ -915,7 +898,6 @@ public function read($remote, &$buffer)
*/
public function get($local, $remote)
{
-
// Determine file type
$mode = $this->_findMode($remote);
@@ -993,7 +975,6 @@ public function get($local, $remote)
*/
public function store($local, $remote = null)
{
-
// If remote file is not given, use the filename of the local file in the current
// working directory.
if ($remote == null)
@@ -1097,7 +1078,6 @@ public function store($local, $remote = null)
*/
public function write($remote, $buffer)
{
-
// Determine file type
$mode = $this->_findMode($remote);
@@ -1181,7 +1161,6 @@ public function write($remote, $buffer)
*/
public function listNames($path = null)
{
-
// Initialise variables.
$data = null;
@@ -1279,7 +1258,6 @@ public function listNames($path = null)
*/
public function listDetails($path = null, $type = 'all')
{
-
// Initialise variables.
$dir_list = array();
$data = null;
@@ -1519,7 +1497,6 @@ public function listDetails($path = null, $type = 'all')
*/
protected function _putCmd($cmd, $expectedResponse)
{
-
// Make sure we have a connection to the server
if (!is_resource($this->_conn))
{
@@ -1547,7 +1524,6 @@ protected function _putCmd($cmd, $expectedResponse)
*/
protected function _verifyResponse($expected)
{
-
// Initialise variables.
$parts = null;
@@ -1606,7 +1582,6 @@ protected function _verifyResponse($expected)
*/
protected function _passive()
{
-
// Initialize variables.
$match = array();
$parts = array();
View
2  libraries/joomla/database/database.php
@@ -67,7 +67,7 @@ static function test();
protected $cursor;
/**
- * @var bool The database driver debugging state.
+ * @var boolean The database driver debugging state.
* @since 11.1
*/
protected $debug = false;
View
8 libraries/joomla/form/fields/databaseconnection.php
@@ -68,6 +68,14 @@ protected function getOptions()
}
}
}
+ else
+ {
+ foreach ($available as $support)
+ {
+ $options[$support] = ucfirst($support);
+ }
+ }
+
// This will come into play if an application is installed that requires
// a database that is not available on the server.
if (empty($options))
View
11 libraries/joomla/form/fields/media.php
@@ -121,15 +121,18 @@ protected function getInput()
: 'index.php?option=com_media&view=images&tmpl=component&asset=' . $asset . '&author='
. $this->form->getValue($authorField)) . '&fieldid=' . $this->id . '&folder=' . $folder) . '"'
. ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
- $html[] = ' ' . JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>';
+ $html[] = JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>';
$html[] = ' </div>';
$html[] = '</div>';
$html[] = '<div class="button2-left">';
$html[] = ' <div class="blank">';
- $html[] = ' <a title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '"' . ' href="#"' . ' onclick="document.getElementById(\'' . $this->id
- . '\').value=\'\'; document.getElementById(\'' . $this->id . '\').onchange();">';
- $html[] = ' ' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '</a>';
+ $html[] = ' <a title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '"' . ' href="#" onclick="';
+ $html[] = 'document.id(\'' . $this->id . '\').value=\'\';';
+ $html[] = 'document.id(\'' . $this->id . '\').fireEvent(\'change\');';
+ $html[] = 'return false;';
+ $html[] = '">';
+ $html[] = JText::_('JLIB_FORM_BUTTON_CLEAR') . '</a>';
$html[] = ' </div>';
$html[] = '</div>';
View
159 libraries/joomla/html/html.php
@@ -276,16 +276,39 @@ public static function iframe($url, $name, $attribs = null, $noFrames = '')
*
* @param string $file path to file
* @param boolean $relative path to file is relative to /media folder
- * @param boolean $detect_browser detect browser to include specific browser js files
+ * @param boolean $detect_browser detect browser to include specific browser files
* @param string $folder folder name to search into (images, css, js, ...)
*
* @return array files to be included
*
* @see JBrowser
* @since 11.1
+ *
+ * @deprecated 12.1
*/
protected static function _includeRelativeFiles($file, $relative, $detect_browser, $folder)
{
+ JLog::add('JHtml::_includeRelativeFiles() is deprecated. Use JHtml::includeRelativeFiles().', JLog::WARNING, 'deprecated');
+
+ return self::includeRelativeFiles($folder, $file, $relative, $detect_browser, false);
+ }
+
+ /**
+ * Compute the files to be include
+ *
+ * @param string $folder folder name to search into (images, css, js, ...)
+ * @param string $file path to file
+ * @param boolean $relative path to file is relative to /media folder
+ * @param boolean $detect_browser detect browser to include specific browser files
+ * @param boolean $detect_debug detect debug to include compressed files if debug is on
+ *
+ * @return array files to be included
+ *
+ * @see JBrowser
+ * @since 11.1
+ */
+ protected static function includeRelativeFiles($folder, $file, $relative, $detect_browser, $detect_debug)
+ {
// If http is present in filename
if (strpos($file, 'http') === 0)
{
@@ -293,6 +316,10 @@ protected static function _includeRelativeFiles($file, $relative, $detect_browse
}
else
{
+ // Extract extension and strip the file
+ $strip = JFile::stripExt($file);
+ $ext = JFile::getExt($file);
+
// Detect browser and compute potential files
if ($detect_browser)
{
@@ -300,17 +327,15 @@ protected static function _includeRelativeFiles($file, $relative, $detect_browse
$browser = $navigator->getBrowser();
$major = $navigator->getMajor();
$minor = $navigator->getMinor();
- $ext = JFile::getExt($file);
- $strip = JFile::stripExt($file);
// Try to include files named filename.ext, filename_browser.ext, filename_browser_major.ext, filename_browser_major_minor.ext
// where major and minor are the browser version names
- $potential = array($file, $strip . '_' . $browser . '.' . $ext, $strip . '_' . $browser . '_' . $major . '.' . $ext,
- $strip . '_' . $browser . '_' . $major . '_' . $minor . '.' . $ext);
+ $potential = array($strip, $strip . '_' . $browser, $strip . '_' . $browser . '_' . $major,
+ $strip . '_' . $browser . '_' . $major . '_' . $minor);
}
else
{
- $potential = array($file);
+ $potential = array($strip);
}
// If relative search in template directory or media directory
@@ -325,69 +350,90 @@ protected static function _includeRelativeFiles($file, $relative, $detect_browse
$includes = array();
// For each potential files
- foreach ($potential as $file)
+ foreach ($potential as $strip)
{
- // If the file is in the template folder
- if (file_exists(JPATH_THEMES . "/$template/$folder/$file"))
+ $files = array();
+ // Detect debug mode
+ if ($detect_debug && JFactory::getConfig()->get('debug'))
{
- $includes[] = JURI::base(true) . "/templates/$template/$folder/$file";
+ $files[] = $strip . '-uncompressed.' . $ext;
}
- else
+ $files[] = $strip . '.' . $ext;
+
+ // Loop on 1 or 2 files and break on first found
+ foreach ($files as $file)
{
- // If the file contains any /: it can be in an media extension subfolder
- if (strpos($file, '/'))
+ // If the file is in the template folder
+ if (file_exists(JPATH_THEMES . "/$template/$folder/$file"))
{
- // Divide the file extracting the extension as the first part before /
- list($extension, $file) = explode('/', $file, 2);
-
- // If the file yet contains any /: it can be a plugin
+ $includes[] = JURI::base(true) . "/templates/$template/$folder/$file";
+ break;
+ }
+ else
+ {
+ // If the file contains any /: it can be in an media extension subfolder
if (strpos($file, '/'))
{
- // Divide the file extracting the element as the first part before /
- list($element, $file) = explode('/', $file, 2);
+ // Divide the file extracting the extension as the first part before /
+ list($extension, $file) = explode('/', $file, 2);
- // Try to deal with plugins group in the media folder
- if (file_exists(JPATH_ROOT . "/media/$extension/$element/$folder/$file"))
+ // If the file yet contains any /: it can be a plugin
+ if (strpos($file, '/'))
{
- $includes[] = JURI::root(true) . "/media/$extension/$element/$folder/$file";
+ // Divide the file extracting the element as the first part before /
+ list($element, $file) = explode('/', $file, 2);
+
+ // Try to deal with plugins group in the media folder
+ if (file_exists(JPATH_ROOT . "/media/$extension/$element/$folder/$file"))
+ {
+ $includes[] = JURI::root(true) . "/media/$extension/$element/$folder/$file";
+ break;
+ }
+ // Try to deal with classical file in a a media subfolder called element
+ elseif (file_exists(JPATH_ROOT . "/media/$extension/$folder/$element/$file"))
+ {
+ $includes[] = JURI::root(true) . "/media/$extension/$folder/$element/$file";
+ break;
+ }
+ // Try to deal with system files in the template folder
+ elseif (file_exists(JPATH_THEMES . "/$template/$folder/system/$element/$file"))
+ {
+ $includes[] = JURI::root(true) . "/templates/$template/$folder/system/$element/$file";
+ break;
+ }
+ // Try to deal with system files in the media folder
+ elseif (file_exists(JPATH_ROOT . "/media/system/$folder/$element/$file"))
+ {
+ $includes[] = JURI::root(true) . "/media/system/$folder/$element/$file";
+ break;
+ }
}
- // Try to deal with classical file in a a media subfolder called element
- elseif (file_exists(JPATH_ROOT . "/media/$extension/$folder/$element/$file"))
+ // Try to deals in the extension media folder
+ elseif (file_exists(JPATH_ROOT . "/media/$extension/$folder/$file"))
{
- $includes[] = JURI::root(true) . "/media/$extension/$folder/$element/$file";
+ $includes[] = JURI::root(true) . "/media/$extension/$folder/$file";
+ break;
}
// Try to deal with system files in the template folder
- elseif (file_exists(JPATH_THEMES . "/$template/$folder/system/$element/$file"))
+ elseif (file_exists(JPATH_THEMES . "/$template/$folder/system/$file"))
{
- $includes[] = JURI::root(true) . "/templates/$template/$folder/system/$element/$file";
+ $includes[] = JURI::root(true) . "/templates/$template/$folder/system/$file";
+ break;
}
// Try to deal with system files in the media folder
- elseif (file_exists(JPATH_ROOT . "/media/system/$folder/$element/$file"))
+ elseif (file_exists(JPATH_ROOT . "/media/system/$folder/$file"))
{
- $includes[] = JURI::root(true) . "/media/system/$folder/$element/$file";
+ $includes[] = JURI::root(true) . "/media/system/$folder/$file";
+ break;
}
}
- // Try to deals in the extension media folder
- elseif (file_exists(JPATH_ROOT . "/media/$extension/$folder/$file"))
- {
- $includes[] = JURI::root(true) . "/media/$extension/$folder/$file";
- }
- // Try to deal with system files in the template folder
- elseif (file_exists(JPATH_THEMES . "/$template/$folder/system/$file"))
- {
- $includes[] = JURI::root(true) . "/templates/$template/$folder/system/$file";
- }
// Try to deal with system files in the media folder
elseif (file_exists(JPATH_ROOT . "/media/system/$folder/$file"))
{
$includes[] = JURI::root(true) . "/media/system/$folder/$file";
+ break;
}
}
- // Try to deal with system files in the media folder
- elseif (file_exists(JPATH_ROOT . "/media/system/$folder/$file"))
- {
- $includes[] = JURI::root(true) . "/media/system/$folder/$file";
- }
}
}
}
@@ -395,11 +441,16 @@ protected static function _includeRelativeFiles($file, $relative, $detect_browse
else
{
$includes = array();
- foreach ($potential as $file)
+ foreach ($potential as $strip)
{
- if (file_exists(JPATH_ROOT . "/$file"))
+ // Detect debug mode
+ if ($detect_debug && JFactory::getConfig()->get('debug') && file_exists(JPATH_ROOT . "/$strip-uncompressed.$ext"))
+ {
+ $includes[] = JURI::root(true) . "/$strip-uncompressed.$ext";
+ }
+ elseif (file_exists(JPATH_ROOT . "/$strip.$ext"))
{
- $includes[] = JURI::root(true) . "/$file";
+ $includes[] = JURI::root(true) . "/$strip.$ext";
}
}
}
@@ -427,7 +478,7 @@ public static function image($file, $alt, $attribs = null, $relative = false, $p
$attribs = JArrayHelper::toString($attribs);
}
- $includes = self::_includeRelativeFiles($file, $relative, false, 'images');
+ $includes = self::includeRelativeFiles('images', $file, $relative, false, false);
// If only path is required
if ($path_only)
@@ -479,13 +530,14 @@ public static function image($file, $alt, $attribs = null, $relative = false, $p
* <tr><td>Firefox</td> <td>mozilla</td> <td>5.0</td></tr>
* </table>
* a lot of others
+ * @param boolean $detect_debug detect debug to search for compressed files if debug is on
*
* @return mixed nothing if $path_only is false, null, path or array of path if specific css browser files were detected
*
* @see JBrowser
* @since 11.1
*/
- public static function stylesheet($file, $attribs = array(), $relative = false, $path_only = false, $detect_browser = true)
+ public static function stylesheet($file, $attribs = array(), $relative = false, $path_only = false, $detect_browser = true, $detect_debug = true)
{
// Need to adjust for the change in API from 1.5 to 1.6.
// Function stylesheet($filename, $path = 'media/system/css/', $attribs = array())
@@ -502,7 +554,7 @@ public static function stylesheet($file, $attribs = array(), $relative = false,
$relative = false;
}
- $includes = self::_includeRelativeFiles($file, $relative, $detect_browser, 'css');
+ $includes = self::includeRelativeFiles('css', $file, $relative, $detect_browser, $detect_debug);
// If only path is required
if ($path_only)
@@ -539,15 +591,16 @@ public static function stylesheet($file, $attribs = array(), $relative = false,
* @param boolean $relative path to file is relative to /media folder
* @param boolean $path_only return the path to the file only
* @param boolean $detect_browser detect browser to include specific browser js files
+ * @param boolean $detect_debug detect debug to search for compressed files if debug is on
*
* @return mixed nothing if $path_only is false, null, path or array of path if specific js browser files were detected
*
* @see JHtml::stylesheet
* @since 11.1
*/
- public static function script($file, $framework = false, $relative = false, $path_only = false, $detect_browser = true)
+ public static function script($file, $framework = false, $relative = false, $path_only = false, $detect_browser = true, $detect_debug = true)
{
- JHtml::core();
+ JHtml::core($detect_debug == false ? false : null);
// Need to adjust for the change in API from 1.5 to 1.6.
// function script($filename, $path = 'media/system/js/', $mootools = true)
@@ -564,7 +617,7 @@ public static function script($file, $framework = false, $relative = false, $pat
JHtml::_('behavior.framework');
}
- $includes = self::_includeRelativeFiles($file, $relative, $detect_browser, 'js');
+ $includes = self::includeRelativeFiles('js', $file, $relative, $detect_browser, $detect_debug);
// If only path is required
if ($path_only)
View
168 libraries/joomla/html/html/behavior.php
@@ -19,6 +19,11 @@
abstract class JHtmlBehavior
{
/**
+ * @var array array containing information for loaded files
+ */
+ protected static $loaded = array();
+
+ /**
* Method to load the MooTools framework into the document head
*
* If debugging mode is on an uncompressed version of MooTools is included for easier debugging.
@@ -32,12 +37,10 @@
*/
public static function framework($extras = false, $debug = null)
{
- static $loaded = array();
-
$type = $extras ? 'more' : 'core';
// Only load once
- if (!empty($loaded[$type]))
+ if (!empty(self::$loaded[__METHOD__][$type]))
{
return;
}
@@ -51,15 +54,13 @@ public static function framework($extras = false, $debug = null)
$debug = $config->get('debug');
}
- $uncompressed = $debug ? '-uncompressed' : '';
-
- if ($type != 'core' && empty($loaded['core']))
+ if ($type != 'core' && empty(self::$loaded[__METHOD__]['core']))
{
self::framework(false, $debug);
}
- JHtml::_('script', 'system/mootools-' . $type . $uncompressed . '.js', false, true, false, false);
- $loaded[$type] = true;
+ JHtml::_('script', 'system/mootools-' . $type . '.js', false, true, false, false, $debug);
+ self::$loaded[__METHOD__][$type] = true;
return;
}
@@ -94,15 +95,8 @@ public static function mootools($debug = null)
*/
public static function caption($selector = 'img.caption')
{
- static $caption;
-
- if (!isset($caption))
- {
- $caption = array();
- }
-
// Only load once
- if (isset($caption[$selector]))
+ if (isset(self::$loaded[__METHOD__][$selector]))
{
return;
}
@@ -110,8 +104,7 @@ public static function caption($selector = 'img.caption')
// Include MooTools framework
self::framework();
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
- JHtml::_('script', 'system/caption' . $uncompressed . '.js', true, true);
+ JHtml::_('script', 'system/caption.js', true, true);
// Attach caption to document
JFactory::getDocument()->addScriptDeclaration(
@@ -121,7 +114,7 @@ public static function caption($selector = 'img.caption')
);
// Set static array
- $caption[$selector] = true;
+ self::$loaded[__METHOD__][$selector] = true;
}
/**
@@ -138,10 +131,8 @@ public static function caption($selector = 'img.caption')
*/
public static function formvalidation()
{
- static $loaded = false;
-
// Only load once
- if ($loaded)
+ if (isset(self::$loaded[__METHOD__]))
{
return;
}
@@ -149,9 +140,8 @@ public static function formvalidation()
// Include MooTools framework
self::framework();
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
- JHtml::_('script', 'system/validate' . $uncompressed . '.js', true, true);
- $loaded = true;
+ JHtml::_('script', 'system/validate.js', true, true);
+ self::$loaded[__METHOD__] = true;
}
/**
@@ -164,10 +154,8 @@ public static function formvalidation()
*/
public static function switcher()
{
- static $loaded = false;
-
// Only load once
- if ($loaded)
+ if (isset(self::$loaded[__METHOD__]))
{
return;
}
@@ -175,8 +163,7 @@ public static function switcher()
// Include MooTools framework
self::framework();
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
- JHtml::_('script', 'system/switcher' . $uncompressed . '.js', true, true);
+ JHtml::_('script', 'system/switcher.js', true, true);
$script = "
document.switcher = null;
@@ -189,7 +176,7 @@ public static function switcher()
});";
JFactory::getDocument()->addScriptDeclaration($script);
- $loaded = true;
+ self::$loaded[__METHOD__] = true;
}
/**
@@ -204,20 +191,15 @@ public static function switcher()
*/
public static function combobox()
{
- static $loaded = false;
-
- // Only load once
- if ($loaded)
+ if (isset(self::$loaded[__METHOD__]))
{
return;
}
-
// Include MooTools framework
self::framework();
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
- JHtml::_('script', 'system/combobox' . $uncompressed . '.js', true, true);
- $loaded = true;
+ JHtml::_('script', 'system/combobox.js', true, true);
+ self::$loaded[__METHOD__] = true;
}
/**
@@ -249,22 +231,15 @@ public static function combobox()
*/
public static function tooltip($selector = '.hasTip', $params = array())
{
- static $tips;
-
- if (!isset($tips))
+ $sig = md5(serialize(array($selector, $params)));
+ if (isset(self::$loaded[__METHOD__][$sig]))
{
- $tips = array();
+ return;
}
// Include MooTools framework
self::framework(true);
- $sig = md5(serialize(array($selector, $params)));
- if (isset($tips[$sig]) && ($tips[$sig]))
- {
- return;
- }
-
// Setup options object
$opt['maxTitleChars'] = (isset($params['maxTitleChars']) && ($params['maxTitleChars'])) ? (int) $params['maxTitleChars'] : 50;
// offsets needs an array in the format: array('x'=>20, 'y'=>30)
@@ -299,7 +274,7 @@ public static function tooltip($selector = '.hasTip', $params = array())
);
// Set static array
- $tips[$sig] = true;
+ self::$loaded[__METHOD__][$sig] = true;
return;
}
@@ -327,32 +302,21 @@ public static function tooltip($selector = '.hasTip', $params = array())
*/
public static function modal($selector = 'a.modal', $params = array())
{
- static $modals;
- static $included;
-
$document = JFactory::getDocument();
// Load the necessary files if they haven't yet been loaded
- if (!isset($included))
+ if (!isset(self::$loaded[__METHOD__]))
{
// Include MooTools framework
self::framework();
// Load the javascript and css
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
- JHtml::_('script', 'system/modal' . $uncompressed . '.js', true, true);
+ JHtml::_('script', 'system/modal.js', true, true);
JHtml::_('stylesheet', 'system/modal.css', array(), true);
-
- $included = true;
- }
-
- if (!isset($modals))
- {
- $modals = array();
}
$sig = md5(serialize(array($selector, $params)));
- if (isset($modals[$sig]) && ($modals[$sig]))
+ if (isset(self::$loaded[__METHOD__][$sig]))
{
return;
}
@@ -393,7 +357,7 @@ public static function modal($selector = 'a.modal', $params = array())
);
// Set static array
- $modals[$sig] = true;
+ self::$loaded[__METHOD__][$sig] = true;
return;
}
@@ -409,15 +373,8 @@ public static function modal($selector = 'a.modal', $params = array())
*/
public static function multiselect($id = 'adminForm')
{
- static $multiselect;
-
- if (!isset($multiselect))
- {
- $multiselect = array();
- }
-
// Only load once
- if (isset($multiselect[$id]))
+ if (isset(self::$loaded[__METHOD__][$id]))
{
return;
}
@@ -435,7 +392,7 @@ public static function multiselect($id = 'adminForm')
);
// Set static array
- $multiselect[$id] = true;
+ self::$loaded[__METHOD__][$id] = true;
return;
}
@@ -455,19 +412,14 @@ public static function uploader($id = 'file-upload', $params = array(), $upload_
// Include MooTools framework
self::framework();
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
- JHtml::_('script', 'system/swf' . $uncompressed . '.js', true, true);
- JHtml::_('script', 'system/progressbar' . $uncompressed . '.js', true, true);
- JHtml::_('script', 'system/uploader' . $uncompressed . '.js', true, true);
+ JHtml::_('script', 'system/swf.js', true, true);
+ JHtml::_('script', 'system/progressbar.js', true, true);
+ JHtml::_('script', 'system/uploader.js', true, true);
$document = JFactory::getDocument();
- static $uploaders;
-
- if (!isset($uploaders))
+ if (!isset(self::$loaded[__METHOD__]))
{
- $uploaders = array();
-
JText::script('JLIB_HTML_BEHAVIOR_UPLOADER_FILENAME');
JText::script('JLIB_HTML_BEHAVIOR_UPLOADER_UPLOAD_COMPLETED');
JText::script('JLIB_HTML_BEHAVIOR_UPLOADER_ERROR_OCCURRED');
@@ -491,7 +443,7 @@ public static function uploader($id = 'file-upload', $params = array(), $upload_
JText::script('JLIB_HTML_BEHAVIOR_UPLOADER_ALL_FILES');
}
- if (isset($uploaders[$id]) && ($uploaders[$id]))
+ if (isset(self::$loaded[__METHOD__][$id]))
{
return;
}
@@ -600,7 +552,7 @@ public static function uploader($id = 'file-upload', $params = array(), $upload_
$document->addScriptDeclaration($uploaderInit);
// Set static array
- $uploaders[$id] = true;
+ self::$loaded[__METHOD__][$id] = true;
return;
}
@@ -618,21 +570,13 @@ public static function uploader($id = 'file-upload', $params = array(), $upload_
*/
public static function tree($id, $params = array(), $root = array())
{
- static $trees;
-
- if (!isset($trees))
- {
- $trees = array();
- }
-
// Include MooTools framework
self::framework();
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
- JHtml::_('script', 'system/mootree' . $uncompressed . '.js', true, true, false, false);
+ JHtml::_('script', 'system/mootree.js', true, true, false, false);
JHtml::_('stylesheet', 'system/mootree.css', array(), true);
- if (isset($trees[$id]) && ($trees[$id]))
+ if (isset(self::$loaded[__METHOD__][$id]))
{
return;
}
@@ -672,7 +616,7 @@ public static function tree($id, $params = array(), $root = array())
$document->addScriptDeclaration($js);
// Set static array
- $trees[$id] = true;
+ self::$loaded[__METHOD__][$id] = true;
return;
}
@@ -686,10 +630,8 @@ public static function tree($id, $params = array(), $root = array())
*/
public static function calendar()
{
- static $loaded = false;
-
// Only load once
- if ($loaded)
+ if (isset(self::$loaded[__METHOD__]))
{
return;
}
@@ -697,18 +639,16 @@ public static function calendar()
$document = JFactory::getDocument();
$tag = JFactory::getLanguage()->getTag();
- //Add uncompressed versions when debug is enabled
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
JHtml::_('stylesheet', 'system/calendar-jos.css', array(' title' => JText::_('JLIB_HTML_BEHAVIOR_GREEN'), ' media' => 'all'), true);
- JHtml::_('script', $tag . '/calendar' . $uncompressed . '.js', false, true);
- JHtml::_('script', $tag . '/calendar-setup' . $uncompressed . '.js', false, true);
+ JHtml::_('script', $tag . '/calendar.js', false, true);
+ JHtml::_('script', $tag . '/calendar-setup.js', false, true);
$translation = JHtmlBehavior::_calendartranslation();
if ($translation)
{
$document->addScriptDeclaration($translation);
}
- $loaded = true;
+ self::$loaded[__METHOD__] = true;
}
/**
@@ -720,10 +660,8 @@ public static function calendar()
*/
public static function colorpicker()
{
- static $loaded = false;
-
// Only load once
- if ($loaded)
+ if (isset(self::$loaded[__METHOD__]))
{
return;
}
@@ -731,8 +669,6 @@ public static function colorpicker()
// Include MooTools framework
self::framework(true);
- //Add uncompressed versions when debug is enabled
- $uncompressed = JFactory::getConfig()->get('debug') ? '-uncompressed' : '';
JHtml::_('stylesheet', 'system/mooRainbow.css', array('media' => 'all'), true);
JHtml::_('script', 'system/mooRainbow.js', false, true);
@@ -763,7 +699,7 @@ public static function colorpicker()
"
);
- $loaded = true;
+ self::$loaded[__METHOD__] = true;
}
/**
@@ -775,10 +711,8 @@ public static function colorpicker()
*/
public static function keepalive()
{
- static $loaded = false;
-
// Only load once
- if ($loaded)
+ if (isset(self::$loaded[__METHOD__]))
{
return;
}
@@ -807,7 +741,7 @@ public static function keepalive()
$script .= ');';
$document->addScriptDeclaration($script);
- $loaded = true;
+ self::$loaded[__METHOD__] = true;
return;
}
@@ -823,10 +757,8 @@ public static function keepalive()
*/
public static function noframes($location = 'top.location.href')
{
- static $loaded = false;
-
// Only load once
- if ($loaded)
+ if (isset(self::$loaded[__METHOD__]))
{
return;
}
@@ -842,7 +774,7 @@ public static function noframes($location = 'top.location.href')
JResponse::setHeader('X-Frames-Options', 'SAME-ORIGIN');
- $loaded = true;
+ self::$loaded[__METHOD__] = true;
}
/**
View
8 libraries/joomla/html/html/sliders.php
@@ -89,11 +89,11 @@ protected static function _loadBehavior($group, $params = array())
$show = (isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']))
? (int) $params['startOffset'] : null;
$options = '{';
- $opt['onActive'] = "function(toggler, i) {toggler.addClass('pane-toggler-down');' .
- 'toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_"
+ $opt['onActive'] = "function(toggler, i) {toggler.addClass('pane-toggler-down');" .
+ "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_"
. $group . "',$$('div#" . $group . ".pane-sliders > .panel > h3').indexOf(toggler));}";
- $opt['onBackground'] = "function(toggler, i) {toggler.addClass('pane-toggler');' .
- 'toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if($$('div#"
+ $opt['onBackground'] = "function(toggler, i) {toggler.addClass('pane-toggler');" .
+ "toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if($$('div#"
. $group . ".pane-sliders > .panel > h3').length==$$('div#" . $group
. ".pane-sliders > .panel > h3.pane-toggler').length) Cookie.write('jpanesliders_" . $group . "',-1);}";
$opt['duration'] = (isset($params['duration'])) ? (int) $params['duration'] : 300;
View
2  libraries/joomla/user/authentication.php
@@ -263,7 +263,7 @@ public function detach($observer)
}
/**
- * Finds out if a set of login credentials are valid by asking all obvserving
+ * Finds out if a set of login credentials are valid by asking all observing
* objects to run their respective authentication routines.
*
* @param array $credentials Array holding the user credentials.
View
0  media/system/css/mooRainbow.css 100755 → 100644
File mode changed
View
0  media/system/images/mooRainbow/blank.gif 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  media/system/images/mooRainbow/moor_arrows.gif 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  media/system/images/mooRainbow/moor_boverlay.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  media/system/images/mooRainbow/moor_cursor.gif 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  media/system/images/mooRainbow/moor_slider.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  media/system/images/mooRainbow/moor_woverlay.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  media/system/js/mooRainbow-uncompressed.js 100755 → 100644
File mode changed
View
0  media/system/js/mooRainbow.js 100755 → 100644
File mode changed
View
6 media/system/js/multiselect.js
@@ -12,8 +12,8 @@
Joomla.JMultiSelect = new Class({
initialize : function(table) {
this.table = document.id(table);
- if (table) {
- this.boxes = table.getElements('input[type=checkbox]');
+ if (this.table) {
+ this.boxes = this.table.getElements('input[type=checkbox]');
this.boxes.addEvent('click', function(e){
this.doselect(e);
}.bind(this));
@@ -35,4 +35,4 @@
this.last = current;
}
});
-})();
+})();
View
0  media/system/swf/uploader.swf 100755 → 100644
File mode changed
View
971 tests/suite/joomla/html/JHtmlTest.php
@@ -1,20 +1,23 @@
<?php
/**
* @package Joomla.UnitTest
- * @subpackage HTML
+ * @subpackage Html
*
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
-require_once JPATH_PLATFORM.'/joomla/filesystem/path.php';
-require_once JPATH_PLATFORM.'/joomla/html/html.php';
-require_once JPATH_PLATFORM.'/joomla/utilities/arrayhelper.php';
+require_once JPATH_PLATFORM . '/joomla/filesystem/path.php';
+require_once JPATH_PLATFORM . '/joomla/html/html.php';
+require_once JPATH_PLATFORM . '/joomla/utilities/arrayhelper.php';
/**
* Tests for the JHtml class.
*
- * @since 11.1
+ * @package Joomla.UnitTest
+ * @subpackage Html
+ *
+ * @since 11.1
*/
class JHtmlTest extends JoomlaTestCase
{
@@ -26,6 +29,8 @@ class JHtmlTest extends JoomlaTestCase
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
+ *
+ * @return void
*/
protected function setUp()
{
@@ -35,6 +40,8 @@ protected function setUp()
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
+ *
+ * @return void
*/
protected function tearDown()
{
@@ -51,7 +58,7 @@ protected function tearDown()
public function test_()
{
// Add the include path to html test files.
- JHtml::addIncludePath(array(__DIR__.'/html/testfiles'));
+ JHtml::addIncludePath(array(__DIR__ . '/html/testfiles'));
// Test the class method was called and the arguments passed correctly.
$this->assertThat(
@@ -196,6 +203,8 @@ public function testIsRegistered()
/**
* @todo Implement testCore().
+ *
+ * @return void
*/
public function testCore()
{
@@ -256,11 +265,16 @@ public function testLink($url, $text, $attribs, $expected)
}
/**
- * @todo Implement testImage().
+ * testImage().
+ *
+ * @return void
+ *
+ * @since 11.1
*/
public function testImage()
{
- if(!is_array($_SERVER)) {
+ if (!is_array($_SERVER))
+ {
$_SERVER = array();
}
@@ -275,7 +289,7 @@ public function testImage()
$urlfilename = 'image1.jpg';
// we generate a random template name so that we don't collide or hit anything
- $template = 'mytemplate'.rand(1, 10000);
+ $template = 'mytemplate' . rand(1, 10000);
// we create a stub (not a mock because we don't enforce whether it is called or not)
// to return a value from getTemplate
@@ -287,78 +301,82 @@ public function testImage()
JFactory::$application = $mock;
// we create the file that JHtml::image will look for
- mkdir(JPATH_THEMES .'/'. $template .'/images/'. $urlpath, 0777, true);
- file_put_contents(JPATH_THEMES .'/'. $template .'/images/'. $urlpath.$urlfilename, 'test');
+ mkdir(JPATH_THEMES . '/' . $template . '/images/' . $urlpath, 0777, true);
+ file_put_contents(JPATH_THEMES . '/' . $template . '/images/' . $urlpath . $urlfilename, 'test');
// we do a test for the case that the image is in the templates directory
$this->assertThat(
- JHtml::image($urlpath.$urlfilename, 'My Alt Text', null, true),
- $this->equalTo('<img src="'.JURI::base(true).'/templates/'.$template.'/images/'.$urlpath.$urlfilename.'" alt="My Alt Text" />'),
+ JHtml::image($urlpath . $urlfilename, 'My Alt Text', null, true),
+ $this->equalTo(
+ '<img src="' . JURI::base(true) . '/templates/' . $template . '/images/' . $urlpath . $urlfilename . '" alt="My Alt Text" />'
+ ),
'JHtml::image failed when we should get it from the templates directory'
);
$this->assertThat(
- JHtml::image($urlpath.$urlfilename, 'My Alt Text', null, true, true),
- $this->equalTo(JURI::base(true).'/templates/'.$template.'/images/'.$urlpath.$urlfilename),
+ JHtml::image($urlpath . $urlfilename, 'My Alt Text', null, true, true),
+ $this->equalTo(JURI::base(true) . '/templates/' . $template . '/images/' . $urlpath . $urlfilename),
'JHtml::image failed in URL only mode when it should come from the templates directory'
);
- unlink(JPATH_THEMES .'/'. $template .'/images/'. $urlpath.$urlfilename);
- rmdir(JPATH_THEMES .'/'. $template .'/images/'. $urlpath);
- rmdir(JPATH_THEMES .'/'. $template .'/images');
- rmdir(JPATH_THEMES .'/'. $template);
+ unlink(JPATH_THEMES . '/' . $template . '/images/' . $urlpath . $urlfilename);
+ rmdir(JPATH_THEMES . '/' . $template . '/images/' . $urlpath);
+ rmdir(JPATH_THEMES . '/' . $template . '/images');
+ rmdir(JPATH_THEMES . '/' . $template);
// we create the file that JHtml::image will look for
- if (!is_dir(dirname(JPATH_ROOT .'/media/'. $urlpath .'images/'. $urlfilename))) {
- mkdir(dirname(JPATH_ROOT .'/media/'. $urlpath .'images/'. $urlfilename), 0777, true);
+ if (!is_dir(dirname(JPATH_ROOT . '/media/' . $urlpath . 'images/' . $urlfilename)))
+ {
+ mkdir(dirname(JPATH_ROOT . '/media/' . $urlpath . 'images/' . $urlfilename), 0777, true);
}
- file_put_contents(JPATH_ROOT .'/media/'. $urlpath .'images/'. $urlfilename, 'test');
+ file_put_contents(JPATH_ROOT . '/media/' . $urlpath . 'images/' . $urlfilename, 'test');
- // we do a test for the case that the image is in the templates directory
+ // we do a test for the case that the image is in the media directory
$this->assertThat(
- JHtml::image($urlpath.$urlfilename, 'My Alt Text', null, true),
- $this->equalTo('<img src="'.JURI::base(true).'/media/'.$urlpath.'images/'.$urlfilename.'" alt="My Alt Text" />'),
+ JHtml::image($urlpath . $urlfilename, 'My Alt Text', null, true),
+ $this->equalTo('<img src="' . JURI::base(true) . '/media/' . $urlpath . 'images/' . $urlfilename . '" alt="My Alt Text" />'),
'JHtml::image failed when we should get it from the media directory'
);
$this->assertThat(
- JHtml::image($urlpath.$urlfilename, 'My Alt Text', null, true, true),
- $this->equalTo(JURI::base(true).'/media/'.$urlpath.'images/'.$urlfilename),
+ JHtml::image($urlpath . $urlfilename, 'My Alt Text', null, true, true),
+ $this->equalTo(JURI::base(true) . '/media/' . $urlpath . 'images/' . $urlfilename),
'JHtml::image failed when we should get it from the media directory in path only mode'
);
- unlink(JPATH_ROOT .'/media/'. $urlpath .'images/'. $urlfilename);
- rmdir(JPATH_ROOT .'/media/'. $urlpath .'images');
- rmdir(JPATH_ROOT .'/media/'. $urlpath);
+ unlink(JPATH_ROOT . '/media/' . $urlpath . 'images/' . $urlfilename);
+ rmdir(JPATH_ROOT . '/media/' . $urlpath . 'images');
+ rmdir(JPATH_ROOT . '/media/' . $urlpath);
// we create the file that JHtml::image will look for
- if (!is_dir(dirname(JPATH_ROOT .'/media/system/images/'. $urlfilename))) {
- mkdir(dirname(JPATH_ROOT .'/media/system/images/'. $urlfilename), 0777, true);
+ if (!is_dir(dirname(JPATH_ROOT . '/media/system/images/' . $urlfilename)))
+ {
+ mkdir(dirname(JPATH_ROOT . '/media/system/images/' . $urlfilename), 0777, true);
}
- file_put_contents(JPATH_ROOT .'/media/system/images/'. $urlfilename, 'test');
+ file_put_contents(JPATH_ROOT . '/media/system/images/' . $urlfilename, 'test');
$this->assertThat(
- JHtml::image($urlpath.$urlfilename, 'My Alt Text', null, true),
- $this->equalTo('<img src="'.JURI::base(true).'/media/system/images/'.$urlfilename.'" alt="My Alt Text" />'),
+ JHtml::image($urlpath . $urlfilename, 'My Alt Text', null, true),
+ $this->equalTo('<img src="' . JURI::base(true) . '/media/system/images/' . $urlfilename . '" alt="My Alt Text" />'),
'JHtml::image failed when we should get it from the media directory'
);
$this->assertThat(
- JHtml::image($urlpath.$urlfilename, 'My Alt Text', null, true, true),
- $this->equalTo(JURI::base(true).'/media/system/images/'.$urlfilename),
+ JHtml::image($urlpath . $urlfilename, 'My Alt Text', null, true, true),
+ $this->equalTo(JURI::base(true) . '/media/system/images/' . $urlfilename),
'JHtml::image failed when we should get it from the media directory in path only mode'
);
- unlink(JPATH_ROOT .'/media/system/images/'. $urlfilename);
+ unlink(JPATH_ROOT . '/media/system/images/' . $urlfilename);
$this->assertThat(
- JHtml::image($urlpath.$urlfilename, 'My Alt Text', null, true),
+ JHtml::image($urlpath . $urlfilename, 'My Alt Text', null, true),
$this->equalTo('<img src="" alt="My Alt Text" />'),
'JHtml::image failed when we should get it from the media directory'
);
$this->assertThat(
- JHtml::image($urlpath.$urlfilename, 'My Alt Text', null, true, true),
+ JHtml::image($urlpath . $urlfilename, 'My Alt Text', null, true, true),
$this->equalTo(null),
'JHtml::image failed when we should get it from the media directory in path only mode'
);
@@ -368,75 +386,82 @@ public function testImage()
$urlpath = 'path1/';
$urlfilename = 'image1.jpg';
- mkdir(JPATH_ROOT .'/media/'. $extension.'/'.$element .'/images/'. $urlpath, 0777, true);
- file_put_contents(JPATH_ROOT .'/media/'. $extension.'/'.$element .'/images/'. $urlpath.$urlfilename, 'test');
+ mkdir(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/images/' . $urlpath, 0777, true);
+ file_put_contents(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/images/' . $urlpath . $urlfilename, 'test');
$this->assertThat(
- JHtml::image($extension.'/'.$element.'/'.$urlpath.$urlfilename, 'My Alt Text', null, true),
- $this->equalTo('<img src="'.JURI::base(true).'/media/'. $extension.'/'.$element .'/images/'. $urlpath.$urlfilename.'" alt="My Alt Text" />'),
+ JHtml::image($extension . '/' . $element . '/' . $urlpath . $urlfilename, 'My Alt Text', null, true),
+ $this->equalTo(
+ '<img src="' . JURI::base(true) . '/media/' . $extension . '/' . $element . '/images/' . $urlpath . $urlfilename .
+ '" alt="My Alt Text" />'
+ ),
'JHtml::image failed when we should get it from the media directory, with the plugin fix'
);
$this->assertThat(
- JHtml::image($extension.'/'.$element.'/'.$urlpath.$urlfilename, 'My Alt Text', null, true, true),
- $this->equalTo(JURI::base(true).'/media/'. $extension.'/'.$element .'/images/'. $urlpath.$urlfilename),
+ JHtml::image($extension . '/' . $element . '/' . $urlpath . $urlfilename, 'My Alt Text', null, true, true),
+ $this->equalTo(JURI::base(true) . '/media/' . $extension . '/' . $element . '/images/' . $urlpath . $urlfilename),
'JHtml::image failed when we should get it from the media directory, with the plugin fix path only mode'
);
// we remove the file from the media directory
- unlink(JPATH_ROOT .'/media/'. $extension.'/'.$element .'/images/'. $urlpath.$urlfilename);
- rmdir(JPATH_ROOT .'/media/'. $extension.'/'.$element .'/images/'. $urlpath);
- rmdir(JPATH_ROOT .'/media/'. $extension.'/'.$element .'/images');
- rmdir(JPATH_ROOT .'/media/'. $extension.'/'.$element);
- rmdir(JPATH_ROOT .'/media/'. $extension);
+ unlink(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/images/' . $urlpath . $urlfilename);
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/images/' . $urlpath);
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/images');
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/' . $element);
+ rmdir(JPATH_ROOT . '/media/' . $extension);
- mkdir(JPATH_ROOT .'/media/'. $extension.'/images/'.$element .'/'. $urlpath, 0777, true);
- file_put_contents(JPATH_ROOT .'/media/'. $extension.'/images/'.$element .'/'. $urlpath.$urlfilename, 'test');
+ mkdir(JPATH_ROOT . '/media/' . $extension . '/images/' . $element . '/' . $urlpath, 0777, true);
+ file_put_contents(JPATH_ROOT . '/media/' . $extension . '/images/' . $element . '/' . $urlpath . $urlfilename, 'test');
$this->assertThat(
- JHtml::image($extension.'/'.$element.'/'.$urlpath.$urlfilename, 'My Alt Text', null, true),
- $this->equalTo('<img src="'.JURI::base(true).'/media/'.$extension.'/images/'.$element.'/'. $urlpath.$urlfilename.'" alt="My Alt Text" />')
+ JHtml::image($extension . '/' . $element . '/' . $urlpath . $urlfilename, 'My Alt Text', null, true),
+ $this->equalTo(
+ '<img src="' . JURI::base(true) . '/media/' . $extension . '/images/' . $element . '/' . $urlpath . $urlfilename .
+ '" alt="My Alt Text" />'
+ )
);
$this->assertThat(
- JHtml::image($extension.'/'.$element.'/'.$urlpath.$urlfilename, 'My Alt Text', null, true, true),
- $this->equalTo(JURI::base(true).'/media/'.$extension.'/images/'.$element.'/'.$urlpath.$urlfilename)
+ JHtml::image($extension . '/' . $element . '/' . $urlpath . $urlfilename, 'My Alt Text', null, true, true),
+ $this->equalTo(JURI::base(true) . '/media/' . $extension . '/images/' . $element . '/' . $urlpath . $urlfilename)
);
- unlink(JPATH_ROOT .'/media/'. $extension.'/images/'.$element .'/'. $urlpath.$urlfilename);
- rmdir(JPATH_ROOT .'/media/'. $extension.'/images/'.$element .'/'. $urlpath);
- rmdir(JPATH_ROOT .'/media/'. $extension.'/images/'.$element);
- rmdir(JPATH_ROOT .'/media/'. $extension.'/images');
- rmdir(JPATH_ROOT .'/media/'. $extension);
+ unlink(JPATH_ROOT . '/media/' . $extension . '/images/' . $element . '/' . $urlpath . $urlfilename);
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/images/' . $element . '/' . $urlpath);
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/images/' . $element);
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/images');
+ rmdir(JPATH_ROOT . '/media/' . $extension);
- mkdir(JPATH_ROOT .'/media/system/images/'. $element.'/'. $urlpath, 0777, true);
- file_put_contents(JPATH_ROOT .'/media/system/images/'. $element.'/'. $urlpath.$urlfilename, 'test');
+ mkdir(JPATH_ROOT . '/media/system/images/' . $element . '/' . $urlpath, 0777, true);
+ file_put_contents(JPATH_ROOT . '/media/system/images/' . $element . '/' . $urlpath . $urlfilename, 'test');
$this->assertThat(
- JHtml::image($extension.'/'.$element.'/'.$urlpath.$urlfilename, 'My Alt Text', null, true),
- $this->equalTo('<img src="'.JURI::base(true).'/media/system/images/'.$element.'/'. $urlpath.$urlfilename.'" alt="My Alt Text" />')
+ JHtml::image($extension . '/' . $element . '/' . $urlpath . $urlfilename, 'My Alt Text', null, true),
+ $this->equalTo('<img src="' . JURI::base(true) . '/media/system/images/' . $element . '/' . $urlpath . $urlfilename . '" alt="My Alt Text" />')
);
$this->assertThat(
- JHtml::image($extension.'/'.$element.'/'.$urlpath.$urlfilename, 'My Alt Text', null, true, true),
- $this->equalTo(JURI::base(true).'/media/system/images/'.$element.'/'.$urlpath.$urlfilename)
+ JHtml::image($extension . '/' . $element . '/' . $urlpath . $urlfilename, 'My Alt Text', null, true, true),
+ $this->equalTo(JURI::base(true) . '/media/system/images/' . $element . '/' . $urlpath . $urlfilename)
);
- unlink(JPATH_ROOT .'/media/system/images/'. $element.'/'. $urlpath.$urlfilename);
- rmdir(JPATH_ROOT .'/media/system/images/'. $element.'/'. $urlpath);
- rmdir(JPATH_ROOT .'/media/system/images/'. $element);
+ unlink(JPATH_ROOT . '/media/system/images/' . $element . '/' . $urlpath . $urlfilename);
+ rmdir(JPATH_ROOT . '/media/system/images/' . $element . '/' . $urlpath);
+ rmdir(JPATH_ROOT . '/media/system/images/' . $element);
$this->assertThat(
- JHtml::image($extension.'/'.$element.'/'.$urlpath.$urlfilename, 'My Alt Text', null, true),
+ JHtml::image($extension . '/' . $element . '/' . $urlpath . $urlfilename, 'My Alt Text', null, true),
$this->equalTo('<img src="" alt="My Alt Text" />')
);
$this->assertThat(
- JHtml::image($extension.'/'.$element.'/'.$urlpath.$urlfilename, 'My Alt Text', null, true, true),
+ JHtml::image($extension . '/' . $element . '/' . $urlpath . $urlfilename, 'My Alt Text', null, true, true),
$this->equalTo(null)
);
$this->assertThat(
- JHtml::image('http://www.example.com/test/image.jpg', 'My Alt Text',
+ JHtml::image(
+ 'http://www.example.com/test/image.jpg', 'My Alt Text',
array(
'width' => 150,
'height' => 150
@@ -446,24 +471,26 @@ public function testImage()
'JHtml::image with an absolute path'
);
- mkdir(JPATH_ROOT .'/test', 0777, true);
- file_put_contents(JPATH_ROOT .'/test/image.jpg', 'test');
+ mkdir(JPATH_ROOT . '/test', 0777, true);
+ file_put_contents(JPATH_ROOT . '/test/image.jpg', 'test');
$this->assertThat(
- JHtml::image('test/image.jpg', 'My Alt Text',
+ JHtml::image(
+ 'test/image.jpg', 'My Alt Text',
array(
'width' => 150,
'height' => 150
),
false
),
- $this->equalTo('<img src="'.JURI::root(true).'/test/image.jpg" alt="My Alt Text" width="150" height="150" />'),
+ $this->equalTo('<img src="' . JURI::root(true) . '/test/image.jpg" alt="My Alt Text" width="150" height="150" />'),
'JHtml::image with an absolute path, URL does not start with http'
);
- unlink(JPATH_ROOT .'/test/image.jpg');
- rmdir(JPATH_ROOT .'/test');
+ unlink(JPATH_ROOT . '/test/image.jpg');
+ rmdir(JPATH_ROOT . '/test');
$this->assertThat(
- JHtml::image('test/image.jpg', 'My Alt Text',
+ JHtml::image(
+ 'test/image.jpg', 'My Alt Text',
array(
'width' => 150,
'height' => 150
@@ -511,11 +538,11 @@ public function dataTestIFrame()
/**
* Tests the iframe method.
*
- * @param string $url
- * @param string $name
- * @param string $attribs
- * @param string $noFrames
- * @param string $expected
+ * @param string $url iframe URL
+ * @param string $name URL name
+ * @param string $attribs iframe attribs
+ * @param string $noFrames replacement for no frames
+ * @param string $expected expected value
*
* @return void
*
@@ -531,18 +558,383 @@ public function testIframe($url, $name, $attribs, $noFrames, $expected)
}
/**
- * @todo Implement testScript
+ * testScript
+ *
+ * @return void
+ *
+ * @since 11.3
*/
public function testScript()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'The original test is causing errors.'
+ if (!is_array($_SERVER))
+ {
+ $_SERVER = array();
+ }
+
+ // we save the state of $_SERVER for later and set it to appropriate values
+ $http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
+ $script_name = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null;
+ $_SERVER['HTTP_HOST'] = 'example.com';
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+
+ // these are some paths to pass to JHtml for testing purposes
+ $urlpath = 'test1/';
+ $urlfilename = 'script1.js';
+
+ // we generate a random template name so that we don't collide or hit anything
+ $template = 'mytemplate' . rand(1, 10000);
+
+ // we create a stub (not a mock because we don't enforce whether it is called or not)
+ // to return a value from getTemplate
+ $mock = $this->getMock('myMockObject', array('getTemplate'));
+ $mock->expects($this->any())
+ ->method('getTemplate')
+ ->will($this->returnValue($template));
+
+ JFactory::$application = $mock;
+
+ // we create the file that JHtml::image will look for
+ mkdir(JPATH_THEMES . '/' . $template . '/js/' . $urlpath, 0777, true);
+ file_put_contents(JPATH_THEMES . '/' . $template . '/js/' . $urlpath . $urlfilename, 'test');
+
+ // we do a test for the case that the js is in the templates directory
+ JHtml::script($urlpath . $urlfilename, false, true);
+ $this->assertArrayHasKey(
+ '/templates/' . $template . '/js/' . $urlpath . $urlfilename,
+ JFactory::$document->_scripts,
+ 'Line:' . __LINE__ . ' JHtml::script failed when we should get it from the templates directory'
+ );
+
+ $this->assertThat(
+ JHtml::script($urlpath . $urlfilename, false, true, true),
+ $this->equalTo(JURI::base(true) . '/templates/' . $template . '/js/' . $urlpath . $urlfilename),
+ 'Line:' . __LINE__ . ' JHtml::script failed in URL only mode when it should come from the templates directory'
+ );
+
+ JFactory::$document->_scripts = array();
+ unlink(JPATH_THEMES . '/' . $template . '/js/' . $urlpath . $urlfilename);
+ rmdir(JPATH_THEMES . '/' . $template . '/js/' . $urlpath);
+ rmdir(JPATH_THEMES . '/' . $template . '/js');
+ rmdir(JPATH_THEMES . '/' . $template);
+
+ // we create the file that JHtml::script will look for
+ if (!is_dir(dirname(JPATH_ROOT . '/media/' . $urlpath . 'js/' . $urlfilename)))
+ {
+ mkdir(dirname(JPATH_ROOT . '/media/' . $urlpath . 'js/' . $urlfilename), 0777, true);
+ }
+ file_put_contents(JPATH_ROOT . '/media/' . $urlpath . 'js/' . $urlfilename, 'test');
+
+ // we do a test for the case that the js is in the media directory
+ JHtml::script($urlpath . $urlfilename, false, true);
+ $this->assertArrayHasKey(
+ '/media/' . $urlpath . 'js/' . $urlfilename,
+ JFactory::$document->_scripts,
+ 'Line:' . __LINE__ . ' JHtml::script failed when we should get it from the media directory'
+ );
+
+ $this->assertThat(
+ JHtml::script($urlpath . $urlfilename, false, true, true),
+ $this->equalTo(JURI::base(true) . '/media/' . $urlpath . 'js/' . $urlfilename),
+ 'Line:' . __LINE__ . ' JHtml::script failed in URL only mode when it should come from the media directory'
+ );
+
+ JFactory::$document->_scripts = array();
+ unlink(JPATH_ROOT . '/media/' . $urlpath . 'js/' . $urlfilename);
+ rmdir(JPATH_ROOT . '/media/' . $urlpath . 'js');
+ rmdir(JPATH_ROOT . '/media/' . $urlpath);
+
+ // we create the file that JHtml::script will look for
+ if (!is_dir(dirname(JPATH_ROOT . '/media/system/js/' . $urlfilename)))
+ {
+ mkdir(dirname(JPATH_ROOT . '/media/system/js/' . $urlfilename), 0777, true);
+ }
+ file_put_contents(JPATH_ROOT . '/media/system/js/' . $urlfilename, 'test');
+
+ // we do a test for the case that the js is in the media directory
+ JHtml::script($urlpath . $urlfilename, false, true);
+ $this->assertArrayHasKey(
+ '/media/system/js/' . $urlfilename,
+ JFactory::$document->_scripts,
+ 'Line:' . __LINE__ . ' JHtml::script failed when we should get it from the media directory'
+ );
+
+ $this->assertThat(
+ JHtml::script($urlpath . $urlfilename, false, true, true),
+ $this->equalTo(JURI::base(true) . '/media/system/js/' . $urlfilename),
+ 'Line:' . __LINE__ . ' JHtml::script failed in URL only mode when it should come from the media directory'
+ );
+
+ JFactory::$document->_scripts = array();
+ unlink(JPATH_ROOT . '/media/system/js/' . $urlfilename);
+
+ // we do a test for the case that the js is in the media directory
+ JHtml::script($urlpath . $urlfilename, false, true);
+ $this->assertThat(
+ JFactory::$document->_scripts,
+ $this->logicalNot(
+ $this->arrayHasKey(
+ '/media/system/js/' . $urlfilename
+ )
+ ),
+ 'Line:' . __LINE__ . ' JHtml::script failed when we should get it from the media directory'
+ );
+
+ $this->assertThat(
+ JHtml::script($urlpath . $urlfilename, false, true, true),
+ $this->equalTo(''),
+ 'Line:' . __LINE__ . ' JHtml::script failed in URL only mode when it should come from the media directory'
+ );
+
+ $extension = 'testextension';
+ $element = 'element';
+ $urlpath = 'path1/';
+ $urlfilename = 'script1.js';
+
+ mkdir(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/js/' . $urlpath, 0777, true);
+ file_put_contents(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/js/' . $urlpath . $urlfilename, 'test');
+
+ JHtml::script($extension . '/' . $element . '/' . $urlpath . $urlfilename, false, true);
+ $this->assertArrayHasKey(
+ '/media/' . $extension . '/' . $element . '/js/' . $urlpath . $urlfilename,
+ JFactory::$document->_scripts,
+ 'Line:' . __LINE__ . ' JHtml::script failed when we should get it from the media directory'
+ );
+
+ $this->assertThat(
+ JHtml::script($extension . '/' . $element . '/' . $urlpath . $urlfilename, false, true, true),
+ $this->equalTo(JURI::base(true) . '/media/' . $extension . '/' . $element . '/js/' . $urlpath . $urlfilename),
+ 'Line:' . __LINE__ . ' JHtml::script failed in URL only mode when it should come from the media directory'
+ );
+
+ // we remove the file from the media directory
+ JFactory::$document->_scripts = array();
+ unlink(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/js/' . $urlpath . $urlfilename);
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/js/' . $urlpath);
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/' . $element . '/js');
+ rmdir(JPATH_ROOT . '/media/' . $extension . '/' . $element);
+ rmdir(JPATH_ROOT . '/media/' . $extension);
+
+ mkdir(JPATH_ROOT . '/media/' . $extension . '/js/' . $element . '/' . $urlpath, 0777, true);
+ file_put_contents(JPATH_ROOT . '/media/' . $extension . '/js/' . $element . '/' . $urlpath . $urlfilename, 'test');
+
+ JHtml::script($extension . '/' . $element . '/' . $urlpath . $urlfilename, false, true);
+ $this->assertArrayHasKey(
+ '/media/' . $extension . '/js/' . $element . '/' . $urlpath . $urlfilename,
+ JFactory::$document->_scripts,
+ 'Line:' . __LINE__ . ' JHtml::script failed when we should get it from the media directory'
+ );
+
+ $this->assertThat(
+ JHtml::script($extension . '/' . $element . '/' . $urlpath . $urlfilename, false, true, true),
+ $this->equalTo(JURI::base(true) . '/media/' . $extension . '/js/' . $element . '/' . $urlpath . $urlfilename),
+ 'Line:' . __LINE__ .