Dieser Commit ist enthalten in:
Ursprung
2b21070b1a
Commit
f7a7c71f86
1583 geänderte Dateien mit 454759 neuen und 0 gelöschten Zeilen
43
application/views/helpers/AbsoluteUrl.php
Normale Datei
43
application/views/helpers/AbsoluteUrl.php
Normale Datei
|
|
@ -0,0 +1,43 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper for returning the absolute URL including scheme and serveraddress
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_AbsoluteUrl extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Build an absolute URL (@see Zend_View_Helper_Url::url())
|
||||
* @param array $urlOptions
|
||||
* @param null $name
|
||||
* @param bool $reset
|
||||
* @param bool $encode
|
||||
* @return string
|
||||
*/
|
||||
public function absoluteUrl(
|
||||
array $urlOptions = array(),
|
||||
$name = null,
|
||||
$reset = false,
|
||||
$encode = true
|
||||
)
|
||||
{
|
||||
$serverUrlViewHelper = new Zend_View_Helper_ServerUrl();
|
||||
$urlViewHelper = new Zend_View_Helper_Url();
|
||||
$url = $urlViewHelper->url($urlOptions, $name, $reset, $encode);
|
||||
|
||||
$absoluteUrl = $serverUrlViewHelper->serverUrl($url);
|
||||
|
||||
return $absoluteUrl;
|
||||
}
|
||||
}
|
||||
49
application/views/helpers/AjaxLoad.php
Normale Datei
49
application/views/helpers/AjaxLoad.php
Normale Datei
|
|
@ -0,0 +1,49 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load additional content via ajax
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_AjaxLoad extends Zend_View_Helper_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Call an ajax action from view
|
||||
*
|
||||
* Renders a view snippet which fires the ajax call. The response will
|
||||
* replace the innerHtml of the given DOM-Id.
|
||||
*
|
||||
* @param array $ajaxOptions Options for ajax call (Controller, Action,
|
||||
* Params to hand over to action)
|
||||
* @param array $viewOptions Options to be printed to screen (showThrobber)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ajaxLoad($ajaxOptions, $viewOptions = null)
|
||||
{
|
||||
$viewRenderer = Zend_Controller_Action_HelperBroker::
|
||||
getStaticHelper('viewRenderer');
|
||||
$viewRenderer->initView();
|
||||
$view = $viewRenderer->view;
|
||||
$view->domId = str_replace('.', '-', uniqid('', true));
|
||||
foreach ($ajaxOptions as $key => $val) {
|
||||
$view->$key = $val;
|
||||
}
|
||||
$view->ajaxOptions = $ajaxOptions;
|
||||
$view->viewOptions = $viewOptions;
|
||||
return $view->render('helper/ajax-load.phtml');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
49
application/views/helpers/ByteOutput.php
Normale Datei
49
application/views/helpers/ByteOutput.php
Normale Datei
|
|
@ -0,0 +1,49 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Human readable byte output
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_ByteOutput extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Humanize byte output
|
||||
*
|
||||
* @param int $bytes
|
||||
* @param int $precision
|
||||
* @param boolean $useHTML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function byteOutput($bytes, $precision = 2, $useHtml = true)
|
||||
{
|
||||
$unitsLong = array('Bytes', 'KiloBytes', 'MegaBytes', 'GigaBytes',
|
||||
'TeraBytes', 'PetaBytes', 'ExaBytes', 'YottaBytes');
|
||||
$unitsShort = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB');
|
||||
for ($level = 0; $bytes >= 1024; $level++) {
|
||||
$bytes /= 1024;
|
||||
}
|
||||
if (!is_numeric($bytes) || !isset($unitsShort[$level])) {
|
||||
return $bytes;
|
||||
}
|
||||
$pattern = '<span class="explain tooltip" title="%s">%s</span>';
|
||||
$suffix = sprintf($pattern, $unitsLong[$level], $unitsShort[$level]);
|
||||
if (!$useHtml) {
|
||||
$suffix = strip_tags($suffix);
|
||||
}
|
||||
$ret = sprintf("%01." . $precision . "f", round($bytes, $precision));
|
||||
return trim($ret . ' ' . $suffix);
|
||||
}
|
||||
|
||||
}
|
||||
44
application/views/helpers/Filesize.php
Normale Datei
44
application/views/helpers/Filesize.php
Normale Datei
|
|
@ -0,0 +1,44 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Output human readable byte output
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_Filesize extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public $view;
|
||||
public function setView(Zend_View_Interface $view)
|
||||
{
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output human readable filesize
|
||||
*
|
||||
* @param string $filename Filename to read size
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function filesize($file)
|
||||
{
|
||||
$size = 0;
|
||||
if (is_readable($file)) {
|
||||
$size = filesize($file);
|
||||
}
|
||||
$size = $this->view->byteOutput($size);
|
||||
return $size;
|
||||
}
|
||||
|
||||
}
|
||||
26
application/views/helpers/GetConfigTitle.php
Normale Datei
26
application/views/helpers/GetConfigTitle.php
Normale Datei
|
|
@ -0,0 +1,26 @@
|
|||
<?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 name of configuration
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_GetConfigTitle extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public function getConfigTitle($configName)
|
||||
{
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$configData = $config->loadConfiguration($configName, false);
|
||||
return $configData->general->title;
|
||||
}
|
||||
}
|
||||
35
application/views/helpers/GetFreeDiskspace.php
Normale Datei
35
application/views/helpers/GetFreeDiskspace.php
Normale Datei
|
|
@ -0,0 +1,35 @@
|
|||
<?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 free disk space
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_GetFreeDiskspace extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Get free diskspace
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFreeDiskspace()
|
||||
{
|
||||
$lang = Msd_Language::getInstance()->getTranslator();
|
||||
$ret = $lang->_('L_NOTAVAIL');
|
||||
$dfs = @diskfreespace(APPLICATION_PATH);
|
||||
if ($dfs) {
|
||||
$ret = $this->view->byteOutput($dfs);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
86
application/views/helpers/GetIcon.php
Normale Datei
86
application/views/helpers/GetIcon.php
Normale Datei
|
|
@ -0,0 +1,86 @@
|
|||
<?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'
|
||||
);
|
||||
}
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$img = '<img src="'.$baseUrl.'/%s/%s" alt="%s" title="%s" />';
|
||||
if ($size>'') {
|
||||
$img = '<img src="'.$baseUrl.'/%s/%sx%s/%s" alt="%s" title="%s" />';
|
||||
$ret = sprintf(
|
||||
$img,
|
||||
$config->get('paths.iconpath'),
|
||||
$size,
|
||||
$size,
|
||||
$icons[$name],
|
||||
$title, $title
|
||||
);
|
||||
} else {
|
||||
$ret = sprintf(
|
||||
$img,
|
||||
$config->get('paths.iconpath'),
|
||||
$icons[$name],
|
||||
$title,
|
||||
$title
|
||||
);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default values from defaultConfig.ini
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function _getIconFilenames ()
|
||||
{
|
||||
static $icons = false;
|
||||
if (!$icons) {
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$file = realpath(
|
||||
APPLICATION_PATH . DS . '..' . DS . 'public'
|
||||
. DS . $config->get('paths.iconpath') . DS . 'icon.ini'
|
||||
);
|
||||
$iconsIni = new Zend_Config_Ini($file, 'icons');
|
||||
$icons = $iconsIni->toArray();
|
||||
unset($iconsIni);
|
||||
}
|
||||
return $icons;
|
||||
}
|
||||
|
||||
}
|
||||
80
application/views/helpers/GetIconSrc.php
Normale Datei
80
application/views/helpers/GetIconSrc.php
Normale Datei
|
|
@ -0,0 +1,80 @@
|
|||
<?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 source
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_GetIconSrc extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Get path of an image
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $size
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIconSrc($name, $size='')
|
||||
{
|
||||
static $baseUrl = false;
|
||||
if (!$baseUrl) {
|
||||
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
|
||||
}
|
||||
$icons = self::_getIconFilenames();
|
||||
if (!isset($icons[$name])) {
|
||||
throw new Msd_Exception(
|
||||
'GetIconSrc: unknown icon \''.$name . '\' requested'
|
||||
);
|
||||
}
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$img = $baseUrl.'/%s/%s';
|
||||
if ($size>'') {
|
||||
$img = $baseUrl.'/%s/%sx%s/%s';
|
||||
$ret = sprintf(
|
||||
$img,
|
||||
$config->get('paths.iconpath'),
|
||||
$size,
|
||||
$size,
|
||||
$icons[$name]
|
||||
);
|
||||
} else {
|
||||
$ret = sprintf(
|
||||
$img, $config->get('paths.iconpath'), $icons[$name]
|
||||
);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default values from defaultConfig.ini
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function _getIconFilenames ()
|
||||
{
|
||||
static $icons = false;
|
||||
if (!$icons) {
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$file = realpath(
|
||||
APPLICATION_PATH . DS . '..' . DS . 'public'
|
||||
. DS . $config->get('paths.iconpath') . DS .'icon.ini'
|
||||
);
|
||||
$iconsIni = new Zend_Config_Ini($file, 'icons');
|
||||
$icons = $iconsIni->toArray();
|
||||
unset($iconsIni);
|
||||
}
|
||||
return $icons;
|
||||
}
|
||||
|
||||
}
|
||||
34
application/views/helpers/GetServerProtocol.php
Normale Datei
34
application/views/helpers/GetServerProtocol.php
Normale Datei
|
|
@ -0,0 +1,34 @@
|
|||
<?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 server protocol
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_GetServerProtocol extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Get server protocol
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServerProtocol()
|
||||
{
|
||||
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
|
||||
return 'https://';
|
||||
} else {
|
||||
return 'http://';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
32
application/views/helpers/GetUsername.php
Normale Datei
32
application/views/helpers/GetUsername.php
Normale Datei
|
|
@ -0,0 +1,32 @@
|
|||
<?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 name of currently logged in user
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_GetUsername extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Get name of currently logged in user
|
||||
*
|
||||
* @param string $time
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
$auth =Zend_Auth::getInstance()->getIdentity();
|
||||
return $auth['name'];
|
||||
}
|
||||
}
|
||||
35
application/views/helpers/IsTableOptimizable.php
Normale Datei
35
application/views/helpers/IsTableOptimizable.php
Normale Datei
|
|
@ -0,0 +1,35 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check if engine of table supports optimization
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_IsTableOptimizable extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Detect if the table engine allwos optimization.
|
||||
*
|
||||
* @param string $tableEngine The engine of the table
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTableOptimizable($tableEngine)
|
||||
{
|
||||
$optimizable = array('MyISAM', 'InnoDB', 'ARCHIVE');
|
||||
if (in_array($tableEngine, $optimizable)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
31
application/views/helpers/JsEscape.php
Normale Datei
31
application/views/helpers/JsEscape.php
Normale Datei
|
|
@ -0,0 +1,31 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Escape quotes in strings placed inside javascript alerts or confirms
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_JsEscape extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Escape quotes
|
||||
*
|
||||
* @param string $text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsEscape($text)
|
||||
{
|
||||
return str_replace('\'', '\\\'', $text);
|
||||
}
|
||||
}
|
||||
105
application/views/helpers/Menu.php
Normale Datei
105
application/views/helpers/Menu.php
Normale Datei
|
|
@ -0,0 +1,105 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the menu
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_Menu extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Renders the menu
|
||||
*
|
||||
* @param Msd_Version $version Msd_Version object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function menu(Msd_Version $version)
|
||||
{
|
||||
$front = Zend_Controller_Front::getInstance();
|
||||
$request = $front->getRequest();
|
||||
if ($request->getActionName() == 'login') {
|
||||
// reset menu state. Maybe user logs in again and has blended out
|
||||
// the menu before.
|
||||
$this->_resetMenuState();
|
||||
//don't render menu when we show the login form
|
||||
return;
|
||||
}
|
||||
$view = $this->view;
|
||||
$view->databases = $this->_getDatabases();
|
||||
$view->showMenu = $this->_isMenuShown();
|
||||
$view->msdVersion = $version->getMsdVersion();
|
||||
$menu = $view->render('index/menu.phtml');
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of databases
|
||||
*
|
||||
* Returns the list of accessable databases for actual user. If no database
|
||||
* is selected, set first one as active and use it.
|
||||
*
|
||||
* @return array Numeric array with names of databases
|
||||
*/
|
||||
private function _getDatabases()
|
||||
{
|
||||
$actualDb = $this->view->config->get('dynamic.dbActual');
|
||||
$databases = $this->view->config->get('dynamic.databases');
|
||||
$dbo = Msd_Db::getAdapter();
|
||||
if (empty($databases) || $dbo->selectDb($actualDb) !== true) {
|
||||
// couldn't connect to db - refresh db-list
|
||||
$databases = $dbo->getDatabaseNames();
|
||||
// if database was deleted or is not accessible by user
|
||||
// fallback to default db
|
||||
$defaultDb = $this->view->config->get('config.dbuser.defaultDb');
|
||||
if ($defaultDb != '') {
|
||||
$actualDb = $defaultDb;
|
||||
if ($dbo->selectDb($actualDb) !== true) {
|
||||
// couldn't connect to default db - fallback to first found
|
||||
$actualDb = $databases[0];
|
||||
$dbo->selectDb($actualDb);
|
||||
}
|
||||
}
|
||||
$this->view->config->set('dynamic.dbActual', $actualDb);
|
||||
$this->view->config->set('dynamic.databases', $databases);
|
||||
}
|
||||
return $databases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if menu must be shown or hidden.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function _isMenuShown()
|
||||
{
|
||||
$menu = new Zend_Session_Namespace('menu');
|
||||
if (!isset($menu->showMenu)) {
|
||||
$menu->showMenu = 1;
|
||||
};
|
||||
return (int) $menu->showMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set menu state to "show".
|
||||
*
|
||||
* Actual menu state is saved to session
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _resetMenuState()
|
||||
{
|
||||
$menu = new Zend_Session_Namespace('menu');
|
||||
$menu->showMenu = 1;
|
||||
}
|
||||
}
|
||||
34
application/views/helpers/NumberFormat.php
Normale Datei
34
application/views/helpers/NumberFormat.php
Normale Datei
|
|
@ -0,0 +1,34 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Formats a number
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_NumberFormat extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Format a number and return string ready to output
|
||||
*
|
||||
* @param float $nr Number to format
|
||||
* @param int $precision Precision defaults to 0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function numberFormat($number, $precision = 0)
|
||||
{
|
||||
$number = round($number, $precision);
|
||||
$ret = number_format($number, $precision, ',', '.');
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
49
application/views/helpers/Out.php
Normale Datei
49
application/views/helpers/Out.php
Normale Datei
|
|
@ -0,0 +1,49 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert output to HTML
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_Out extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Helper to convert common values to HTML output
|
||||
*
|
||||
* Escape values
|
||||
* Conditionally convert NULL values to "NULL" as string.
|
||||
* Conditionally surround value with a HTML tag.
|
||||
*
|
||||
* @param string $value The value that may be converted
|
||||
* @param boolean $ouputNull Whether to convert NULL values to string NULL
|
||||
* @param string $decorator Decorate output with this HTML-Tag
|
||||
*
|
||||
* @return string HTML-Text ready to print to screen
|
||||
*/
|
||||
public function out($value, $outputNull = false, $decorator = '')
|
||||
{
|
||||
$ret = $this->view->escape($value);
|
||||
if ($outputNull === true && is_null($value)) {
|
||||
$ret = 'NULL';
|
||||
}
|
||||
if ($decorator > '') {
|
||||
/*
|
||||
* '%1$s means: Use the same value as in the first appearance of
|
||||
* '%s' is used.
|
||||
*/
|
||||
$ret = sprintf('<%s>'.$ret.'</%1$s>', $decorator);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
254
application/views/helpers/Paginator.php
Normale Datei
254
application/views/helpers/Paginator.php
Normale Datei
|
|
@ -0,0 +1,254 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build a paginator.
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_Paginator extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Types for the buttons in the view script.
|
||||
* The type depends on the current mode.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_buttonTypes = array(
|
||||
'form' => 'submit',
|
||||
'js' => 'button',
|
||||
'url' => 'button',
|
||||
);
|
||||
|
||||
/**
|
||||
* Defaults for the options. This array is used to fill missing options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_defaults = array(
|
||||
'currentPage' => 1,
|
||||
'pageCount' => 1,
|
||||
'urlParam' => 'pageNr',
|
||||
'baseUrl' => '',
|
||||
'mode' => 'form',
|
||||
'actions' => array(
|
||||
'first' => '',
|
||||
'prev' => '',
|
||||
'next' => '',
|
||||
'last' => '',
|
||||
'change' => '',
|
||||
),
|
||||
'method' => 'post',
|
||||
'enctype' => 'multipart/form-data',
|
||||
);
|
||||
|
||||
/**
|
||||
* Builds a paginator depending on the given options.
|
||||
*
|
||||
* <code>
|
||||
* <?php
|
||||
* $options = array(
|
||||
* 'currentPage', // Number of the currently selected page.
|
||||
* 'pageCount', // Number of total pages.
|
||||
* 'urlParam', // Name of the url parameter which gets the new selected page number.
|
||||
* 'baseUrl', // Base URL for form action and buttons. urlParam and new page number will be appended.
|
||||
* 'mode', // Mode, in which the paginator operates (can be "form", "url" or "js")
|
||||
* 'actions' => array( // JS code for the buttons in "js" mode and JS code for the text input field.
|
||||
* 'first', // The string ":PAGE:" will be replaced with the target page number.
|
||||
* 'prev',
|
||||
* 'next',
|
||||
* 'last',
|
||||
* 'change', // If you want to call a JS function with the new page number as parameter
|
||||
* ), // use "myFunc(this.value);".
|
||||
* 'method', // Value for "method" HTML attribute of the "form" tag.
|
||||
* 'enctype', // Value for "enctype" HTML attribute of the "form" tag.
|
||||
* );
|
||||
* ?>
|
||||
* <code>
|
||||
*
|
||||
* @param array $options Options for the paginator
|
||||
*
|
||||
* @return string HTML code for view script inclusion
|
||||
*/
|
||||
public function paginator(array $options)
|
||||
{
|
||||
$view = clone $this->view;
|
||||
$view->clearVars();
|
||||
|
||||
$options = array_merge($this->_defaults, $options);
|
||||
|
||||
$buttons = $this->_getButtons($options);
|
||||
$onChange = $this->_getOnChange($options['mode'], $options['baseUrl'], $options['urlParam']);
|
||||
if ($options['mode'] == 'js') {
|
||||
$onChange = $this->_getOnChange($options['mode'], $options['actions']['change'], $options['urlParam']);
|
||||
}
|
||||
|
||||
$viewData = array(
|
||||
'currentPage' => $options['currentPage'],
|
||||
'pageCount' => $options['pageCount'],
|
||||
'urlParam' => $options['urlParam'],
|
||||
'onChange' => $onChange,
|
||||
'buttonType' => $this->_buttonTypes[$options['mode']],
|
||||
'first' => $buttons['first'],
|
||||
'prev' => $buttons['prev'],
|
||||
'next' => $buttons['next'],
|
||||
'last' => $buttons['last'],
|
||||
'formEncType' => $options['enctype'],
|
||||
'formAction' => $options['baseUrl'],
|
||||
'formMethod' => $options['method'],
|
||||
);
|
||||
|
||||
$view->assign($viewData);
|
||||
return $view->render('helper/paginator.phtml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the information for the buttons (first page, previous page, next page and last page).
|
||||
*
|
||||
* @param array $options Button options
|
||||
*
|
||||
* @return array Information for the view script
|
||||
*/
|
||||
protected function _getButtons(array $options)
|
||||
{
|
||||
$buttons = array();
|
||||
$buttons['first'] = $this->_getButtonInfo(
|
||||
(bool) ($options['currentPage'] <= 1)
|
||||
);
|
||||
$buttons['first']['icon'] = 'First' . $buttons['first']['icon'];
|
||||
$buttons['first']['click'] = $this->_getButtonClick(
|
||||
$options['mode'],
|
||||
array(
|
||||
'targetPage' => 1,
|
||||
'onClick' => $options['actions']['first'],
|
||||
'baseUrl' => $options['baseUrl'],
|
||||
'urlParam' => $options['urlParam'],
|
||||
)
|
||||
);
|
||||
|
||||
$buttons['prev'] = $this->_getButtonInfo(
|
||||
(bool) ($options['currentPage'] <= 1)
|
||||
);
|
||||
$buttons['prev']['icon'] = 'Back' . $buttons['prev']['icon'];
|
||||
$buttons['prev']['click'] = $this->_getButtonClick(
|
||||
$options['mode'],
|
||||
array(
|
||||
'targetPage' => $options['currentPage'] - 1,
|
||||
'onClick' => $options['actions']['prev'],
|
||||
'baseUrl' => $options['baseUrl'],
|
||||
'urlParam' => $options['urlParam'],
|
||||
)
|
||||
);
|
||||
|
||||
$buttons['next'] = $this->_getButtonInfo(
|
||||
(bool) ($options['currentPage'] >= $options['pageCount'])
|
||||
);
|
||||
$buttons['next']['icon'] = 'Forward' . $buttons['next']['icon'];
|
||||
$buttons['next']['click'] = $this->_getButtonClick(
|
||||
$options['mode'],
|
||||
array(
|
||||
'targetPage' => $options['currentPage'] + 1,
|
||||
'onClick' => $options['actions']['next'],
|
||||
'baseUrl' => $options['baseUrl'],
|
||||
'urlParam' => $options['urlParam'],
|
||||
)
|
||||
);
|
||||
|
||||
$buttons['last'] = $this->_getButtonInfo(
|
||||
(bool) ($options['currentPage'] >= $options['pageCount'])
|
||||
);
|
||||
$buttons['last']['icon'] = 'Last' . $buttons['last']['icon'];
|
||||
$buttons['last']['click'] = $this->_getButtonClick(
|
||||
$options['mode'],
|
||||
array(
|
||||
'targetPage' => $options['pageCount'],
|
||||
'onClick' => $options['actions']['last'],
|
||||
'baseUrl' => $options['baseUrl'],
|
||||
'urlParam' => $options['urlParam'],
|
||||
)
|
||||
);
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the basic info for a button (disabled status and disabled suffix for buttons icon)
|
||||
*
|
||||
* @param bool $disabled Status of the button
|
||||
*
|
||||
* @return array Basic info about the button
|
||||
*/
|
||||
protected function _getButtonInfo($disabled)
|
||||
{
|
||||
return array(
|
||||
'disabled' => $disabled ? ' disabled="disabled"' : '',
|
||||
'icon' => $disabled ? 'Disabled' : '',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the javascript code for the HTML attribute "onclick".
|
||||
*
|
||||
* @param string $mode Current paginator mode (can be "form", "url" or "js")
|
||||
* @param array $options Options for the "onclick" attribute
|
||||
*
|
||||
* @return string JS-Code for the "onclick" attribute
|
||||
*/
|
||||
protected function _getButtonClick($mode, array $options)
|
||||
{
|
||||
$onClick = '';
|
||||
|
||||
if ($mode == 'form') {
|
||||
$onClick = "$(this).parent().children('select').val(" . $options['targetPage'] . "); "
|
||||
. "$(this).parent().parent()[0].submit();";
|
||||
}
|
||||
|
||||
if ($mode == 'url') {
|
||||
$onClick = "window.location.href = '" . rtrim($options['baseUrl'], '/')
|
||||
. "/{$options['urlParam']}/{$options['targetPage']}/';";
|
||||
}
|
||||
|
||||
if ($mode == 'js') {
|
||||
$onClick = str_replace(':PAGE:', $options['targetPage'], $options['onClick']);
|
||||
}
|
||||
|
||||
return $onClick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the Javascript code for "onchange" HTML attribute.
|
||||
* This code is used for the combobox.
|
||||
*
|
||||
* @param string $mode Current paginator mode (can be "form", "url" or "js")
|
||||
* @param string $baseUrl Base URL or Javascript code for the event.
|
||||
* @param string $urlParam Name of the URL param. Its value will set to the entered page.
|
||||
*
|
||||
* @return string JS-Code for the "onchange" HTML attribute.
|
||||
*/
|
||||
protected function _getOnChange($mode, $baseUrl = '', $urlParam = '')
|
||||
{
|
||||
$onChange = "";
|
||||
if ($mode == 'form') {
|
||||
$onChange = "$(this).parent().parent()[0].submit();";
|
||||
}
|
||||
|
||||
if ($mode == 'url') {
|
||||
$onChange = "window.location.href = '" . rtrim($baseUrl, '/') . "/$urlParam/' + this.value + '/';";
|
||||
}
|
||||
|
||||
if ($mode == 'js') {
|
||||
$onChange = "$baseUrl";
|
||||
}
|
||||
|
||||
return $onChange;
|
||||
}
|
||||
}
|
||||
178
application/views/helpers/PopUpMessage.php
Normale Datei
178
application/views/helpers/PopUpMessage.php
Normale Datei
|
|
@ -0,0 +1,178 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Displayment of messages
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_PopUpMessage extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Stores the information about the messages to display.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_messages = array();
|
||||
|
||||
/**
|
||||
* Mapping of Msd_Config position to jquery ui param
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_positions = array(
|
||||
'topLeft' => array('left','top'),
|
||||
'topCenter' => array('center','top'),
|
||||
'topRight' => array('right','top'),
|
||||
'middleLeft' => array('left','center'),
|
||||
'middleCenter' => array('center','center'),
|
||||
'middleRight' => array('right','center'),
|
||||
'bottomLeft' => array('left','bottom'),
|
||||
'bottomCenter' => array('center','bottom'),
|
||||
'bottomRight' => array('right','bottom'),
|
||||
);
|
||||
|
||||
/**
|
||||
* returns the instance of this view helper.
|
||||
*
|
||||
* @return Zend_View_Helper_PopUpMessage
|
||||
*/
|
||||
public function popUpMessage()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new message to the stack.
|
||||
*
|
||||
* @param string $messageId Dom-Id of the dialog
|
||||
* @param string $title Title for the dialog
|
||||
* @param string|array $message Message to display
|
||||
* @param array $options Additional options for the dialog box
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addMessage($messageId, $title, $message, $options = array())
|
||||
{
|
||||
$lang = Msd_Language::getInstance();
|
||||
$translator = $lang->getTranslator();
|
||||
$optionKeys = array_keys($options);
|
||||
if (!in_array('buttons', $optionKeys)) {
|
||||
$options['buttons'] = array(
|
||||
'L_OK' => 'function() {$(this).dialog(\'close\');}'
|
||||
);
|
||||
}
|
||||
$translatedButtons = array();
|
||||
foreach ($options['buttons'] as $key => $value) {
|
||||
$translatedButtons[ucfirst($translator->_($key))] = $value;
|
||||
}
|
||||
$options['buttons'] = $translatedButtons;
|
||||
if (!in_array('dialogClass', $optionKeys)) {
|
||||
$options['dialogClass'] = 'info';
|
||||
}
|
||||
if (!in_array('position', $optionKeys)) {
|
||||
$options['position'] = $this->_getDefaultPosition();
|
||||
}
|
||||
$options['title'] = $translator->_($title);
|
||||
if (!empty($message)) {
|
||||
if (is_array($message)) {
|
||||
$message[0] = $translator->_($message[0]);
|
||||
$message = call_user_func_array('sprintf', $message);
|
||||
} else {
|
||||
$message = $translator->_($message);
|
||||
}
|
||||
}
|
||||
$this->_messages[$messageId] = array(
|
||||
'message' => $message,
|
||||
'params' => $options,
|
||||
'attribs' => array(
|
||||
'id' => $messageId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the dialogs.
|
||||
*
|
||||
* Add "OnLoad" scripts to jQuery and create the HTML-Output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$messages = array();
|
||||
foreach ($this->_messages as $messageInfo) {
|
||||
$html = '<div class="nodisplay"';
|
||||
foreach ($messageInfo['attribs'] as $attribName => $attribValue) {
|
||||
$html .= ' ' . $attribName . '="' . $attribValue . '"';
|
||||
}
|
||||
$html .= '>' . $messageInfo['message'] . '</div>';
|
||||
$javascript = sprintf(
|
||||
'%s(\'#%s\').dialog(%s);',
|
||||
ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
|
||||
$messageInfo['attribs']['id'],
|
||||
$this->_renderOptions($messageInfo['params'])
|
||||
);
|
||||
$this->view->jQuery()->addOnLoad($javascript);
|
||||
$messages[] = $html;
|
||||
}
|
||||
return implode("\n", $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the dialog options.
|
||||
*
|
||||
* This will return modified but valid JSON.
|
||||
*
|
||||
* @param array $options Dialog options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _renderOptions($options)
|
||||
{
|
||||
$json = '{';
|
||||
$opts = array();
|
||||
foreach ($options as $key => $value) {
|
||||
$jsonOpt = $key . ': ';
|
||||
if (is_array($value)) {
|
||||
$jsonOpt .= $this->_renderOptions($value);
|
||||
} elseif (is_bool($value)) {
|
||||
$jsonOpt .= $value === true ? 'true':'false';
|
||||
} elseif (
|
||||
is_numeric($value) || strpos($value, 'function') !== false
|
||||
) {
|
||||
$jsonOpt .= $value;
|
||||
} else {
|
||||
$jsonOpt .= '"' . $value . '"';
|
||||
}
|
||||
$opts[] = $jsonOpt;
|
||||
}
|
||||
$json .= implode(',', $opts) . '}';
|
||||
return $json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get position of notification window from config and mapt to jQueryUi
|
||||
*
|
||||
* @return array Array containing jQuerUi-params
|
||||
*/
|
||||
private function _getDefaultPosition()
|
||||
{
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$position = $config->get('config.interface.notificationWindowPosition');
|
||||
if (isset($this->_positions[$position])) {
|
||||
$position = $this->_positions[$position];
|
||||
}
|
||||
return $position;
|
||||
}
|
||||
}
|
||||
|
||||
26
application/views/helpers/SqlHeadNavi.php
Normale Datei
26
application/views/helpers/SqlHeadNavi.php
Normale Datei
|
|
@ -0,0 +1,26 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the SqlBrowser head naviagtion menu
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_SqlHeadNavi extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public function sqlHeadNavi()
|
||||
{
|
||||
$view = $this->view;
|
||||
return $view->render('sql/sql-head-navi.phtml');
|
||||
}
|
||||
|
||||
}
|
||||
37
application/views/helpers/TimeToDate.php
Normale Datei
37
application/views/helpers/TimeToDate.php
Normale Datei
|
|
@ -0,0 +1,37 @@
|
|||
<?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$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a formatted string from a w3c timestamp
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage View_Helpers
|
||||
*/
|
||||
class Msd_View_Helper_TimeToDate extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Get date by native w3c timestamp
|
||||
*
|
||||
* @param string $time
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function timeToDate($time)
|
||||
{
|
||||
Zend_Date::setOptions(array('format_type' => 'php'));
|
||||
try {
|
||||
$date = new Zend_Date($time);
|
||||
return $date->toString("d.m.Y H:i:s");
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren