2011-06-10 21:55:32 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
|
|
|
* http://www.mysqldumper.net
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage View_Helpers
|
|
|
|
* @version SVN: $Rev$
|
|
|
|
* @author $Author$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get img-tag for icon
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage View_Helpers
|
|
|
|
*/
|
|
|
|
class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Get html-img-tag for icon image
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @param string $title
|
|
|
|
* @param int $size
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getIcon($name, $title='', $size='')
|
|
|
|
{
|
|
|
|
static $baseUrl = false;
|
|
|
|
if (!$baseUrl) {
|
|
|
|
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
|
|
|
|
}
|
|
|
|
$icons = self::_getIconFilenames();
|
|
|
|
if (!isset($icons[$name])) {
|
|
|
|
throw new Msd_Exception(
|
|
|
|
'GetIcon: unknown icon \''.$name .'\' requested'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$img = '<img src="'.$baseUrl.'/%s/%s" alt="%s" title="%s" />';
|
2012-08-05 17:05:08 +00:00
|
|
|
$config = Msd_Registry::getConfig();
|
2011-06-10 21:55:32 +00:00
|
|
|
if ($size>'') {
|
|
|
|
$img = '<img src="'.$baseUrl.'/%s/%sx%s/%s" alt="%s" title="%s" />';
|
|
|
|
$ret = sprintf(
|
|
|
|
$img,
|
2012-08-05 17:05:08 +00:00
|
|
|
$config->getParam('paths.iconPath'),
|
2011-06-10 21:55:32 +00:00
|
|
|
$size,
|
|
|
|
$size,
|
|
|
|
$icons[$name],
|
|
|
|
$title, $title
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$ret = sprintf(
|
|
|
|
$img,
|
2012-08-05 17:05:08 +00:00
|
|
|
$config->getParam('paths.iconPath'),
|
2011-06-10 21:55:32 +00:00
|
|
|
$icons[$name],
|
|
|
|
$title,
|
|
|
|
$title
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get default values from defaultConfig.ini
|
|
|
|
*
|
|
|
|
* @return object
|
|
|
|
*/
|
|
|
|
private function _getIconFilenames ()
|
|
|
|
{
|
|
|
|
static $icons = false;
|
|
|
|
if (!$icons) {
|
2012-08-04 17:09:48 +00:00
|
|
|
$config = $this->view->config;
|
2011-06-10 21:55:32 +00:00
|
|
|
$file = realpath(
|
2012-08-04 10:40:48 +00:00
|
|
|
APPLICATION_PATH . '/../public/'
|
2012-08-04 17:09:48 +00:00
|
|
|
. $config->getParam('paths.iconPath') . '/icon.ini'
|
2011-06-10 21:55:32 +00:00
|
|
|
);
|
|
|
|
$iconsIni = new Zend_Config_Ini($file, 'icons');
|
|
|
|
$icons = $iconsIni->toArray();
|
|
|
|
unset($iconsIni);
|
|
|
|
}
|
|
|
|
return $icons;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|