当前位置: 首页>>代码示例>>PHP>>正文


PHP PMA_sprites函数代码示例

本文整理汇总了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;
}
开发者ID:AmberWish,项目名称:laba_web,代码行数:69,代码来源:common.lib.php

示例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
开发者ID:TheBlackBloodyUnicorn,项目名称:pico_wanderblog,代码行数:31,代码来源:get_image.js.php

示例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;
 }
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:19,代码来源:Theme.php


注:本文中的PMA_sprites函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。