Show
Ignore:
Timestamp:
08/29/06 12:34:21 (6 years ago)
Author:
max-horvath
Message:

"2006-08-29 Max Horvath <max.horvath@…>

  • Cleaned up PHPdoc tags
  • Updated german translation
  • Updated portuguese translation, thanks to Gabriel Hahmann
  • Added spanish translation, thanks to Ricardo Jose Guevara Ochoa"
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/ThemePack.php

    r1031 r1084  
    11<?php 
    2  
    32 
    43/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
     
    4443 
    4544/** 
    46  * Load required file 
    47  */ 
    48  
    49 /** 
    5045 * Theme packs contain stylesheets and graphical elements to customize the 
    5146 * 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. 
    5251 */ 
    5352class ThemePack { 
     53    /** 
     54     * ID of ThemePack 
     55     * 
     56     * @var string 
     57     * @access private 
     58     */ 
    5459    private $_id; 
     60 
     61    /** 
     62     * Name of ThemePack 
     63     * 
     64     * @var string 
     65     * @access private 
     66     */ 
    5567    private $_name; 
     68 
     69    /** 
     70     * Description of ThemePack 
     71     * 
     72     * @var string 
     73     * @access private 
     74     */ 
    5675    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 
    57108    /** 
    58109     * Get an interface to pick a theme pack 
     
    60111     * If there is only one network available, no interface is actually shown 
    61112     * 
    62      * @param string $userPrefix          A identifier provided by the 
     113     * @param string $userPrefix           An identifier provided by the 
    63114     *                                     programmer to recognise it's 
    64115     *                                     generated html form 
    65116     * @param object $preSelectedThemePack Theme object: The theme to be pre- 
    66      * selected in the form object 
     117     *                                     selected in the form object 
    67118     * 
    68119     * @return string HTML markup 
     
    78129        if ($preSelectedThemePack) { 
    79130            $selected_id = $preSelectedThemePack->getId(); 
    80         } 
    81         else { 
     131        } else { 
    82132            $selected_id = null; 
    83133        } 
     134 
    84135        if ($handle = @ opendir(WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR)) { 
    85136            $tab = array (); 
    86137            $i = 0; 
     138 
    87139            while (false !== ($directory = readdir($handle))) { 
    88140                if ($directory != '.' && $directory != '..' && $directory != '.svn' && is_dir(WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR.$directory.'/')) { 
     
    95147            } 
    96148            closedir($handle); 
    97         } 
    98         else { 
     149        } else { 
    99150            throw new exception(_("Unable to open the network theme packs directory")); 
    100151        } 
     152 
    101153        //pretty_print_r($tab); 
    102154        if (count($tab) > 0) { 
    103155            $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, true); 
    104         } 
    105         else { 
     156        } else { 
    106157            $html .= sprintf(_("No network theme packs available in %s"), WIFIDOG_ABS_FILE_PATH.NETWORK_THEME_PACKS_DIR); 
    107158            $html .= "<input type='hidden' name='$name' value=''>"; 
     
    111162    } 
    112163 
    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     * 
    132172     * @see GenericObject 
    133      * @param $id The object id 
    134      * @return the Content object, or null if there was an error (an exception is also thrown) 
     173     * @static 
     174     * @access public 
    135175     */ 
    136176    static public function getObject($id) { 
    137177        return new self($id); 
    138178    } 
    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     */ 
    141187    public function getId() { 
    142188        return $this->_id; 
    143189    } 
    144190 
    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     */ 
    147198    public function getName() { 
    148199        return $this->_name; 
    149200    } 
    150201 
    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     */ 
    153209    public function getDescription() { 
    154210        return $this->_description; 
    155211    } 
    156212 
    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     */ 
    159220    public function getStylesheetUrl() { 
    160         return BASE_URL_PATH.NETWORK_THEME_PACKS_DIR.$this->_id.'/stylesheet.css'; 
    161     } 
    162  
    163 } //End class 
     221        return BASE_URL_PATH . NETWORK_THEME_PACKS_DIR . $this->_id . '/stylesheet.css'; 
     222    } 
     223 
     224} 
    164225 
    165226/*