Permalink
Browse files

Move Debug after Date (Dependency)

  • Loading branch information...
1 parent d71d98d commit 1809f951b4c0e1f0dd298a391a13b362075b01b4 Amy Stephen committed May 1, 2012
View
19 source/Molajo/Application.php
@@ -85,7 +85,7 @@
public function process($override_request_url = null, $override_catalog_id = null,
$override_sequence_xml = null, $override_final_xml = null)
{
- /** Initialise */
+ /** Initialise Sets the Configuration Registry */
$continue = $this->initialise();
Services::Registry()->set('Override', 'request_url', $override_request_url);
@@ -100,7 +100,7 @@ public function process($override_request_url = null, $override_catalog_id = nul
Services::Debug()->set('Application Initialise succeeded');
}
- /** Route */
+ /** Route: Sets the Request, Catalog, and Menuitem Registry */
$continue = $this->route();
if ($continue == false) {
@@ -110,7 +110,7 @@ public function process($override_request_url = null, $override_catalog_id = nul
Services::Debug()->set('Application Route succeeded');
}
- /** Authorise */
+ /** Authorise: Services::Registry()->get('Request', 'status_authorised') */
$continue = $this->authorise();
if ($continue === false) {
@@ -216,9 +216,18 @@ protected function initialise()
}
/**
- * route application
+ * Evaluates HTTP Request to determine routing requirements, including:
+ *
+ * - Normal page request: populates Registry for Request, Catalog, and Menuitem (if appropriate)
+ * Saves array of non_routable_parameters (if identified in request) to Request registry
+ * - Issues redirect request for "home" duplicate content
+ * - For 'Application Offline Mode', sets a 503 error and registry values for View
+ * - For 'Page not found', sets 404 error and registry values for Error Template/View
+ * - For defined redirect with Catalog, issues 301 Redirect to new URL
+ * - For 'Logon requirement' situations, issues 303 redirect to configured login page
*
* @return boolean
+ *
* @since 1.0
*/
protected function route()
@@ -234,8 +243,6 @@ protected function route()
} else {
return false;
}
-
- return true;
}
/**
View
2 source/Molajo/Configuration/Application/services.xml
@@ -9,7 +9,6 @@
<service>Model</service>
<service>Configuration</service>
<service>Log</service>
- <service>Debug</service>
<service>Request</service>
<service>Parse</service>
<service>Route</service>
@@ -20,6 +19,7 @@
<service>User</service>
<service>Language</service>
<service>Date</service>
+ <service>Debug</service>
<service>Document</service>
<service>Authorisation</service>
<service>Asset</service>
View
16 source/Molajo/Service/Services/AuthorisationService.php
@@ -30,7 +30,7 @@
/**
* Registry specific to the AuthorisationService class
*
- * @var Registry
+ * @var RegistryService
* @since 1.0
*/
protected $registry;
@@ -61,7 +61,7 @@ public function __construct()
}
/**
- * Load lists of ACL-related data needed by this method and other classes within the application
+ * Load ACL-related data for use with Authorisation
*
* @return null
* @since 1.0
@@ -88,7 +88,7 @@ protected function initialise()
}
/**
- * Check if the site is authorized for this application
+ * Check if the site is authorised for this application
*
* Usage:
* $results = Services::Authorisation()->authoriseSiteApplication();
@@ -117,6 +117,7 @@ public function authoriseSiteApplication()
403
);
}
+
return $application_id;
}
@@ -164,8 +165,9 @@ public function authoriseTaskList($tasklist = array(), $catalog_id = 0)
$taskPermissions = array();
foreach ($tasklist as $task) {
- $taskPermissions[$task] = Services::Authorisation()->authoriseTask($task, $catalog_id);
+ $taskPermissions[$task] = $this->authoriseTask($task, $catalog_id);
}
+
return $taskPermissions;
}
@@ -183,7 +185,8 @@ public function authoriseAction()
/** 403: authoriseTask handles redirecting to error page */
if (in_array(Services::Registry()->get('Catalog', 'view_group_id'),
- Services::Registry()->get('User', 'ViewGroups')) ) {
+ Services::Registry()->get('User', 'ViewGroups'))
+ ) {
Services::Registry()->set('Request', 'status_authorised', true);
@@ -193,7 +196,8 @@ public function authoriseAction()
/** display view verified in getCatalog */
if (Services::Registry()->get('Request', 'action', 'display') == 'display'
- && Services::Registry()->get('Request', 'status_authorised') == true) {
+ && Services::Registry()->get('Request', 'status_authorised') == true
+ ) {
return true;
}
View
7 source/Molajo/Service/Services/DebugService.php
@@ -34,7 +34,7 @@
* @var object
* @since 1.0
*/
- public $on;
+ protected $on;
/**
* Log Type
@@ -71,7 +71,10 @@ public function __construct()
$this->on = Services::Registry()->get('Configuration', 'Debug', 0);
if ($this->on == 0) {
+ Services::Registry()->set('DebugService', 'on', false);
return false;
+ } else {
+ Services::Registry()->set('DebugService', 'on', true);
}
/** Valid Logger Options */
@@ -90,8 +93,6 @@ public function __construct()
/** Logger Type */
$options['logger'] = Services::Registry()->get('Configuration', 'debug_logger', 'echo');
- $options['logger'] = 'firephp';
-
if (in_array($options['logger'], $loggerOptions)) {
} else {
$options['logger'] = 'echo';
View
2 source/Molajo/Service/Services/ImageService.php
@@ -114,7 +114,7 @@ public function __construct()
*
* Build an SQL query to select an image.
*
- * @return JDatabaseQuery
+ * @return
* @since 1.0
*/
public function getImage($id, $size = 0, $type = 'crop')
View
22 source/Molajo/Service/Services/ModelService.php
@@ -28,7 +28,7 @@
protected static $instance;
/**
- * Model
+ * Used with Model get and set
*
* @var object
* @since 1.0
@@ -41,39 +41,39 @@
* @var string
* @since 1.0
*/
- public $model_name;
+ protected $model_name;
/**
* Table Name
*
* @var string
* @since 1.0
*/
- public $table_name;
+ protected $table_name;
/**
* Table XML
*
* @var object
* @since 1.0
*/
- public $table_xml;
+ protected $table_xml;
/**
* Primary Key
*
* @var integer
* @since 1.0
*/
- public $primary_key;
+ protected $primary_key;
/**
* DB Driver
*
* @var integer
* @since 1.0
*/
- public $dbDriver;
+ protected $dbDriver;
/**
* Valid DB Options
@@ -129,8 +129,9 @@ public static function getInstance()
/**
* Prepares data needed for the model
*
- * Single-table queries - retrieve Table Definitions, create a model instance, and sets model properties
- * examples include User, Site Application, and Authorisation queries
+ * Single-table queries - retrieve Table Definitions, create a model instance,
+ * and sets model properties examples include User, Site Application, and
+ * Authorisation queries
*
* More complex queries
*
@@ -156,7 +157,7 @@ public function connect($table = null)
$modelClass = 'Molajo\\MVC\\Model\\EntryModel';
try {
- $this->model = new $modelClass ();
+ $this->model = new $modelClass();
}
catch (\Exception $e) {
throw new \RuntimeException('Model entry failed. Error: ' . $e->getMessage());
@@ -189,7 +190,7 @@ public function connect($table = null)
*
* @param $table
*
- * @return mixed
+ * @return void
* @throws \RuntimeException
*/
protected function setModelTable($table)
@@ -216,7 +217,6 @@ protected function setModelTable($table)
if ($this->dbDriver === '') {
$this->dbDriver = $this->default_dbDriver;
}
- $dbo = $this->dbDriver;
return;
}
View
41 source/Molajo/Service/Services/RegistryService.php
@@ -12,7 +12,7 @@
defined('MOLAJO') or die;
//todo: consider namespace reuse - intentional and otherwise
-// Lock from change
+//todo: Lock from change
//
/**
@@ -33,6 +33,16 @@
protected static $instance;
/**
+ * The debug service is activated after the registry and therefore cannot be used
+ * to log system activity immediately. Once Services::Debug()->on = true this indicator
+ * is set to true, existing registries are logged, and individual creates are logged
+ *
+ * @var object
+ * @since 1.0
+ */
+ protected $debug_available;
+
+ /**
* Array containing registry keys
*
* @var Object Array
@@ -111,6 +121,24 @@ public function createRegistry($namespace)
/** Namespace array */
$this->registry[$namespace] = array();
+ /** Log it */
+ if (in_array('DebugService', $this->registryKeys)) {
+
+ if (Services::Registry()->get('DebugService', 'on') === true) {
+
+ if ($this->debug_available === false) {
+ $this->debug_available = true;
+ /* Catch up logging Registries created before Debug Service started */
+ foreach ($this->registryKeys as $ns) {
+ Services::Debug()->set('Create Registry ' . $ns);
+ }
+ } else {
+ Services::Debug()->set('Create Registry ' . $namespace);
+ }
+ }
+ }
+
+ /** Return new registry */
return $this->registry[$namespace];
}
@@ -212,6 +240,8 @@ public function set($namespace, $key, $value = '')
/**
* Copy one namespace registry to another
+ * Note: this is a merge if there are existing registry values
+ * If that is not desired, delete the registry prior to the copy
*
* Usage:
* Services::Registry()->copy('namespace-x', 'to-namespace-y');
@@ -224,14 +254,19 @@ public function set($namespace, $key, $value = '')
*/
public function copy($copyThis, $intoThis)
{
+
/** Get (or create) the Registry that will be copied */
$copy = $this->getRegistry($copyThis);
/** Get (or create) the Registry that will be copied to */
$into = $this->getRegistry($intoThis);
- /** Save the new registry */
- $this->registry[$intoThis] = $copy;
+ /** Merge */
+ if (count($copy > 0)) {
+ foreach ($copy as $key => $value) {
+ $this->set($intoThis, $key, $value);
+ }
+ }
return $this;
}
View
6 source/Molajo/Service/Services/RouteService.php
@@ -32,8 +32,6 @@
protected static $instance = null;
/**
- * Returns the global site object, creating if not existing
- *
* @return Object
*
* @since 1.0
@@ -44,14 +42,15 @@ public static function getInstance()
} else {
self::$instance = new RouteService();
}
+
return self::$instance;
}
/**
* Using the PAGE_REQUEST constant:
*
* - retrieve the catalog record
- * - set registry values needed to render output
+ * - set registry values needed to fulfill the page request
*
* @return mixed
*
@@ -182,7 +181,6 @@ public function process()
*/
protected function checkHome($path = '')
{
-
if (strlen($path) == 0) {
return true;
View
2 source/Site/1/configuration.php
@@ -57,7 +57,7 @@
public $smtphost = 'localhost';
/* Debug Logging */
- public $debug_logger = 'email';
+ public $debug_logger = 'echo';
/* Text */
public $debug_text_file = 'debug.php';
public $debug_text_file_path = 'SITE_LOGS_FOLDER';

0 comments on commit 1809f95

Please sign in to comment.