Changeset 322

Show
Ignore:
Timestamp:
08/25/07 20:39:23 (1 year ago)
Author:
bermiferrer
Message:

Updating many small issues related to no mod_rewrite availability and sqlite setup.
- Fixed bug on double slashes when not using URL_
- AK_URL_REWRITE_ENABLED is not set by default.
- Setup script creates a clean testing environment.
- Sqlite DB connection failure throws a PHP version warning.
- Errors in docs
- Removed public/500.html and public/400.html, 404 errors never arrived and 500 errors gave a not found error.
- Mac OSX sqlite3 does not like hidden files as databases, so now it uses a hashed db name by default.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/.htaccess

    r243 r322  
    4949</IfModule> 
    5050 
    51 ErrorDocument 400 /public/400.html 
    52 ErrorDocument 500 /public/500.html 
     51ErrorDocument 500 "<h2>Apache server error</h2>Akelos application failed to start properly" 
  • trunk/app/models/framework_setup.php

    r306 r322  
    204204        }else{ 
    205205            return $this->getDatabaseType() == 'sqlite' ? 
    206             "sqlite://".urlencode(AK_CONFIG_DIR.DS.'.ht-'.$this->getDatabaseName($mode).'.sqlite') : 
     206            "sqlite://".urlencode(AK_CONFIG_DIR.DS.$this->getDatabaseName($mode).'-'.$this->random.'.sqlite') : 
    207207            $this->getDatabaseType($mode)."://".$this->getDatabaseUser($mode).":".$this->getDatabasePassword($mode). 
    208208            "@".$this->getDatabaseHost($mode)."/".$this->getDatabaseName($mode); 
     
    327327define('AK_PUBLIC_LOCALES', '%locales'); 
    328328 
     329%AK_URL_REWRITINGdefined('AK_URL_REWRITE_ENABLED') ? null : define('AK_URL_REWRITE_ENABLED', true); 
     330 
    329331%AK_FRAMEWORK_DIR 
    330332 
     
    340342                if($settings['%'.$mode.'_database_type'] == 'sqlite'){ 
    341343 
    342                     $settings['%'.$mode.'_database_file'] = AK_CONFIG_DIR.DS.'.ht-'.$this->getDatabaseName($mode).'.sqlite'; 
     344                    $settings['%'.$mode.'_database_file'] = AK_CONFIG_DIR.DS.$this->getDatabaseName($mode).'-'.$this->random.'.sqlite'; 
    343345                    $settings['%'.$mode.'_database_user'] = 
    344346                    $settings['%'.$mode.'_database_password'] = 
     
    358360 
    359361            $settings['%locales'] = $this->getLocales(); 
     362             
     363            $settings['%AK_URL_REWRITING'] = $this->isUrlRewriteEnabled() ? '' : "// The web configuration wizard could not detect if you have mod_rewrite enabled. \n// If that is the case, you should uncomment the next line line for better performance. \n// "; 
    360364            $settings['%AK_FRAMEWORK_DIR'] = defined('AK_FRAMEWORK_DIR') ? 
    361365            "defined('AK_FRAMEWORK_DIR') ? null : define('AK_FRAMEWORK_DIR', '".AK_FRAMEWORK_DIR."');" : ''; 
     
    557561        'ftp_user' => $this->getFtpUser(), 
    558562        'ftp_host' => $this->getFtpHost(), 
    559         'ftp_path' => $this->getFtpPath() 
     563        'ftp_path' => $this->getFtpPath(), 
     564         
     565        'random' => Ak::randomString(), 
    560566        ); 
    561567    } 
  • trunk/app/views/framework_setup/compiled/set_database_details.tpl.php

    r140 r322  
    2828              <?php if($FrameworkSetup->database_type != 'sqlite') : ?> 
    2929        
    30               <label for='<?php  
    31  echo $mode; 
    32 ?>_database_host'><?php echo $text_helper->translate('Database Host', array()); ?></label> 
    33                         <input type='text' name='<?php  
    34  echo $mode; 
    35 ?>_database_host' id='<?php  
    36  echo $mode; 
    37 ?>_database_host'  
     30              <label for='<?php echo $mode; ?>_database_host'><?php echo $text_helper->translate('Database Host', array()); ?></label> 
     31                        <input type='text' name='<?php echo $mode; ?>_database_host' id='<?php echo $mode; ?>_database_host'  
    3832                        value='<?php echo $FrameworkSetup->getDatabaseHost($mode)?>' /> 
    3933                         
    40                     <label for='<?php  
    41  echo $mode; 
    42 ?>_database_name'><?php echo $text_helper->translate('Database name', array()); ?></label> 
    43                         <input type='text' name='<?php  
    44  echo $mode; 
    45 ?>_database_name' id='<?php  
    46  echo $mode; 
    47 ?>_database_name'  
     34                    <label for='<?php echo $mode; ?>_database_name'><?php echo $text_helper->translate('Database name', array()); ?></label> 
     35                        <input type='text' name='<?php echo $mode; ?>_database_name' id='<?php echo $mode; ?>_database_name'  
    4836                        value='<?php echo $FrameworkSetup->getDatabaseName($mode)?>' /> 
    4937                         
    50                     <label for='<?php  
    51  echo $mode; 
    52 ?>_database_user'><?php echo $text_helper->translate('User', array()); ?></label> 
    53                         <input type='text' name='<?php  
    54  echo $mode; 
    55 ?>_database_user' id='<?php  
    56  echo $mode; 
    57 ?>_database_user'  
     38                    <label for='<?php echo $mode; ?>_database_user'><?php echo $text_helper->translate('User', array()); ?></label> 
     39                        <input type='text' name='<?php echo $mode; ?>_database_user' id='<?php echo $mode; ?>_database_user'  
    5840                        value='<?php echo $FrameworkSetup->getDatabaseUser($mode)?>' /> 
    5941                         
    60                     <label for='<?php  
    61  echo $mode; 
    62 ?>_database_password'><?php echo $text_helper->translate('Password', array()); ?></label> 
    63                         <input type='password' name='<?php  
    64  echo $mode; 
    65 ?>_database_password' id='<?php  
    66  echo $mode; 
    67 ?>_database_password'  
     42                    <label for='<?php echo $mode; ?>_database_password'><?php echo $text_helper->translate('Password', array()); ?></label> 
     43                        <input type='password' name='<?php echo $mode; ?>_database_password' id='<?php echo $mode; ?>_database_password'  
    6844                        value='<?php echo $FrameworkSetup->getDatabasePassword($mode)?>' /> 
    6945                         
    7046            <?php else : ?> 
    7147            
    72               <label for='<?php  
    73  echo $mode; 
    74 ?>_database_name'><?php echo $text_helper->translate('Database name', array()); ?></label> 
    75               <b>config/.ht-</b><input class="sqlite_database_name" type='text'  
    76                         name='<?php  
    77  echo $mode; 
    78 ?>_database_name' id='<?php  
    79  echo $mode; 
    80 ?>_database_name'  
    81                         value='<?php echo $FrameworkSetup->getDatabaseName($mode)?>' /><b>.sqlite</b> 
     48              <label for='<?php echo $mode; ?>_database_name'><?php echo $text_helper->translate('Database name', array()); ?></label> 
     49              <b>config/</b><input class="sqlite_database_name" type='text'  
     50                        name='<?php echo $mode; ?>_database_name' id='<?php echo $mode; ?>_database_name'  
     51                        value='<?php echo $FrameworkSetup->getDatabaseName($mode)?>' /><b>-<?php echo $FrameworkSetup->random?>.sqlite</b> 
    8252             
    8353            <?php endif; ?> 
     
    9060         
    9161         
    92         <?php 
     62        <?php  
    9363        /** 
    9464         * @todo Database creation form. Requires extensive testing before  
  • trunk/app/views/framework_setup/set_database_details.tpl

    r2 r322  
    4747            
    4848              <label for='{mode}_database_name'>_{Database name}</label> 
    49               <b>config/.ht-</b><input class="sqlite_database_name" type='text'  
     49              <b>config/</b><input class="sqlite_database_name" type='text'  
    5050                        name='{mode}_database_name' id='{mode}_database_name'  
    51                         value='<?=$FrameworkSetup->getDatabaseName($mode)?>' /><b>.sqlite</b> 
     51                        value='<?=$FrameworkSetup->getDatabaseName($mode)?>' /><b>-<?=$FrameworkSetup->random?>.sqlite</b> 
    5252             
    5353            <? endif; ?> 
  • trunk/docs/tutorial.markdown

    r321 r322  
    370370 * and many more... 
    371371  
    372 My apologies for any typo or grammatical error you might find. English is not my mother tongue and I would really like you to help me fixing errors in this document. 
    373  
     372My apologies for any typo or grammatical error you might find. English is not my mother tongue and I would really like you to help me [improving and fixing errors in this document](http://trac.akelos.org/newticket?keywords=booklink%20english&component=Documentation&priority=minor&type=documentation&summary=Booklin%20Tutorial%20improvements). 
  • trunk/lib/Ak.php

    r312 r322  
    8585                    $fn(); 
    8686                } 
     87                if(!AK_PHP5 && substr($dsn,0,6) == 'sqlite'){ 
     88                    echo "\nWarning, sqlite support is not available by default on PHP4.\n Check your PHP version by running \"env php -v\", and change the first line in your scripts/ so they point to a php5 binary\n\n"; 
     89                } 
    8790                die(Ak::t('Connection to the database failed.').' '. 
    88                 (AK_DEBUG?preg_replace('/\/\/(\w+):(.*)@/i','//$1:******@', $dsn)."\n":'')); 
     91                (AK_DEBUG?preg_replace('/\/\/(\w+):(.*)@/i','//$1:******@', urldecode($dsn))."\n":'')); 
    8992            } 
    9093            $db[$connection_id]->debug = AK_DEBUG == 2; 
  • trunk/lib/AkActionController.php

    r296 r322  
    983983        } 
    984984 
    985         $rewritten_url .= (substr($rewritten_url,-1) == '/' ? '' : (AK_URL_REWRITE_ENABLED ? '' : '/')); 
     985        $rewritten_url .= (substr($rewritten_url,-1) == '/' ? '' : (AK_URL_REWRITE_ENABLED ? '' : (!empty($path[0]) && $path[0] != '/' ? '/' : ''))); 
    986986        $rewritten_url .= $path; 
    987987        $rewritten_url .= empty($options['trailing_slash']) ? '' : '/'; 
  • trunk/lib/AkActiveRecord.php

    r315 r322  
    35973597    *   $Person->save(); // => true (and person is now saved in the database) 
    35983598    *  
    3599     * An "Errors" object is automatically created for every Active Record. 
     3599    * An "_errors" array is available for every Active Record. 
    36003600    *  
    36013601    */ 
  • trunk/lib/AkActiveRecord/AkHasAndBelongsToMany.php

    r320 r322  
    2525* an option, it is guessed using the lexical order of the class names. So a join between Developer and Project 
    2626* will give the default join table name of "developers_projects" because "D" outranks "P". 
    27 * 
    28 * Any additional fields added to the join table will be placed as attributes when pulling records out through 
    29 * hasAndBelongsToMany associations. This is helpful when have information about the association itself 
    30 * that you want available on retrieval. Note that any fields in the join table will override matching field names 
    31 * in the two joined tables. As a consequence, having an "id" field in the join table usually has the undesirable 
    32 * result of clobbering the "id" fields in either of the other two tables. 
    3327* 
    3428* Adds the following methods for retrieval and query. 
  • trunk/lib/constants.php

    r302 r322  
    4646// defined('AK_PUBLIC_LOCALES') ? null : define('AK_PUBLIC_LOCALES','en,es'); 
    4747 
    48 defined('AK_URL_REWRITE_ENABLED') ? null : define('AK_URL_REWRITE_ENABLED', true); 
     48// defined('AK_URL_REWRITE_ENABLED') ? null : define('AK_URL_REWRITE_ENABLED', true); 
    4949 
    5050defined('AK_TIME_DIFFERENCE') ? null : define('AK_TIME_DIFFERENCE', 0); // Time difference from the webserver 
  • trunk/public/.htaccess

    r243 r322  
    5252</IfModule> 
    5353 
    54 ErrorDocument 400 /400.html 
    55 ErrorDocument 500 /500.html 
     54ErrorDocument 500 "<h2>Apache server error</h2>Akelos application failed to start properly" 
  • trunk/script/setup

    r304 r322  
    4444 
    4545        if(empty($this->options['dependencies'])){ 
    46             $this->framework_dirs = array('lib', 'vendor'); 
     46            $this->framework_dirs = array('lib', 'vendor', 'test'); 
    4747 
    4848            foreach ($this->framework_dirs as $framework_dir){ 
     
    6868 
    6969            if(empty($this->options['dependencies'])){ 
     70                $this->_setupApplicationTestingEnvironment(); 
    7071                $this->_linkDependencies(); 
    7172            } 
     
    7980 
    8081    } 
     82 
     83 
     84    function _setupApplicationTestingEnvironment() 
     85    { 
     86        $source_test_dir = $this->options['source'].DS.'test'; 
     87        $test_dir = $this->options['directory'].DS.'test'; 
     88         
     89        $this->_makeDir($test_dir); 
     90        $this->_copyFile($source_test_dir.DS.'app.php'); 
     91         
     92        $this->_makeDir($test_dir.DS.'fixtures'); 
     93        $this->_makeDir($test_dir.DS.'fixtures'.DS.'app'); 
     94         
     95        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'app'.DS.'application_controller.php'); 
     96        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'app'.DS.'shared_model.php'); 
     97         
     98        $this->_makeDir($test_dir.DS.'fixtures'.DS.'config'); 
     99        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'config'.DS.'config.php'); 
     100 
     101        $this->_makeDir($test_dir.DS.'fixtures'.DS.'data'); 
     102        $this->_makeDir($test_dir.DS.'fixtures'.DS.'public'); 
     103        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'public'.DS.'.htaccess'); 
     104        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'public'.DS.'index.php'); 
     105    } 
     106 
    81107 
    82108    function _linkPublicHtmlFolder() 
  • trunk/test/fixtures/config/config.php

    r303 r322  
    2222defined('AK_ENABLE_AKELOS_ARGS') ? null : define('AK_ENABLE_AKELOS_ARGS', true); 
    2323//define('AK_SKIP_DB_CONNECTION',isset($db) && $db === false); 
     24defined('AK_URL_REWRITE_ENABLED') ? null : define('AK_URL_REWRITE_ENABLED', true); 
    2425 
    2526include_once(substr(AK_TEST_DIR,0,-5).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');