Show
Ignore:
Timestamp:
03/07/06 09:44:21 (6 years ago)
Author:
haas
Message:

partial doc, test of ActionController?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/action_controller.php

    r162 r163  
    186186 
    187187    /** 
    188      *  @todo Document this attribute 
     188     *  Name of the controller (without the _controller.php) 
     189     * 
     190     *  Set by {@link recognize_route()} 
     191     *  @var string 
    189192     */ 
    190193    private $controller; 
    191194 
    192195    /** 
    193      *  @todo Document this attribute 
     196     *  Name of the action method in the controller class 
     197     * 
     198     *  Set by {@link recognize_route()} 
     199     *  @var string 
    194200     */ 
    195201    private $action; 
     
    201207 
    202208    /** 
    203      *  @todo Document this attribute 
     209     *  Filesystem path to ../app/controllers/ directory 
     210     * 
     211     *  Set by {@link recognize_route()} 
     212     *  @var string 
    204213     */ 
    205214    private $controllers_path; 
    206215 
    207216    /** 
    208      *  @todo Document this attribute 
     217     *  Filesystem path to ../app/helpers/ directory 
     218     * 
     219     *  Set by {@link recognize_route()} 
     220     *  @var string 
    209221     */ 
    210222    private $helpers_path; 
     
    216228 
    217229    /** 
    218      *  @todo Document this attribute 
     230     *  Filesystem path to ../app/layouts/ directory 
     231     * 
     232     *  Set by {@link recognize_route()} 
     233     *  @todo <b>FIXME:</> declare $layouts_base_path 
     234     *  @var string 
    219235     */ 
    220236    private $layouts_path; 
    221237 
    222238    /** 
    223      *  @todo Document this attribute 
     239     *  User's URL in components 
     240     * 
     241     *  Contains user's URL stripped of TRAX_URL_PREFIX and leading 
     242     *  and trailing slashes, then exploded into an array on slash 
     243     *  boundaries. 
     244     *  @var string[] 
    224245     */ 
    225246    private $url_path; 
    226247 
    227248    /** 
    228      *  @todo Document this attribute 
     249     *  Filesystem path to the default layouts file application.phtml 
     250     * 
     251     *  Set by {@link recognize_route()} 
     252     *  @var string 
    229253     */ 
    230254    private $default_layout_file; 
     
    236260 
    237261    /** 
    238      *  @todo Document this attribute 
     262     *  Filesystem path to application.php file 
     263     * 
     264     *  Set by {@link recognize_route()} 
     265     *  @var string 
    239266     */ 
    240267    private $application_controller_file; 
    241268 
    242269    /** 
    243      *  @todo Document this attribute 
     270     *  Filesystem path to application_helper.php file 
     271     * 
     272     *  Set by {@link recognize_route()} 
     273     *  @var string 
    244274     */ 
    245275    private $application_helper_file; 
    246276 
    247277    /** 
    248      *  @todo Document this attribute 
     278     *  URL recognized, paths resoved, controller file found 
     279     * 
     280     *  Set by {@link recognize_route()} 
     281     *  @var boolean 
    249282     */ 
    250283    private $loaded = false; 
     
    258291     *    <li>false => no Router object exists</li> 
    259292     *  </ul> 
     293     *  @todo <b>FIXME:</b> No declaration of $router so no place to hang 
     294     *    its documentation. 
    260295     */ 
    261296    private $router_loaded = false; 
     
    297332 
    298333    /** 
    299      *  @todo Document this attribute 
     334     *  Filesystem path to the ../app/views/ directory 
     335     * 
     336     *  Set by {@link recognize_route()} 
     337     *  @var string 
    300338     */ 
    301339    public $views_path; 
     
    322360 
    323361    /** 
     362     *  Build a Router object and load routes from config/route.php 
     363     *  @uses load_router() 
     364     */ 
     365    function __construct() { 
     366        if(!isset($this->router) || !is_object($this->router)) { 
     367            $this->load_router(); 
     368        } 
     369    } 
     370 
     371    /** 
    324372     *  @todo Document this method 
    325      */ 
    326     function __construct() { 
    327       if(!isset($this->router) || !is_object($this->router)) { 
    328             $this->load_router(); 
    329         } 
    330     } 
    331  
    332     /** 
    333      *  @todo Document this method 
     373     *  @uses add_after_filter() 
     374     *  @uses add_before_filter() 
     375     *  @uses add_helper() 
    334376     */ 
    335377    function __set($key, $value) { 
    336         #echo "setting: $key = $value<br>"; 
    337378        if($key == "before_filter") { 
    338379            $this->add_before_filter($value); 
     
    348389    /** 
    349390     *  @todo Document this method 
     391     *  Implement before_filter(), after_filter(), helper() 
    350392     */ 
    351393    function __call($method_name, $parameters) { 
     
    366408 
    367409    /** 
    368      *  Load routes from configuration file routes.php 
     410     *  Load routes from configuration file config/routes.php 
    369411     * 
    370412     *  Routes are loaded by requiring {@link routes.php} from the 
    371      *  configuration directory. 
     413     *  configuration directory.  The file routes.php contains 
     414     *  statements of the form "$router->connect(path,params);" where 
     415     *  (path,params) describes the route being added by the 
     416     *  statement. Route syntax is described in 
     417     *  {@tutorial PHPonTrax/Router.cls the Router class tutorial}. 
     418     * 
    372419     *  @uses Router 
    373420     *  @uses $router 
     
    377424        $this->router_loaded = false; 
    378425        $router = new Router(); 
    379         # Load the routes 
    380         require_once(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['config']."/routes.php"); 
     426 
     427        // Load the routes. 
     428        require(TRAX_ROOT.$GLOBALS['TRAX_INCLUDES']['config']."/routes.php"); 
    381429        $this->router = $router; 
    382430        if(is_object($this->router)) { 
     
    386434 
    387435    /** 
    388      *  @todo Document this method 
     436     *  Convert URL to controller, action and id 
     437     * 
     438     *  Parse the URL in $_SERVER['REDIRECT_URL'] into elements. 
     439     *  Compute filesystem paths to the various components used by the 
     440     *  URL and store the paths in object private variables. 
     441     *  Verify that the controller exists. 
     442     * 
    389443     *  @uses load_router() 
     444     *  @uses $action 
     445     *  @uses $application_controller_file 
     446     *  @uses $controller 
     447     *  @uses $controller_class 
     448     *  @uses $controller_file 
     449     *  @uses $controllers_path 
     450     *  @uses $default_layout_file 
     451     *  @uses $helper_file 
     452     *  @uses $helpers_path 
     453     *  @uses $id 
     454     *  @uses $layouts_path 
     455     *  @uses $loaded 
    390456     *  @uses $router 
    391457     *  @uses $router_loaded 
    392458     *  @uses set_paths() 
    393459     *  @uses $url_path 
     460     *  @uses $views_file_extention 
     461     *  @uses $views_path 
     462     *  @return boolean 
     463     *  <ul> 
     464     *    <li>true =>  route recognized, controller found.</li> 
     465     *    <li>false => failed, route not recognized.</li> 
     466     *  </ul> 
    394467     */ 
    395468    function recognize_route() { 
    396  
    397469        if(!$this->router_loaded) { 
    398470            $this->load_router(); 
     
    448520                } 
    449521 
     522                //  FIXME: get a warning if ':id' not in $url_path 
    450523                if(@in_array(":id",$route_path)) { 
    451524                    $this->id = strtolower($this->url_path[@array_search(":id", $route_path)]); 
     
    473546    /** 
    474547     *  @todo Document this method 
     548     *  @uses $action 
     549     *  @uses $application_controller_file 
     550     *  @uses $application_helper_file 
     551     *  @uses $controller 
     552     *  @uses $controller_class 
     553     *  @uses $controller_file 
     554     *  @uses $controller_object 
     555     *  @uses determine_layout() 
     556     *  @uses execute_after_filters() 
     557     *  @uses $helpers 
     558     *  @uses $helper_file 
     559     *  @uses $helpers_base_path 
     560     *  @uses $keep_flash 
     561     *  @uses $loaded 
     562     *  @uses recognize_route() 
     563     *  @uses raise() 
     564     *  @uses ScaffoldController 
     565     *  @uses $view_file 
     566     *  @uses $views_file_extention 
     567     *  @uses $views_path 
     568     *  @return boolean true 
    475569     */ 
    476570    function process_route() { 
    477571 
    478         # First try to load the routes and setup the pathes to everything 
     572        # First try to load the routes and setup the paths to everything 
    479573        if(!$this->loaded) { 
    480574            if(!$this->recognize_route()) { 
     
    494588 
    495589        # Include the controller file and execute action 
     590        // FIXME: redundant, recognize_route() already test for file exists 
    496591        if(file_exists($this->controller_file)) { 
    497592            include_once($this->controller_file); 
     
    502597                    $this->controller_object->controller = $this->controller; 
    503598                    $this->controller_object->action = $this->action; 
     599                    //  FIXME: $added_path doesn't exist at this point 
    504600                    $this->controller_object->controller_path = "$this->added_path/$this->controller"; 
    505601                    $GLOBALS['current_controller_path'] = "$this->added_path/$this->controller"; 
     
    635731    /** 
    636732     *  @todo Document this method 
     733     *  @uses $added_path 
     734     *  @uses $controllers_path 
     735     *  @uses $helpers_path 
     736     *  @uses $layous_path 
     737     *  @uses $views_path 
     738     *  @uses $url_path 
    637739     */ 
    638740    function set_paths() { 
     
    821923    /** 
    822924     *  @todo Document this method 
     925     *  @uses $controller_object 
     926     *  @uses $layouts_base_path 
     927     *  @uses $layouts_path 
     928     *  @return mixed Layout file or null if none 
     929     *  @todo <b>FIXME:</b> Should this method be private? 
    823930     */ 
    824931    function determine_layout() { 
    825932        # I guess you don't want any layout 
     933        // FIXME: Do we really want to test for null here? 
     934        // It might make more sense to test isset(...layout) 
    826935        if($this->controller_object->layout == "null") { 
    827936            return null; 
     
    848957            } 
    849958        } 
    850         # No defined layout found so just use the default layout app/views/layouts/application.phtml 
     959        //  No defined layout found so just use the default layout 
     960        //  app/views/layouts/application.phtml  
     961        //  FIXME: this file isn't in the distribution so 
     962        //  this reference will fail 
    851963        if(!$layout_file) { 
    852964            $layout_file = $this->default_layout_file;