/[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.4 - (hide annotations)
Tue Mar 11 01:22:22 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +11 -6 lines
+ fixed metadata for phpDocumentor

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

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