Files
@ 1db340eef40b
Branch filter:
Location: hot67beta/libraries/joomla/html/html/image.php
1db340eef40b
4.6 KiB
text/x-php
add mtop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | <?php
/**
* @version $Id: image.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla.Framework
* @subpackage HTML
* @copyright Copyright (C) 2005 - 2008 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.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
/**
* Utility class working with images
*
* @static
* @package Joomla.Framework
* @subpackage HTML
* @since 1.5
*/
class JHTMLImage
{
/**
* Checks to see if an image exists in the current templates image directory
* if it does it loads this image. Otherwise the default image is loaded.
* Also can be used in conjunction with the menulist param to create the chosen image
* load the default or use no image
*
* @param string The file name, eg foobar.png
* @param string The path to the image
* @param int empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder
* @param string Another path. Only used for the contact us form based on the value of the imagelist parm
* @param string Alt text
* @param array An associative array of attributes to add
* @param boolean True (default) to display full tag, false to return just the path
*/
function site( $file, $folder='/images/M_images/', $altFile=NULL, $altFolder='/images/M_images/', $alt=NULL, $attribs = null, $asTag = 1)
{
static $paths;
global $mainframe;
if (!$paths) {
$paths = array();
}
if (is_array( $attribs )) {
$attribs = JArrayHelper::toString( $attribs );
}
$cur_template = $mainframe->getTemplate();
if ( $altFile )
{
// $param allows for an alternative file to be used
$src = $altFolder . $altFile;
}
else if ( $altFile == -1 )
{
// Comes from an image list param field with 'Do not use' selected
return '';
} else {
$path = JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file;
if (!isset( $paths[$path] ))
{
if ( file_exists( JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file ) ) {
$paths[$path] = 'templates/'. $cur_template .'/images/'. $file;
} else {
// outputs only path to image
$paths[$path] = $folder . $file;
}
}
$src = $paths[$path];
}
if (substr($src, 0, 1 ) == "/") {
$src = substr_replace($src, '', 0, 1);
}
// Prepend the base path
$src = JURI::base(true).'/'.$src;
// outputs actual html <img> tag
if ($asTag) {
return '<img src="'. $src .'" alt="'. html_entity_decode( $alt ) .'" '.$attribs.' />';
}
return $src;
}
/**
* Checks to see if an image exists in the current templates image directory
* if it does it loads this image. Otherwise the default image is loaded.
* Also can be used in conjunction with the menulist param to create the chosen image
* load the default or use no image
*
* @param string The file name, eg foobar.png
* @param string The path to the image
* @param int empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder
* @param string Another path. Only used for the contact us form based on the value of the imagelist parm
* @param string Alt text
* @param array An associative array of attributes to add
* @param boolean True (default) to display full tag, false to return just the path
*/
function administrator( $file, $directory='/images/', $param=NULL, $param_directory='/images/', $alt = NULL, $attribs = null, $type = 1 )
{
global $mainframe;
if (is_array( $attribs )) {
$attribs = JArrayHelper::toString( $attribs );
}
$cur_template = $mainframe->getTemplate();
// strip html
$alt = html_entity_decode( $alt );
if ( $param ) {
$image = $param_directory . $param;
} else if ( $param == -1 ) {
$image = '';
} else {
if ( file_exists( JPATH_ADMINISTRATOR .'/templates/'. $cur_template .'/images/'. $file ) ) {
$image = 'templates/'. $cur_template .'/images/'. $file;
} else {
// compability with previous versions
if ( substr($directory, 0, 14 )== "/administrator" ) {
$image = substr($directory,15) . $file;
} else {
$image = $directory . $file;
}
}
}
if (substr($image, 0, 1 ) == "/") {
$image = substr_replace($image, '', 0, 1);
}
// Prepend the base path
$image = JURI::base(true).'/'.$image;
// outputs actual html <img> tag
if ( $type ) {
$image = '<img src="'. $image .'" alt="'. $alt .'" '.$attribs.' />';
}
return $image;
}
}
|