getPath() . '/info.inc.php')) { return false; } if ($this->mtime_info === filemtime($this->getPath() . '/info.inc.php')) { return true; } @include $this->getPath() . '/info.inc.php'; // was it set correctly? if (! isset($theme_name)) { return false; } $this->mtime_info = filemtime($this->getPath() . '/info.inc.php'); $this->filesize_info = filesize($this->getPath() . '/info.inc.php'); if (isset($theme_full_version)) { $this->setVersion($theme_full_version); } elseif (isset($theme_generation, $theme_version)) { $this->setVersion($theme_generation . '.' . $theme_version); } $this->setName($theme_name); return true; } /** * returns theme object loaded from given folder * or false if theme is invalid * * @param string $folder path to theme * * @return PMA_Theme|false * @static * @access public */ static public function load($folder) { $theme = new PMA_Theme(); $theme->setPath($folder); if (! $theme->loadInfo()) { return false; } $theme->checkImgPath(); return $theme; } /** * checks image path for existance - if not found use img from fallback theme * * @access public * @return bool */ public function checkImgPath() { // try current theme first if (is_dir($this->getPath() . '/img/')) { $this->setImgPath($this->getPath() . '/img/'); return true; } // try fallback theme $fallback = $GLOBALS['cfg']['ThemePath'] . '/' . PMA_Theme_Manager::FALLBACK_THEME . '/img/'; if (is_dir($fallback)) { $this->setImgPath($fallback); return true; } // we failed trigger_error( sprintf( __('No valid image path for theme %s found!'), $this->getName() ), E_USER_ERROR ); return false; } /** * returns path to theme * * @access public * @return string path to theme */ public function getPath() { return $this->path; } /** * returns layout file * * @access public * @return string layout file */ public function getLayoutFile() { return $this->getPath() . '/layout.inc.php'; } /** * set path to theme * * @param string $path path to theme * * @return void * @access public */ public function setPath($path) { $this->path = trim($path); } /** * sets version * * @param string $version version to set * * @return void * @access public */ public function setVersion($version) { $this->version = trim($version); } /** * returns version * * @return string version * @access public */ public function getVersion() { return $this->version; } /** * checks theme version agaisnt $version * returns true if theme version is equal or higher to $version * * @param string $version version to compare to * * @return boolean true if theme version is equal or higher to $version * @access public */ public function checkVersion($version) { return version_compare($this->getVersion(), $version, 'lt'); } /** * sets name * * @param string $name name to set * * @return void * @access public */ public function setName($name) { $this->name = trim($name); } /** * returns name * * @access public * @return string name */ public function getName() { return $this->name; } /** * sets id * * @param string $id new id * * @return void * @access public */ public function setId($id) { $this->id = trim($id); } /** * returns id * * @return string id * @access public */ public function getId() { return $this->id; } /** * Sets path to images for the theme * * @param string $path path to images for this theme * * @return void * @access public */ public function setImgPath($path) { $this->img_path = $path; } /** * Returns the path to image for the theme. * If filename is given, it possibly fallbacks to fallback * theme for it if image does not exist. * * @param string $file file name for image * * @access public * @return string image path for this theme */ public function getImgPath($file = null) { if (is_null($file)) { return $this->img_path; } else { if (is_readable($this->img_path . $file)) { return $this->img_path . $file; } else { return $GLOBALS['cfg']['ThemePath'] . '/' . PMA_Theme_Manager::FALLBACK_THEME . '/img/' . $file; } } } /** * load css (send to stdout, normally the browser) * * @return bool * @access public */ public function loadCss() { $success = true; if ($GLOBALS['text_dir'] === 'ltr') { $right = 'right'; $left = 'left'; } else { $right = 'left'; $left = 'right'; } foreach ($this->_cssFiles as $file) { $path = $this->getPath() . "/css/$file.css.php"; $fallback = "./themes/" . PMA_Theme_Manager::FALLBACK_THEME . "/css/$file.css.php"; if (is_readable($path)) { echo "\n/* FILE: $file.css.php */\n"; include $path; } else if (is_readable($fallback)) { echo "\n/* FILE: $file.css.php */\n"; include $fallback; } else { $success = false; } } include './themes/sprites.css.php'; return $success; } /** * Renders the preview for this theme * * @return string * @access public */ public function getPrintPreview() { $url_params = array('set_theme' => $this->getId()); $url = 'index.php'. PMA_URL_getCommon($url_params); $retval = '