Changeset 1294

Show
Ignore:
Timestamp:
09/17/07 13:25:32 (1 year 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@texnet.it, mea-culpa, I didn't know I broke the install script.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/CHANGELOG

    r1292 r1294  
    11# $Id$ 
     22007-09-17 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
     3        * SmartyWifidog:  If ANY of the mandatory dependencies (not just smarty) are missing, user will be redirected to the install script 
     4        * 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. 
     5        * Fix #381 by applying patch from leandro@texnet.it, mea-culpa, I didn't know I broke the install script. 
     6         
    272007-09-12 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
    38        * Scratch a few itches:  Fix the link from node admin to stats, minor CSS fixes 
  • trunk/wifidog-auth/wifidog/classes/DependenciesList.php

    r1287 r1294  
    131131           $html .= "</table>"; 
    132132 
    133            $components = Dependency::getDependency(); 
     133           $components = Dependency::getDependencies(); 
    134134           $html .= "<table BORDER=\"1\">\n"; 
    135135           $html .= "<tr><th>"._("Component").'<br/>'._("Click for the component's website")."</th>\n"; 
  • 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; 
  • trunk/wifidog-auth/wifidog/classes/SmartyWifidog.php

    r1249 r1294  
    4747require_once("classes/Locale.php"); 
    4848require_once("classes/Utils.php"); 
    49 require_once("include/smarty.resource.string.php"); 
    50  
    51 // Check if Smarty installed, if not redirect user to web-base installation 
    52 if (Dependency::check("Smarty", $errmsg)) { 
     49// Check if all mandatory components (such as Smarty) installed, if not redirect user to web-base installation 
     50if (Dependency::checkMandatoryComponents($errmsg)) { 
    5351    // Load Smarty library 
    54     require_once('lib/smarty/Smarty.class.php'); 
     52    require_once(SMARTY_PATH.'Smarty.class.php'); 
    5553} else { 
    5654    // Build the system_path for the auth-server 
    57     print "Redirecting to Wifidog web-based install script since Smarty is missing (Error was: $errmsg)<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=".BASE_URL_PATH."/install.php\">"; 
     55    print "Redirecting to Wifidog web-based install script since a mandatory Dependency is missing (Error was: $errmsg)<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=".BASE_URL_PATH."/install.php\">"; 
    5856    exit(); 
    5957} 
    60  
     58require_once("include/smarty.resource.string.php"); 
    6159/* 
    6260 * Smarty plugin 
  • trunk/wifidog-auth/wifidog/install.php

    r1289 r1294  
    166166'tmp/simplepie_cache', 
    167167'lib/', 
    168 'lib/smarty', 
    169 'lib/smarty/plugins', 
    170168'tmp/smarty/templates_c', 
    171169'tmp/smarty/cache', 
     
    500498                array ( 
    501499                "title" => "Next", 
    502                 "page" => "smarty
     500                "page" => "simplepie
    503501                ) 
    504502                )); 
     
    506504 
    507505            break; 
    508             ################################### 
    509         case 'smarty' : // Download, uncompress and install Smarty 
    510             print<<< EndHTML 
    511     <h1>Smarty template engine installation</h1> 
    512     <p><A HREF="http://smarty.php.net/">Smarty</A> is Template Engine. WifiDog requires you install it before you continue.</p> 
    513 EndHTML; 
    514 if ($neededPackages['smarty']['available']) { 
    515             print "Already installed !<br/>"; 
    516 } 
    517 else { 
    518     $output = WIFIDOG_ABS_FILE_PATH."tmp/"; 
    519     //chdir($output); 
    520     list ($url, $filename) = split("=", $smarty_full_url); 
    521  
    522     print "Download source code ($filename) : "; 
    523     if (!file_exists($output.$filename)) 
    524     Dependency::downloadFile($smarty_full_url, $output.$filename); 
    525  
    526     if (!file_exists($output.$filename)) { 
    527         print "<B STYLE=\"color:red\">Error</b><p>Current working directory : <em>$output</em>"; 
    528         print "<pre><em>wget \"$smarty_full_url\"</em>\n$output</pre>"; 
    529         exit (); 
    530     } 
    531     else { 
    532         print "OK<BR>"; 
    533     } 
    534  
    535     print "Uncompressing : "; 
    536     $dir_array = split(".tar.gz", $output.$filename); 
    537     $dirname = array_shift($dir_array); 
    538  
    539     if (!file_exists($dirname)) 
    540     Dependency::execVerbose("cd $output; tar -xzf $dirname.tar.gz", $output, $return); 
    541     print "OK<BR>"; 
    542     print "Copying : "; 
    543     if (!file_exists(WIFIDOG_ABS_FILE_PATH . "lib/smarty")); 
    544     Dependency::execVerbose("cp -r $dirname/libs/* " . WIFIDOG_ABS_FILE_PATH . "/lib/smarty", $output, $return); # TODO : Utiliser SMARTY_REL_PATH 
    545     print "OK<BR>"; 
    546  
    547     refreshButton(); 
    548 } 
    549 navigation(array ( 
    550 array ( 
    551 "title" => "Back", 
    552 "page" => "version" 
    553             ), 
    554 array ( 
    555 "title" => "Next", 
    556 "page" => "simplepie" 
    557             ) 
    558 )); 
    559 break; 
    560506################################### 
    561507        case 'simplepie' : // Download, uncompress and install SimplePie 
     
    576522            } 
    577523            elseif ($action == 'install') { 
    578  
     524                require_once (dirname(__FILE__) . '/include/common.php'); 
    579525                print "Download source code frpm svn($filename) : "; 
    580526                Dependency::execVerbose("svn co ".escapeshellarg($neededPackages['simplepie']['svn_source'])." ".escapeshellarg(WIFIDOG_ABS_FILE_PATH."lib/simplepie"), $output, $return); 
     
    634580            } 
    635581            elseif ($action == 'install') { 
    636  
     582                require_once (dirname(__FILE__) . '/include/common.php'); 
    637583                print "Download source code frpm svn($filename) : "; 
    638584                Dependency::execVerbose("svn co ".escapeshellarg($neededPackages['feedpressreview']['svn_source'])." ".escapeshellarg(WIFIDOG_ABS_FILE_PATH."lib/feedpressreview"), $output, $return);