Changeset 1250
- Timestamp:
- 11/23/2007 05:10:56 PM (11 months ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
application/config/config.php (modified) (4 diffs)
-
system/core/Benchmark.php (modified) (1 diff)
-
system/core/Bootstrap.php (modified) (2 diffs)
-
system/core/Kohana.php (modified) (6 diffs)
-
system/helpers/text.php (modified) (2 diffs)
-
system/helpers/url.php (modified) (1 diff)
-
system/libraries/Router.php (modified) (1 diff)
-
system/libraries/Validation.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/application/config/config.php
r1230 r1250 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * File: config.php 4 * This configuration file is unique to every application. 3 * Site-specific application configuration is done here. This configuration file 4 * does not extend any other configuration file. All of the items here are prefixed 5 * with "core", eg: core.index_page would fetch the index_page variable from the 6 * configuration array. 5 7 * 6 8 * Options: … … 9 11 * index_page - name of the front controller, can be removed with URL rewriting 10 12 * url_suffix - an extension that will be added to all generated URLs 13 * enable_utf8 - enable or disable internal utf8 support 14 * global_xss_filtering - enable or disable XSS attack filtering on all user input 11 15 * allow_config_set - enable or disable setting of Config items 12 * global_xss_filtering - enable or disable XSS attack filtering on all user input13 16 * extension_prefix - filename prefix for library extensions 14 * include_paths - extra Kohana resource paths, see <Kohana.find_file>17 * include_paths - "module" support, additional resource paths that will be searched 15 18 * autoload - libraries and models to be loaded with the controller 16 19 */ … … 21 24 'index_page' => 'index.php', 22 25 'url_suffix' => '', 23 ' allow_config_set'=> TRUE,26 'enable_utf8' => TRUE, 24 27 'global_xss_filtering' => FALSE, 28 'allow_config_set' => FALSE, 25 29 'extension_prefix' => 'MY_', 26 30 'include_paths' => array 27 31 ( 28 // 'modules/auth', 29 // 'modules/ikeafans', 30 // 'modules/user_guide', 31 // 'modules/orm', 32 'modules/kodoc', 33 // 'modules/mixnotify' 32 // To enable the demo module, uncomment the following line 33 // 'modules/demo', 34 34 ), 35 35 'autoload' => array … … 37 37 'libraries' => '', 38 38 'models' => '' 39 ) 39 ), 40 40 ); -
trunk/system/core/Benchmark.php
r1230 r1250 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * Kohana 4 * 5 * copyright - (c) 2007 Kohana Team 6 * license - <http://kohanaphp.com/license.html> 7 * revision - $Id$ 8 */ 9 10 /** 3 11 * Simple benchmarking. 4 *5 * Kohana Source Code:6 * author - Kohana Team7 * copyright - (c) 2007 Kohana Team8 * license - <http://kohanaphp.com/license.html>9 12 */ 10 13 final class Benchmark { -
trunk/system/core/Bootstrap.php
r1230 r1250 18 18 Benchmark::start(SYSTEM_BENCHMARK.'_total_execution_time'); 19 19 20 Benchmark::start(SYSTEM_BENCHMARK.'_environment_setup'); 21 require SYSPATH.'core/utf8'.EXT; 20 Benchmark::start(SYSTEM_BENCHMARK.'_kohana_loading'); 22 21 require SYSPATH.'core/Config'.EXT; 23 22 require SYSPATH.'core/Log'.EXT; 24 23 require SYSPATH.'core/Event'.EXT; 25 24 require SYSPATH.'core/Kohana'.EXT; 25 Benchmark::stop(SYSTEM_BENCHMARK.'_kohana_loading'); 26 26 27 27 Event::run('system.setup'); 28 Benchmark::stop(SYSTEM_BENCHMARK.'_environment_setup');29 28 30 29 Benchmark::start(SYSTEM_BENCHMARK.'_system_initialization'); … … 33 32 Benchmark::stop(SYSTEM_BENCHMARK.'_system_initialization'); 34 33 35 Benchmark::start(SYSTEM_BENCHMARK.'_controller_execution');36 34 Event::run('system.execute'); 37 Benchmark::stop(SYSTEM_BENCHMARK.'_controller_execution');38 35 39 36 Event::run('system.shutdown'); -
trunk/system/core/Kohana.php
r1249 r1250 83 83 return; 84 84 85 // Start the environment setup benchmark 86 Benchmark::start(SYSTEM_BENCHMARK.'_environment_setup'); 87 85 88 if (function_exists('date_default_timezone_set')) 86 89 { … … 112 115 set_magic_quotes_runtime(0); 113 116 117 // Only include utf8 support if it's enabled 118 Config::item('core.enable_utf8') and require SYSPATH.'core/utf8'.EXT; 119 114 120 // Send default text/html UTF-8 header 115 121 header('Content-type: text/html; charset=UTF-8'); … … 154 160 // Setup is complete, prevent it from being run again 155 161 $run = TRUE; 162 163 // Stop the environment setup routine 164 Benchmark::start(SYSTEM_BENCHMARK.'_environment_setup'); 156 165 } 157 166 … … 164 173 if (self::$instance == FALSE) 165 174 { 175 Benchmark::start(SYSTEM_BENCHMARK.'_controller_setup'); 176 166 177 // Include the Controller file 167 178 require Router::$directory.Router::$controller.EXT; … … 217 228 // Run system.post_controller_constructor 218 229 Event::run('system.post_controller_constructor'); 230 231 // Stop the controller setup benchmark 232 Benchmark::stop(SYSTEM_BENCHMARK.'_controller_setup'); 233 234 // Start the controller execution benchmark 235 Benchmark::start(SYSTEM_BENCHMARK.'_controller_execution'); 219 236 220 237 // Controller method name, used for calling … … 253 270 // Run system.post_controller 254 271 Event::run('system.post_controller'); 272 273 Benchmark::stop(SYSTEM_BENCHMARK.'_controller_execution'); 255 274 } 256 275 -
trunk/system/helpers/text.php
r1230 r1250 53 53 * A character-limited string with the end character attached. 54 54 */ 55 public static function limit_chars($str, $limit = 100, $end_char = '…', $preserve_words = FALSE) 56 { 55 public static function limit_chars($str, $limit = 100, $end_char = NULL, $preserve_words = FALSE) 56 { 57 $end_char = ($end_char === NULL) ? '…' : $end_char; 58 57 59 $limit = (int) $limit; 58 60 59 if (trim($str) == '' OR utf8::strlen($str) <= $limit)61 if (trim($str) == '' OR (class_exists('utf8', FALSE) AND utf8::strlen($str) <= $limit) OR strlen($str) <= $limit) 60 62 return $str; 61 63 … … 63 65 return $end_char; 64 66 65 if ( ! $preserve_words) 66 return rtrim(utf8::substr($str, 0, $limit)).$end_char; 67 if ($preserve_words == FALSE) 68 { 69 return rtrim(class_exists('utf8', FALSE) ? utf8::substr($str, 0, $limit) : substr($str, 0, $limit)).$end_char; 70 } 67 71 68 72 preg_match('/^.{'.($limit - 1).'}\S*/us', $str, $matches); -
trunk/system/helpers/url.php
r1230 r1250 102 102 $title = preg_replace('/[-_\s]+/', $separator, $title); 103 103 104 // Replace accented characters by their unaccented equivalents 105 $title = utf8::transliterate_to_ascii($title); 104 if (class_exists('utf8', FALSE)) 105 { 106 // Replace accented characters by their unaccented equivalents 107 $title = utf8::transliterate_to_ascii($title); 108 } 106 109 107 110 // Remove all characters that are not a-z, 0-9, or the separator -
trunk/system/libraries/Router.php
r1230 r1250 207 207 list ($key, $val) = array_pad(explode('=', $pair), 1, ''); 208 208 209 $_GET[utf8::clean($key)] = utf8::clean($val); 209 if (class_exists('utf8', FALSE)) 210 { 211 $_GET[utf8::clean($key)] = utf8::clean($val); 212 } 213 else 214 { 215 $_GET[$key] = $val; 216 } 210 217 } 211 218 } -
trunk/system/libraries/Validation.php
r1230 r1250 773 773 if (ctype_digit($val)) 774 774 { 775 if (utf8::strlen($str) >= $val) 776 return TRUE; 775 if (class_exists('utf8', FALSE)) 776 { 777 if (utf8::strlen($str) >= $val) 778 return TRUE; 779 } 780 else 781 { 782 if (strlen($str) >= $val) 783 return TRUE; 784 } 777 785 } 778 786 … … 798 806 if (ctype_digit($val)) 799 807 { 800 if (utf8::strlen($str) <= $val) 801 return TRUE; 808 if (class_exists('utf8', FALSE)) 809 { 810 if (utf8::strlen($str) <= $val) 811 return TRUE; 812 } 813 else 814 { 815 if (strlen($str) <= $val) 816 return TRUE; 817 } 802 818 } 803 819 … … 823 839 if (ctype_digit($val)) 824 840 { 825 if (utf8::strlen($str) == $val) 826 return TRUE; 841 if (class_exists('utf8', FALSE)) 842 { 843 if (utf8::strlen($str) == $val) 844 return TRUE; 845 } 846 else 847 { 848 if (strlen($str) == $val) 849 return TRUE; 850 } 827 851 } 828 852
