added some functionality
This commit is contained in:
@@ -28,6 +28,11 @@ class PMA_Theme {
|
|||||||
*/
|
*/
|
||||||
var $img_path = '';
|
var $img_path = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array valid css types
|
||||||
|
*/
|
||||||
|
var $types = array( 'left', 'right', 'print' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns theme object loaded from given folder
|
* returns theme object loaded from given folder
|
||||||
* or false if theme is invalid
|
* or false if theme is invalid
|
||||||
@@ -74,22 +79,64 @@ class PMA_Theme {
|
|||||||
return $theme;
|
return $theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns path to theme
|
||||||
|
* @uses $this->$path as return value
|
||||||
|
* @return string $path path to theme
|
||||||
|
*/
|
||||||
function getPath() {
|
function getPath() {
|
||||||
return $this->path;
|
return $this->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns layout file
|
||||||
|
*
|
||||||
|
* @return string layout file
|
||||||
|
*/
|
||||||
|
function getLayoutFile() {
|
||||||
|
return $this->getPath() . '/layout.inc.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set path to theme
|
||||||
|
* @uses $this->$path to set it
|
||||||
|
* @param string $path path to theme
|
||||||
|
*/
|
||||||
function setPath( $path ) {
|
function setPath( $path ) {
|
||||||
$this->path = trim( $path );
|
$this->path = trim( $path );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets version
|
* sets version
|
||||||
|
* @uses $this->version
|
||||||
* @param string new version
|
* @param string new version
|
||||||
*/
|
*/
|
||||||
function setVersion( $version ) {
|
function setVersion( $version ) {
|
||||||
$this->version = trim( $version );
|
$this->version = trim( $version );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns version
|
||||||
|
* @uses $this->version
|
||||||
|
* @return string version
|
||||||
|
*/
|
||||||
|
function getVersion() {
|
||||||
|
return $this->version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* checks theme version agaisnt $version
|
||||||
|
* returns true if theme version is equal or higher to $version
|
||||||
|
*
|
||||||
|
* @uses version_compare()
|
||||||
|
* @uses $this->getVersion()
|
||||||
|
* @param string $version version to compare to
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function checkVersion( $version ) {
|
||||||
|
return version_compare( $this->getVersion(), $version, 'lt' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets name
|
* sets name
|
||||||
* @param string $name new name
|
* @param string $name new name
|
||||||
@@ -129,6 +176,41 @@ class PMA_Theme {
|
|||||||
function getImgPath() {
|
function getImgPath() {
|
||||||
return $this->img_path;
|
return $this->img_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load css (send to stdout, normaly the browser)
|
||||||
|
*
|
||||||
|
* @uses $this->getPath()
|
||||||
|
* @uses $this->types
|
||||||
|
* @uses PMA_SQP_buildCssData()
|
||||||
|
* @uses file_exists()
|
||||||
|
* @uses in_array()
|
||||||
|
* @param string $type left, right or print
|
||||||
|
*/
|
||||||
|
function loadCss( &$type ) {
|
||||||
|
if ( empty( $type ) || ! in_array( $type, $this->types ) ) {
|
||||||
|
$type = 'left';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $type == 'right' ) {
|
||||||
|
echo PMA_SQP_buildCssData();
|
||||||
|
}
|
||||||
|
|
||||||
|
$_css_file = $this->getPath()
|
||||||
|
. '/css/theme_' . $type . '.css.php';
|
||||||
|
|
||||||
|
if ( file_exists( $_css_file ) ) {
|
||||||
|
if ( $GLOBALS['text_dir'] === 'ltr' ) {
|
||||||
|
$right = 'right';
|
||||||
|
$left = 'left';
|
||||||
|
} else {
|
||||||
|
$right = 'left';
|
||||||
|
$left = 'right';
|
||||||
|
}
|
||||||
|
|
||||||
|
include( $_css_file );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@@ -83,7 +83,8 @@ class PMA_Theme_Manager {
|
|||||||
$this->active_theme = $theme;
|
$this->active_theme = $theme;
|
||||||
$this->theme = $this->themes[$theme];
|
$this->theme = $this->themes[$theme];
|
||||||
|
|
||||||
$this->setThemeCookie();
|
// need to set later
|
||||||
|
//$this->setThemeCookie();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -100,6 +101,10 @@ class PMA_Theme_Manager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns name of theme stored in the cookie
|
||||||
|
* @return string theme name from cookie
|
||||||
|
*/
|
||||||
function getThemeCookie() {
|
function getThemeCookie() {
|
||||||
if ( isset( $_COOKIE[$this->getThemeCookieName()] ) ) {
|
if ( isset( $_COOKIE[$this->getThemeCookieName()] ) ) {
|
||||||
return $_COOKIE[$this->getThemeCookieName()];
|
return $_COOKIE[$this->getThemeCookieName()];
|
||||||
@@ -110,21 +115,16 @@ class PMA_Theme_Manager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* save theme in cookie
|
* save theme in cookie
|
||||||
|
*
|
||||||
|
* @uses PMA_setCookie();
|
||||||
|
* @uses PMA_Theme_Manager::getThemeCookieName()
|
||||||
|
* @uses PMA_Theme_Manager::$theme
|
||||||
|
* @uses PMA_Theme_Manager::$theme_default
|
||||||
|
* @uses PMA_Theme::getId()
|
||||||
*/
|
*/
|
||||||
function setThemeCookie() {
|
function setThemeCookie() {
|
||||||
if ( $this->theme_default === $this->theme->getId() ) {
|
PMA_setCookie( $this->getThemeCookieName(), $this->theme->id,
|
||||||
// remove cookie
|
$this->theme_default );
|
||||||
setcookie( $this->getThemeCookieName(), $this->theme->getId(),
|
|
||||||
time() - 3600, $GLOBALS['cookie_path'], '', $GLOBALS['is_https'] );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $this->getThemeCookie() === $this->theme->getId() ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
setcookie( $this->getThemeCookieName(), $this->theme->getId(),
|
|
||||||
time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https'] );
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,10 +187,12 @@ class PMA_Theme_Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getHtmlSelectBox( $form = true ) {
|
function getHtmlSelectBox( $form = true ) {
|
||||||
|
$select_box = '';
|
||||||
|
|
||||||
if ( $form ) {
|
if ( $form ) {
|
||||||
echo '<form name="setTheme" method="post" action="index.php"'
|
$select_box .= '<form name="setTheme" method="post" action="index.php"'
|
||||||
.' target="_parent">';
|
.' target="_parent">';
|
||||||
echo PMA_generate_common_hidden_inputs();
|
$select_box .= PMA_generate_common_hidden_inputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
$theme_selected = FALSE;
|
$theme_selected = FALSE;
|
||||||
@@ -198,23 +200,25 @@ class PMA_Theme_Manager {
|
|||||||
$theme_preview_href = '<a href="' . $theme_preview_path . '" target="themes" onclick="'
|
$theme_preview_href = '<a href="' . $theme_preview_path . '" target="themes" onclick="'
|
||||||
. "window.open('" . $theme_preview_path . "','themes','left=10,top=20,width=510,height=350,scrollbars=yes,status=yes,resizable=yes');"
|
. "window.open('" . $theme_preview_path . "','themes','left=10,top=20,width=510,height=350,scrollbars=yes,status=yes,resizable=yes');"
|
||||||
. '">';
|
. '">';
|
||||||
echo $theme_preview_href . $GLOBALS['strTheme'] . '</a>:' . "\n";
|
$select_box .= $theme_preview_href . $GLOBALS['strTheme'] . '</a>:' . "\n";
|
||||||
|
|
||||||
echo '<select name="set_theme" xml:lang="en" dir="ltr"'
|
$select_box .= '<select name="set_theme" xml:lang="en" dir="ltr"'
|
||||||
.' onchange="this.form.submit();" >';
|
.' onchange="this.form.submit();" >';
|
||||||
foreach ( $this->themes as $each_theme_id => $each_theme ) {
|
foreach ( $this->themes as $each_theme_id => $each_theme ) {
|
||||||
echo '<option value="' . $each_theme_id . '"';
|
$select_box .= '<option value="' . $each_theme_id . '"';
|
||||||
if ( $this->active_theme === $each_theme_id ) {
|
if ( $this->active_theme === $each_theme_id ) {
|
||||||
echo ' selected="selected"';
|
$select_box .= ' selected="selected"';
|
||||||
}
|
}
|
||||||
echo '>' . htmlspecialchars( $each_theme->getName() ) . '</option>';
|
$select_box .= '>' . htmlspecialchars( $each_theme->getName() ) . '</option>';
|
||||||
}
|
}
|
||||||
echo '</select>';
|
$select_box .= '</select>';
|
||||||
|
|
||||||
if ( $form ) {
|
if ( $form ) {
|
||||||
echo '<noscript><input type="submit" value="' . $GLOBALS['strGo'] . '" /></noscript>';
|
$select_box .= '<noscript><input type="submit" value="' . $GLOBALS['strGo'] . '" /></noscript>';
|
||||||
echo '</form>';
|
$select_box .= '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $select_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user