Show
Ignore:
Timestamp:
09/17/07 13:25:32 (6 years ago)
Author:
benoitg
Message:
  • SmartyWifidog?: If ANY of the mandatory dependencies (not just smarty) are missing, user will be redirected to the install script
  • Move Smarty detection and install to common framework. Take this opportunity to move to upgrade to latest Smarty since people will have to re-run the install script anyway.
  • Fix #381 by applying patch from leandro@…, mea-culpa, I didn't know I broke the install script.


Files:
1 modified

Legend:

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

    r1287 r1294  
    5555 
    5656 require_once ('classes/Utils.php'); 
    57        define('OPENID_PATH', WIFIDOG_ABS_FILE_PATH.'lib/php-openid-2.0.0-rc2/'); 
     57  
     58        define('OPENID_PATH', WIFIDOG_ABS_FILE_PATH.'lib/php-openid-2.0.0-rc2/'); 
     59        define('SMARTY_PATH', WIFIDOG_ABS_FILE_PATH.'lib/Smarty-2.6.18/libs/');         
    5860 /** 
    5961  * This class checks the existence of components required by WiFiDog. 
     
    7173  { 
    7274      /** 
    73        * List of components used by WiFiDog 
    74        * 
     75       * An array of components used by WiFiDog 
     76       * The main array key is the EXACT name name of the dependency.  Do NOT translate it or blindly change it; 
     77       *   It is used in the code if various ways, for example to detect PHP or PEAR modules  
     78       * Documentation of the various array keys:   
     79       * 'mandatory' => Optional.  Set to true if the dependency absolutely required for basic operation of an auth server 
     80       * 'type' => Mandatory.  The type of Dependency.  Currently, allowed values are:  
     81           *    "phpExtension":  Standard PHP extension  
     82           *    "peclStandard":  Standard (in the PECL reposidory) PECL PHP module 
     83           *    "peclStandard":  Standard (in the PEAR reposidory) PEAR PHP module 
     84           *    "pearCustom":   PEAR-compatible tarball 
     85           *    "localLib": Custom PHP extension, to be downloaded and installed in wifidog/lib 
     86           * 'detectFiles' => Mandatory for most type of dependencies, the relative path to the file that must exist for the dependency to be considered present. 
     87           *                                    The path is relative to the PHP path, or wifidog/lib depending on the type of install 
     88           * 'description' => Description of the dependency, and what it's used for in wifidog 
     89           * 'website' => URL to the dependency's official website 
     90       * 'installSourceUrl' => For localLib and pearCustom dependency, the URL where the dependency can be downloaded. 
     91       * 'installMethod' => For localLib, the protocol to be used to download and install the dependency.  Currently, allowed values are: 
     92       *        'tarball': Decompress a tarball in wifidog/lib 
     93       * 'installDestination' => For localLib, the path, relative to wifidog/lib where the dependency should be installed 
     94       *  
    7595       * @var array 
    7696       */ 
     
    7999       /* PHP extensions (mandatory) */ 
    80100       'mbstring' => array ( 
    81        'mandatory' => 1, 
     101       'mandatory' => true, 
    82102       "type" => "phpExtension", 
    83103       'description' => 'Required for core auth-server and RSS support' 
    84104       ), 
    85105       'session' => array ( 
    86        'mandatory' => 1, 
     106       'mandatory' => true, 
    87107       "type" => "phpExtension", 
    88108       'description' => 'Required for core auth-server' 
    89109       ), 
    90110       'pgsql' => array ( 
    91        'mandatory' => 1, 
     111       'mandatory' => true, 
    92112       "type" => "phpExtension", 
    93113       'description' => 'Required for auth-server to connect to Postgresql database' 
    94114       ), 
    95  
     115       "Smarty" => array ( 
     116       'mandatory' => true, 
     117       "type" => "localLib", 
     118       "detectFiles" => "lib/Smarty-2.6.18/libs/Smarty.class.php", 
     119       'description' => "Required for all parts of wifidog", 
     120       'website' => "http://smarty.php.net/", 
     121       'installSourceUrl' => "http://smarty.php.net/do_download.php?download_file=Smarty-2.6.18.tar.gz", 
     122       'installMethod' => "tarball", 
     123       'installDestination' => "/" 
     124       ), 
    96125       /* PHP extensions (optional) */ 
    97126       'gettext' => array ( 
     
    146175 
    147176       /* Locally installed libraries */ 
    148        "Smarty" => array ( 
    149        "type" => "localLib", 
    150        "detectFiles" => "lib/smarty/Smarty.class.php", 
    151        'description' => "Required for all parts of wifidog", 
    152        'website' => "http://smarty.php.net/" 
    153        ), 
    154177       "FCKeditor" => array ( 
    155178       "type" => "localLib", 
     
    247270          * @return boolean Returns whether the file has been found or not. 
    248271          */ 
    249           public static function getDependency() 
     272          public static function getDependencies() 
    250273          { 
    251274              $retval = array(); 
     
    396419            } 
    397420 
     421                       /** 
     422            * Checks if one of the mandatory components is missing. 
     423            * 
     424            * @param string $errmsg    Reference of a string which would contain an 
     425            *                          error message. 
     426            * 
     427            * @return boolean Returns false if any components are missing. 
     428            */ 
     429            public static function checkMandatoryComponents(&$errmsg = null) 
     430            { 
     431                // Init values 
     432                $returnValue = true; 
     433$components = self::getDependencies(); 
     434foreach($components as $component) { 
     435    if($component->isMandatory()) { 
     436        $returnValue &= self::check($component->getId(), $errmsg); 
     437    } 
     438} 
     439 
     440                return $returnValue; 
     441            } 
     442             
    398443            /** Use PHP internal functions to download a file */ 
    399444            static public function downloadFile($remoteURL, $localPath) { 
     
    424469                             break; 
    425470                         case "localLib": 
    426                              $name = $this->getId().'_install'; 
    427                              $html .= sprintf(_("<input type='submit' name='%s' value='Install %s'/>"), $name,$this->getId()); 
     471                                                  if($this->getInstallSourceUrl()) { 
     472                                                                                   $name = $this->getId().'_install'; 
     473                                                                                   $value = sprintf(_("Install %s"), $this->getId()); 
     474                                                              $html .= sprintf("<input type='submit' name='%s' value='%s'/>", $name, $value); 
     475                                                       
     476                             } 
     477                             else { 
     478                                 $html .= sprintf(_("Sorry, i couldn't find the source for %s in installSourceUrl"), $this->getId()); 
     479                             } 
     480 
    428481 
    429482                             break;