Source code for file /joomla/html/html.php
Documentation is available at html.php
* @version $Id: html.php 13341 2009-10-27 03:03:54Z ian $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
* Utility class for all HTML drawing classes
* @package Joomla.Framework
* Additional arguments may be supplied and are passed to the sub-class.
* Additional include paths are also able to be specified for third-party use
* @param string The name of helper method to load, (prefix).(class).function
* prefix and class are optional and can be used to load custom
// Check to see if we need to load a helper file
$className =
$prefix.
ucfirst($file);
foreach ($temp as $k =>
$v) {
* Write a <a></a> element
* @param string The relative URL to use for the href attribute
* @param string The target attribute to use
* @param array An associative array of attributes to add
function link($url, $text, $attribs =
null)
return '<a href="'.
$url.
'" '.
$attribs.
'>'.
$text.
'</a>';
* Write a <img></amg> element
* @param string The relative or absoluete URL to use for the src attribute
* @param string The target attribute to use
* @param array An associative array of attributes to add
function image($url, $alt, $attribs =
null)
if(strpos($url, 'http') !==
0) {
return '<img src="'.
$url.
'" alt="'.
$alt.
'" '.
$attribs.
' />';
* Write a <iframe></iframe> element
* @param string The relative URL to use for the src attribute
* @param string The target attribute to use
* @param array An associative array of attributes to add
* @param string The message to display if the iframe tag is not supported
function iframe( $url, $name, $attribs =
null, $noFrames =
'' )
return '<iframe src="'.
$url.
'" '.
$attribs.
' name="'.
$name.
'">'.
$noFrames.
'</iframe>';
* Write a <script></script> element
* @param string The name of the script file
* * @param string The relative or absolute path of the script file
* @param boolean If true, the mootools library will be loaded
function script($filename, $path =
'media/system/js/', $mootools =
true)
// Include mootools framework
JHTML::_('behavior.mootools');
if(strpos($path, 'http') !==
0) {
$document->addScript( $path.
$filename );
* Write a <link rel="stylesheet" style="text/css" /> element
* @param string The relative URL to use for the href attribute
function stylesheet($filename, $path =
'media/system/css/', $attribs =
array())
if(strpos($path, 'http') !==
0) {
$document->addStylesheet( $path.
$filename, 'text/css', null, $attribs );
* Returns formated date according to current local and adds time offset
* @param string date in an US English date format
* @param string format optional format for strftime
* @returns string formated date
function date($date, $format =
null, $offset =
NULL)
$format =
JText::_('DATE_FORMAT_LC1');
$offset =
$config->getValue('config.offset');
$instance->setOffset($offset);
return $instance->toFormat($format);
* Creates a tooltip with an image as button
* @param string $tooltip The tip string
* @param string $title The title of the tooltip
* @param string $image The image for the tip, if no text is provided
* @param string $text The text for the tip
* @param string $href An URL that will be used to create the link
* @param boolean depreciated
function tooltip($tooltip, $title=
'', $image=
'tooltip.png', $text=
'', $href=
'', $link=
1)
$image =
JURI::root(true).
'/includes/js/ThemeOffice/'.
$image;
$text =
'<img src="'.
$image .
'" border="0" alt="'.
JText::_( 'Tooltip' ) .
'"/>';
$text =
JText::_( $text, true );
$style =
'style="text-decoration: none; color: #333;"';
$tip =
'<span class="editlinktip hasTip" title="'.
$title.
$tooltip.
'" '.
$style .
'><a href="'.
$href .
'">'.
$text .
'</a></span>';
$tip =
'<span class="editlinktip hasTip" title="'.
$title.
$tooltip.
'" '.
$style .
'>'.
$text .
'</span>';
* Displays a calendar control field
* @param string The date value
* @param string The name of the text field
* @param string The id of the text field
* @param string The date format
* @param array Additional html attributes
function calendar($value, $name, $id, $format =
'%Y-%m-%d', $attribs =
null)
JHTML::_('behavior.calendar'); //load the calendar behavior
$document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({
inputField : "'.
$id.
'", // id of the input field
ifFormat : "'.
$format.
'", // format of the input field
button : "'.
$id.
'_img", // trigger for the calendar (button ID)
align : "Tl", // alignment (defaults to "Bl")
return '<input type="text" name="'.
$name.
'" id="'.
$id.
'" value="'.
htmlspecialchars($value, ENT_COMPAT, 'UTF-8').
'" '.
$attribs.
' />'.
'<img class="calendar" src="'.
JURI::root(true).
'/templates/system/images/calendar.png" alt="calendar" id="'.
$id.
'_img" />';
* Add a directory where JHTML should search for helpers. You may
* either pass a string or an array of directories.
* @param string A path to search.
* @return array An array with directory elements
$paths =
array( JPATH_LIBRARIES.
DS.
'joomla'.
DS.
'html'.
DS.
'html' );
// loop through the path directories
if (!empty($dir) &&
!in_array($dir, $paths)) {