Changeset 303
- Timestamp:
- 08/02/07 12:49:01 (1 year ago)
- Files:
-
- trunk/app/installers/versions (added)
- trunk/app/models/framework_setup.php (modified) (3 diffs)
- trunk/lib/Ak.php (modified) (2 diffs)
- trunk/lib/AkInstaller.php (modified) (10 diffs)
- trunk/script/setup (modified) (1 diff)
- trunk/test/fixtures/config/config.php (modified) (2 diffs)
- trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_3.php (modified) (1 diff)
- trunk/test/unit/lib/utils/_Ak_file_functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/models/framework_setup.php
r293 r303 244 244 require_once(AK_APP_DIR.DS.'installers'.DS.'framework_installer.php'); 245 245 246 foreach (array(' development', 'production', 'testing') as $mode){246 foreach (array('production', 'development') as $mode){ 247 247 $db_conn = Ak::db($this->_getDsn($mode)); 248 248 $installer = new FrameworkInstaller($db_conn); 249 $installer->install( );249 $installer->install(null, array('mode' => $mode)); 250 250 } 251 251 … … 329 329 %AK_FRAMEWORK_DIR 330 330 331 %AK_ASSET_URL_PREFIX332 333 331 include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'boot.php'); 334 332 … … 362 360 $settings['%AK_FRAMEWORK_DIR'] = defined('AK_FRAMEWORK_DIR') ? 363 361 "defined('AK_FRAMEWORK_DIR') ? null : define('AK_FRAMEWORK_DIR', '".AK_FRAMEWORK_DIR."');" : ''; 364 365 366 $asset_path = $this->_getAssetBasePath();367 if(!empty($asset_path)){368 $settings['%AK_ASSET_URL_PREFIX'] = "define('AK_ASSET_URL_PREFIX','/".trim($this->getUrlSuffix(),'/').'/'.$asset_path."');";369 }else{370 $settings['%AK_ASSET_URL_PREFIX'] = '';371 }372 373 362 } 374 363 trunk/lib/Ak.php
r296 r303 64 64 function &db($dsn = null, $connection_id = null) 65 65 { 66 static $db ;66 static $db, $default_connection_id; 67 67 68 68 // In order to retrieve a database connection we just need to provide its identifier 69 $connection_id = empty($connection_id) ? 70 (empty($dsn) || strstr($dsn,':') ? 'default' : $dsn) : 71 $connection_id; 72 69 if(empty($default_connection_id)){ 70 $default_connection_id = md5($dsn); 71 } 72 $connection_id = empty($connection_id) ? $default_connection_id : $connection_id; 73 73 74 if(empty($db[$connection_id])){ 74 75 require_once(AK_CONTRIB_DIR.DS.'adodb'.DS.'adodb.inc.php'); … … 1649 1650 ak_compat('mime_content_type'); 1650 1651 1651 $mime = mime_content_type($file);1652 $mime = @mime_content_type($file); 1652 1653 1653 1654 if(empty($mime)){ 1654 1655 empty($mime_types) ? require(AK_LIB_DIR.DS.'utils'.DS.'mime_types.php') : null; 1655 $file_name = substr($file,strrpos($file,'/')+1); 1656 $file_extension = substr($file_name,strrpos($file_name,'.')+1); 1656 $file_extension = substr($file,strrpos($file,'.')+1); 1657 1657 $mime = !empty($mime_types[$file_extension]) ? $mime_types[$file_extension] : false; 1658 1658 } trunk/lib/AkInstaller.php
r298 r303 49 49 function install($version = null, $options = array()) 50 50 { 51 $version = (is_null($version)) ? max($this->getAvailableVersions()) : $version; 52 return $this->_upgradeOrDowngrade('up', $version , $options); 53 } 54 55 function up($version = null, $options = array()) 56 { 51 57 return $this->_upgradeOrDowngrade('up', $version, $options); 52 58 } 53 59 54 function up($version = null, $options = array())55 {56 return $this->_upgradeOrDowngrade('up', $version, $options);57 }58 59 60 60 61 function uninstall($version = null, $options = array()) 61 62 { 63 $version = (is_null($version)) ? 0 : $version; 62 64 return $this->_upgradeOrDowngrade('down', $version, $options); 63 65 } … … 77 79 } 78 80 79 $current_version = $this->getInstalledVersion( );81 $current_version = $this->getInstalledVersion($options); 80 82 $available_versions = $this->getAvailableVersions(); 81 83 … … 86 88 $version = isset($version[0]) && is_numeric($version[0]) ? $version[0] : $newest_version; 87 89 $versions = range($current_version+1,$version); 88 90 89 91 if($current_version > $version){ 90 92 echo Ak::t("You can't upgrade to version %version, when you are currently on version %current_version", array('%version'=>$version,'%current_version'=>$current_version)); … … 95 97 $versions = range($current_version, empty($version) ? 1 : $version+1); 96 98 97 if($current_version < $version){ 99 if($current_version == 0){ 100 return true; 101 }elseif($current_version < $version){ 98 102 echo Ak::t("You can't downgrade to version %version, when you just have installed version %current_version", array('%version'=>$version,'%current_version'=>$current_version)); 99 103 return false; … … 153 157 $this->transactionComplete(); 154 158 if($success){ 155 $this->setInstalledVersion($version_number );159 $this->setInstalledVersion($version_number, $options); 156 160 } 157 161 return $success; … … 164 168 165 169 166 function _versionPath() 167 { 168 return AK_APP_DIR.DS.'installers'.DS.$this->getInstallerName().'_version.txt'; 169 } 170 171 172 function getInstalledVersion() 173 { 174 $version_file = $this->_versionPath(); 170 function _versionPath($options = array()) 171 { 172 $mode = empty($options['mode']) ? AK_ENVIRONMENT : $options['mode']; 173 return AK_APP_DIR.DS.'installers'.DS.'versions'.DS.$mode.'_'.$this->getInstallerName().'_version.txt'; 174 } 175 176 177 function getInstalledVersion($options = array()) 178 { 179 $version_file = $this->_versionPath($options); 180 175 181 if(!is_file($version_file)){ 176 $this->setInstalledVersion(0 );177 } 178 return Ak::file_get_contents($this->_versionPath( ));179 } 180 181 182 function setInstalledVersion($version )183 { 184 return Ak::file_put_contents($this->_versionPath( ), $version);182 $this->setInstalledVersion(0, $options); 183 } 184 return Ak::file_get_contents($this->_versionPath($options)); 185 } 186 187 188 function setInstalledVersion($version, $options = array()) 189 { 190 return Ak::file_put_contents($this->_versionPath($options), $version); 185 191 } 186 192 … … 317 323 $index_name = ($index_name == '') ? 'idx_'.$table_name.'_'.$columns : $index_name; 318 324 $index_options = array(); 319 if (preg_match('/(UNIQUE|FULLTEXT|HASH)/',$columns,$match)){325 if(preg_match('/(UNIQUE|FULLTEXT|HASH)/',$columns,$match)){ 320 326 $columns = trim(str_replace($match[1],'',$columns),' '); 321 327 $index_options[] = $match[1]; … … 326 332 function removeIndex($table_name, $columns_or_index_name) 327 333 { 328 if (!$this->tableExists($table_name)) return false;334 if(!$this->tableExists($table_name)) return false; 329 335 $available_indexes =& $this->db->MetaIndexes($table_name); 330 336 $index_name = isset($available_indexes[$columns_or_index_name]) ? $columns_or_index_name : 'idx_'.$table_name.'_'.$columns_or_index_name; 331 if (!isset($available_indexes[$index_name])){337 if(!isset($available_indexes[$index_name])){ 332 338 trigger_error(Ak::t('Index %index_name does not exist.', array('%index_name'=>$index_name)), E_USER_NOTICE); 333 339 return false; … … 408 414 if(strstr($columns,"\n")){ 409 415 $columns = explode("\n",$columns); 410 }elseif (strstr($columns,',')){416 }elseif(strstr($columns,',')){ 411 417 $columns = explode(',',$columns); 412 418 } … … 437 443 if(is_string($replacement)){ 438 444 $column = preg_replace($regex,$replacement,$column); 439 }elseif (preg_match($regex,$column,$match)){445 }elseif(preg_match($regex,$column,$match)){ 440 446 $column = call_user_func_array($replacement,$match); 441 447 } trunk/script/setup
r293 r303 126 126 { 127 127 foreach($this->source_tree as $k=>$node){ 128 $folder = array_shift(array_keys($node)); 129 $path = $this->options['directory'].DS.$folder; 130 if(is_dir($path) && !file_exists($path.DS.'.htaccess') && $folder != 'public'){ 131 file_put_contents($path.DS.'.htaccess', "order allow,deny\ndeny from all"); 132 } 133 } 134 128 if (is_array($node)){ 129 $folder = array_shift(array_keys($node)); 130 $path = $this->options['directory'].DS.$folder; 131 if(is_dir($path) && !file_exists($path.DS.'.htaccess') && $folder != 'public'){ 132 file_put_contents($path.DS.'.htaccess', "order allow,deny\ndeny from all"); 133 } 134 } 135 } 135 136 } 136 137 trunk/test/fixtures/config/config.php
r278 r303 20 20 (array)@explode('/',@$_SERVER['REQUEST_URI']))),DIRECTORY_SEPARATOR),array('','/'),AK_TEST_DIR)); 21 21 22 defined('AK_ENABLE_AKELOS_ARGS') ? null : define('AK_ENABLE_AKELOS_ARGS', true); 22 defined('AK_ENABLE_AKELOS_ARGS') ? null : define('AK_ENABLE_AKELOS_ARGS', true); 23 23 //define('AK_SKIP_DB_CONNECTION',isset($db) && $db === false); 24 24 … … 30 30 31 31 defined('AK_TESTING_URL') ? null : define('AK_TESTING_URL', rtrim(AK_URL,'/').'/test/fixtures/public'); 32 defined('AK_TESTING_REWRITE_BASE') ? null : define('AK_TESTING_REWRITE_BASE', false); 32 33 33 34 defined('AK_LIB_TESTS_DIRECTORY') ? null : define('AK_LIB_TESTS_DIRECTORY', AK_TEST_DIR.DS.'unit'.DS.'lib'); 35 36 if(AK_TESTING_REWRITE_BASE){ 37 Ak::file_put_contents(AK_BASE_DIR.'/test/fixtures/public/.htaccess', str_replace('# RewriteBase /test/fixtures/public','RewriteBase '.AK_TESTING_REWRITE_BASE, Ak::file_get_contents(AK_BASE_DIR.'/test/fixtures/public/.htaccess'))); 38 } 34 39 35 40 if(defined('AK_TEST_DATABASE_ON')){ trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_3.php
r217 r303 284 284 function Test_of_binary_data_on_database() 285 285 { 286 $long_string = Ak::file_get_contents(AK_LIB_DIR.DS.'AkActiveRecord.php');286 $long_string = file_get_contents(AK_LIB_DIR.DS.'AkActiveRecord.php'); 287 287 288 288 $_tmp_file = fopen(AK_LIB_DIR.DS.'AkActiveRecord.php', "rb"); trunk/test/unit/lib/utils/_Ak_file_functions.php
r296 r303 103 103 function test_mime_type_detection() 104 104 { 105 $this->assertEqual(Ak::mime_content_type(AK_PUBLIC_DIR.DS.'images'.DS.'akelos_framework_logo.png'),'image/png'); 105 // png is not in any RFC so we might want to check if it has a /x- preffix for non standard values 106 $this->assertTrue(in_array(Ak::mime_content_type(AK_PUBLIC_DIR.DS.'images'.DS.'akelos_framework_logo.png'),array('image/png','image/x-png'))); 106 107 $this->assertEqual(Ak::mime_content_type('C:\Folder\image.png'),'image/png'); 108 } 109 110 function test_should_read_files_using_scoped_file_get_contents_function() 111 { 112 $this->assertEqual(Ak::file_get_contents(AK_LIB_DIR.DS.'AkActiveRecord.php'), file_get_contents(AK_LIB_DIR.DS.'AkActiveRecord.php')); 107 113 } 108 114
