Changeset 1084 for trunk/wifidog-auth/wifidog/classes/ThemePack.php
- Timestamp:
- 08/29/06 12:34:21 (6 years ago)
- Files:
-
- 1 modified
-
trunk/wifidog-auth/wifidog/classes/ThemePack.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/wifidog/classes/ThemePack.php
r1031 r1084 1 1 <?php 2 3 2 4 3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ … … 44 43 45 44 /** 46 * Load required file47 */48 49 /**50 45 * Theme packs contain stylesheets and graphical elements to customize the 51 46 * general look of the system. 47 * 48 * @package WiFiDogAuthServer 49 * @author Benoit Grégoire <bock@step.polymtl.ca> 50 * @copyright 2006 Benoit Grégoire, Technologies Coeus inc. 52 51 */ 53 52 class ThemePack { 53 /** 54 * ID of ThemePack 55 * 56 * @var string 57 * @access private 58 */ 54 59 private $_id; 60 61 /** 62 * Name of ThemePack 63 * 64 * @var string 65 * @access private 66 */ 55 67 private $_name; 68 69 /** 70 * Description of ThemePack 71 * 72 * @var string 73 * @access private 74 */ 56 75 private $_description; 76 77 /** 78 * Constructor 79 * 80 * @param string $themePackId The id of the theme pack (actually, the 81 * folder name without the path) 82 * 83 * @return void 84 * 85 * @access private 86 */ 87 private function __construct($themePackId) { 88 $handle = @ opendir(WIFIDOG_ABS_FILE_PATH . NETWORK_THEME_PACKS_DIR . $themePackId.'/'); 89 90 if (!$handle) { 91 throw new exception(sprintf(_("Theme pack %s cannot be found in %s"), $themePackId, WIFIDOG_ABS_FILE_PATH . NETWORK_THEME_PACKS_DIR . $themePackId . '/')); 92 } 93 94 $this->_id = $themePackId; 95 $this->_name = file_get_contents(WIFIDOG_ABS_FILE_PATH . NETWORK_THEME_PACKS_DIR . $this->_id . '/name.txt'); 96 97 if ($this->_name == null) { 98 $this->_name = sprintf(_("%s (Theme did not include a name.txt file)"), $this->_id); 99 } 100 101 $this->_description = file_get_contents(WIFIDOG_ABS_FILE_PATH . NETWORK_THEME_PACKS_DIR . $this->_id . '/description.txt'); 102 103 if ($this->_description == null) { 104 $this->_description = sprintf(_("%s (Theme did not include a description.txt file)"), $this->_name); 105 } 106 } 107 57 108 /** 58 109 * Get an interface to pick a theme pack … … 60 111 * If there is only one network available, no interface is actually shown 61 112 * 62 * @param string $userPrefix Aidentifier provided by the113 * @param string $userPrefix An identifier provided by the 63 114 * programmer to recognise it's 64 115 * generated html form 65 116 * @param object $preSelectedThemePack Theme object: The theme to be pre- 66 * selected in the form object117 * selected in the form object 67 118 * 68 119 * @return string HTML markup … … 78 129 if ($preSelectedThemePack) { 79 130 $selected_id = $preSelectedThemePack->getId(); 80 } 81 else { 131 } else { 82 132 $selected_id = null; 83 133 } 134 84 135 if ($handle = @ opendir(WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR)) { 85 136 $tab = array (); 86 137 $i = 0; 138 87 139 while (false !== ($directory = readdir($handle))) { 88 140 if ($directory != '.' && $directory != '..' && $directory != '.svn' && is_dir(WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR.$directory.'/')) { … … 95 147 } 96 148 closedir($handle); 97 } 98 else { 149 } else { 99 150 throw new exception(_("Unable to open the network theme packs directory")); 100 151 } 152 101 153 //pretty_print_r($tab); 102 154 if (count($tab) > 0) { 103 155 $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, true); 104 } 105 else { 156 } else { 106 157 $html .= sprintf(_("No network theme packs available in %s"), WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR); 107 158 $html .= "<input type='hidden' name='$name' value=''>"; … … 111 162 } 112 163 113 /** @param $themePackId The id of the theme pack (actually, the folder name without the path) */ 114 private function __construct($themePackId) { 115 $handle = @ opendir(WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR.$themePackId.'/'); 116 if (!$handle) { 117 throw new exception(sprintf(_("Theme pack %s cannot be found in %s"), $themePackId, WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR.$themePackId.'/')); 118 } 119 $this->_id = $themePackId; 120 $this->_name = file_get_contents(WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR.$this->_id.'/name.txt'); 121 if ($this->_name == null) { 122 $this->_name = sprintf(_("%s (Theme did not include a name.txt file)"), $this->_id); 123 } 124 $this->_description = file_get_contents(WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR.$this->_id.'/description.txt'); 125 if ($this->_description == null) { 126 $this->_description = sprintf(_("%s (Theme did not include a description.txt file)"), $this->_name); 127 } 128 129 } 130 131 /** Get an instance of the object 164 /** 165 * Get an instance of the object 166 * 167 * @param object $id The object id 168 * 169 * @return object The Content object, or null if there was an error (an 170 * exception is also thrown) 171 * 132 172 * @see GenericObject 133 * @ param $id The object id134 * @ return the Content object, or null if there was an error (an exception is also thrown)173 * @static 174 * @access public 135 175 */ 136 176 static public function getObject($id) { 137 177 return new self($id); 138 178 } 139 /** Retreives the id of the object 140 * @return The id, a string */ 179 180 /** 181 * Retreives the id of the object 182 * 183 * @return string The id 184 * 185 * @access public 186 */ 141 187 public function getId() { 142 188 return $this->_id; 143 189 } 144 190 145 /** Retreives the name of the ThemePack 146 * @return a string */ 191 /** 192 * Retreives the name of the ThemePack 193 * 194 * @return string Name of ThemePack 195 * 196 * @access public 197 */ 147 198 public function getName() { 148 199 return $this->_name; 149 200 } 150 201 151 /** Retreives the description of the ThemePack 152 * @return a string */ 202 /** 203 * Retreives the description of the ThemePack 204 * 205 * @return string Description of ThemePack 206 * 207 * @access public 208 */ 153 209 public function getDescription() { 154 210 return $this->_description; 155 211 } 156 212 157 /** Retreives the url of this theme's stylesheet 158 * @return url */ 213 /** 214 * Retreives the url of this theme's stylesheet 215 * 216 * @return string URL of this theme's stylesheet 217 * 218 * @access public 219 */ 159 220 public function getStylesheetUrl() { 160 return BASE_URL_PATH .NETWORK_THEME_PACKS_DIR.$this->_id.'/stylesheet.css';161 } 162 163 } //End class221 return BASE_URL_PATH . NETWORK_THEME_PACKS_DIR . $this->_id . '/stylesheet.css'; 222 } 223 224 } 164 225 165 226 /*
