[ Index ] |
|
Code source de PHPonTrax 2.6.6-svn |
1 <?php 2 /** 3 * File containing the Trax class for framework configs 4 * 5 * (PHP 5) 6 * 7 * @package PHPonTrax 8 * @version $Id:$ 9 * @copyright (c) 2005 John Peterson 10 * 11 * Permission is hereby granted, free of charge, to any person obtaining 12 * a copy of this software and associated documentation files (the 13 * "Software"), to deal in the Software without restriction, including 14 * without limitation the rights to use, copy, modify, merge, publish, 15 * distribute, sublicense, and/or sell copies of the Software, and to 16 * permit persons to whom the Software is furnished to do so, subject to 17 * the following conditions: 18 * 19 * The above copyright notice and this permission notice shall be 20 * included in all copies or substantial portions of the Software. 21 * 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 26 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 */ 30 31 /** 32 * @todo Document this class 33 * @package PHPonTrax 34 */ 35 class Trax { 36 37 public static 38 $models_path = null, 39 $views_path = null, 40 $controllers_path = null, 41 $helpers_path = null, 42 $layouts_path = null, 43 $config_path = null, 44 $environments_path = null, 45 $lib_path = null, 46 $app_path = null, 47 $log_path = null, 48 $vendor_path = null, 49 $public_path = null, 50 $url_prefix = null, 51 $views_extension = 'phtml', 52 $path_seperator = ":", # default is Unix 53 $current_controller_path = null, 54 $current_controller_name = null, 55 $current_action_name = null, 56 $current_controller_object = null; 57 58 59 function initialize() { 60 61 if(substr(PHP_OS, 0, 3) == 'WIN') { 62 # Windows 63 self::$path_seperator = ";"; 64 } 65 66 # Set include paths 67 self::$models_path = TRAX_ROOT."/app/models"; 68 self::$views_path = TRAX_ROOT."/app/views"; 69 self::$controllers_path = TRAX_ROOT."/app/controllers"; 70 self::$helpers_path = TRAX_ROOT."/app/helpers"; 71 self::$layouts_path = TRAX_ROOT."/app/views/layouts"; 72 self::$config_path = TRAX_ROOT."/config"; 73 self::$environments_path = TRAX_ROOT."/config/environments"; 74 self::$lib_path = TRAX_ROOT."/lib"; 75 self::$app_path = TRAX_ROOT."/app"; 76 self::$log_path = TRAX_ROOT."/log"; 77 self::$vendor_path = TRAX_ROOT."/vendor"; 78 self::$public_path = TRAX_ROOT."/public"; 79 80 # Set which file to log php errors to for this application 81 # As well in your application you can do error_log("whatever") and it will go to this log file. 82 ini_set("log_errors", "On"); 83 ini_set("error_log", self::$log_path."/".TRAX_ENV.".log"); 84 85 if(TRAX_ENV == "development") { 86 # Display errors to browser if in development mode for debugging 87 ini_set("display_errors", "On"); 88 } else { 89 # Hide errors from browser if not in development mode 90 ini_set("display_errors", "Off"); 91 } 92 93 # Set the include_path 94 ini_set("include_path", 95 ".".self::$path_seperator. # current directory 96 TRAX_LIB_ROOT.self::$path_seperator. # trax libs (vendor/trax or server trax libs) 97 PHP_LIB_ROOT.self::$path_seperator. # php libs dir (ex: /usr/local/lib/php) 98 TRAX_ROOT.self::$lib_path.self::$path_seperator. # app specific libs extra libs to include 99 ini_get("include_path")); # add on old include_path to end 100 101 # Include Trax library files. 102 include_once ("session.php"); 103 include_once ("input_filter.php"); 104 include_once ("trax_exceptions.php"); 105 include_once ("inflector.php"); 106 include_once ("active_record.php"); 107 include_once ("action_controller.php"); 108 include_once ("action_view.php"); 109 include_once ("action_mailer.php"); 110 include_once ("dispatcher.php"); 111 include_once ("router.php"); 112 113 # Make sure database settings are cleared out 114 ActiveRecord::$database_settings = array(); 115 if(file_exists(self::$config_path."/database.ini")) { 116 # Load databse settings 117 ActiveRecord::$database_settings = parse_ini_file(self::$config_path."/database.ini", true); 118 } 119 120 } 121 122 function include_env_config() { 123 # Include the application environment specific config file 124 if(file_exists(self::$environments_path."/".TRAX_ENV.".php")) { 125 include_once(self::$environments_path."/".TRAX_ENV.".php"); 126 } 127 } 128 } 129 130 131 ################################################################### 132 # Auto include model / controller / other app specific libs files 133 ################################################################### 134 function __autoload($class_name) { 135 $file = Inflector::underscore($class_name).".php"; 136 $file_org = $class_name.".php"; 137 138 if(file_exists(Trax::$models_path."/$file")) { 139 # Include model classes 140 include_once(Trax::$models_path."/$file"); 141 } elseif(file_exists(Trax::$controllers_path."/$file")) { 142 # Include extra controller classes 143 include_once(Trax::$controllers_path."/$file"); 144 } elseif(file_exists(Trax::$lib_path."/$file")) { 145 # Include users application libs 146 include_once(Trax::$lib_path."/$file"); 147 } elseif(file_exists(Trax::$lib_path."/$file_org")) { 148 # Include users application libs 149 include_once(Trax::$lib_path."/$file_org"); 150 } 151 } 152 153 154 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 20:04:38 2007 | par Balluche grâce à PHPXref 0.7 |