/[cvs]/nfo/php/libs/org.netfrag.glib/Application/Request/BaseController.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.glib/Application/Request/BaseController.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Mon Mar 3 21:12:55 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.1: +57 -2 lines
split up processing into more steps

1 joko 1.1 <?php
2    
3     /**
4     * This file contains the abstract Application::Request::BaseController class.
5     *
6     * @author Andreas Motl <andreas.motl@ilo.de>
7     * @package org.netfrag.glib
8     * @module Application::Request::BaseController
9     *
10     */
11    
12     /**
13 joko 1.2 * $Id: BaseController.php,v 1.1 2003/03/01 21:11:18 joko Exp $
14     *
15     * $Log: BaseController.php,v $
16     * Revision 1.1 2003/03/01 21:11:18 joko
17     * + initial commit
18 joko 1.1 *
19     *
20     */
21    
22    
23     /**
24     * ---
25     *
26     *
27     * @author Andreas Motl <andreas.motl@ilo.de>
28     * @copyright (c) 2003 - All Rights reserved.
29     * @license GNU LGPL (GNU Lesser General Public License)
30     *
31     * @author-url http://www.netfrag.org/~joko/
32     * @license-url http://www.gnu.org/licenses/lgpl.txt
33     *
34     * @package org.netfrag.glib
35     * @module Application::Request::BaseController
36     *
37     */
38    
39     /**
40     * Todo:
41     *
42     * o xyz
43     * o bla, bli, blub
44     *
45     *
46     */
47    
48    
49     // isn't required by now:
50     //loadModule('DesignPattern::Object');
51     //class DesignPattern_MVC extends DesignPattern_Object {
52    
53     //loadModule('DesignPattern::Container');
54     class Application_Request_BaseController {
55    
56     var $_request = null;
57    
58     var $_rules = null;
59    
60    
61     /**
62     * The constructor ...
63     * ... just does nothing.
64     *
65     * @param registry
66     */
67     function Application_Request_BaseController() {
68     }
69    
70     function _abstract_method($method) {
71     $package = get_class($this);
72     print "$package: Please implement method '$method'.<br/>";
73     }
74    
75     /*
76     function set_request() {
77     $this->_abstract_method('set_request');
78     }
79     */
80    
81 joko 1.2 function get_request() {
82     $this->_abstract_method('get_request');
83     }
84    
85     function get_request_translated() {
86     $this->_abstract_method('get_request_translated');
87     }
88    
89     /*
90     function translate_request() {
91     $this->_abstract_method('translate_request');
92     }
93     */
94    
95     function translate_request($request_raw) {
96    
97     // 1. map it! mungle request and model together - generic processing here!
98     // now: translate it! (done in concrete mvc controller now)
99    
100     $request_translated = array();
101    
102     $metadata = $this->metadata;
103    
104     // check all areas
105     foreach ($metadata[request_args] as $area_name) {
106     $area_metadata = $metadata[request_arg][$area_name];
107     if ($http_arg_key = $area_metadata[query_arg]) {
108     $this->translate_to($request_raw, $http_arg_key, $request_translated, $area_name);
109     }
110     if ($http_arg_keys = $area_metadata[query_args]) {
111     foreach ($http_arg_keys as $key) {
112     $this->translate_to($request_raw, $key, $request_translated, $area_name);
113     }
114     }
115     }
116    
117     if (!sizeof($request_translated)) {
118     user_error("MVC Error - HttpController: mapped request is empty!");
119     }
120    
121     return $request_translated;
122    
123     }
124    
125     function translate_to(&$source, $source_key, &$target, $target_key) {
126     if (in_array($source_key, array_keys($source))) {
127     $target[$target_key] = $source[$source_key];
128     }
129     }
130    
131 joko 1.1 // called from parent context
132     function set_request(&$request) {
133     $this->_request = &$request;
134     }
135    
136     // called from DesignPattern::MVC
137     function set_rules(&$rules) {
138     $this->_rules = &$rules;
139     }
140    
141 joko 1.2 /*
142 joko 1.1 function &get_request() {
143     return $this->_request;
144     }
145 joko 1.2 */
146 joko 1.1
147     }
148    
149     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed