Hide style chooser unless two or more styles are given
authorAlexander Ebert <ebert@woltlab.com>
Wed, 2 Jan 2013 18:09:53 +0000 (19:09 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 2 Jan 2013 18:09:53 +0000 (19:09 +0100)
Fixes #895

com.woltlab.wcf/template/headInclude.tpl
wcfsetup/install/files/lib/data/package/Package.class.php
wcfsetup/install/files/lib/system/style/StyleHandler.class.php

index e241e6119dbb6a0c71eb05ee06e3c2094ff660e4..da33326f6fcba7f6975a95db1807c116178d4f63 100644 (file)
                new WCF.Effect.SmoothScroll();
                new WCF.Effect.BalloonTooltip();
                new WCF.Sitemap();
-               new WCF.Style.Chooser();
+               {if $__wcf->getStyleHandler()->countStyles() > 1}new WCF.Style.Chooser();{/if}
                WCF.Dropdown.init();
                WCF.System.PageNavigation.init('.pageNavigation');
                WCF.Date.Picker.init();
index 7863312002ab4ba289842e02ed9e47baf7e5146a..ff1fd379e0c9520e152ca59148ee6e6402e9176b 100644 (file)
@@ -207,6 +207,23 @@ class Package extends DatabaseObject {
                }
        }
        
+       /**
+        * Returns true, if package identified by $package is already installed.
+        * 
+        * @param       string          $package
+        * @return      boolean
+        */
+       public static function isAlreadyInstalled($package) {
+               $sql = "SELECT  COUNT(*) AS count
+                       FROM    wcf".WCF_N."_package
+                       WHERE   package = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($package));
+               $row = $statement->fetchArray();
+               
+               return ($row['count'] ? true : false);
+       }
+       
        /**
         * Checks if a package name is valid.
         * 
index 74221c7b5457fb8724af697e5b45f702dcd3082d..5a9a6befbac663b28329b4ed60057cb9c9e9a8e0 100644 (file)
@@ -147,6 +147,15 @@ class StyleHandler extends SingletonFactory {
                }
        }
        
+       /**
+        * Returns number of available styles.
+        * 
+        * @return      integer
+        */
+       public function countStyles() {
+               return count($this->getAvailableStyles());
+       }
+       
        /**
         * Resets all stylesheets.
         */