Changeset 3381

Show
Ignore:
Timestamp:
08/28/2008 03:10:50 PM (3 months ago)
Author:
Shadowhand
Message:

Follow up to r3366:

  • Updated config and routes configuration comments
  • Added "prefix" to routes, to allow prefixes to be added to any route key
  • Removed slash-to-underscore modification to controller and method keys...that was a bit of a hack, anyways
Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/config/config.php

    r3376 r3381  
    11<?php 
    22/** 
    3  * Base path of the web site. If this includes a domain, eg: localhost/kohana/ 
    4  * then a full URL will be used, eg: http://localhost/kohana/. If it only includes 
    5  * the path, and a site_protocol is specified, the domain will be auto-detected. 
     3 * Base URL path of the website, including domain. 
     4 * 
     5 *     $config['site_domain'] = '/kohana/'; 
     6 * 
     7 * If the site_domain contains a domain, eg: wwww.example.com/kohana/, then a 
     8 * full URL, including the protocol and domain will be generated. If set to a 
     9 * a path, generated URLs will not contain a domain name. (See exception in 
     10 * [site_protocol][ref-sip] below.) 
    611 */ 
    7 $config['site_domain'] = '/kohana/trunk/'; 
     12$config['site_domain'] = '/kohana/'; 
    813 
    914/** 
    10  * Force a default protocol to be used by the site. If no site_protocol is 
    11  * specified, then the current protocol is used, or when possible, only an 
    12  * absolute path (with no protocol/domain) is used. 
     15 * Set a default protocol protocol for this application. 
     16 * 
     17 *     $config['site_protocol'] = ''; 
     18 * 
     19 * If no site_protocol is specified, then the current protocol will be detected. 
     20 * This setting must be left empty if you do not want generated URLs to not 
     21 * contain the domain name. 
    1322 */ 
    1423$config['site_protocol'] = ''; 
    1524 
    1625/** 
    17  * Name of the front controller for this application. Default: index.php 
     26 * Name of the front controller for this application.  
    1827 * 
    19  * This can be removed by using URL rewriting. 
     28 *     $config['index_page'] = 'index.php'; 
     29 * 
     30 * If the front controller is removed from the URL using [rewriting][ref-url], 
     31 * this setting must be set to an empty string, or generated URLs will still 
     32 * contain the index_page filename. 
     33 * 
     34 * [ref-url]: http://doc.kohanaphp.com/routing 
    2035 */ 
    2136$config['index_page'] = 'index.php'; 
    2237 
    2338/** 
    24  * Fake file extension that will be added to all generated URLs. Example: .html 
    25  */ 
    26 $config['url_suffix'] = ''; 
    27  
    28 /** 
    29  * Length of time of the internal cache in seconds. 0 or FALSE means no caching. 
    30  * The internal cache stores file paths and config entries across requests and 
    31  * can give significant speed improvements at the expense of delayed updating. 
     39 * Length of internal configuration, language, and include path caching. 
     40 * 
     41 *    $config['internal_cache'] = FALSE; 
     42 * 
     43 * Disabled by default, internal caching can give significant speed improvements 
     44 * at the expense of configuration changes being visibly delayed. Enabling 
     45 * short (30-300) seconds of internal caching on production sites is a highly 
     46 * recommended way to increase performance. 
    3247 */ 
    3348$config['internal_cache'] = FALSE; 
    3449 
    3550/** 
    36  * Enable or disable gzip output compression. This can dramatically decrease 
    37  * server bandwidth usage, at the cost of slightly higher CPU usage. Set to 
    38  * the compression level (1-9) that you want to use, or FALSE to disable. 
     51 * Enable or disable gzip output compression. 
    3952 * 
    40  * Do not enable this option if you are using output compression in php.ini! 
     53 *     $config['output_compression'] = FALSE; 
     54 * 
     55 * Disabled by default, gzip output compression can significantly increase page 
     56 * latency by decreasing server bandwidth usage, at the cost of slightly higher 
     57 * CPU usage. A number from 1-9 can be used to set the compression level, or 
     58 * TRUE can be used to use the PHP default. 
     59 * 
     60 * **Do not enable this if PHP output compression is enabled in php.ini!** 
    4161 */ 
    4262$config['output_compression'] = FALSE; 
    4363 
    4464/** 
    45  * Enable or disable global XSS filtering of GET, POST, and SERVER data. This 
    46  * option also accepts a string to specify a specific XSS filtering tool. 
     65 * Enable or disable statistics in the final output. 
     66 * 
     67 *     $config['render_stats'] = TRUE; 
     68 * 
     69 * Enable by default, this will replace specific stings in generated output 
     70 * with generated statistics or information. 
     71 * 
     72 * {execution_time} 
     73 * :  Total execution time in seconds 
     74 * 
     75 * {memory_usage} 
     76 * :  Total memory usage in megabytes (MB) 
     77 * 
     78 * {included_files} 
     79 * :  All of the filenames that are currently loaded 
     80 * 
     81 * {kohana_version} 
     82 * :  The Kohana release version number 
     83 * 
     84 * {kohana_codename} 
     85 * :  The Kohana release code name 
     86 * 
     87 * This setting can be disabled for a small performance increase. 
     88 */ 
     89$config['render_stats'] = TRUE; 
     90 
     91/** 
     92 * Enable or disable global XSS filtering of GET, POST, and SERVER data. 
     93 * 
     94 *    $config['global_xss_filtering'] = TRUE; 
     95 * 
     96 * Enabled by default, global XSS filtering prevents client-side output attacks. 
     97 * This can either be TRUE or 'htmlpurifier' to use [HTMLPurifier][ref-hpr]. 
    4798 */ 
    4899$config['global_xss_filtering'] = TRUE; 
    49  
    50 /** 
    51  * Enable or disable hooks. Setting this option to TRUE will enable 
    52  * all hooks. By using an array of hook filenames, you can control 
    53  * which hooks are enabled. Setting this option to FALSE disables hooks. 
    54  */ 
    55 $config['enable_hooks'] = FALSE; 
    56  
    57 /** 
    58  * Log thresholds: 
    59  *  0 - Disable logging 
    60  *  1 - Errors and exceptions 
    61  *  2 - Warnings 
    62  *  3 - Notices 
    63  *  4 - Debugging 
    64  */ 
    65 $config['log_threshold'] = 1; 
    66  
    67 /** 
    68  * Message logging directory. 
    69  */ 
    70 $config['log_directory'] = APPPATH.'logs'; 
    71100 
    72101/** 
     
    77106 
    78107/** 
    79  * Enable or disable statistics in the final output. Stats are replaced via 
    80  * specific strings, such as {execution_time}. 
     108 * Set default logging threshold. 
    81109 * 
    82  * @see http://docs.kohanaphp.com/general/configuration 
     110 *     $config['log_threshold'] = 1; 
     111 * 
     112 * It is highly recommended to enable error and exception logging on production 
     113 * websites and to disable  
     114 * 
     115 * - 0: Disable all logging 
     116 * - 1: Log only PHP errors and exceptions 
     117 * - 2: Also log PHP warnings 
     118 * - 3: Also log PHP notices 
     119 * - 4: Also log Kohana debugging messages 
     120 * 
    83121 */ 
    84 $config['render_stats'] = TRUE; 
     122$config['log_threshold'] = 1; 
     123 
     124/** 
     125 * Set default logging directory. 
     126 * 
     127 *     $config['log_directory'] = APPPATH.'logs'; 
     128 * 
     129 * Any writable directory can be specified here. Path can be relative to the 
     130 * DOCROOT, or an absolute path. 
     131 */ 
     132$config['log_directory'] = APPPATH.'logs'; 
     133 
     134/** 
     135 * Enable or disable hooks, raw PHP files that are included during setup. 
     136 * 
     137 *     $config['enable_hooks'] = FALSE; 
     138 * 
     139 * Disabled by default, hooks allow you to change default Events, run custom 
     140 * code, and extend Kohana in completely custom ways. This option can be set 
     141 * to TRUE, FALSE, or an array of filenames (no extension). 
     142 */ 
     143$config['enable_hooks'] = FALSE; 
    85144 
    86145/** 
    87146 * Additional resource paths, or "modules". Each path can either be absolute 
    88  * or relative to the docroot. Modules can include any resource that can exist 
     147 * or relative to the DOCROOT. Modules can include any resource that can exist 
    89148 * in your application directory, configuration files, controllers, views, etc. 
    90149 */ 
  • trunk/system/classes/router.php

    r3371 r3381  
    1212class Router_Core { 
    1313 
     14        public static $readonly_keys = array('regex', 'prefix'); 
     15 
    1416        public static $current_uri  = ''; 
    1517        public static $query_string = ''; 
     
    7678                                        foreach ($keys as $i => $key) 
    7779                                        { 
     80                                                if (in_array($key, Router::$readonly_keys)) 
     81                                                { 
     82                                                        // Skip keys that are readonly, such as "regex" 
     83                                                        continue; 
     84                                                } 
     85 
    7886                                                if (isset($matches[$i])) 
    7987                                                { 
    8088                                                        // Set the route value from the URI 
    8189                                                        $route[$key] = $matches[$i]; 
     90                                                } 
     91 
     92                                                if (isset($route['prefix'][$key])) 
     93                                                { 
     94                                                        // Add the prefix to the key 
     95                                                        $route[$key] = $route['prefix'][$key].$route[$key]; 
    8296                                                } 
    8397 
     
    90104                                } 
    91105 
    92                                 // Set controller name 
    93                                 self::$controller = str_replace('/', '_', $route['controller']); 
    94  
    95106                                if (isset($route['method'])) 
    96107                                { 
    97108                                        // Set controller method 
    98                                         self::$method = str_replace('/', '_', $route['method']); 
     109                                        self::$method = $route['method']; 
    99110                                } 
    100111                                else 
  • trunk/system/config/profiler.php

    r3366 r3381  
    88 * sections can be used too. 
    99 */ 
    10 $config['show'] = array('benchmarks'); 
     10$config['show'] = TRUE; 
  • trunk/system/config/routes.php

    r3366 r3381  
    44 * @package  Core 
    55 * 
    6  * Sets default routing, allowing up to 3 segments to be used: 
    7  *  - controller, defaults to "welcome" 
    8  *  - method, defaults to "index" 
    9  *  - id, no default 
     6 * Sets default routing, allowing up to 3 segments to be used. 
     7 * 
     8 *     $config['default'] = array 
     9 *     ( 
     10 *         // Default routing 
     11 *         :controller/:method/:id.xml', 
     12 *     
     13 *         // Defaults for route keys 
     14 *         'controller' => 'welcome', 
     15 *         'method' => 'index', 
     16 *     ); 
    1017 * 
    1118 * The converted regex for this route is: 
    1219 * 
    1320 *     (?:([^/]+)(?:/([^/]+)(?:/([^/]+))?)?)? 
     21 * 
     22 * To define a specific pattern for a key, you can use the special "regex" key: 
     23 * 
     24 *     $config['default'] = array 
     25 *     ( 
     26 *         // Limit the controller to letters and underscores 
     27 *         'regex' => array('controller' => '[a-z_]+'), 
     28 *     ); 
     29 * 
     30 * To add a prefix to any key, you can use the special "prefix" key: 
     31 * 
     32 *     $config['admin'] = array 
     33 *     ( 
     34 *         'admin/:controller/:method/:id', 
     35 * 
     36 *         // Will change all controllers to admin_:controller 
     37 *         'prefix' => array('controller' => 'admin_'), 
     38 *     ); 
    1439 * 
    1540 */