Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move Debug after Date (Dependency)

  • Loading branch information...
commit 1809f951b4c0e1f0dd298a391a13b362075b01b4 1 parent d71d98d
authored April 30, 2012
19  source/Molajo/Application.php
@@ -85,7 +85,7 @@
85 85
 	public function process($override_request_url = null, $override_catalog_id = null,
86 86
 							$override_sequence_xml = null, $override_final_xml = null)
87 87
 	{
88  
-		/** Initialise */
  88
+		/** Initialise Sets the Configuration Registry  */
89 89
 		$continue = $this->initialise();
90 90
 
91 91
 		Services::Registry()->set('Override', 'request_url', $override_request_url);
@@ -100,7 +100,7 @@ public function process($override_request_url = null, $override_catalog_id = nul
100 100
 			Services::Debug()->set('Application Initialise succeeded');
101 101
 		}
102 102
 
103  
-		/** Route */
  103
+		/** Route: Sets the Request, Catalog, and Menuitem Registry */
104 104
 		$continue = $this->route();
105 105
 
106 106
 		if ($continue == false) {
@@ -110,7 +110,7 @@ public function process($override_request_url = null, $override_catalog_id = nul
110 110
 			Services::Debug()->set('Application Route succeeded');
111 111
 		}
112 112
 
113  
-		/** Authorise */
  113
+		/** Authorise: Services::Registry()->get('Request', 'status_authorised') */
114 114
 		$continue = $this->authorise();
115 115
 
116 116
 		if ($continue === false) {
@@ -216,9 +216,18 @@ protected function initialise()
216 216
 	}
217 217
 
218 218
 	/**
219  
-	 * route application
  219
+	 * Evaluates HTTP Request to determine routing requirements, including:
  220
+	 *
  221
+	 * - Normal page request: populates Registry for Request, Catalog, and Menuitem (if appropriate)
  222
+	 *     Saves array of non_routable_parameters (if identified in request) to Request registry
  223
+	 * - Issues redirect request for "home" duplicate content
  224
+	 * - For 'Application Offline Mode', sets a 503 error and registry values for View
  225
+	 * - For 'Page not found', sets 404 error and registry values for Error Template/View
  226
+	 * - For defined redirect with Catalog, issues 301 Redirect to new URL
  227
+	 * - For 'Logon requirement' situations, issues 303 redirect to configured login page
220 228
 	 *
221 229
 	 * @return boolean
  230
+	 *
222 231
 	 * @since  1.0
223 232
 	 */
224 233
 	protected function route()
@@ -234,8 +243,6 @@ protected function route()
234 243
 		} else {
235 244
 			return false;
236 245
 		}
237  
-
238  
-		return true;
239 246
 	}
240 247
 
241 248
 	/**
2  source/Molajo/Configuration/Application/services.xml
@@ -9,7 +9,6 @@
9 9
     <service>Model</service>
10 10
     <service>Configuration</service>
11 11
     <service>Log</service>
12  
-    <service>Debug</service>
13 12
     <service>Request</service>
14 13
     <service>Parse</service>
15 14
     <service>Route</service>
@@ -20,6 +19,7 @@
20 19
     <service>User</service>
21 20
     <service>Language</service>
22 21
     <service>Date</service>
  22
+    <service>Debug</service>
23 23
     <service>Document</service>
24 24
     <service>Authorisation</service>
25 25
     <service>Asset</service>
16  source/Molajo/Service/Services/AuthorisationService.php
@@ -30,7 +30,7 @@
30 30
 	/**
31 31
 	 * Registry specific to the AuthorisationService class
32 32
 	 *
33  
-	 * @var    Registry
  33
+	 * @var    RegistryService
34 34
 	 * @since  1.0
35 35
 	 */
36 36
 	protected $registry;
@@ -61,7 +61,7 @@ public function __construct()
61 61
 	}
62 62
 
63 63
 	/**
64  
-	 * Load lists of ACL-related data needed by this method and other classes within the application
  64
+	 * Load ACL-related data for use with Authorisation
65 65
 	 *
66 66
 	 * @return null
67 67
 	 * @since  1.0
@@ -88,7 +88,7 @@ protected function initialise()
88 88
 	}
89 89
 
90 90
 	/**
91  
-	 * Check if the site is authorized for this application
  91
+	 * Check if the site is authorised for this application
92 92
 	 *
93 93
 	 * Usage:
94 94
 	 * $results = Services::Authorisation()->authoriseSiteApplication();
@@ -117,6 +117,7 @@ public function authoriseSiteApplication()
117 117
 				403
118 118
 			);
119 119
 		}
  120
+
120 121
 		return $application_id;
121 122
 	}
122 123
 
@@ -164,8 +165,9 @@ public function authoriseTaskList($tasklist = array(), $catalog_id = 0)
164 165
 		$taskPermissions = array();
165 166
 
166 167
 		foreach ($tasklist as $task) {
167  
-			$taskPermissions[$task] = Services::Authorisation()->authoriseTask($task, $catalog_id);
  168
+			$taskPermissions[$task] = $this->authoriseTask($task, $catalog_id);
168 169
 		}
  170
+
169 171
 		return $taskPermissions;
170 172
 	}
171 173
 
@@ -183,7 +185,8 @@ public function authoriseAction()
183 185
 
184 186
 		/** 403: authoriseTask handles redirecting to error page */
185 187
 		if (in_array(Services::Registry()->get('Catalog', 'view_group_id'),
186  
-			Services::Registry()->get('User', 'ViewGroups')) ) {
  188
+			Services::Registry()->get('User', 'ViewGroups'))
  189
+		) {
187 190
 
188 191
 			Services::Registry()->set('Request', 'status_authorised', true);
189 192
 
@@ -193,7 +196,8 @@ public function authoriseAction()
193 196
 
194 197
 		/** display view verified in getCatalog */
195 198
 		if (Services::Registry()->get('Request', 'action', 'display') == 'display'
196  
-			&& Services::Registry()->get('Request', 'status_authorised') == true) {
  199
+			&& Services::Registry()->get('Request', 'status_authorised') == true
  200
+		) {
197 201
 
198 202
 			return true;
199 203
 		}
7  source/Molajo/Service/Services/DebugService.php
@@ -34,7 +34,7 @@
34 34
 	 * @var    object
35 35
 	 * @since  1.0
36 36
 	 */
37  
-	public $on;
  37
+	protected $on;
38 38
 
39 39
 	/**
40 40
 	 * Log Type
@@ -71,7 +71,10 @@ public function __construct()
71 71
 		$this->on = Services::Registry()->get('Configuration', 'Debug', 0);
72 72
 
73 73
 		if ($this->on == 0) {
  74
+			Services::Registry()->set('DebugService', 'on', false);
74 75
 			return false;
  76
+		} else {
  77
+			Services::Registry()->set('DebugService', 'on', true);
75 78
 		}
76 79
 
77 80
 		/** Valid Logger Options */
@@ -90,8 +93,6 @@ public function __construct()
90 93
 		/** Logger Type */
91 94
 		$options['logger'] = Services::Registry()->get('Configuration', 'debug_logger', 'echo');
92 95
 
93  
-		$options['logger'] = 'firephp';
94  
-
95 96
 		if (in_array($options['logger'], $loggerOptions)) {
96 97
 		} else {
97 98
 			$options['logger'] = 'echo';
2  source/Molajo/Service/Services/ImageService.php
@@ -114,7 +114,7 @@ public function __construct()
114 114
 	 *
115 115
 	 * Build an SQL query to select an image.
116 116
 	 *
117  
-	 * @return    JDatabaseQuery
  117
+	 * @return
118 118
 	 * @since    1.0
119 119
 	 */
120 120
 	public function getImage($id, $size = 0, $type = 'crop')
22  source/Molajo/Service/Services/ModelService.php
@@ -28,7 +28,7 @@
28 28
 	protected static $instance;
29 29
 
30 30
 	/**
31  
-	 * Model
  31
+	 * Used with Model get and set
32 32
 	 *
33 33
 	 * @var    object
34 34
 	 * @since  1.0
@@ -41,7 +41,7 @@
41 41
 	 * @var    string
42 42
 	 * @since  1.0
43 43
 	 */
44  
-	public $model_name;
  44
+	protected $model_name;
45 45
 
46 46
 	/**
47 47
 	 * Table Name
@@ -49,7 +49,7 @@
49 49
 	 * @var    string
50 50
 	 * @since  1.0
51 51
 	 */
52  
-	public $table_name;
  52
+	protected $table_name;
53 53
 
54 54
 	/**
55 55
 	 * Table XML
@@ -57,7 +57,7 @@
57 57
 	 * @var    object
58 58
 	 * @since  1.0
59 59
 	 */
60  
-	public $table_xml;
  60
+	protected $table_xml;
61 61
 
62 62
 	/**
63 63
 	 * Primary Key
@@ -65,7 +65,7 @@
65 65
 	 * @var    integer
66 66
 	 * @since  1.0
67 67
 	 */
68  
-	public $primary_key;
  68
+	protected $primary_key;
69 69
 
70 70
 	/**
71 71
 	 * DB Driver
@@ -73,7 +73,7 @@
73 73
 	 * @var    integer
74 74
 	 * @since  1.0
75 75
 	 */
76  
-	public $dbDriver;
  76
+	protected $dbDriver;
77 77
 
78 78
 	/**
79 79
 	 * Valid DB Options
@@ -129,8 +129,9 @@ public static function getInstance()
129 129
 	/**
130 130
 	 * Prepares data needed for the model
131 131
 	 *
132  
-	 * Single-table queries - retrieve Table Definitions, create a model instance, and sets model properties
133  
-	 *     examples include User, Site Application, and Authorisation queries
  132
+	 * Single-table queries - retrieve Table Definitions, create a model instance,
  133
+	 * and sets model properties examples include User, Site Application, and
  134
+	 * Authorisation queries
134 135
 	 *
135 136
 	 * More complex queries
136 137
 	 *
@@ -156,7 +157,7 @@ public function connect($table = null)
156 157
 		$modelClass = 'Molajo\\MVC\\Model\\EntryModel';
157 158
 
158 159
 		try {
159  
-			$this->model = new $modelClass ();
  160
+			$this->model = new $modelClass();
160 161
 		}
161 162
 		catch (\Exception $e) {
162 163
 			throw new \RuntimeException('Model entry failed. Error: ' . $e->getMessage());
@@ -189,7 +190,7 @@ public function connect($table = null)
189 190
 	 *
190 191
 	 * @param   $table
191 192
 	 *
192  
-	 * @return  mixed
  193
+	 * @return  void
193 194
 	 * @throws  \RuntimeException
194 195
 	 */
195 196
 	protected function setModelTable($table)
@@ -216,7 +217,6 @@ protected function setModelTable($table)
216 217
 		if ($this->dbDriver === '') {
217 218
 			$this->dbDriver = $this->default_dbDriver;
218 219
 		}
219  
-		$dbo = $this->dbDriver;
220 220
 
221 221
 		return;
222 222
 	}
41  source/Molajo/Service/Services/RegistryService.php
@@ -12,7 +12,7 @@
12 12
 defined('MOLAJO') or die;
13 13
 
14 14
 //todo: consider namespace reuse - intentional and otherwise
15  
-// Lock from change
  15
+//todo: Lock from change
16 16
 //
17 17
 
18 18
 /**
@@ -33,6 +33,16 @@
33 33
 	protected static $instance;
34 34
 
35 35
 	/**
  36
+	 * The debug service is activated after the registry and therefore cannot be used
  37
+	 * to log system activity immediately. Once Services::Debug()->on = true this indicator
  38
+	 * is set to true, existing registries are logged, and individual creates are logged
  39
+	 *
  40
+	 * @var    object
  41
+	 * @since  1.0
  42
+	 */
  43
+	protected $debug_available;
  44
+
  45
+	/**
36 46
 	 * Array containing registry keys
37 47
 	 *
38 48
 	 * @var    Object Array
@@ -111,6 +121,24 @@ public function createRegistry($namespace)
111 121
 		/** Namespace array */
112 122
 		$this->registry[$namespace] = array();
113 123
 
  124
+		/** Log it */
  125
+		if (in_array('DebugService', $this->registryKeys)) {
  126
+
  127
+			if (Services::Registry()->get('DebugService', 'on') === true) {
  128
+
  129
+				if ($this->debug_available === false) {
  130
+					$this->debug_available = true;
  131
+					/* Catch up logging Registries created before Debug Service started */
  132
+					foreach ($this->registryKeys as $ns) {
  133
+						Services::Debug()->set('Create Registry ' . $ns);
  134
+					}
  135
+				} else {
  136
+					Services::Debug()->set('Create Registry ' . $namespace);
  137
+				}
  138
+			}
  139
+		}
  140
+
  141
+		/** Return new registry */
114 142
 		return $this->registry[$namespace];
115 143
 	}
116 144
 
@@ -212,6 +240,8 @@ public function set($namespace, $key, $value = '')
212 240
 
213 241
 	/**
214 242
 	 * Copy one namespace registry to another
  243
+	 * Note: this is a merge if there are existing registry values
  244
+	 * If that is not desired, delete the registry prior to the copy
215 245
 	 *
216 246
 	 * Usage:
217 247
 	 * Services::Registry()->copy('namespace-x', 'to-namespace-y');
@@ -224,14 +254,19 @@ public function set($namespace, $key, $value = '')
224 254
 	 */
225 255
 	public function copy($copyThis, $intoThis)
226 256
 	{
  257
+
227 258
 		/** Get (or create) the Registry that will be copied */
228 259
 		$copy = $this->getRegistry($copyThis);
229 260
 
230 261
 		/** Get (or create) the Registry that will be copied to */
231 262
 		$into = $this->getRegistry($intoThis);
232 263
 
233  
-		/** Save the new registry */
234  
-		$this->registry[$intoThis] = $copy;
  264
+		/** Merge */
  265
+		if (count($copy > 0)) {
  266
+			foreach ($copy as $key => $value) {
  267
+				$this->set($intoThis, $key, $value);
  268
+			}
  269
+		}
235 270
 
236 271
 		return $this;
237 272
 	}
6  source/Molajo/Service/Services/RouteService.php
@@ -32,8 +32,6 @@
32 32
 	protected static $instance = null;
33 33
 
34 34
 	/**
35  
-	 * Returns the global site object, creating if not existing
36  
-	 *
37 35
 	 * @return  Object
38 36
 	 *
39 37
 	 * @since   1.0
@@ -44,6 +42,7 @@ public static function getInstance()
44 42
 		} else {
45 43
 			self::$instance = new RouteService();
46 44
 		}
  45
+
47 46
 		return self::$instance;
48 47
 	}
49 48
 
@@ -51,7 +50,7 @@ public static function getInstance()
51 50
 	 * Using the PAGE_REQUEST constant:
52 51
 	 *
53 52
 	 *  - retrieve the catalog record
54  
-	 *  - set registry values needed to render output
  53
+	 *  - set registry values needed to fulfill the page request
55 54
 	 *
56 55
 	 * @return mixed
57 56
 	 *
@@ -182,7 +181,6 @@ public function process()
182 181
 	 */
183 182
 	protected function checkHome($path = '')
184 183
 	{
185  
-
186 184
 		if (strlen($path) == 0) {
187 185
 			return true;
188 186
 
2  source/Site/1/configuration.php
@@ -57,7 +57,7 @@
57 57
     public $smtphost = 'localhost';
58 58
 
59 59
 	/* Debug Logging */
60  
-	public $debug_logger = 'email';
  60
+	public $debug_logger = 'echo';
61 61
 	/* Text */
62 62
 	public $debug_text_file = 'debug.php';
63 63
 	public $debug_text_file_path = 'SITE_LOGS_FOLDER';

0 notes on commit 1809f95

Please sign in to comment.
Something went wrong with that request. Please try again.