From df7cf760ac02057c87db3756d31cfc04b0cfc39f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 9 Jan 2006 17:19:06 +0000 Subject: [PATCH] Adding do_get() to the kernel and get() to all the modules that have set(). --- date.php | 15 +++++++++++++ db_postgresql.php | 16 ++++++++++++++ functions.php | 15 +++++++++++++ kernel.php | 55 +++++++++++++++++++++++++++++++++++++---------- mail.php | 15 +++++++++++++ printer.php | 15 +++++++++++++ template.php | 15 +++++++++++++ template_fs.php | 15 +++++++++++++ xml.php | 15 +++++++++++++ 9 files changed, 165 insertions(+), 11 deletions(-) diff --git a/date.php b/date.php index cd98203..fd8f48c 100644 --- a/date.php +++ b/date.php @@ -124,6 +124,21 @@ class Date $this->registry->do_set($name, $value, 'date'); } + // ################################################################### + /** + * Gets an ISSO field + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->registry->do_get($fieldname, 'date'); + } + // ################################################################### /** * Computes the total offset, taking into account all the various diff --git a/db_postgresql.php b/db_postgresql.php index dca8d27..b6b9e20 100644 --- a/db_postgresql.php +++ b/db_postgresql.php @@ -110,6 +110,22 @@ class DB_PostgreSQL extends DB_Abstract $this->registry->do_set($name, $value, 'db_postgresql'); } + // ################################################################### + /** + * Gets an ISSO field + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->registry->do_get($fieldname, 'db_postgresql'); + } + + // ################################################################### /** * Wrapper: pg_connect diff --git a/functions.php b/functions.php index c3fe7f1..921a78b 100644 --- a/functions.php +++ b/functions.php @@ -118,6 +118,21 @@ class Functions $this->registry->do_set($name, $value, 'functions'); } + // ################################################################### + /** + * Gets an ISSO field + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->registry->do_get($fieldname, 'functions'); + } + // ################################################################### /** * Sets a cookie with a friendly interface diff --git a/kernel.php b/kernel.php index 7265f2f..42de993 100644 --- a/kernel.php +++ b/kernel.php @@ -356,32 +356,65 @@ class Shared_Object_Framework // ################################################################### /** - * Returns the value of an ISSO field. You should not access any instance - * variables directly, use this instead. + * Fetches the value of a field. This is protected because get() should + * be defined in each module to make a call to this function. * - * @access public + * @access protected * * @param string Field name - * - * @return mixed Value of the field + * @param string Module name (as referred to in ISSO->modules[]) to fetch from */ - function get($fieldname) + function do_get($fieldname, $module) { - if (is_array($this->fields["$fieldname"])) + if ($module == null) + { + $field =& $this->fields["$fieldname"]; + } + else + { + $field =& $this->modules["$module"]->fields["$fieldname"]; + } + + if (is_array($field)) { - if ($this->fields["$fieldname"][2] == false) + if ($field[2] == false) + { + trigger_error('Field ' . $module . ':: ' . $filedname . ' is not set and therefore cannot be get()', E_USER_ERROR); + } + + if ($module == null) { - trigger_error('Field `' . $fieldname . '` is not set and therefore cannot ISSO->get()', E_USER_ERROR); + return $this->$fieldname; + } + else + { + return $this->modules["$module"]->$fieldname; } - return $this->$fieldname; + $field[2] = true; } else { - trigger_error('Invalid field `' . $fieldname . '` specified in ISSO->get()', E_USER_ERROR); + trigger_error('Invalid field `' . $module . '.' . $fieldname . '` specified in ISSO->do_get()', E_USER_ERROR); } } + // ################################################################### + /** + * Returns the value of an ISSO field. You should not access any instance + * variables directly, use this instead. + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->registry->do_get($fieldname, null); + } + // ################################################################### /** * Makes sure that all of the required fields in ISSO are set before diff --git a/mail.php b/mail.php index eb219f7..41257c0 100644 --- a/mail.php +++ b/mail.php @@ -135,6 +135,21 @@ class Mail $this->registry->do_set($name, $value, 'mail'); } + // ################################################################### + /** + * Gets an ISSO field + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->registry->do_get($fieldname, 'mail'); + } + // ################################################################### /** * Sends an email to the specified address with the specified diff --git a/printer.php b/printer.php index 2e501f4..e08aa5b 100644 --- a/printer.php +++ b/printer.php @@ -112,6 +112,21 @@ class Printer $this->registry->do_set($name, $value, 'printer'); } + // ################################################################### + /** + * Gets an ISSO field + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->registry->do_get($fieldname, 'printer'); + } + // ################################################################### /** * Creates a redirect to another page; constructs the header and footer diff --git a/template.php b/template.php index 1d0f9b0..c8e2024 100644 --- a/template.php +++ b/template.php @@ -175,6 +175,21 @@ class Template $this->registry->do_set($name, $value, 'template'); } + // ################################################################### + /** + * Gets an ISSO field + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->registry->do_get($fieldname, 'template'); + } + // ################################################################### /** * Takes an array of template names, loads them, and then stores a diff --git a/template_fs.php b/template_fs.php index 7f914c0..db3efce 100644 --- a/template_fs.php +++ b/template_fs.php @@ -98,6 +98,21 @@ class Template_FS extends Template $this->registry->do_set($name, $value, 'template_fs'); } + // ################################################################### + /** + * Gets an ISSO field + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->do_get($fieldname, 'template_fs'); + } + // ################################################################### /** * Takes an array of template names, loads them, and then stores a diff --git a/xml.php b/xml.php index 0393ff0..27c627f 100644 --- a/xml.php +++ b/xml.php @@ -129,6 +129,21 @@ class XML $this->registry->do_set($name, $value, 'xml'); } + // ################################################################### + /** + * Gets an ISSO field + * + * @access public + * + * @param string Field name + * + * @return mixed Value of the field + */ + function get($fieldname) + { + return $this->registry->do_get($fieldname, 'xml'); + } + // ################################################################### /** * Parse an XML file -- 2.22.5