Changeset 10013

Show
Ignore:
Timestamp:
11/28/08 03:30:52 (1 month ago)
Author:
afz
Message:

Add new feature to database options: database path for using in Interbase, Firebird and SQLite

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/jaws/html/config/JawsConfig.php.sample

    r7813 r10013  
    33 * JawsConfig.php - Configuration variables 
    44 * 
    5  * @author Jonathan Hernandez <ion@gluch.org.mx> 
    6  * @copyright Jaws 2004-2008 
     5 * @author     Jonathan Hernandez <ion@suavizado.com> 
     6 * @author     Ali Fazelzadeh <afz@php.net> 
     7 * @copyright  2004-2008 Jaws Development Group 
    78 */ 
    8  
    99// Path where Jaws is installed 
    1010define('JAWS_DPATH', ''); 
     
    2727$db['password'] = ''; 
    2828$db['isdba']    = 'false'; 
     29$db['path']     = ''; 
    2930$db['name']     = ''; 
    3031$db['prefix']   = ''; 
  • trunk/jaws/html/include/Jaws/DB.php

    r10011 r10013  
    4646     * @access private 
    4747     */ 
    48     var $_isDBAdmin; 
     48    var $_is_dba; 
     49 
     50    /** 
     51     * This DB path 
     52     * 
     53     * @var    string 
     54     * @access private 
     55     */ 
     56    var $_db_path; 
    4957 
    5058    var $_dsn; 
     
    6876        } 
    6977 
    70         $this->_isDBAdmin = $options['isdba'] == 'true' ? true : false; 
    71         $this->_driver    = strtolower($options['driver']); 
    72         $this->_prefix    = $options['prefix']; 
    73         $this->_charset   = $options['charset']; 
     78        $this->_db_path = isset($options['path'])? $options['path'] : ''; 
     79        $this->_is_dba  = $options['isdba'] == 'true' ? true : false; 
     80        $this->_driver  = strtolower($options['driver']); 
     81        $this->_prefix  = $options['prefix']; 
     82        $this->_charset = $options['charset']; 
    7483 
    7584        $this->connect(); 
     
    110119 
    111120        if ($this->_dsn['phptype'] == 'sqlite' || $this->_dsn['phptype'] == 'ibase') { 
    112             $options['database_path'] = JAWS_DATA
     121            $options['database_path'] = empty($this->_db_path)? JAWS_DATA : $this->_db_path
    113122        } 
    114123 
     
    117126        } 
    118127 
    119         if ($this->_isDBAdmin) { 
     128        if ($this->_is_dba) { 
    120129            $options['DBA_username'] = $this->_dsn['username']; 
    121130            $options['DBA_password'] = $this->_dsn['password']; 
     
    567576 
    568577        if ($this->_dsn['phptype'] == 'sqlite' || $this->_dsn['phptype'] == 'ibase') { 
    569             $options['database_path'] = JAWS_DATA
     578            $options['database_path'] = empty($this->_db_path)? JAWS_DATA : $this->_db_path
    570579        } 
    571580 
     
    574583        } 
    575584 
    576         if ($this->_isDBAdmin) { 
     585        if ($this->_is_dba) { 
    577586            $options['DBA_username'] = $this->_dsn['username']; 
    578587            $options['DBA_password'] = $this->_dsn['password']; 
  • trunk/jaws/html/install/stages/Database.php

    r9997 r10013  
    2222        'user'     => '', 
    2323        'isdba'    => '', 
     24        'path'     => '', 
    2425        'database' => 'jaws', 
    2526        'prefix'   => '', 
     
    104105            $tpl->SetVariable('database', $values['database']); 
    105106            $tpl->ParseBlock('Database/database'); 
     107        } 
     108 
     109        if (!isset($data['path'])) { 
     110            $fields++; 
     111            $tpl->SetBlock('Database/path'); 
     112            $tpl->setVariable('lbl_db_path', _t('INSTALL_DB_PATH')); 
     113            $tpl->setVariable('path_info',   _t('INSTALL_DB_PATH_INFO')); 
     114            $tpl->SetVariable('path', $values['path']); 
     115            $tpl->ParseBlock('Database/path'); 
    106116        } 
    107117 
     
    194204    { 
    195205        $request =& Jaws_Request::getInstance(); 
    196         $post = $request->get(array('host', 'user', 'database', 'port'), 'post'); 
     206        $post = $request->get(array('host', 'user', 'database', 'path', 'port'), 'post'); 
    197207        if (isset($_SESSION['install']['data']['Database'])) { 
    198208            $post = $_SESSION['install']['data']['Database'] + $post; 
     209        } 
     210 
     211        if (isset($post['path']) && $post['path'] !== '' && !is_dir($post['path'])) { 
     212            log_install("The database path must be exists"); 
     213            return new Jaws_Error(_t('INSTALL_DB_RESPONSE_PATH'), 0, JAWS_ERROR_WARNING); 
    199214        } 
    200215 
     
    250265        } 
    251266 
     267        if (!empty($post['path'])) { 
     268            if (DIRECTORY_SEPARATOR != '/') { 
     269                $post['path'] = str_replace('/', '\\', $post['path']); 
     270            } 
     271            if (substr($post['path'], -1) != DIRECTORY_SEPARATOR) { 
     272                $post['path'] .= DIRECTORY_SEPARATOR; 
     273            } 
     274        } 
     275 
    252276        $_SESSION['install']['Database'] = array( 
    253277            'user'     => trim($post['user']), 
     
    255279            'isdba'    => !empty($post['isdba'])? 'true' : 'false', 
    256280            'name'     => trim($post['database']), 
     281            'path'     => trim($post['path']), 
    257282            'host'     => trim($post['host']), 
    258283            'port'     => trim($post['port']), 
  • trunk/jaws/html/install/stages/Database/templates/display.html

    r8128 r10013  
    6161  </tr> 
    6262  <!-- END database --> 
     63  <!-- BEGIN path --> 
     64  <tr> 
     65   <td><label for="path">{lbl_db_path}:</label></td> 
     66   <td><input type="text" name="path" id="path" value="{path}" size="30" style="direction: ltr;" /></td> 
     67  </tr> 
     68  <tr> 
     69   <td></td> 
     70   <td class="form_comment">{path_info}</td> 
     71  </tr> 
     72  <!-- END path --> 
    6373  <!-- BEGIN port --> 
    6474  <tr> 
  • trunk/jaws/html/install/stages/WriteConfig.php

    r7909 r10013  
    2727        $tpl->SetVariable('db_pass',    $_SESSION['install']['Database']['password']); 
    2828        $tpl->SetVariable('db_isdba',   $_SESSION['install']['Database']['isdba']); 
     29        $tpl->SetVariable('db_path',    addslashes($_SESSION['install']['Database']['path'])); 
    2930        $tpl->SetVariable('db_name',    $_SESSION['install']['Database']['name']); 
    3031        $tpl->SetVariable('db_prefix',  $_SESSION['install']['Database']['prefix']); 
  • trunk/jaws/html/install/stages/WriteConfig/templates/JawsConfig.php

    r7925 r10013  
    33 * JawsConfig.php - Configuration variables 
    44 * 
    5  * @author Jonathan Hernandez <ion@suavizado.com> 
    6  * @copyright Jaws 2004-2008 
     5 * @author     Jonathan Hernandez <ion@suavizado.com> 
     6 * @author     Ali Fazelzadeh <afz@php.net> 
     7 * @copyright  2004-2008 Jaws Development Group 
    78 */ 
    89// Path where Jaws is installed 
     
    2627$db['password'] = '{db_pass}'; 
    2728$db['isdba']    = '{db_isdba}'; 
     29$db['path']     = '{db_path}'; 
    2830$db['name']     = '{db_name}'; 
    2931$db['prefix']   = '{db_prefix}'; 
  • trunk/jaws/html/languages/en/Install.php

    r8523 r10013  
    7474define('_EN_INSTALL_DB_IS_ADMIN', "Is DB Admin?"); 
    7575define('_EN_INSTALL_DB_NAME', "Database Name"); 
     76define('_EN_INSTALL_DB_PATH', "Database Path"); 
     77define('_EN_INSTALL_DB_PATH_INFO', "Only fill this field out if you like change your database path in SQLite, Interbase and Firebird driver."); 
    7678define('_EN_INSTALL_DB_PORT', "Database Port"); 
    7779define('_EN_INSTALL_DB_PORT_INFO', "Only fill this field out if your database is running on an another port then the default is.<br />If you have <strong>no idea</strong> what port the database is running then most likely it's running on the default port and thus we <strong>advice</strong> you to leave this field alone."); 
    7880define('_EN_INSTALL_DB_PREFIX', "Tables Prefix"); 
    7981define('_EN_INSTALL_DB_PREFIX_INFO', "Some text that will be placed in front of table names, so you can run more than one Jaws site from the same database, for example <strong>blog_</strong>"); 
     82define('_EN_INSTALL_DB_RESPONSE_PATH', "The database path not exist"); 
    8083define('_EN_INSTALL_DB_RESPONSE_PORT', "The port can only be a numeric value"); 
    8184define('_EN_INSTALL_DB_RESPONSE_INCOMPLETE', "You must fill in all the fields apart from table prefix and port."); 
  • trunk/jaws/html/languages/en/Upgrade.php

    r9599 r10013  
    7373define('_EN_UPGRADE_DB_IS_ADMIN', "Is DB Admin?"); 
    7474define('_EN_UPGRADE_DB_NAME', "Database Name"); 
     75define('_EN_UPGRADE_DB_PATH', "Database Path"); 
     76define('_EN_UPGRADE_DB_PATH_INFO', "Only fill this field out if you like change your database path in SQLite, Interbase and Firebird driver."); 
    7577define('_EN_UPGRADE_DB_PORT', "Database Port"); 
    7678define('_EN_UPGRADE_DB_PORT_INFO', "Only fill this field out if your database is running on an another port then the default is.<br />If you have <strong>no idea</strong> what port the database is running then most likely it's running on the default port and thus we <strong>advice</strong> you to leave this field alone."); 
    7779define('_EN_UPGRADE_DB_PREFIX', "Tables Prefix"); 
    7880define('_EN_UPGRADE_DB_PREFIX_INFO', "Some text that will be placed in front of table names, so you can run more than one Jaws site from the same database, for example <strong>blog_</strong>"); 
     81define('_EN_UPGRADE_DB_RESPONSE_PATH', "The database path not exist"); 
    7982define('_EN_UPGRADE_DB_RESPONSE_PORT', "The port can only be a numeric value"); 
    8083define('_EN_UPGRADE_DB_RESPONSE_INCOMPLETE', "You must fill in all the fields apart from table prefix and port."); 
  • trunk/jaws/html/languages/fa/Install.php

    r8523 r10013  
    6565define('_FA_INSTALL_DB_IS_ADMIN', "آیا دسترسی سوپروایزری دارد؟"); 
    6666define('_FA_INSTALL_DB_NAME', "نام دیتابیس"); 
     67define('_FA_INSTALL_DB_PATH', "مسیر دیتابیس"); 
     68define('_FA_INSTALL_DB_PATH_INFO', "این فیلد در صورتی پر کنید که قصد تغییر مسیر دیتابیس در SQLite، Interbase و یا Firebird را داشته باشید."); 
    6769define('_FA_INSTALL_DB_PORT', "پورت دیتابیس"); 
    6870define('_FA_INSTALL_DB_PORT_INFO', "این فیلد را فقط وقتی پر کنید که دیتابیس شما روی پورتی غیر از حالت پیش فرضش نصب شده باشد. البته به صورت معمول دیتابیس ها روی پورت پیش فرض نصب میشوند، لذا اگر اطلاع کافی در مورد آن ندارید آنرا بصورت خالی نگه دارید."); 
    6971define('_FA_INSTALL_DB_PREFIX', "پیش نام جدول"); 
    7072define('_FA_INSTALL_DB_PREFIX_INFO', "کلمه ای که قبل از نام جداول قرار خواهد گرفت، بوسیله آن می توان بیش از یک جاوز را برروی یک دیتابیس نصب کرد، به عنوان مثال blog_"); 
     73define('_FA_INSTALL_DB_RESPONSE_PATH', "مسیر دیتابیس وجود ندارد."); 
    7174define('_FA_INSTALL_DB_RESPONSE_PORT', "پورت تنها می تواند شامل اعداد باشد."); 
    7275define('_FA_INSTALL_DB_RESPONSE_INCOMPLETE', "پر کردن همه فیلدها (بغیر از پیش نام جداول و پورت دیتابیس) اجباری است."); 
  • trunk/jaws/html/languages/fa/Upgrade.php

    r9599 r10013  
    6464define('_FA_UPGRADE_DB_IS_ADMIN', "آیا دسترسی سوپروایزری دارد؟"); 
    6565define('_FA_UPGRADE_DB_NAME', "نام دیتابیس"); 
     66define('_FA_UPGRADE_DB_PATH', "مسیر دیتابیس"); 
     67define('_FA_UPGRADE_DB_PATH_INFO', "این فیلد در صورتی پر کنید که قصد تغییر مسیر دیتابیس در SQLite، Interbase و یا Firebird را داشته باشید."); 
    6668define('_FA_UPGRADE_DB_PORT', "پورت دیتابیس"); 
    6769define('_FA_UPGRADE_DB_PORT_INFO', "این فیلد را فقط وقتی پر کنید که دیتابیس شما روی پورتی غیر از حالت پیش فرضش نصب شده باشد. البته به صورت معمول دیتابیس ها روی پورت پیش فرض نصب میشوند، لذا اگر اطلاع کافی در مورد آن ندارید آنرا بصورت خالی نگه دارید."); 
    6870define('_FA_UPGRADE_DB_PREFIX', "پیش نام جدول"); 
    6971define('_FA_UPGRADE_DB_PREFIX_INFO', "کلمه ای که قبل از نام جداول قرار خواهد گرفت، بوسیله آن می توان بیش از یک جاوز را برروی یک دیتابیس نصب کرد، به عنوان مثال blog_"); 
     72define('_FA_UPGRADE_DB_RESPONSE_PATH', "مسیر دیتابیس وجود ندارد."); 
    7073define('_FA_UPGRADE_DB_RESPONSE_PORT', "پورت تنها می تواند شامل اعداد باشد."); 
    7174define('_FA_UPGRADE_DB_RESPONSE_INCOMPLETE', "پر کردن همه فیلدها (بغیر از پیش نام جداول و پورت دیتابیس) اجباری است."); 
  • trunk/jaws/html/upgrade/stages/Database.php

    r7932 r10013  
    2121        'user'     => '', 
    2222        'isdba'    => '', 
     23        'path'     => '', 
    2324        'database' => 'jaws', 
    2425        'prefix'   => '', 
     
    102103            $tpl->SetVariable('database', $values['database']); 
    103104            $tpl->ParseBlock('Database/database'); 
     105        } 
     106 
     107        if (!isset($data['path'])) { 
     108            $fields++; 
     109            $tpl->SetBlock('Database/path'); 
     110            $tpl->setVariable('lbl_db_path', _t('UPGRADE_DB_PATH')); 
     111            $tpl->setVariable('path_info',   _t('UPGRADE_DB_PATH_INFO')); 
     112            $tpl->SetVariable('path', $values['path']); 
     113            $tpl->ParseBlock('Database/path'); 
    104114        } 
    105115 
     
    192202    { 
    193203        $request =& Jaws_Request::getInstance(); 
    194         $post = $request->get(array('host', 'user', 'database', 'port'), 'post'); 
     204        $post = $request->get(array('host', 'user', 'database', 'path', 'port'), 'post'); 
    195205        if (isset($_SESSION['upgrade']['data']['Database'])) { 
    196206            $post = $_SESSION['upgrade']['data']['Database'] + $post; 
     207        } 
     208 
     209        if (isset($post['path']) && $post['path'] !== '' && !is_dir($post['path'])) { 
     210            log_upgrade("The database path must be exists"); 
     211            return new Jaws_Error(_t('UPGRADE_DB_RESPONSE_PATH'), 0, JAWS_ERROR_WARNING); 
    197212        } 
    198213 
     
    248263        } 
    249264 
     265        if (!empty($post['path'])) { 
     266            if (DIRECTORY_SEPARATOR != '/') { 
     267                $post['path'] = str_replace('/', '\\', $post['path']); 
     268            } 
     269            if (substr($post['path'], -1) != DIRECTORY_SEPARATOR) { 
     270                $post['path'] .= DIRECTORY_SEPARATOR; 
     271            } 
     272        } 
     273 
    250274        $_SESSION['upgrade']['Database'] = array( 
    251275            'user'     => trim($post['user']), 
     
    253277            'isdba'    => !empty($post['isdba'])? 'true' : 'false', 
    254278            'name'     => trim($post['database']), 
     279            'path'     => trim($post['path']), 
    255280            'host'     => trim($post['host']), 
    256281            'port'     => trim($post['port']), 
  • trunk/jaws/html/upgrade/stages/Database/templates/display.html

    r8128 r10013  
    6060  </tr> 
    6161  <!-- END database --> 
     62  <!-- BEGIN path --> 
     63  <tr> 
     64   <td><label for="path">{lbl_db_path}:</label></td> 
     65   <td><input type="text" name="path" id="path" value="{path}" size="30" style="direction: ltr;" /></td> 
     66  </tr> 
     67  <tr> 
     68   <td></td> 
     69   <td class="form_comment">{path_info}</td> 
     70  </tr> 
     71  <!-- END path --> 
    6272  <!-- BEGIN port --> 
    6373  <tr> 
  • trunk/jaws/html/upgrade/stages/WriteConfig.php

    r7948 r10013  
    3232        $tpl->SetVariable('db_isdba',   $_SESSION['upgrade']['Database']['isdba']); 
    3333        $tpl->SetVariable('db_name',    $_SESSION['upgrade']['Database']['name']); 
     34        $tpl->SetVariable('db_path',    addslashes($_SESSION['upgrade']['Database']['path'])); 
    3435        $tpl->SetVariable('db_prefix',  $_SESSION['upgrade']['Database']['prefix']); 
    3536        $tpl->SetVariable('db_charset', $_SESSION['upgrade']['Database']['charset']); 
  • trunk/jaws/html/upgrade/stages/WriteConfig/templates/JawsConfig.php

    r7925 r10013  
    33 * JawsConfig.php - Configuration variables 
    44 * 
    5  * @author Jonathan Hernandez <ion@suavizado.com> 
    6  * @copyright Jaws 2004-2008 
     5 * @author     Jonathan Hernandez <ion@suavizado.com> 
     6 * @author     Ali Fazelzadeh <afz@php.net> 
     7 * @copyright  2004-2008 Jaws Development Group 
    78 */ 
    89// Path where Jaws is installed 
     
    2627$db['password'] = '{db_pass}'; 
    2728$db['isdba']    = '{db_isdba}'; 
     29$db['path']     = '{db_path}'; 
    2830$db['name']     = '{db_name}'; 
    2931$db['prefix']   = '{db_prefix}';