| [ Index ] |
|
Code source de PHPonTrax 2.6.6-svn |
[Code source] [Imprimer] [Statistiques]
File containing ActionController class (PHP 5)
| Copyright: | (c) 2005 John Peterson |
| Version: | $Id: action_controller.php 229 2006-07-18 11:20:04Z john $ |
| Poids: | 1293 lignes (49 kb) |
| Inclus ou requis: | 1 fois |
| Référencé: | 0 fois |
| Nécessite: | 2 fichiers vendor/trax/templates/error.phtml vendor/trax/scaffold_controller.php |
ActionController:: (22 méthodes):
__construct()
__set()
__call()
load_router()
recognize_route()
process_route()
set_paths()
execute_before_filters()
add_before_filter()
execute_after_filters()
add_after_filter()
add_helper()
render()
render_text()
render_action()
render_to_string()
render_file()
render_partial()
determine_layout()
redirect_to()
raise()
process_with_exception()
Classe: ActionController - X-Ref
Action controller| __construct() X-Ref |
| Build a Router object and load routes from config/route.php |
| __set($key, $value) X-Ref |
| __call($method_name, $parameters) X-Ref |
| load_router() X-Ref |
| Load routes from configuration file config/routes.php Routes are loaded by requiring {@link routes.php} from the configuration directory. The file routes.php contains statements of the form "$router->connect(path,params);" where (path,params) describes the route being added by the statement. Route syntax is described in {@tutorial PHPonTrax/Router.cls the Router class tutorial}. |
| recognize_route() X-Ref |
| Convert URL to controller, action and id Parse the URL in {@link http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server $_SERVER}['REDIRECT_URL'] into elements. Compute filesystem paths to the various components used by the URL and store the paths in object private variables. Verify that the controller exists. return: boolean |
| process_route() X-Ref |
| Parse URL, extract controller and action and execute them return: boolean true |
| set_paths() X-Ref |
| Extend the search path for components On entry, $url_path is set according to the browser's URL and $controllers_path has been set according to the configuration in {@link environment.php config/environment.php} . Examine the $controllers_path directory for files or directories that match any component of the URL. If one is found, add that component to all paths. Replace the contents of $url_path with the list of URL components that did NOT match any files or directories. |
| execute_before_filters() X-Ref |
| Execute the before filters |
| add_before_filter($filter_function_name) X-Ref |
| Append a before filter to the filter chain param: mixed $filter_function_name String with the name of |
| execute_after_filters() X-Ref |
| Execute the after filters |
| add_after_filter($filter_function_name) X-Ref |
| Append an after filter to the filter chain param: mixed $filter_function_name String with the name of |
| add_helper($helper_name) X-Ref |
| Add a helper to the list of helpers used by a controller object param: $helper_name string Name of a helper to add to the list |
| render($options = array() X-Ref |
| Renders the content that will be returned to the browser as the response body. |
| render_text($text, $options = array() X-Ref |
| Rendering of text is usually used for tests or for rendering prepared content. By default, text rendering is not done within the active layout. # Renders the clear text "hello world" render(array("text" => "hello world!")) # Renders the clear text "Explosion!" render(array("text" => "Explosion!")) # Renders the clear text "Hi there!" within the current active layout (if one exists) render(array("text" => "Explosion!", "layout" => true)) # Renders the clear text "Hi there!" within the layout # placed in "app/views/layouts/special.phtml" render(array("text" => "Explosion!", "layout" => "special")) |
| render_action($action, $options = array() X-Ref |
| Action rendering is the most common form and the type used automatically by Action Controller when nothing else is specified. By default, actions are rendered within the current layout (if one exists). # Renders the template for the action "goal" within the current controller render(array("action" => "goal")) # Renders the template for the action "short_goal" within the current controller, # but without the current active layout render(array("action" => "short_goal", "layout" => false)) # Renders the template for the action "long_goal" within the current controller, # but with a custom layout render(array("action" => "long_goal", "layout" => "spectacular")) |
| render_to_string($options = array() X-Ref |
| Renders according to the same rules as render, but returns the result in a string instead of sending it as the response body to the browser. |
| render_file($path, $use_full_path = false, $locals = array() X-Ref |
| File rendering works just like action rendering except that it takes a filesystem path. By default, the path is assumed to be absolute, and the current layout is not applied. # Renders the template located at the absolute filesystem path render(array("file" => "/path/to/some/template.phtml")) render(array("file" => "c:/path/to/some/template.phtml")) # Renders a template within the current layout render(array("file" => "/path/to/some/template.rhtml", "layout" => true)) render(array("file" => "c:/path/to/some/template.rhtml", "layout" => true)) # Renders a template relative to app/views render(array("file" => "some/template", "use_full_path" => true)) |
| render_partial($path, $options = array() X-Ref |
| Rendering partials <p>Partial rendering is most commonly used together with Ajax calls that only update one or a few elements on a page without reloading. Rendering of partials from the controller makes it possible to use the same partial template in both the full-page rendering (by calling it from within the template) and when sub-page updates happen (from the controller action responding to Ajax calls). By default, the current layout is not used.</p> <ul> <li><samp>render_partial("win");</samp><br> Renders the partial located at app/views/controller/_win.phtml</li> <li><samp>render_partial("win", array("locals" => array("name" => "david")));</samp><br> Renders the same partial but also makes a local variable available to it</li> <li><samp>render_partial("win", array("collection" => array(...)));</samp><br> Renders a collection of the same partial by making each element of the collection available through the local variable "win" as it builds the complete response </li> <li><samp>render_partial("win", array("collection" => $wins, "spacer_template" => "win_divider"));</samp><br> Renders the same collection of partials, but also renders the win_divider partial in between each win partial.</li> </ul> param: string $path Path to file containing partial view param: string[] $options Options array |
| determine_layout($full_path = true) X-Ref |
| Select a layout file based on the controller object return: mixed Layout file or null if none |
| redirect_to($options = null) X-Ref |
| Redirect the browser to a specified target Redirect the browser to the target specified in $options. This parameter can take one of three forms: <ul> <li>Array: The URL will be generated by calling {@link url_for()} with the options.</li> <li>String starting with a protocol:// (like http://): Is passed straight through as the target for redirection.</li> <li>String not containing a protocol: The current protocol and host is prepended to the string.</li> <li>back: Back to the page that issued the request. Useful for forms that are triggered from multiple places. Short-hand for redirect_to(request.env["HTTP_REFERER"]) </ul> Examples: <ul> <li>redirect_to(array(":action" => "show", ":id" => 5))</li> <li>redirect_to("http://www.rubyonrails.org")</li> <li>redirect_to("/images/screenshot.jpg")</li> <li>redirect_to("back")</li> </ul> param: mixed $options array or string url |
| raise($error_message, $error_heading, $error_code = "404") X-Ref |
| Raise an ActionControllerError exception param: string $error_message Error message param: string $error_heading Error heading param: string $error_code Error code |
| process_with_exception(&$exception) X-Ref |
| Generate an HTML page describing an error |
| Généré le : Sun Feb 25 20:04:38 2007 | par Balluche grâce à PHPXref 0.7 |