3 // vim: expandtab sw=4 ts=4 sts=4:
9 var $version = '0.0.0.0';
32 * @var array valid css types
34 var $types = array('left', 'right', 'print');
37 * @var integer last modification time for info file
44 $this->checkImgPath();
49 if (! file_exists($this->getPath() . '/info.inc.php')) {
53 if ($this->mtime_info
=== filemtime($this->getPath() . '/info.inc.php')) {
57 @include
$this->getPath() . '/info.inc.php';
59 // did it set correctly?
60 if (! isset($theme_name)) {
64 $this->mtime_info
= filemtime($this->getPath() . '/info.inc.php');
66 if (isset($theme_full_version)) {
67 $this->setVersion($theme_full_version);
68 } elseif (isset($theme_generation, $theme_version)) {
69 $this->setVersion($theme_generation . '.' . $theme_version);
71 $this->setName($theme_name);
77 * returns theme object loaded from given folder
78 * or false if theme is invalid
81 * @param string path to theme
82 * @return object PMA_Theme
84 function load($folder)
87 $theme = new PMA_Theme();
89 $theme->setPath($folder);
91 if (! $theme->loadInfo()) {
95 $theme->checkImgPath();
100 function checkImgPath()
102 if (is_dir($this->getPath() . '/img/')) {
103 $this->setImgPath($this->getPath() . '/img/');
105 } elseif (is_dir($GLOBALS['cfg']['ThemePath'] . '/original/img/')) {
106 $this->setImgPath($GLOBALS['cfg']['ThemePath'] . '/original/img/');
109 $GLOBALS['PMA_errors'][] =
110 sprintf($GLOBALS['strThemeNoValidImgPath'], $this->getName());
112 sprintf($GLOBALS['strThemeNoValidImgPath'], $this->getName()),
119 * returns path to theme
120 * @uses $this->$path as return value
121 * @return string $path path to theme
129 * returns layout file
131 * @return string layout file
133 function getLayoutFile()
135 return $this->getPath() . '/layout.inc.php';
140 * @uses $this->$path to set it
141 * @param string $path path to theme
143 function setPath($path)
145 $this->path
= trim($path);
150 * @uses $this->version
151 * @param string new version
153 function setVersion($version)
155 $this->version
= trim($version);
160 * @uses $this->version
161 * @return string version
163 function getVersion()
165 return $this->version
;
169 * checks theme version agaisnt $version
170 * returns true if theme version is equal or higher to $version
172 * @uses version_compare()
173 * @uses $this->getVersion()
174 * @param string $version version to compare to
177 function checkVersion($version)
179 return version_compare($this->getVersion(), $version, 'lt');
184 * @param string $name new name
186 function setName($name)
188 $this->name
= trim($name);
193 * @return string name
202 * @param string $id new id
206 $this->id
= trim($id);
218 function setImgPath($path)
220 $this->img_path
= $path;
223 function getImgPath()
225 return $this->img_path
;
229 * load css (send to stdout, normaly the browser)
231 * @uses $this->getPath()
233 * @uses PMA_SQP_buildCssData()
234 * @uses file_exists()
236 * @param string $type left, right or print
238 function loadCss(&$type)
240 if (empty($type) ||
! in_array($type, $this->types
)) {
244 if ($type == 'right') {
245 echo PMA_SQP_buildCssData();
248 $_css_file = $this->getPath()
249 . '/css/theme_' . $type . '.css.php';
251 if (! file_exists($_css_file)) {
255 if ($GLOBALS['text_dir'] === 'ltr') {
268 * prints out the preview for this theme
270 * @uses $this->getName()
271 * @uses $this->getVersion()
272 * @uses $this->getId()
273 * @uses $this->getPath()
274 * @uses $GLOBALS['strThemeNoPreviewAvailable']
275 * @uses $GLOBALS['strTakeIt']
276 * @uses PMA_generate_common_url()
278 * @uses file_exists()
279 * @uses htmlspecialchars()
281 function printPreview()
283 echo '<div class="theme_preview">';
284 echo '<h2>' . htmlspecialchars($this->getName())
285 .' (' . htmlspecialchars($this->getVersion()) . ')</h2>'
287 .'<a target="_top" href="index.php'
288 .PMA_generate_common_url(array('set_theme' => $this->getId())) . '"'
289 .' onclick="takeThis(\'' . addslashes($this->getId()) . '\');'
291 if (@file_exists
($this->getPath() . '/screen.png')) {
292 // if screen exists then output
294 echo '<img src="' . $this->getPath() . '/screen.png" border="1"'
295 .' alt="' . htmlspecialchars($this->getName()) . '"'
296 .' title="' . htmlspecialchars($this->getName()) . '" /><br />';
298 echo $GLOBALS['strThemeNoPreviewAvailable'];
301 echo '[ <strong>' . $GLOBALS['strTakeIt'] . '</strong> ]</a>'