Changeset 2819

Show
Ignore:
Timestamp:
11/17/08 02:30:09 (8 weeks ago)
Author:
freakerz
Message:

Removing the index.php installer calls, fix the default form values, also fix the locale change. Will probably cache the FormUI since we call locale-form twice... and probably more during install. Oh and fixed the class change of installstep rather than options.

Location:
branches/081018-handlers/htdocs
Files:
1 removed
7 modified

Legend:

Unmodified
Added
Removed
  • branches/081018-handlers/htdocs/index.php

    r2818 r2819  
    2020date_default_timezone_set( 'UTC' ); 
    2121 
     22define('MIN_PHP_VERSION', '5.2.0'); 
     23 
    2224// Compares PHP version against our requirement. 
    23 if ( ! version_compare( PHP_VERSION, '5.2.0', '>=' ) ) { 
     25if ( ! version_compare( PHP_VERSION, MIN_PHP_VERSION, '>=' ) ) { 
    2426    die ( 'Habari needs PHP 5.2.x or higher to run. You are currently running PHP ' . PHP_VERSION . '.' ); 
    2527} 
     
    112114Error::handle_errors(); 
    113115 
    114 /* Initiate install verifications */ 
    115  
    116  
    117 /** 
    118  * We make sure the configuration file exist. 
    119  * If it does, we load it and check it's validity. 
    120  * 
    121  * @todo Call the installer from the database classes. 
    122  */ 
    123 /*if ( file_exists( $config ) ) { 
    124     require_once $config; 
    125  
    126     if ( !defined( 'DEBUG' ) ) define( 'DEBUG', false ); 
    127  
    128     // Make sure we have a DSN string and database credentials. 
    129     // $db_connection is an array with necessary informations to connect to the database. 
    130     if ( ! isset($db_connection) ) { 
    131         $installer = new InstallHandler(); 
    132         $installer->begin_install(); 
    133     } 
    134  
    135     // Try to connect to the database. 
    136     if (DB::connect()) { 
    137         // Make sure Habari is installed properly. 
    138         // If the 'installed' option is missing, we assume the database tables are missing or corrupted. 
    139         // @todo Find a decent solution, we have to compare tables and restore or upgrade them. 
    140         if (! @ Options::get('installed')) { 
    141             $installer = new InstallHandler(); 
    142             $installer->begin_install(); 
    143         } 
    144     } 
    145     else { 
    146         $installer = new InstallHandler(); 
    147         $installer->begin_install(); 
    148     } 
    149 } 
    150 else 
    151 { 
    152     if ( !defined( 'DEBUG' ) ) define( 'DEBUG', false ); 
    153     // The configuration file does not exist. 
    154     // Therefore we load the installer to create the configuration file and install a base database. 
    155     $installer = new InstallHandler(); 
    156     $installer->begin_install(); 
    157 } */ 
    158  
    159116DB::connect(); 
    160117 
  • branches/081018-handlers/htdocs/system/classes/installhandler.php

    r2818 r2819  
    11<?php 
    2 define('MIN_PHP_VERSION', '5.2.0'); 
    3  
    42/** 
    53 * The class which responds to installer actions 
     
    2826         * Set user selected Locale or default 
    2927         */ 
    30         $this->theme->locales = Locale::list_all(); 
    3128        if ( isset($_POST['locale']) && $_POST['locale'] != null ) { 
    3229            Locale::set($_POST['locale']); 
    3330            $this->theme->locale = $_POST['locale']; 
    3431            $this->handler_vars['locale'] = $_POST['locale']; 
    35         } 
    36         else { 
    37             Locale::set( 'en-us' ); 
    38             $this->theme->locale = 'en-us'; 
    39             $this->handler_vars['locale'] = 'en_us'; 
    4032        } 
    4133 
     
    137129        EventLog::log(_t('Habari successfully installed.'), 'info', 'default', 'habari'); 
    138130        return true; 
    139     } 
    140      
    141     /* 
    142      * Helper function to grab list of plugins 
    143      */ 
    144     public function get_plugins() { 
    145         $all_plugins = Plugins::list_all(); 
    146         $recommended_list = array( 
    147             'coredashmodules.plugin.php', 
    148             'habarisilo.plugin.php', 
    149             'pingback.plugin.php', 
    150             'spamchecker.plugin.php', 
    151             'undelete.plugin.php' 
    152         ); 
    153  
    154         foreach ( $all_plugins as $file ) { 
    155             $plugin = array(); 
    156             $plugin_id = Plugins::id_from_file( $file ); 
    157             $plugin['plugin_id']= $plugin_id; 
    158             $plugin['file']= $file; 
    159  
    160             $error = ''; 
    161             if ( Utils::php_check_file_syntax( $file, $error ) ) { 
    162                 $plugin['debug']= false; 
    163                 // instantiate this plugin 
    164                 // in order to get its info() 
    165                 include_once( $file ); 
    166                 Plugins::get_plugin_classes(); 
    167                 $pluginobj = Plugins::load( $file, false ); 
    168                 $plugin['active']= false; 
    169                 $plugin['verb']= _t( 'Activate' ); 
    170                 $plugin['actions']= array(); 
    171                 $plugin['info']= $pluginobj->info; 
    172                 $plugin['recommended'] = in_array( basename($file), $recommended_list ); 
    173             } 
    174             else { 
    175                 $plugin['debug']= true; 
    176                 $plugin['error']= $error; 
    177                 $plugin['active']= false; 
    178             } 
    179              
    180             $plugins[$plugin_id]= $plugin; 
    181         } 
    182          
    183         return $plugins; 
    184131    } 
    185132     
  • branches/081018-handlers/htdocs/system/schema/mysql/install/mysqlinstall.php

    r2818 r2819  
    2222         
    2323        $form->mysqlsettings->append('text', 'mysqldatabasehost', 'null:null', _t('Database Host')); 
    24         $form->mysqldatabasehost->value = $theme->mysqldatabasehost; 
     24        $form->mysqldatabasehost->value = 'localhost'; 
    2525        $form->mysqldatabasehost->required = true; 
    2626        $form->mysqldatabasehost->help = _t('<strong>Database Host</strong> is the host (domain) name or server IP 
     
    3131         
    3232        $form->mysqlsettings->append('text', 'mysqldatabaseuser', 'null:null', _t('Username')); 
    33         $form->mysqldatabaseuser->value = $theme->mysqldatabaseuser; 
    3433        $form->mysqldatabaseuser->required = true; 
    3534        $form->mysqldatabaseuser->help = _t('<strong>Database User</strong> is the username used to connect Habari 
     
    3736         
    3837        $form->mysqlsettings->append('text', 'mysqldatabasepass', 'null:null', _t('Password')); 
    39         $form->mysqldatabasepass->value = $theme->mysqldatabasepass; 
    4038        $form->mysqldatabasepass->required = true; 
    4139        $form->mysqldatabasepass->help = _t('<strong>Database Password</strong> is the password used to connect 
     
    4341         
    4442        $form->mysqlsettings->append('text', 'mysqldatabasename', 'null:null', _t('Database Name')); 
    45         $form->mysqldatabasename->value = $theme->mysqldatabasename; 
     43        $form->mysqldatabasename->value = 'habari'; 
    4644        $form->mysqldatabasename->required = true; 
    4745        $form->mysqldatabasename->help = _t('<strong>Database Name</strong> is the name of the MySQL database to 
  • branches/081018-handlers/htdocs/system/schema/pgsql/install/pgsqlinstall.php

    r2818 r2819  
    2222         
    2323        $form->pgsqlsettings->append('text', 'pgsqldatabasehost', 'null:null', _t('Database Host')); 
    24         $form->pgsqldatabasehost->value = $theme->pgsqldatabasehost; 
     24        $form->pgsqldatabasehost->value = 'localhost'; 
    2525        $form->pgsqldatabasehost->required = true; 
    2626        $form->pgsqldatabasehost->help = _t('<strong>Database Host</strong> is the host (domain) name or server IP 
     
    3131         
    3232        $form->pgsqlsettings->append('text', 'pgsqldatabaseuser', 'null:null', _t('Username')); 
    33         $form->pgsqldatabaseuser->value = $theme->pgsqldatabaseuser; 
    3433        $form->pgsqldatabaseuser->required = true; 
    3534        $form->pgsqldatabaseuser->help = _t('<strong>Database User</strong> is the username used to connect Habari 
     
    3736         
    3837        $form->pgsqlsettings->append('text', 'pgsqldatabasepass', 'null:null', _t('Password')); 
    39         $form->pgsqldatabasepass->value = $theme->pgsqldatabasepass; 
    4038        $form->pgsqldatabasepass->required = true; 
    4139        $form->pgsqldatabasepass->help = _t('<strong>Database Password</strong> is the password used to connect 
     
    4341         
    4442        $form->pgsqlsettings->append('text', 'pgsqldatabasename', 'null:null', _t('Database Name')); 
    45         $form->pgsqldatabasename->value = $theme->pgsqldatabasename; 
     43        $form->pgsqldatabasename->value = 'habari'; 
    4644        $form->pgsqldatabasename->required = true; 
    4745        $form->pgsqldatabasename->help = _t('<strong>Database Name</strong> is the name of the PostgreSQL database to 
  • branches/081018-handlers/htdocs/system/schema/sqlite/install/sqliteinstall.php

    r2818 r2819  
    2222         
    2323        $form->sqlitesettings->append('text', 'databasefile', 'null:null', _t('Data file')); 
    24         $form->databasefile->value = $theme->databasefile; 
     24        $form->databasefile->value = 'habari.db'; 
    2525        $form->databasefile->required = true; 
    2626        $form->databasefile->help = _t('<strong>Data file</strong> is the SQLite file that will store  
     
    4545        $theme->handler_vars['db_file']= $remainder; 
    4646    } 
     47     
     48    /** 
     49     * Checks for the existance of a SQLite datafile 
     50     * tries to create it if it does not exist 
     51    **/ 
     52    private function check_sqlite() { 
     53        $db_file = $this->db_file; 
     54        if ( file_exists( $db_file ) && is_writable( $db_file ) && is_writable( dirname( $db_file ) ) ) { 
     55            // the file exists, and is writable.  We're all set 
     56            return true; 
     57        } 
     58 
     59        // try to figure out what the problem is. 
     60        if ( file_exists( $db_file ) ) { 
     61            // the DB file exists, why can't we access it? 
     62            if ( ! is_writable( $db_file ) ) { 
     63                $this->assign('form_errors', array('db_file'=>_t('The SQLite data file is not writable by the web server.') ) ); 
     64                return false; 
     65            } 
     66            if ( ! is_writable( dirname( $db_file ) ) ) { 
     67                $this->assign('form_errors', array('db_file'=>_t('SQLite requires that the directory that holds the DB file be writable by the web server.') ) ); 
     68                return false; 
     69            } 
     70        } 
     71 
     72        if ( ! file_exists( $db_file ) ) { 
     73            // let's see if the directory is writable 
     74            // so that we could create the file 
     75            if ( ! is_writable( dirname( $db_file ) ) ) { 
     76                $this->assign('form_errors', array('db_file'=>_t('The SQLite data file does not exist, and it cannot be created in the specified directory.  SQLite requires that the directory containing the database file be writable by the web server.')) ); 
     77                return false; 
     78            } 
     79        } 
     80        return true; 
     81    } 
     82     
    4783 
    4884    /** 
  • branches/081018-handlers/htdocs/system/themes/installer/script.js

    r2818 r2819  
    5656        if(installok) { 
    5757            $('#siteconfiguration').addClass('done'); 
    58             $('#install').children('.options').fadeIn().addClass('ready').addClass('done'); 
    59             $('#pluginactivation').children('.options').fadeIn().addClass('ready').addClass('done'); 
     58            $('#install').children('.options').fadeIn().parent().addClass('ready').addClass('done'); 
     59            $('#pluginactivation').children('.options').fadeIn().parent().addClass('ready').addClass('done'); 
    6060            $('#pluginactivation').children('.help-me').show(); 
    6161            $('#submitinstall').removeAttr( 'disabled' ); 
  • branches/081018-handlers/htdocs/system/themes/installer/theme.php

    r2818 r2819  
    44class DefaultInstaller extends Theme 
    55{ 
    6          
     6             
    77    public function filter_control_theme_dir( $dirs ) 
    88    { 
     
    1010    } 
    1111     
     12    public function add_template_vars() 
     13    { 
     14        Locale::set( $this->form_locales()->locales->value ); 
     15        $this->plugins = $this->get_plugins(); 
     16    } 
     17     
    1218    public function form_locales() 
    1319    { 
    14         $locs= array(); 
    15         foreach ($this->locales as $loc) { 
    16             $locs[$loc]= $loc; 
     20        $locales= array(); 
     21        foreach (Locale::list_all() as $locale) { 
     22            $locales[$locale]= $locale; 
    1723        } 
    1824         
     
    2430                 
    2531        $form->locale->append('wrapper', 'locale_options', null, 'installer_options'); 
    26         $form->locale_options->append('select', 'locales', 'null:null', _t('Language'), $locs); 
    27         $form->locales->selected = $this->locale; 
     32        $form->locale_options->append('select', 'locales', 'null:null', _t('Language'), $locales); 
     33        $form->locales->value = Options::get('locale'); 
    2834        $form->locales->required = false; 
    2935        $form->locales->help = ''; 
     
    3137        $form->append('wrapper', 'locale_nextstep', null, 'installer_nextstep'); 
    3238 
     39        $form->on_success( array($this, 'set_locale') ); 
     40         
    3341        Plugins::act('install_form_localeform', $form, $this); 
    3442        return $form; 
     
    4755        // Database Type 
    4856        $form->databasesetup_options->append('select', 'db_type', 'null:null', _t('Database Type')); 
    49         $form->db_type->selected = $this->db_type; 
     57        $form->db_type->value = 'mysql'; 
    5058        $form->db_type->required = true; 
    5159        $form->db_type->help = _t('<strong>Database Type</strong> specifies the type of database to which 
     
    5765        // Table Prefix 
    5866        $form->databasesetup_advancedoptions->append('text', 'table_prefix', 'null:null', _t('Table Prefix')); 
    59         $form->table_prefix->value = $this->table_prefix; 
     67        $form->table_prefix->value = 'habari__'; 
    6068        $form->table_prefix->help = _t('<strong>Table Prefix</strong> is a prefix that will be appended to 
    6169        each table that Habari creates in the database, making it easy to 
     
    7381        // Blog Title 
    7482        $form->siteconfiguration_options->append('text', 'blog_title', 'null:null', _t('Site Name')); 
    75         $form->blog_title->value = $this->blog_title; 
     83        $form->blog_title->value = 'My Habari'; 
    7684        $form->blog_title->required = true; 
    7785        $form->blog_title->help = _t('<strong>Site Name</strong> is the name of your site as it will appear 
     
    7987        // Admin Username 
    8088        $form->siteconfiguration_options->append('text', 'admin_username', 'null:null', _t('Username')); 
    81         $form->admin_username->value = $this->admin_username; 
     89        $form->admin_username->value = 'admin'; 
    8290        $form->admin_username->required = true; 
    8391        $form->admin_username->help = _t('<strong>Username</strong> is the username of the initial user in  
     
    8694        $form->siteconfiguration_options->append('wrapper', 'admin_pass_wrapper', null, 'installer_password_wrapper'); 
    8795        $form->admin_pass_wrapper->append('password', 'admin_pass1', 'null:null', _t('Password'), 'installer_password'); 
    88         $form->admin_pass1->value = $this->admin_pass1; 
    8996        $form->admin_pass1->required = true; 
    9097        $form->admin_pass_wrapper->append('password', 'admin_pass2', 'null:null', _t('Password (again)'), 'installer_password'); 
    91         $form->admin_pass2->value = $this->admin_pass2; 
    9298        $form->admin_pass2->required = true; 
    9399        $form->admin_pass_wrapper->message = ''; 
     
    96102        // Admin Email 
    97103        $form->siteconfiguration_options->append('text', 'admin_email', 'null:null', _t('E-mail')); 
    98         $form->admin_email->value = $this->admin_email; 
    99104        $form->admin_email->required = true; 
    100105        $form->admin_email->help = _t('<strong>Admin Email</strong> is the email address of the first user 
     
    130135    } 
    131136     
     137    /* 
     138     * Helper function to grab list of plugins 
     139     */ 
     140    public function get_plugins() { 
     141        $all_plugins = Plugins::list_all(); 
     142        $recommended_list = array( 
     143            'coredashmodules.plugin.php', 
     144            'habarisilo.plugin.php', 
     145            'pingback.plugin.php', 
     146            'spamchecker.plugin.php', 
     147            'undelete.plugin.php' 
     148        ); 
     149 
     150        foreach ( $all_plugins as $file ) { 
     151            $plugin = array(); 
     152            $plugin_id = Plugins::id_from_file( $file ); 
     153            $plugin['plugin_id']= $plugin_id; 
     154            $plugin['file']= $file; 
     155 
     156            $error = ''; 
     157            if ( Utils::php_check_file_syntax( $file, $error ) ) { 
     158                $plugin['debug']= false; 
     159                // instantiate this plugin 
     160                // in order to get its info() 
     161                include_once( $file ); 
     162                Plugins::get_plugin_classes(); 
     163                $pluginobj = Plugins::load( $file, false ); 
     164                $plugin['active']= false; 
     165                $plugin['verb']= _t( 'Activate' ); 
     166                $plugin['actions']= array(); 
     167                $plugin['info']= $pluginobj->info; 
     168                $plugin['recommended'] = in_array( basename($file), $recommended_list ); 
     169            } 
     170            else { 
     171                $plugin['debug']= true; 
     172                $plugin['error']= $error; 
     173                $plugin['active']= false; 
     174            } 
     175             
     176            $plugins[$plugin_id]= $plugin; 
     177        } 
     178         
     179        return $plugins; 
     180    } 
     181     
    132182} 
    133183?>