本文整理汇总了PHP中PMA_sprites函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_sprites函数的具体用法?PHP PMA_sprites怎么用?PHP PMA_sprites使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_sprites函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_getImage
/**
* Returns an HTML IMG tag for a particular image from a theme,
* which may be an actual file or an icon from a sprite
*
* @param string $image The name of the file to get
* @param string $alternate Used to set 'alt' and 'title' attributes of the image
* @param array $attributes An associative array of other attributes
*
* @return string an html IMG tag
*/
function PMA_getImage($image, $alternate = '', $attributes = array())
{
static $sprites;
// cached list of available sprites (if any)
$url = '';
$is_sprite = false;
$alternate = htmlspecialchars($alternate);
// If it's the first time this function is called
if (!isset($sprites)) {
// Try to load the list of sprites
if (is_readable($_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php')) {
include_once $_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php';
$sprites = PMA_sprites();
} else {
// No sprites are available for this theme
$sprites = array();
}
}
// Check if we have the requested image as a sprite
// and set $url accordingly
$class = str_replace(array('.gif', '.png'), '', $image);
if (array_key_exists($class, $sprites)) {
$is_sprite = true;
$url = 'themes/dot.gif';
} else {
$url = $GLOBALS['pmaThemeImage'] . $image;
}
// set class attribute
if ($is_sprite) {
if (isset($attributes['class'])) {
$attributes['class'] = "icon ic_{$class} " . $attributes['class'];
} else {
$attributes['class'] = "icon ic_{$class}";
}
}
// set all other attributes
$attr_str = '';
foreach ($attributes as $key => $value) {
if (!in_array($key, array('alt', 'title'))) {
$attr_str .= " {$key}=\"{$value}\"";
}
}
// override the alt attribute
if (isset($attributes['alt'])) {
$alt = $attributes['alt'];
} else {
$alt = $alternate;
}
// override the title attribute
if (isset($attributes['title'])) {
$title = $attributes['title'];
} else {
$title = $alternate;
}
// generate the IMG tag
$template = '<img src="%s" title="%s" alt="%s"%s />';
$retval = sprintf($template, $url, $title, $alt, $attr_str);
return $retval;
}
示例2: define
// non-js-compatible stuff like DOCTYPE
define('PMA_MINIMUM_COMMON', true);
require_once './libraries/common.inc.php';
require_once './libraries/OutputBuffering.class.php';
$buffer = PMA_OutputBuffering::getInstance();
$buffer->start();
register_shutdown_function(function () {
echo PMA_OutputBuffering::getInstance()->getContents();
});
// Get the data for the sprites, if it's available
if (is_readable($_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php')) {
include $_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php';
}
$sprites = array();
if (function_exists('PMA_sprites')) {
$sprites = PMA_sprites();
}
// We only need the keys from the array of sprites data,
// since they contain the (partial) class names
$keys = array();
foreach ($sprites as $key => $value) {
$keys[] = "'{$key}'";
}
?>
/**
* Returns an HTML IMG tag for a particular image from a theme,
* which may be an actual file or an icon from a sprite
*
* @param string image The name of the file to get
* @param string alternate Used to set 'alt' and 'title' attributes of the image
* @param object attributes An associative array of other attributes
示例3: getSpriteData
/**
* Loads sprites data
*
* @return array with sprites
*/
public function getSpriteData()
{
$sprites = array();
$filename = $this->getPath() . '/sprites.lib.php';
if (is_readable($filename)) {
// This defines sprites array
include $filename;
// Backwards compatibility for themes from 4.6 and older
if (function_exists('PMA_sprites')) {
$sprites = PMA_sprites();
}
}
return $sprites;
}