當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。