From 4fa557e3a92944d4245dba9a461cc2547303332b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 31 Dec 2005 08:35:58 +0000 Subject: [PATCH] Adding set() and get() methods to ISSO --- kernel.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/kernel.php b/kernel.php index c8399f3..ad59498 100644 --- a/kernel.php +++ b/kernel.php @@ -123,6 +123,16 @@ define('TYPE_STRUN', 32); define('TYPE_NOCLEAN', 64); /**#@-*/ +/** +* Yes, required +*/ +define('REQ_YES', 1); + +/** +* No, not required +*/ +define('REQ_NO', 0); + /** * Iris Studios Shared Object Framework (ISSO) * @@ -209,6 +219,20 @@ class Shared_Object_Framework */ var $magicquotes = 0; + /** + * Array of user-specified fields that are required for ISSO initialization + * fieldname => array(REQUIRED, CALLBACK PARSER, SET) + * @var array + */ + var $fields = array( + 'sourcepath' => array(REQ_YES, 'fetch_sourcepath', false), + 'apppath' => array(REQ_YES, 'fetch_sourcepath', false), + 'webpath' => array(REQ_YES, 'fetch_sourcepath', false), + 'application' => array(REQ_YES, null, false), + 'appversion' => array(REQ_NO, null, false), + 'debug' => array(REQ_NO, null, false) + ); + // ################################################################### /** * Constructor @@ -245,6 +269,64 @@ class Shared_Object_Framework $this->__construct(); } + // ################################################################### + /** + * Sets a specified field in the ISSO. This is used to set all the + * required fields that ISSO uses for linking. It replaces the old + * method of setting the instance variables directly. + * + * @access public + * + * @param string Field name + * @param mixed Value of the field + */ + function set($fieldname, $value) + { + if (is_array($this->fields["$fieldname"])) + { + if (method_exists($this, $this->fields["$fieldname"][1])) + { + $value = $this->{$this->fields["$fieldname"][1]}($value); + } + + $this->$fieldname = $value; + + $this->fields["$fieldname"][2] = true; + } + else + { + trigger_error('Invalid field `' . $fieldname . '` specified in ISSO->set()', 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) + { + if (is_array($this->fields["$fieldname"])) + { + if ($this->fields["$fieldname"][2] == false) + { + trigger_error('Field `' . $fieldname . '` is not set and therefore cannot ISSO->get()', E_USER_ERROR); + } + + return $this->$fieldname; + } + else + { + trigger_error('Invalid field `' . $fieldname . '` specified in ISSO->get()', E_USER_ERROR); + } + } + // ################################################################### /** * Prepares a path for being set as the sourcepath -- 2.22.5