From ad0d5a80a8ef017ec05444916c575cc020695f59 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 10 May 2017 10:57:13 -0500 Subject: [PATCH] Progress: path, breadcrumbs, and menus Continuing work on paths, now starting to add support for breadcrumbs and menus. --- common/base/classes/base_array.php | 330 ++++++ common/base/classes/base_database.php | 2 + common/base/classes/base_defaults_global.php | 3 + common/base/classes/base_error.php | 292 +++-- .../base/classes/base_error_messages_english.php | 2 +- .../base/classes/base_error_messages_japanese.php | 2 +- common/base/classes/base_html.php | 25 +- common/base/classes/base_http.php | 131 ++- common/base/classes/base_markup.php | 376 ++---- common/base/classes/base_menu.php | 440 +++++++ common/base/classes/base_path.php | 150 ++- common/base/classes/base_paths.php | 68 +- common/base/classes/base_return.php | 167 ++- common/base/classes/base_rfc_string.php | 203 ++-- common/base/classes/base_session.php | 13 +- common/standard/classes/standard_index.php | 20 +- common/standard/classes/standard_menu.php | 278 +++++ common/standard/classes/standard_path.php | 380 ++++++- common/standard/classes/standard_paths.php | 309 +++-- common/standard/internal/access_denied.php | 38 +- common/standard/internal/bad_method.php | 41 + common/standard/internal/index.php | 39 +- common/standard/internal/ja/access_denied.php | 17 + common/standard/internal/ja/bad_method.php | 17 + common/standard/internal/ja/index.php | 17 + common/standard/internal/ja/not_found.php | 17 + common/standard/internal/ja/server_error.php | 17 + common/standard/internal/not_found.php | 38 +- common/standard/internal/server_error.php | 38 +- common/standard/menus/ja/menu_breadcrumbs.php | 30 + common/standard/menus/ja/menu_content.php | 30 + common/standard/menus/ja/menu_footer.php | 30 + common/standard/menus/ja/menu_header.php | 30 + common/standard/menus/ja/menu_utility.php | 51 + common/standard/menus/menu_breadcrumbs.php | 91 ++ common/standard/menus/menu_content.php | 37 + common/standard/menus/menu_footer.php | 37 + common/standard/menus/menu_header.php | 37 + common/standard/menus/menu_utility.php | 132 +++ common/standard/paths/u/dashboard.php | 6 +- common/standard/paths/u/ja/user_create.php | 29 + common/standard/paths/u/ja/user_delete.php | 29 + common/standard/paths/u/ja/user_lock.php | 29 + common/standard/paths/u/ja/user_settings.php | 74 ++ common/standard/paths/u/ja/user_unlock.php | 29 + common/standard/paths/u/ja/user_view.php | 74 ++ common/standard/paths/u/login.php | 56 +- common/standard/paths/u/logout.php | 4 +- common/standard/paths/u/user_create.php | 79 ++ common/standard/paths/u/user_delete.php | 79 ++ common/standard/paths/u/user_lock.php | 79 ++ common/standard/paths/u/user_settings.php | 124 ++ common/standard/paths/u/user_unlock.php | 79 ++ common/standard/paths/u/user_view.php | 124 ++ common/theme/classes/theme_html.php | 1196 +++++--------------- documentation/loops.txt | 1 - .../reservation/reservation_defaults_global.php | 3 + 57 files changed, 4472 insertions(+), 1597 deletions(-) create mode 100644 common/base/classes/base_array.php create mode 100644 common/base/classes/base_menu.php create mode 100644 common/standard/classes/standard_menu.php create mode 100644 common/standard/menus/ja/menu_breadcrumbs.php create mode 100644 common/standard/menus/ja/menu_content.php create mode 100644 common/standard/menus/ja/menu_footer.php create mode 100644 common/standard/menus/ja/menu_header.php create mode 100644 common/standard/menus/ja/menu_utility.php create mode 100644 common/standard/menus/menu_breadcrumbs.php create mode 100644 common/standard/menus/menu_content.php create mode 100644 common/standard/menus/menu_footer.php create mode 100644 common/standard/menus/menu_header.php create mode 100644 common/standard/menus/menu_utility.php create mode 100644 common/standard/paths/u/ja/user_create.php create mode 100644 common/standard/paths/u/ja/user_delete.php create mode 100644 common/standard/paths/u/ja/user_lock.php create mode 100644 common/standard/paths/u/ja/user_settings.php create mode 100644 common/standard/paths/u/ja/user_unlock.php create mode 100644 common/standard/paths/u/ja/user_view.php create mode 100644 common/standard/paths/u/user_create.php create mode 100644 common/standard/paths/u/user_delete.php create mode 100644 common/standard/paths/u/user_lock.php create mode 100644 common/standard/paths/u/user_settings.php create mode 100644 common/standard/paths/u/user_unlock.php create mode 100644 common/standard/paths/u/user_view.php diff --git a/common/base/classes/base_array.php b/common/base/classes/base_array.php new file mode 100644 index 0000000..060cc57 --- /dev/null +++ b/common/base/classes/base_array.php @@ -0,0 +1,330 @@ + array(':{argument_name}' => 'array', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->items = $array; + return new c_base_return_true(); + } + + /** + * Assign the item at a specific index in the array. + * + * @param $item + * Any item to assign. + * @param int|string $key + * A key to assign a specific value to. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * FALSE with the error bit set is returned on error. + */ + public function set_item_at($item, $key) { + if (!is_int($key) && !is_string($key)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'key', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->items)) { + $this->items = array(); + } + + $this->items[$key] = $item; + return new c_base_return_true(); + } + + /** + * Append the item at the end of the array. + * + * @param $item + * Any value. + * This does not perform clone() on objects. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * FALSE with the error bit set is returned on error. + */ + public function set_item_append($item) { + if (!is_array($this->items)) { + $this->items = array(); + } + + $this->items[] = $item; + return new c_base_return_true(); + } + + /** + * Assigns the array from a serialized array string. + * + * @param string $serialized + * A serialized string to convert to an array. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * If converted string does not produce an array, FALSE is returned and items is set to an empty array. + * FALSE with the error bit set is returned on error. + * + * @see: unserialize() + */ + public function set_items_serialized($serialized) { + if (!is_string($serialized)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'serialized', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $unserialized = unserialize($serialized); + if (is_array($unserialized)) { + $this->items = $unserialized; + unset($unserialized); + + return new c_base_return_true(); + } + unset($unserialized); + + $this->items = array(); + return new c_base_return_false(); + } + + /** + * Returns the data as a json-serialized array string. + * + * @param jsonized + * A jsonized string to convert to an array. + * @param bool $associative + * (optional) When TRUE array is return as an associative array. + * @param int $options + * (optional) bitmask of json constants. + * @param int $depth + * (optional) Maximum array depth. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * if converted string does not produce an array, FALSE is returned and items is set to an empty array. + * + * @see: json_decode() + */ + public function set_items_jsonized($jsonized, $associative = TRUE, $options = 0, $depth = 512) { + if (!is_string($jsonized)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'jsonized', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_bool($associative)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'associative', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_int($options)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_int($depth) || $depth < 1) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'depth', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $decoded = json_decode($jsonized, $associative, $options, $depth); + if (is_array($decoded)) { + $this->items = $decoded; + unset($decoded); + + return new c_base_return_true(); + } + unset($decoded); + + $this->items = array(); + return new c_base_return_false(); + } + + /** + * Return the array. + * + * @return c_base_return_array + * The array stored within this class. + * An empty array with error bit set is returned on error. + */ + public function get_items() { + if (!is_null($this->items) && !is_array($this->items)) { + return c_base_return_array::s_new(array()); + } + + return c_base_return_array::s_new($this->items); + } + + /** + * Return the item at a specific index in the array. + * + * @param string $key + * A key to assign a specific value to. + * + * @return c_base_return_status|c_base_return_value + * Value on success, FALSE otherwise. + * FALSE without error bit set is returned if $key us not defined. + * FALSE with the error bit set is returned on error. + */ + public function get_item_at($key) { + if (!is_string($key) || empty($key)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'key', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->items) || !array_key_exists($key, $this->items)) { + return new c_base_return_false(); + } + + return c_base_return_value::s_new($this->items[$key]); + } + + /** + * Return the total number of values in the array. + * + * @return c_base_return_int + * A positive integer. + * 0 with the error bit set is returned on error. + */ + public function get_items_count() { + if (empty($this->items)) { + return 0; + } + + return count($this->items); + } + + /** + * Return the array keys of the array. + * + * @return c_base_return_array + * An array of array keys. + * An empty array with the error bit set is returned on error. + */ + public function get_items_keys() { + if (empty($this->items)) { + return array(); + } + + return array_keys($this->items); + } + + /** + * Returns the data as a serialized array string. + * + * @return c_base_return_string|c_base_return_bool + * A serialized string representing the array on success. + * FALSE on failure. + * An empty string with the error bit set is returned on error. + * + * @see: serialize() + */ + public function get_items_serialized() { + if (!is_array($this->items)) { + return c_base_return_string::s_new(serialize(array())); + } + + return c_base_return_string::s_new(serialize($this->items)); + } + + /** + * Returns the data as a json-serialized array string. + * + * @param int $options + * (optional) bitmask of json constants. + * @param int $depth + * (optional) Maximum array depth. + * + * @return c_base_return_string|c_base_return_bool + * A json-serialized string representing the array on success. + * FALSE on failure. + * FALSE with the error bit set is returned on error. + * + * @see: json_encode() + */ + public function get_items_jsonized($options = 0, $depth = 512) { + if (!is_int($options)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'options', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_int($depth)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'depth', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_int($options)) { + $options = 0; + } + + if (!is_int($depth) || $depth < 1) { + $depth = 512; + } + + $encoded = json_encode($this->items, $options, $depth); + if ($encoded === FALSE) { + unset($encoded); + + $error = c_base_error::s_log(NULL, array('arguments' => array(':{operation_name}' => 'json_encode', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::OPERATION_FAILURE); + return c_base_return_error::s_false($error); + } + + return c_base_return_string::s_new($encoded); + } +} diff --git a/common/base/classes/base_database.php b/common/base/classes/base_database.php index ed90693..f4596be 100644 --- a/common/base/classes/base_database.php +++ b/common/base/classes/base_database.php @@ -685,6 +685,7 @@ class c_base_database extends c_base_return { * * @param c_base_database_connection_string $connection_string * An already processed and configured connection string object. + * This does perform clone(). * * @return c_base_return_status * TRUE on success, FALSE otherwise. @@ -708,6 +709,7 @@ class c_base_database extends c_base_return { * @return c_base_database_connection_string * A connection string object on success. * The error bit set is on error. + * This does perform clone(). */ public function get_connection_string() { if (!is_object($this->connection_string) || !($this->connection_string instanceof c_base_database_connection_string)) { diff --git a/common/base/classes/base_defaults_global.php b/common/base/classes/base_defaults_global.php index 48bb399..642da35 100644 --- a/common/base/classes/base_defaults_global.php +++ b/common/base/classes/base_defaults_global.php @@ -42,6 +42,9 @@ class c_base_defaults_global { // default log facility (17 = c_base_error::FACILITY_LOCAL_0). const LOG_FACILITY = 17; + // default backtrace setting (TRUE = perform backtrace on error, FALSE do not perform backtrace on error). + const BACKTRACE_PERFORM = TRUE; + // Represents the current timestamp of this PHP process/session, see: self::s_get_timestamp_session(). private static $s_timestamp_session = NULL; diff --git a/common/base/classes/base_error.php b/common/base/classes/base_error.php index 6c6c479..60f5aa0 100644 --- a/common/base/classes/base_error.php +++ b/common/base/classes/base_error.php @@ -11,9 +11,6 @@ * Therefore, it is an exception case to the use of base_return classes as a return value and must instead return raw/native PHP values. * * This provides a custom facility for syslog/openlog calls so that a 'none' facility can be supported. - * - * @todo: I either need to create a global/static (aka: non-threadsafe) class for assigning error settings OR I need to add a variable to each class object to assign error settings (uses more resources). - * This needs to be done so that stuff like debug_backtrace() is called only once and is only called if needed. */ class c_base_error { const SEVERITY_NONE = 0; @@ -59,24 +56,32 @@ class c_base_error { private $details; private $severity; private $limit; + private $recovered; + private $backtrace; - private $code; + private $backtrace_perform; private $ignore_arguments; - private $backtrace_performed; + + private $code; /** * Class constructor. */ public function __construct() { - $this->message = NULL; - $this->details = NULL; - $this->severity = NULL; - $this->limit = self::DEFAULT_BACKTRACE_LIMIT; - $this->backtrace = array(); + $this->message = NULL; + $this->details = NULL; + $this->severity = NULL; + $this->limit = self::DEFAULT_BACKTRACE_LIMIT; + $this->recovered = FALSE; + + $this->backtrace = array(); + $this->backtrace_perform = FALSE; + $this->ignore_arguments = TRUE; + $this->code = NULL; - $this->ignore_arguments = TRUE; - $this->backtrace_performed = FALSE; + + } /** @@ -87,10 +92,13 @@ class c_base_error { unset($this->details); unset($this->severity); unset($this->limit); + unset($this->recovered); + unset($this->backtrace); - unset($this->code); + unset($this->backtrace_perform); unset($this->ignore_arguments); - unset($this->backtrace_performed); + + unset($this->code); } /** @@ -111,12 +119,15 @@ class c_base_error { * @param int|bool|null $limit * (optional) A number representing the backtrace limit. * If set to FALSE, then no backtrace is generated. + * @param bool $recovered + * (optional) If TRUE, then this designates that the error was recovered from. + * If FALSE, then the error has not been recovered from. * * @return c_base_error * Always returns a newly created c_base_error object. * No error status is ever returned. */ - public static function s_log($message = NULL, $details = NULL, $code = NULL, $severity = NULL, $limit = NULL) { + public static function s_log($message = NULL, $details = NULL, $code = NULL, $severity = NULL, $limit = NULL, $recovered = FALSE) { $class = __CLASS__; $entry = new $class(); unset($class); @@ -153,6 +164,10 @@ class c_base_error { $entry->set_limit($limit); } + if (is_bool($recovered)) { + $entry->set_recovered($recovered); + } + // build the backtrace, but ignore this function call when generating. $entry->set_backtrace(1); @@ -174,16 +189,7 @@ class c_base_error { } $this->message = $message; - } - - /** - * Returns the assigned message. - * - * @return string|null - * An error message string or NULL if not defined. - */ - public function get_message() { - return $this->message; + return TRUE; } /** @@ -207,18 +213,6 @@ class c_base_error { } /** - * Returns the details array. - * - * The details array is defined by the caller and may have any structure, so long as it is an array. - * - * @return array|null - * An array of additional details or NULL if not defined. - */ - public function get_details() { - return $this->details; - } - - /** * Assigns a severity level. * * @param int $severity @@ -235,21 +229,6 @@ class c_base_error { } /** - * Returns the currently assigned severity level. - * - * @return int - * The currently assigned severity level. - * This defaults to self::SEVERITY_ERROR when undefined. - */ - public function get_severity() { - if (is_null($this->severity)) { - $this->severity = self::SEVERITY_ERROR; - } - - return $this->severity; - } - - /** * Assigns a limit for use with debug_backtrace(). * * @param int|bool $limit @@ -269,24 +248,6 @@ class c_base_error { } /** - * Returns the currently assigned limit. - * - * @return int|bool - * The currently assigned limit integer. - * FALSE is returned if backtracing is disabled. - * This defaults to self::DEFAULT_BACKTRACE_LIMIT. - * - * @see: c_base_error::set_backtrace() - */ - public function get_limit() { - if ($limit !== FALSE && (!is_int($limit) || $limit < 0)) { - $this->limit = self::DEFAULT_BACKTRACE_LIMIT; - } - - return $this->limit; - } - - /** * Assigns a backtrace. * * This is auto-performed by the class. @@ -321,15 +282,39 @@ class c_base_error { } /** - * Returns the backtrace object. + * Assign the backtrace perform boolean. * - * @return array|null - * A populate backtrace array of objects or NULL if no backtrace is defined. + * @param bool $backtrace_perform + * The backtrace perform boolean. * - * @see: c_base_error::set_limit() + * @return bool + * TRUE on success, FALSE otherwise. */ - public function get_backtrace() { - return $this->backtrace; + public function set_backtrace_perform($backtrace_perform) { + if (!is_bool($backtrace_perform)) { + return FALSE; + } + + $this->backtrace_perform = $backtrace_perform; + return TRUE; + } + + /** + * Assign an error ignore arguments boolean. + * + * @param bool $ignore_arguments + * The ignore arguments boolean. + * + * @return bool + * TRUE on success, FALSE otherwise. + */ + public function set_ignore_arguments($ignore_arguments) { + if (!is_bool($ignore_arguments)) { + return FALSE; + } + + $this->ignore_arguments = $ignore_arguments; + return TRUE; } /** @@ -349,19 +334,7 @@ class c_base_error { } $this->code = $code; - } - - /** - * Returns the assigned code. - * - * A code is used to categorize the error in some manner. - * - * @return int|null - * A code to associate with the error. - * NULL is returned if not defined. - */ - public function get_code() { - return $this->code; + return TRUE; } /** @@ -384,34 +357,99 @@ class c_base_error { } /** - * Returns the reported object. + * Assign an error recovered boolean. * - * Use this to determine the results of the last report status. + * @param bool $recovered + * The recovered boolean. * - * @return object|null - * A populate reported object or NULL if no report was performed. + * @return bool + * TRUE on success, FALSE otherwise. + */ + public function set_recovered($recovered) { + if (!is_bool($recovered)) { + return FALSE; + } + + $this->recovered = $recovered; + return TRUE; + } + + /** + * Returns the assigned message. * - * @see: c_base_error::set_limit() + * @return string|null + * An error message string or NULL if not defined. */ - public function get_reported() { - return $this->reported; + public function get_message() { + return $this->message; } /** - * Assign an error ignore arguments boolean. + * Returns the details array. * - * @param bool $ignore_arguments - * The ignore arguments boolean. + * The details array is defined by the caller and may have any structure, so long as it is an array. * - * @return bool - * TRUE on success, FALSE otherwise. + * @return array|null + * An array of additional details or NULL if not defined. */ - public function set_ignore_arguments($ignore_arguments) { - if (!is_bool($ignore_arguments)) { - return FALSE; + public function get_details() { + return $this->details; + } + + /** + * Returns the currently assigned severity level. + * + * @return int + * The currently assigned severity level. + * This defaults to self::SEVERITY_ERROR when undefined. + */ + public function get_severity() { + if (is_null($this->severity)) { + $this->severity = self::SEVERITY_ERROR; } - $this->ignore_arguments = $ignore_arguments; + return $this->severity; + } + + /** + * Returns the currently assigned limit. + * + * @return int|bool + * The currently assigned limit integer. + * FALSE is returned if backtracing is disabled. + * This defaults to self::DEFAULT_BACKTRACE_LIMIT. + * + * @see: c_base_error::set_backtrace() + */ + public function get_limit() { + if ($limit !== FALSE && (!is_int($limit) || $limit < 0)) { + $this->limit = self::DEFAULT_BACKTRACE_LIMIT; + } + + return $this->limit; + } + + /** + * Returns the backtrace object. + * + * @return array|null + * A populate backtrace array of objects or NULL if no backtrace is defined. + * + * @see: c_base_error::set_limit() + */ + public function get_backtrace() { + return $this->backtrace; + } + + /** + * Returns the assigned backtrace perform boolean. + * + * @return bool|null + * A boolean representing whether or not to the backtrace should be performed. + * NULL is returned if not defined. + */ + public function get_backtrace_perform() { + return $this->backtrace_perform; } /** @@ -426,6 +464,43 @@ class c_base_error { } /** + * Returns the assigned code. + * + * A code is used to categorize the error in some manner. + * + * @return int|null + * A code to associate with the error. + * NULL is returned if not defined. + */ + public function get_code() { + return $this->code; + } + + /** + * Returns the reported object. + * + * Use this to determine the results of the last report status. + * + * @return object|null + * A populate reported object or NULL if no report was performed. + * + * @see: c_base_error::set_limit() + */ + public function get_reported() { + return $this->reported; + } + + /** + * Returns the recovered setting. + * + * @return bool|null + * The recovered boolean or NULL if not assigned. + */ + public function get_recovered() { + return $this->recovered; + } + + /** * Build the debug backtrace. * * This will not include this function in the backtrace. @@ -440,6 +515,10 @@ class c_base_error { * @see: debug_backtrace() */ private function p_backtrace($count = 0) { + if (!c_base_defaults_global::BACKTRACE_PERFORM || !$this->backtrace_perform) { + return; + } + $this->backtrace = array(); // when limit is set to FALSE, backtrace is disabled. @@ -479,7 +558,8 @@ class c_base_error { } unset($backtrace); - $this->backtrace_performed = TRUE; + // do not perform this backtrace multiple times. + $this->backtrace_perform = TRUE; } } diff --git a/common/base/classes/base_error_messages_english.php b/common/base/classes/base_error_messages_english.php index bfebb0d..c022f9a 100644 --- a/common/base/classes/base_error_messages_english.php +++ b/common/base/classes/base_error_messages_english.php @@ -183,7 +183,7 @@ final class c_base_error_messages_english implements i_base_error_messages { } elseif ($code === self::NOT_FOUND_ARRAY_INDEX) { if ($arguments === TRUE) { - return c_base_return_string::s_new('The index, :index_name, was not found in the array, :{array_name}' . $function_name_string . '.'); + return c_base_return_string::s_new('The index, :{index_name}, was not found in the array, :{array_name}' . $function_name_string . '.'); } else { return c_base_return_string::s_new('Failed to find index within specified array.'); diff --git a/common/base/classes/base_error_messages_japanese.php b/common/base/classes/base_error_messages_japanese.php index ddb6344..28f22e0 100644 --- a/common/base/classes/base_error_messages_japanese.php +++ b/common/base/classes/base_error_messages_japanese.php @@ -188,7 +188,7 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::NOT_FOUND_ARRAY_INDEX) { if ($arguments === TRUE) { - return c_base_return_string::s_new('配列 :index_name に索引 :{array_name} が見つかりませんでした。' . $function_name_string . '。'); + return c_base_return_string::s_new('配列 :{index_name} に索引 :{array_name} が見つかりませんでした。' . $function_name_string . '。'); } else { return c_base_return_string::s_new('指定された配列内のインデックスの検索に失敗しました。'); diff --git a/common/base/classes/base_html.php b/common/base/classes/base_html.php index 46e4b24..2a04c3b 100644 --- a/common/base/classes/base_html.php +++ b/common/base/classes/base_html.php @@ -222,7 +222,7 @@ class c_base_html extends c_base_return { * The attribute to assign. * * @return c_base_return_int|c_base_return_string|c_base_return_bool|c_base_return_status - * The value assigned to the attribte (the data type is different per attribute). + * The value assigned to the attribute (the data type is different per attribute). * FALSE is returned if the element does not exist. * FALSE with error bit set is returned on error. */ @@ -244,7 +244,7 @@ class c_base_html extends c_base_return { * The attribute to assign. * * @return c_base_return_int|c_base_return_string|c_base_return_bool|c_base_return_status - * The value assigned to the attribte (the data type is different per attribute). + * The value assigned to the attribute (the data type is different per attribute). * FALSE is returned if the element does not exist. * FALSE with error bit set is returned on error. */ @@ -564,7 +564,7 @@ class c_base_html extends c_base_return { * When FALSE, the normal attributes are returned. * * @return c_base_return_int|c_base_return_string|c_base_return_bool|c_base_return_status - * The value assigned to the attribte (the data type is different per attribute). + * The value assigned to the attribute (the data type is different per attribute). * FALSE is returned if the element does not exist. * FALSE with error bit set is returned on error. */ @@ -1389,6 +1389,25 @@ class c_base_html extends c_base_return { case c_base_markup_attributes::ATTRIBUTE_CLASS: if (!is_array($value)) { + if (is_string($value)) { + if ($body) { + if (!isset($this->attributes_body[$attribute])) { + $this->attributes_body[$attribute] = array(); + } + + $this->attributes_body[$attribute][] = $value; + } + else { + if (!isset($this->attributes[$attribute])) { + $this->attributes[$attribute] = array(); + } + + $this->attributes[$attribute][] = $value; + } + + return new c_base_return_true(); + } + return new c_base_return_false(); } break; diff --git a/common/base/classes/base_http.php b/common/base/classes/base_http.php index 076d03e..d090835 100644 --- a/common/base/classes/base_http.php +++ b/common/base/classes/base_http.php @@ -256,18 +256,18 @@ class c_base_http extends c_base_rfc_string { public function __construct() { parent::__construct(); - $this->headers = NULL; + $this->headers = NULL; $this->headers_sent = FALSE; - $this->request = array(); + $this->request = array(); $this->request_time = NULL; - $this->response = array(); + $this->response = array(); $this->request_uri_relative = NULL; $this->request_uri_query = NULL; - $this->content = NULL; + $this->content = NULL; $this->content_is_file = NULL; - $this->buffer_enabled = FALSE; + $this->buffer_enabled = FALSE; $this->languages = NULL; } @@ -376,7 +376,7 @@ class c_base_http extends c_base_rfc_string { } if (!array_key_exists($header_name, $this->request)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $header_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => $header_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -389,7 +389,7 @@ class c_base_http extends c_base_rfc_string { return c_base_return_value::s_new($this->request[$header_name]['data'][$delta]); } - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -488,7 +488,7 @@ class c_base_http extends c_base_rfc_string { } if (!array_key_exists($header_name, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $header_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => $header_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -505,7 +505,7 @@ class c_base_http extends c_base_rfc_string { return c_base_return_value::s_new($this->response[$header_name][$delta]); } - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -2871,6 +2871,7 @@ class c_base_http extends c_base_rfc_string { * These header fields apply only to the immediate client. * The header name format is: * - 1*(tchar) + * This does perform clone(). * @param bool $append * (optional) If TRUE, then append the header name. * If FALSE, then assign the header name. @@ -3682,7 +3683,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_access_control_allow_origin() { if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3703,7 +3704,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_access_control_allow_credentials() { if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ACCESS_CONTROL_ALLOW_CREDENTIALS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(FALSE, 'c_base_return_bool', $error); } @@ -3723,7 +3724,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_access_control_expose_headers() { if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ACCESS_CONTROL_EXPOSE_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3743,7 +3744,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_access_control_max_age() { if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_MAX_AGE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_MAX_AGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ACCESS_CONTROL_MAX_AGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0, 'c_base_return_int', $error); } @@ -3762,7 +3763,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_access_control_allow_methods() { if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ACCESS_CONTROL_ALLOW_METHODS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3782,7 +3783,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_access_control_allow_headers() { if (!array_key_exists(self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3802,7 +3803,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_accept_patch() { if (!array_key_exists(self::RESPONSE_ACCEPT_PATCH, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCEPT_PATCH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ACCEPT_PATCH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3826,7 +3827,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_accept_ranges() { if (!array_key_exists(self::RESPONSE_ACCEPT_RANGES, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ACCEPT_RANGES, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ACCEPT_RANGES, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value('', 'c_base_return_string', $error); } @@ -3844,7 +3845,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_age() { if (!array_key_exists(self::RESPONSE_AGE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_AGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_AGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0, 'c_base_return_int', $error); } @@ -3862,7 +3863,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_allow() { if (!array_key_exists(self::RESPONSE_ALLOW, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ALLOW, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ALLOW, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3896,7 +3897,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_cache_control() { if (!array_key_exists(self::RESPONSE_CACHE_CONTROL, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CACHE_CONTROL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CACHE_CONTROL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3917,7 +3918,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_connection() { if (!array_key_exists(self::RESPONSE_CONNECTION, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONNECTION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONNECTION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3935,7 +3936,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_content_disposition() { if (!array_key_exists(self::RESPONSE_CONTENT_DISPOSITION, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_DISPOSITION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONTENT_DISPOSITION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3951,7 +3952,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_content_encoding() { if (!array_key_exists(self::RESPONSE_CONTENT_ENCODING, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_ENCODING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONTENT_ENCODING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3969,7 +3970,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_content_language() { if (!array_key_exists(self::RESPONSE_CONTENT_LANGUAGE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_LANGUAGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONTENT_LANGUAGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -3987,7 +3988,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_content_length() { if (!array_key_exists(self::RESPONSE_CONTENT_LENGTH, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_LENGTH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONTENT_LENGTH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0, 'c_base_return_int', $error); } @@ -4013,7 +4014,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_content_range() { if (!array_key_exists(self::RESPONSE_CONTENT_RANGE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_RANGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONTENT_RANGE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4033,7 +4034,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_content_type() { if (!array_key_exists(self::RESPONSE_CONTENT_TYPE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_TYPE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONTENT_TYPE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4051,7 +4052,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_date() { if (!array_key_exists(self::RESPONSE_DATE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_DATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_DATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0.0, 'c_base_return_float', $error); } @@ -4077,7 +4078,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_date_actual() { if (!array_key_exists(self::RESPONSE_DATE_ACTUAL, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_DATE_ACTUAL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_DATE_ACTUAL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0.0, 'c_base_return_float', $error); } @@ -4101,7 +4102,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_etag() { if (!array_key_exists(self::RESPONSE_ETAG, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_ETAG, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_ETAG, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4119,7 +4120,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_expires() { if (!array_key_exists(self::RESPONSE_EXPIRES, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_EXPIRES, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_EXPIRES, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0.0, 'c_base_return_float', $error); } @@ -4141,7 +4142,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_last_modified() { if (!array_key_exists(self::RESPONSE_LAST_MODIFIED, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LAST_MODIFIED, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_LAST_MODIFIED, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0.0, 'c_base_return_float', $error); } @@ -4166,7 +4167,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_link() { if (!array_key_exists(self::RESPONSE_LINK, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LINK, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_LINK, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4186,7 +4187,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_location() { if (!array_key_exists(self::RESPONSE_LOCATION, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_LOCATION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_LOCATION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4205,7 +4206,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_pragma() { if (!array_key_exists(self::RESPONSE_PRAGMA, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PRAGMA, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_PRAGMA, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4225,7 +4226,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_proxy_authenticate() { if (!array_key_exists(self::RESPONSE_PROXY_AUTHENTICATE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PROXY_AUTHENTICATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_PROXY_AUTHENTICATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4248,7 +4249,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_public_key_pins() { if (!array_key_exists(self::RESPONSE_PUBLIC_KEY_PINS, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PUBLIC_KEY_PINS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_PUBLIC_KEY_PINS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4274,7 +4275,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_refresh() { if (!array_key_exists(self::RESPONSE_REFRESH, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_REFRESH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_REFRESH, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4298,7 +4299,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_retry_after() { if (!array_key_exists(self::RESPONSE_RETRY_AFTER, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_RETRY_AFTER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_RETRY_AFTER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4316,7 +4317,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_set_cookie() { if (!array_key_exists(self::RESPONSE_SET_COOKIE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_SET_COOKIE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_SET_COOKIE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_cookie', $error); } @@ -4333,7 +4334,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_server() { if (!array_key_exists(self::RESPONSE_SERVER, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_SERVER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_SERVER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4354,7 +4355,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_status() { if (!array_key_exists(self::RESPONSE_STATUS, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_STATUS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_STATUS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0, 'c_base_return_int', $error); } @@ -4372,7 +4373,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_strict_transport_security() { if (!array_key_exists(self::RESPONSE_STRICT_TRANSPORT_SECURITY, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_STRICT_TRANSPORT_SECURITY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_STRICT_TRANSPORT_SECURITY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value('', 'c_base_return_string', $error); } @@ -4398,7 +4399,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_trailer() { if (!array_key_exists(self::RESPONSE_TRAILER, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_TRAILER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_TRAILER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4419,7 +4420,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_transfer_encoding() { if (!array_key_exists(self::RESPONSE_TRANSFER_ENCODING, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_TRANSFER_ENCODING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_TRANSFER_ENCODING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4439,7 +4440,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_upgrade() { if (!array_key_exists(self::RESPONSE_UPGRADE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_UPGRADE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_UPGRADE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4460,7 +4461,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_vary() { if (!array_key_exists(self::RESPONSE_VARY, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_VARY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_VARY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4478,7 +4479,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_warning() { if (!array_key_exists(self::RESPONSE_WARNING, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_WARNING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_WARNING, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4499,7 +4500,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_www_authenticate() { if (!array_key_exists(self::RESPONSE_WWW_AUTHENTICATE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_WWW_AUTHENTICATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_WWW_AUTHENTICATE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -4518,7 +4519,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_protocol() { if (!array_key_exists(self::RESPONSE_PROTOCOL, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_PROTOCOL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_PROTOCOL, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value('', 'c_base_return_string', $error); } @@ -4538,7 +4539,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_content_security_policy() { if (!array_key_exists(self::RESPONSE_CONTENT_SECURITY_POLICY, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_SECURITY_POLICY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONTENT_SECURITY_POLICY, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4554,7 +4555,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_x_content_type_options() { if (!array_key_exists(self::RESPONSE_X_CONTENT_TYPE_OPTIONS, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_X_CONTENT_TYPE_OPTIONS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_X_CONTENT_TYPE_OPTIONS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(FALSE, 'c_base_return_bool', $error); } @@ -4570,7 +4571,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_x_ua_compatible() { if (!array_key_exists(self::RESPONSE_X_UA_COMPATIBLE, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_X_UA_COMPATIBLE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_X_UA_COMPATIBLE, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4592,7 +4593,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_checksum_header() { if (!array_key_exists(self::RESPONSE_CHECKSUM_HEADER, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_HEADER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CHECKSUM_HEADER, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4608,7 +4609,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_checksum_headers() { if (!array_key_exists(self::RESPONSE_CHECKSUM_HEADERS, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CHECKSUM_HEADERS, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4628,7 +4629,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_checksum_content() { if (!array_key_exists(self::RESPONSE_CHECKSUM_CONTENT, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CHECKSUM_CONTENT, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CHECKSUM_CONTENT, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } @@ -4644,7 +4645,7 @@ class c_base_http extends c_base_rfc_string { */ public function get_response_content_revision() { if (!array_key_exists(self::RESPONSE_CONTENT_REVISION, $this->response)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => self::RESPONSE_CONTENT_REVISION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => self::RESPONSE_CONTENT_REVISION, ':{array_name}' => 'this->response', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_value(0, 'c_base_return_int', $error); } @@ -4891,6 +4892,22 @@ class c_base_http extends c_base_rfc_string { } /** + * Returns whether or not response content is a file. + * + * @return c_base_return_bool + * TRUE if content is a file. + * FALSE otherwise. + * FALSE with error bit set is returned on error. + */ + public function is_response_content_file() { + if ($this->content_is_file) { + return new c_base_return_true(); + } + + return new c_base_return_false(); + } + + /** * Encode the HTTP response content. * * This must be performed after all content has been buffered and before the HTTP headers are sent. diff --git a/common/base/classes/base_markup.php b/common/base/classes/base_markup.php index a588388..bf2c3ab 100644 --- a/common/base/classes/base_markup.php +++ b/common/base/classes/base_markup.php @@ -435,104 +435,105 @@ class c_base_markup_tag extends c_base_rfc_string { const TYPE_H4 = 59; const TYPE_H5 = 60; const TYPE_H6 = 61; - const TYPE_HEADER = 62; - const TYPE_HIDDEN = 63; - const TYPE_HORIZONTAL_RULER = 64; - const TYPE_ITALICS = 65; - const TYPE_INLINE_FRAME = 66; - const TYPE_IMAGE = 67; - const TYPE_IMAGE_SVG = 68; - const TYPE_INPUT = 69; - const TYPE_INS = 70; - const TYPE_KEYBOARD = 71; - const TYPE_KEY_GEN = 72; - const TYPE_LABEL = 73; - const TYPE_LEGEND = 74; - const TYPE_LIST_ITEM = 75; - const TYPE_LINE = 76; - const TYPE_LINEAR_GRADIENT = 77; - const TYPE_LINK = 78; - const TYPE_MAIN = 79; - const TYPE_MAP = 80; - const TYPE_MARK = 81; - const TYPE_MARKER = 82; - const TYPE_MASK = 83; - const TYPE_MENU = 84; - const TYPE_MENU_ITEM = 85; - const TYPE_MATH = 86; - const TYPE_META = 87; - const TYPE_METER = 88; - const TYPE_MONTH = 89; - const TYPE_NAVIGATION = 90; - const TYPE_NO_SCRIPT = 91; - const TYPE_NUMBER = 92; - const TYPE_OBJECT = 93; - const TYPE_ORDERED_LIST = 94; - const TYPE_OPTIONS_GROUP = 95; - const TYPE_OPTION = 96; - const TYPE_OUTPUT = 97; - const TYPE_PARAGRAPH = 98; - const TYPE_PARAM = 99; - const TYPE_PASSWORD = 100; - const TYPE_PATH = 101; - const TYPE_PATTERN = 102; - const TYPE_PICTURE = 103; - const TYPE_POLYGON = 104; - const TYPE_POLYLINE = 105; - const TYPE_PREFORMATTED = 106; - const TYPE_PROGRESS = 107; - const TYPE_Q = 108; - const TYPE_RADIAL_GRADIENT = 109; - const TYPE_RADIO = 110; - const TYPE_RANGE = 111; - const TYPE_RECTANGLE = 112; - const TYPE_RESET = 113; - const TYPE_RUBY = 114; - const TYPE_RUBY_PARENTHESIS = 115; - const TYPE_RUBY_PRONUNCIATION = 116; - const TYPE_STRIKE_THROUGH = 117; - const TYPE_SAMPLE = 118; - const TYPE_SCRIPT = 119; - const TYPE_SEARCH = 120; - const TYPE_SECTION = 121; - const TYPE_SELECT = 122; - const TYPE_SMALL = 123; - const TYPE_SOURCE = 124; - const TYPE_SPAN = 125; - const TYPE_STOP = 126; - const TYPE_STRONG = 127; - const TYPE_STYLE = 128; - const TYPE_SUB_SCRIPT = 129; - const TYPE_SUBMIT = 130; - const TYPE_SUPER_SCRIPT = 131; - const TYPE_SVG = 132; - const TYPE_TABLE = 133; - const TYPE_TABLE_BODY = 134; - const TYPE_TABLE_CELL = 135; - const TYPE_TABLE_FOOTER = 136; - const TYPE_TABLE_HEADER = 137; - const TYPE_TABLE_HEADER_CELL = 138; - const TYPE_TABLE_ROW = 139; - const TYPE_TELEPHONE = 140; - const TYPE_TEMPLATE = 141; - const TYPE_TERM_DESCRIPTION = 142; - const TYPE_TERM_NAME = 143; - const TYPE_TEXT = 144; - const TYPE_TEXT_AREA = 145; - const TYPE_TEXT_REFERENCE = 146; - const TYPE_TEXT_SPAN = 147; - const TYPE_TEXT_SVG = 148; - const TYPE_TIME = 149; - const TYPE_TITLE = 150; - const TYPE_TRACK = 151; - const TYPE_UNDERLINE = 152; - const TYPE_UNORDERED_LIST = 153; - const TYPE_URL = 154; - const TYPE_USE = 155; - const TYPE_VARIABLE = 156; - const TYPE_VIDEO = 157; - const TYPE_WEEK = 158; - const TYPE_WIDE_BREAK = 159; + const TYPE_HX = 62; + const TYPE_HEADER = 63; + const TYPE_HIDDEN = 64; + const TYPE_HORIZONTAL_RULER = 65; + const TYPE_ITALICS = 66; + const TYPE_INLINE_FRAME = 67; + const TYPE_IMAGE = 68; + const TYPE_IMAGE_SVG = 69; + const TYPE_INPUT = 70; + const TYPE_INS = 71; + const TYPE_KEYBOARD = 72; + const TYPE_KEY_GEN = 73; + const TYPE_LABEL = 74; + const TYPE_LEGEND = 75; + const TYPE_LIST_ITEM = 76; + const TYPE_LINE = 77; + const TYPE_LINEAR_GRADIENT = 78; + const TYPE_LINK = 79; + const TYPE_MAIN = 80; + const TYPE_MAP = 81; + const TYPE_MARK = 82; + const TYPE_MARKER = 83; + const TYPE_MASK = 84; + const TYPE_MENU = 85; + const TYPE_MENU_ITEM = 86; + const TYPE_MATH = 87; + const TYPE_META = 88; + const TYPE_METER = 89; + const TYPE_MONTH = 90; + const TYPE_NAVIGATION = 91; + const TYPE_NO_SCRIPT = 92; + const TYPE_NUMBER = 93; + const TYPE_OBJECT = 94; + const TYPE_ORDERED_LIST = 95; + const TYPE_OPTIONS_GROUP = 96; + const TYPE_OPTION = 97; + const TYPE_OUTPUT = 98; + const TYPE_PARAGRAPH = 99; + const TYPE_PARAM = 100; + const TYPE_PASSWORD = 101; + const TYPE_PATH = 102; + const TYPE_PATTERN = 103; + const TYPE_PICTURE = 104; + const TYPE_POLYGON = 105; + const TYPE_POLYLINE = 106; + const TYPE_PREFORMATTED = 107; + const TYPE_PROGRESS = 108; + const TYPE_Q = 109; + const TYPE_RADIAL_GRADIENT = 110; + const TYPE_RADIO = 111; + const TYPE_RANGE = 112; + const TYPE_RECTANGLE = 113; + const TYPE_RESET = 114; + const TYPE_RUBY = 115; + const TYPE_RUBY_PARENTHESIS = 116; + const TYPE_RUBY_PRONUNCIATION = 117; + const TYPE_STRIKE_THROUGH = 118; + const TYPE_SAMPLE = 119; + const TYPE_SCRIPT = 120; + const TYPE_SEARCH = 121; + const TYPE_SECTION = 122; + const TYPE_SELECT = 123; + const TYPE_SMALL = 124; + const TYPE_SOURCE = 125; + const TYPE_SPAN = 126; + const TYPE_STOP = 127; + const TYPE_STRONG = 128; + const TYPE_STYLE = 129; + const TYPE_SUB_SCRIPT = 130; + const TYPE_SUBMIT = 131; + const TYPE_SUPER_SCRIPT = 132; + const TYPE_SVG = 133; + const TYPE_TABLE = 134; + const TYPE_TABLE_BODY = 135; + const TYPE_TABLE_CELL = 136; + const TYPE_TABLE_FOOTER = 137; + const TYPE_TABLE_HEADER = 138; + const TYPE_TABLE_HEADER_CELL = 139; + const TYPE_TABLE_ROW = 140; + const TYPE_TELEPHONE = 141; + const TYPE_TEMPLATE = 142; + const TYPE_TERM_DESCRIPTION = 143; + const TYPE_TERM_NAME = 144; + const TYPE_TEXT = 145; + const TYPE_TEXT_AREA = 146; + const TYPE_TEXT_REFERENCE = 147; + const TYPE_TEXT_SPAN = 148; + const TYPE_TEXT_SVG = 149; + const TYPE_TIME = 150; + const TYPE_TITLE = 151; + const TYPE_TRACK = 152; + const TYPE_UNDERLINE = 153; + const TYPE_UNORDERED_LIST = 154; + const TYPE_URL = 155; + const TYPE_USE = 156; + const TYPE_VARIABLE = 157; + const TYPE_VIDEO = 158; + const TYPE_WEEK = 159; + const TYPE_WIDE_BREAK = 160; protected $attributes; protected $tags; @@ -982,6 +983,15 @@ class c_base_markup_tag extends c_base_rfc_string { case c_base_markup_attributes::ATTRIBUTE_CLASS: if (!is_array($value)) { + if (is_string($value)) { + if (!isset($this->attributes[$attribute])) { + $this->attributes[$attribute] = array(); + } + + $this->attributes[$attribute][] = $value; + return new c_base_return_true(); + } + return new c_base_return_false(); } break; @@ -1019,10 +1029,10 @@ class c_base_markup_tag extends c_base_rfc_string { * Get the value of a single attribute assigned to this object. * * @param int $attribute - * The attribute to assign. + * The attribute to get. * * @return c_base_return_int|c_base_return_string|c_base_return_bool|c_base_return_status - * The value assigned to the attribte (the data type is different per attribute). + * The value assigned to the attribute (the data type is different per attribute). * FALSE is returned if the element does not exist. * FALSE with error bit set is returned on error. */ @@ -1744,170 +1754,8 @@ class c_base_markup_tag extends c_base_rfc_string { return c_base_return_error::s_false($error); } - switch ($type) { - case self::TYPE_NONE: - case self::TYPE_A: - case self::TYPE_ABBR: - case self::TYPE_ADDRESS: - case self::TYPE_ALTERNATE_GLYPH: - case self::TYPE_ALTERNATE_GLYPH_DEFINITION: - case self::TYPE_ALTERNATE_GLYPH_ITEM: - case self::TYPE_ANIMATE: - case self::TYPE_ANIMATE_MOTION: - case self::TYPE_ANIMATE_TRANSFORM: - case self::TYPE_AREA: - case self::TYPE_ARTICLE: - case self::TYPE_ASIDE: - case self::TYPE_AUDIO: - case self::TYPE_BOLD: - case self::TYPE_BASE: - case self::TYPE_BDI: - case self::TYPE_BDO: - case self::TYPE_BLOCKQUOTE: - case self::TYPE_BREAK: - case self::TYPE_BUTTON: - case self::TYPE_CANVAS: - case self::TYPE_CHECKBOX: - case self::TYPE_CIRCLE: - case self::TYPE_CITE: - case self::TYPE_CLIP_PATH: - case self::TYPE_CODE: - case self::TYPE_COL: - case self::TYPE_COL_GROUP: - case self::TYPE_COLOR: - case self::TYPE_COLOR_PROFILE: - case self::TYPE_CURSOR: - case self::TYPE_DATA: - case self::TYPE_DATA_LIST: - case self::TYPE_DATE: - case self::TYPE_DATE_TIME_LOCAL: - case self::TYPE_DEFS: - case self::TYPE_DEL: - case self::TYPE_DESCRIPTION: - case self::TYPE_DETAILS: - case self::TYPE_DFN: - case self::TYPE_DIALOG: - case self::TYPE_DIVIDER: - case self::TYPE_DEFINITION_LIST: - case self::TYPE_TERM_NAME: - case self::TYPE_ELLIPSE: - case self::TYPE_EM: - case self::TYPE_EMAIL: - case self::TYPE_EMBED: - case self::TYPE_FE_BLEND: - case self::TYPE_FIELD_SET: - case self::TYPE_FIGURE: - case self::TYPE_FIGURE_CAPTION: - case self::TYPE_FILE: - case self::TYPE_FOOTER: - case self::TYPE_FORM: - case self::TYPE_GROUP: - case self::TYPE_H1: - case self::TYPE_H2: - case self::TYPE_H3: - case self::TYPE_H4: - case self::TYPE_H5: - case self::TYPE_H6: - case self::TYPE_HEADER: - case self::TYPE_HIDDEN: - case self::TYPE_HORIZONTAL_RULER: - case self::TYPE_ITALICS: - case self::TYPE_INLINE_FRAME: - case self::TYPE_IMAGE: - case self::TYPE_IMAGE_SVG: - case self::TYPE_INPUT: - case self::TYPE_INS: - case self::TYPE_KEYBOARD: - case self::TYPE_KEY_GEN: - case self::TYPE_LABEL: - case self::TYPE_LEGEND: - case self::TYPE_LIST_ITEM: - case self::TYPE_LINE: - case self::TYPE_LINEAR_GRADIENT: - case self::TYPE_LINK: - case self::TYPE_MAIN: - case self::TYPE_MAP: - case self::TYPE_MARK: - case self::TYPE_MARKER: - case self::TYPE_MASK: - case self::TYPE_MENU: - case self::TYPE_MENU_ITEM: - case self::TYPE_MATH: - case self::TYPE_META: - case self::TYPE_METER: - case self::TYPE_MONTH: - case self::TYPE_NAVIGATION: - case self::TYPE_NO_SCRIPT: - case self::TYPE_NUMBER: - case self::TYPE_OBJECT: - case self::TYPE_ORDERED_LIST: - case self::TYPE_OPTIONS_GROUP: - case self::TYPE_OPTION: - case self::TYPE_OUTPUT: - case self::TYPE_PARAGRAPH: - case self::TYPE_PARAM: - case self::TYPE_PASSWORD: - case self::TYPE_PATH: - case self::TYPE_PATTERN: - case self::TYPE_PICTURE: - case self::TYPE_POLYGON: - case self::TYPE_POLYLINE: - case self::TYPE_PREFORMATTED: - case self::TYPE_PROGRESS: - case self::TYPE_Q: - case self::TYPE_RADIAL_GRADIENT: - case self::TYPE_RADIO: - case self::TYPE_RANGE: - case self::TYPE_RECTANGLE: - case self::TYPE_RESET: - case self::TYPE_RUBY: - case self::TYPE_RUBY_PARENTHESIS: - case self::TYPE_RUBY_PRONUNCIATION: - case self::TYPE_STRIKE_THROUGH: - case self::TYPE_SAMPLE: - case self::TYPE_SCRIPT: - case self::TYPE_SEARCH: - case self::TYPE_SECTION: - case self::TYPE_SELECT: - case self::TYPE_SMALL: - case self::TYPE_SOURCE: - case self::TYPE_SPAN: - case self::TYPE_STOP: - case self::TYPE_STRONG: - case self::TYPE_STYLE: - case self::TYPE_SUB_SCRIPT: - case self::TYPE_SUBMIT: - case self::TYPE_SUPER_SCRIPT: - case self::TYPE_SVG: - case self::TYPE_TABLE: - case self::TYPE_TABLE_BODY: - case self::TYPE_TABLE_CELL: - case self::TYPE_TABLE_FOOTER: - case self::TYPE_TABLE_HEADER: - case self::TYPE_TABLE_HEADER_CELL: - case self::TYPE_TABLE_ROW: - case self::TYPE_TELEPHONE: - case self::TYPE_TEMPLATE: - case self::TYPE_TERM_DESCRIPTION: - case self::TYPE_TEXT: - case self::TYPE_TEXT_AREA: - case self::TYPE_TEXT_REFERENCE: - case self::TYPE_TEXT_SPAN: - case self::TYPE_TEXT_SVG: - case self::TYPE_TIME: - case self::TYPE_TITLE: - case self::TYPE_TRACK: - case self::TYPE_UNDERLINE: - case self::TYPE_UNORDERED_LIST: - case self::TYPE_URL: - case self::TYPE_USE: - case self::TYPE_VARIABLE: - case self::TYPE_VIDEO: - case self::TYPE_WEEK: - case self::TYPE_WIDE_BREAK: - break; - default: - return new c_base_return_false(); + if ($type < 0) { + return new c_base_return_false(); } $this->type = $type; diff --git a/common/base/classes/base_menu.php b/common/base/classes/base_menu.php new file mode 100644 index 0000000..764234f --- /dev/null +++ b/common/base/classes/base_menu.php @@ -0,0 +1,440 @@ +, , or even breadcrumbs. + */ +class c_base_menu extends c_base_rfc_string { + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, array()); + } + + /** + * Build the menu structure. + * + * @param c_base_http &$http + * The entire HTTP information to allow for the execution to access anything that is necessary. + * @param c_base_database &$database + * The database object, which is usually used by form and ajax paths. + * @param c_base_session &$session + * The current session. + * @param array $settings + * An array of additional settings that are usually site-specific. + * @param array|null $items + * (optional) An array of menu items to use for the menu. + * How this is treated is left to the implementing class. + * This is generally intended to be used for certain types of dynamic content, such as breadcrumbs. + * + * @return c_base_markup_tag|c_base_return_status + * An HTML tag containing the menu. + * FALSE without error bit set is returned if menu is undefined. + * FALSE with error bit set is returned on error. + */ + public function do_build(&$http, &$database, &$session, $settings, $items = NULL) { + if (!($http instanceof c_base_http)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'http', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + elseif (!($database instanceof c_base_database)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + elseif (!($session instanceof c_base_session)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + elseif (!is_array($settings)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + elseif (!is_null($items) && !is_array($items)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'items', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + return new c_base_return_false(); + } +} + +/** + * A generic class for managing a menu item. + * + * This can also be used as a menu of items. + */ +class c_base_menu_item extends c_base_array { + private $text; + private $uri; + private $attributes; + + + /** + * Class constructor. + */ + public function __construct() { + parent::__construct(); + + $this->text = NULL; + $this->uri = NULL; + $this->attributes = NULL; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->text); + unset($this->uri); + unset($this->attributes); + + parent::__destruct(); + } + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, array()); + } + + /** + * Assign the attribute text. + * + * @param string|int $text + * The text representing the item name. + * May be a number to represent a code used for converting itno a language-specific text. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with the error bit set on error. + */ + public function set_text($text) { + if (!is_int($text) && !is_string($text)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'text', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->text = $text; + return new c_base_return_true(); + } + + /** + * Assign or unassign the menu items URI. + * + * @param string|array|null $uri + * The uri string or array to assign. + * Set to NULL to remove any existing uri string. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with the error bit set on error. + */ + public function set_uri($uri) { + if (!is_null($uri) && !is_string($uri) && !is_array($uri)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'uri', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->uri = $uri; + return new c_base_return_true(); + } + + /** + * Assign a single attribute. + * + * @param int $attribute + * The attribute id to assign. + * @param $value + * The attribute value to assign. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with the error bit set on error. + */ + public function set_attribute($attribute, $value) { + if (!is_int($attribute)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->attributes)) { + $this->attributes = array(); + } + + $this->attributes[$attribute] = $value; + return new c_base_return_true(); + } + + /** + * Assign an array of attributes. + * + * @param array $attributes + * An array of attributes to assign. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with the error bit set on error. + */ + public function set_attributes($attributes) { + if (!is_array($attributes)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attributes', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->attributes = $attributes; + return new c_base_return_true(); + } + + /** + * Assign the item at a specific index in the array. + * + * @param c_base_menu_item $item + * An instance of c_base_menu_item to assign. + * This does perform clone(). + * @param int|string|NULL $index + * An index to assign a specific value to. + * Set to NULL to append item. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * FALSE with the error bit set is returned on error. + */ + public function set_item($item, $index = NULL) { + if (!($item instanceof c_base_menu_item)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'item', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_null($index) && !is_int($index) && !is_string($index)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'index', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->items)) { + $this->items = array(); + } + + if (is_null($index)) { + $this->items[] = clone($item); + } + else { + $this->items[$index] = clone($item); + } + + return new c_base_return_true(); + } + + /** + * Assign the items array. + * + * @param c_base_array $items + * Replace the current array with this value. + * If NULL, then a new array is created. + * This does perform clone(). + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * FALSE with the error bit set is returned on error. + */ + public function set_items($items) { + if (!is_null($items) && !($items instanceof c_base_menu_item)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'items', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->items = clone($items); + return new c_base_return_true(); + } + + /** + * Get any text assigned to this menu item. + * + * @return c_base_return_int|return c_base_return_string + * A URI string is returned or an integer for language-specific conversion. + * An empty string with the error bit set is returned on error. + */ + public function get_text() { + if (!is_int($this->text) && !is_string($this->text)) { + return c_base_return_string::s_new(''); + } + + if (is_int($this->text)) { + return c_base_return_int::s_new($this->text); + } + + return c_base_return_string::s_new($this->text); + } + + /** + * Get any uri assigned to this menu item. + * + * @return c_base_return_array|c_base_return_string|c_base_return_null + * A URI string or URI array, if defined. + * Otherwise NULL is returned. + * NULL with the error bit set is returned on error. + */ + public function get_uri() { + if (!is_array($this->uri) && !is_string($this->uri)) { + return new c_base_return_null(); + } + + if (is_array($this->uri)) { + return c_base_return_array::s_new($this->uri); + } + + return c_base_return_string::s_new($this->uri); + } + + /** + * Get a single attribute assigned to this menu item. + * + * @param int $attribute + * The attribute to get. + * + * @return c_base_return_value + * The value assigned to the attribute (the data type is different per attribute). + * FALSE is returned if the element does not exist. + * FALSE with error bit set is returned on error. + */ + + public function get_attribute($attribute) { + if (!is_int($attribute)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'attribute', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->attributes) || !array_key_exists($attribute, $this->attributes)) { + return new c_base_return_false(); + } + + return c_base_return_value::s_new($this->attributes[$attribute]); + } + + /** + * Get all attributes assigned to this menu item. + * + * @return c_base_return_array + * An array of assigned attributes. + * An empty array with the error bit set on error. + */ + public function get_attributes() { + if (!is_array($this->attributes)) { + return c_base_return_array::s_new(array()); + } + + return c_base_return_array::s_new($this->attributes); + } + + /** + * Return the item at a specific index in the array. + * + * @param string $index + * An index to assign a specific value to. + * + * @return c_base_return_status|c_base_menu_item + * Value on success, FALSE otherwise. + * FALSE without error bit set is returned if $index us not defined. + * FALSE with the error bit set is returned on error. + * This does perform clone(). + */ + public function get_item($index) { + if (!is_string($index) || empty($index)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'index', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($this->items) || !array_key_exists($index, $this->items)) { + return new c_base_return_false(); + } + + return clone($this->items[$index]); + } + + /** + * Return the items array. + * + * @return c_base_return_array + * The array stored within this class. + * An empty array with error bit set is returned on error. + */ + public function get_items() { + if (!is_null($this->items) && !is_array($this->items)) { + return c_base_return_array::s_new(array()); + } + + return c_base_return_array::s_new($this->items); + } + + /** + * Return the total number of items in the array. + * + * @return c_base_return_int + * A positive integer. + * 0 with the error bit set is returned on error. + */ + public function get_items_count() { + if (empty($this->items)) { + return 0; + } + + return count($this->items); + } + + /** + * Return the array keys assigned to the array. + * + * @return c_base_return_array + * An array of array keys. + * An empty array with the error bit set is returned on error. + */ + public function get_items_keys() { + if (empty($this->items)) { + return array(); + } + + return array_keys($this->items); + } +} diff --git a/common/base/classes/base_path.php b/common/base/classes/base_path.php index bb82731..0dbf429 100644 --- a/common/base/classes/base_path.php +++ b/common/base/classes/base_path.php @@ -20,6 +20,7 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_utf8.php'); require_once('common/base/classes/base_http.php'); require_once('common/base/classes/base_cookie.php'); +require_once('common/base/classes/base_array.php'); /** * A generic class for managing paths information. @@ -96,6 +97,8 @@ class c_base_path extends c_base_rfc_string { protected $allowed_methods; protected $sanitize_html; + protected $path_tree; + /** * Class constructor. @@ -124,6 +127,8 @@ class c_base_path extends c_base_rfc_string { $this->allowed_methods = self::DEFAULT_ALLOWED_METHODS; $this->sanitize_html = self::DEFAULT_SANITIZE_HTML; + + $this->path_tree = NULL; } /** @@ -152,6 +157,8 @@ class c_base_path extends c_base_rfc_string { unset($this->allowed_methods); unset($this->sanitize_html); + unset($this->path_tree); + parent::__destruct(); } @@ -650,6 +657,36 @@ class c_base_path extends c_base_rfc_string { } /** + * Assign an path tree associated with the path. + * + * This should include the current path. + * This can be used to generate the breadcrumb. + * + * @param c_base_path_tree|null $path_tree + * A path tree to the current path that this object represents. + * Set to NULL to remove the currently assigned path tree value. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * FALSE with error bit set is returned on error. + */ + public function set_path_tree($path_tree) { + if (!is_null($path_tree) && !($path_tree instanceof c_base_path_tree)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'path_tree', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (is_null($path_tree)) { + $this->path_tree = NULL; + } + else { + $this->path_tree = clone($path_tree); + } + + return new c_base_return_true(); + } + + /** * Return the value. * * @return string|null @@ -848,6 +885,25 @@ class c_base_path extends c_base_rfc_string { } /** + * Get the assigned path tree. + * + * This should include the current path. + * This can be used to generate the breadcrumb. + * + * @return c_base_path_tree|c_base_return_null + * An array of path strings + * NULL is returned if the path tree is not assigned. + * Error bit is set on error. + */ + public function get_path_tree() { + if (!($this->path_tree instanceof c_base_path_tree)) { + return new c_base_return_null(); + } + + return clone($this->path_tree); + } + + /** * Get or Assign the is content boolean setting. * * @param bool|null $is_content @@ -1048,9 +1104,9 @@ class c_base_path extends c_base_rfc_string { /** * Execute using the specified path, rendering the page. * - * @param c_base_http $http + * @param c_base_http &$http * The entire HTTP information to allow for the execution to access anything that is necessary. - * @param c_base_database $database + * @param c_base_database &$database * The database object, which is usually used by form and ajax paths. * @param c_base_session &$session * The current session. @@ -1242,7 +1298,7 @@ class c_base_path extends c_base_rfc_string { * * @see: c_base_path() */ -class c_base_path_executed extends c_base_return_array { +class c_base_path_executed extends c_base_array { private $cookies = NULL; private $output = NULL; private $form = NUll; @@ -1294,7 +1350,7 @@ class c_base_path_executed extends c_base_return_array { /** * Assign cookies. * - * @param c_base_cookie + * @param c_base_cookie $cookie * The cookie to assign. * @param bool $append * (optional) When TRUE the $cookie is appended. @@ -1326,7 +1382,7 @@ class c_base_path_executed extends c_base_return_array { /** * Assign output. * - * @param c_base_return|null + * @param c_base_return|null $output * The output to assign. * NULL may be specified to remove any output. * @@ -1359,3 +1415,87 @@ class c_base_path_executed extends c_base_return_array { return $this->output; } } + +/** + * A generic class for providing path trees (like a breadcrumb). + * + * @see: c_base_path() + */ +class c_base_path_tree extends c_base_array { + private $id_group = NULL; + + + /** + * Class constructor. + */ + public function __construct() { + parent::__construct(); + + $this->id_group = NULL; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->id_group); + + parent::__destruct(); + } + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, array()); + } + + /** + * Assign group id. + * + * @param int $id_group + * The group id to assign. + * + * @return c_base_return_status + * TRUE is returned on success. + * FALSE with error bit set is returned on error. + */ + public function set_id_group($id_group) { + if (!is_int($id_group)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id_group', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->id_group = $id_group; + return new c_base_return_true(); + } + + /** + * Gets the assigned output + * + * @return c_base_return|c_base_return_null + * The assigned output is returned. + * If there is no assigned output (generally when execution is not performed) NULL is returned. + */ + public function get_id_group() { + if (!is_int($this->id_group)) { + return c_base_return_int::s_new(0); + } + + return c_base_return_int::s_new($this->id_group); + } +} diff --git a/common/base/classes/base_paths.php b/common/base/classes/base_paths.php index e15b81c..7952dd4 100644 --- a/common/base/classes/base_paths.php +++ b/common/base/classes/base_paths.php @@ -18,6 +18,8 @@ require_once('common/base/classes/base_path.php'); * Third, the paths are exploded and searched based on all their sub-parts. */ class c_base_paths extends c_base_return { + protected const SCRIPT_EXTENSION = '.php'; + private $paths = NULL; private $root = NULL; @@ -124,7 +126,6 @@ class c_base_paths extends c_base_return { $methods = $allowed_methods; } - if (mb_strlen($path) == 0) { unset($path_object); $this->root = array('handler' => $handler, 'include_directory' => $include_directory, 'include_name' => $include_name, 'is_root' => TRUE, 'methods' => $methods); @@ -137,7 +138,7 @@ class c_base_paths extends c_base_return { return c_base_return_error::s_false($error); } - $valid_path = $path_object->set_value($path); + $valid_path = $path_object->set_value('/' . $path); if (!$valid_path) { unset($path_object); unset($valid_path); @@ -242,11 +243,17 @@ class c_base_paths extends c_base_return { * An array containing: * - 'include_directory': the prefix path of the file to include that contains the handler class implementation. * - 'include_name': the suffix path of the file to include that contains the handler class implementation. - * - 'handler': the name of the handler class. + * - 'handler': the name of the handler class (set to the boolean TRUE, when redirects are used). + * - 'methods': An array of HTTP request codes that are allowed at this path. + * - 'path_tree': An array of the path tree. + * - 'id_group': The group id code for the specified path. * - 'redirect': if specified, then a redirect path (instead of include/handler). + * - 'redirect_partial': boolean designating if the redirect url is only a partial url. * - 'code': if redirect is specified, then the http response code associated with the redirect. + * - 'extra_slashes': boolean designating that there are multiple extra slashes found (a reason for a url redirect). + * * Wildcards are matched after all non-wildcards. - * NULL is returned if not found. + * If not found, the 'handler' in the array will be set to NULL. * FALSE with error bit set is returned on error. * * @see: self::set_login() @@ -260,10 +267,21 @@ class c_base_paths extends c_base_return { if (is_null($path_string) || mb_strlen($path_string) == 0) { if (is_array($this->root)) { - return c_base_return_array::s_new($this->root); + $root_array = $this->root; + $root_array['id_group'] = 0; + $root_array['path_tree'] = array(); + + return c_base_return_array::s_new($root_array); } - return new c_base_return_null(); + return c_base_return_array::s_new(array( + 'include_directory' => NULL, + 'include_name' => NULL, + 'handler' => NULL, + 'methods' => NULL, + 'id_group' => 0, + 'path_tree' => array(), + )); } @@ -281,7 +299,13 @@ class c_base_paths extends c_base_return { // if the sanitized path is different from the original, then send a url redirect. if (strcmp($path_string, $sanitized) != 0 && $path_string != '/' . $sanitized) { - return c_base_return_array::s_new(array('redirect' => $sanitized, 'code' => c_base_http_status::MOVED_PERMANENTLY)); + return c_base_return_array::s_new(array( + 'handler' => TRUE, + 'redirect' => $sanitized, + 'code' => c_base_http_status::MOVED_PERMANENTLY, + 'redirect_partial' => TRUE, + 'extra_slashes' => TRUE, + )); } $path_parts = explode('/', $sanitized); @@ -304,6 +328,7 @@ class c_base_paths extends c_base_return { $depth_total = count($path_parts); $found = NULL; $path_tree = &$this->paths[$id_group]; + $path_tree_history = array(); // @fixme: the current design needs to handle multiple possible wildcard paths when searching (such as '/a/b/c/%', '/a/%/c', where '/a/b/c/%' would prevent '/a/%/c' from ever matching). $path_part = array_shift($path_parts); @@ -315,6 +340,14 @@ class c_base_paths extends c_base_return { $path_tree = &$path_tree['%']; } + $path_tree_history[] = array( + 'path' => $path_part, + 'include_directory' => isset($path_tree['include_directory']) ? $path_tree['include_directory'] : NULL, + 'include_name' => isset($path_tree['include_name']) ? $path_tree['include_name'] : NULL, + 'handler' => isset($path_tree['handler']) ? $path_tree['handler'] : NULL, + 'methods' => isset($path_tree['methods']) ? $path_tree['methods'] : NULL, + ); + if ($depth_current == $depth_total) { $found = array( 'include_directory' => $path_tree['include_directory'], @@ -322,6 +355,7 @@ class c_base_paths extends c_base_return { 'handler' => $path_tree['handler'], 'methods' => $path_tree['methods'], 'id_group' => $id_group, + 'path_tree' => $path_tree_history, ); } else { @@ -338,6 +372,14 @@ class c_base_paths extends c_base_return { break; } + $path_tree_history[] = array( + 'path' => $path_part, + 'include_directory' => isset($path_tree['include_directory']) ? $path_tree['include_directory'] : NULL, + 'include_name' => isset($path_tree['include_name']) ? $path_tree['include_name'] : NULL, + 'handler' => isset($path_tree['handler']) ? $path_tree['handler'] : NULL, + 'methods' => isset($path_tree['methods']) ? $path_tree['methods'] : NULL, + ); + if ($depth_current == $depth_total) { $found = array( 'include_directory' => $path_tree['include_directory'], @@ -345,6 +387,7 @@ class c_base_paths extends c_base_return { 'handler' => $path_tree['handler'], 'methods' => $path_tree['methods'], 'id_group' => $id_group, + 'path_tree' => $path_tree_history, ); break; } @@ -358,10 +401,19 @@ class c_base_paths extends c_base_return { unset($path_tree); if (is_array($found) && !is_null($found['handler'])) { + unset($id_group); + unset($path_tree_history); return c_base_return_array::s_new($found); } unset($found); - return new c_base_return_null(); + return c_base_return_array::s_new(array( + 'include_directory' => NULL, + 'include_name' => NULL, + 'handler' => NULL, + 'methods' => NULL, + 'id_group' => $id_group, + 'path_tree' => $path_tree_history, + )); } } diff --git a/common/base/classes/base_return.php b/common/base/classes/base_return.php index 09de24c..e42c82f 100644 --- a/common/base/classes/base_return.php +++ b/common/base/classes/base_return.php @@ -259,6 +259,38 @@ class c_base_return { } /** + * Provide a simple way to check for (unrecovered) error in a single step. + * + * This is intended to help clean up code and make code more readable. + * + * @return bool + * return TRUE if the passed argument is an object class of type __CLASS__ and has an error flag set. + */ + public static function s_has_error_unrecovered($return) { + if (!is_object($return) && $return instanceof c_base_return && $return->has_error()) { + return FALSE; + } + + return $return->has_error_unrecovered(); + } + + /** + * Provide a simple way to check for (recovered) error in a single step. + * + * This is intended to help clean up code and make code more readable. + * + * @return bool + * return TRUE if the passed argument is an object class of type __CLASS__ and has an error flag set. + */ + public static function s_has_error_recovered($return) { + if (!is_object($return) && $return instanceof c_base_return && $return->has_error()) { + return FALSE; + } + + return $return->has_error_recovered(); + } + + /** * Copy errors from one return type to another. * * Invalid parameters are silently ignored and no actions are performed. @@ -368,8 +400,12 @@ class c_base_return { * @see: get_error() */ public function has_error($delta = NULL) { - if (is_int($delta) && array_key_exists($delta, $this->errors)) { - return ($this->errors[$delta]) instanceof c_base_error; + if (is_int($delta)) { + if (array_key_exists($delta, $this->errors)) { + return ($this->errors[$delta]) instanceof c_base_error; + } + + return FALSE; } // when there is no error flag assigned, its value should be NULL so a simple existence check should be all that is needed. @@ -377,6 +413,90 @@ class c_base_return { } /** + * Return the error state in a simple TRUE/FALSE manner, but only if the error is designated as recovered. + * + * This is similar to get_error(), but should instead be used to to check to see if there is an error and not check what the error is set to. + * + * @param null|int $delta + * (optional) When an integer, the error assigned at the specified position in the errors array is checked. + * When NULL, the entire errors array is checked for any error. + * + * @return bool + * TRUE if any error is assigned and is has recovered set to TRUE, otherwise FALSE is returned. + * + * @see: has_error() + * @see: get_error() + */ + public function has_error_recovered($delta = NULL) { + if (is_int($delta)) { + if (array_key_exists($delta, $this->errors)) { + if ($this->errors[$delta] instanceof c_base_error) { + return $this->errors[$delta]->get_recovered(); + } + } + + return FALSE; + } + + // when there is no error flag assigned, its value should be NULL so a simple existence check should be all that is needed. + if (empty($this->errors)) { + return FALSE; + } + + foreach ($this->errors as $error) { + if ($error->get_recovered()) { + unset($error); + return TRUE; + } + } + unset($error); + + return FALSE; + } + + /** + * Return the error state in a simple TRUE/FALSE manner, but only if the error is designated as unrecovered. + * + * This is similar to get_error(), but should instead be used to to check to see if there is an error and not check what the error is set to. + * + * @param null|int $delta + * (optional) When an integer, the error assigned at the specified position in the errors array is checked. + * When NULL, the entire errors array is checked for any error. + * + * @return bool + * TRUE if any error is assigned and is has recovered set to TRUE, otherwise FALSE is returned. + * + * @see: has_error() + * @see: get_error() + */ + public function has_error_unrecovered($delta = NULL) { + if (is_int($delta)) { + if (array_key_exists($delta, $this->errors)) { + if ($this->errors[$delta] instanceof c_base_error) { + return !$this->errors[$delta]->get_recovered(); + } + } + + return FALSE; + } + + // when there is no error flag assigned, its value should be NULL so a simple existence check should be all that is needed. + if (empty($this->errors)) { + return FALSE; + } + + foreach ($this->errors as $error) { + if (!$error->get_recovered()) { + unset($error); + return TRUE; + } + } + unset($error); + + return FALSE; + } + + /** * Return the value. * * @return null $value @@ -982,10 +1102,9 @@ class c_base_return_array extends c_base_return_value { /** * Assign the value at a specific index in the array. * - * @param array $value - * Any value so long as it is an array. - * NULL is not allowed. - * @param string $key + * @param $value + * Any value to be assigned at the specified position in the array. + * @param int|string $key * A key to assign a specific value to. * @param string $type * (optional) When key is not NULL, a specific known type to assign. @@ -1009,7 +1128,7 @@ class c_base_return_array extends c_base_return_value { * TRUE on success, FALSE otherwise. */ public function set_value_at($value, $key, $type = NULL) { - if (!is_string($key) || empty($key)) { + if (!is_int($key) && !is_string($key)) { return FALSE; } @@ -1069,9 +1188,8 @@ class c_base_return_array extends c_base_return_value { /** * Append the value at the end of the array. * - * @param array $value - * Any value so long as it is an array. - * NULL is not allowed. + * @param $value + * Any value to be appended in the array. * @param string $type * (optional) When key is not NULL, a specific known type to assign. * This does nothing if $key is not provided. @@ -1148,9 +1266,9 @@ class c_base_return_array extends c_base_return_value { } /** - * Returns the data as a serialized array string. + * Assigns the array from a serialized array string. * - * @param string + * @param string $serialized * A serialized string to convert to an array. * * @return bool @@ -1159,12 +1277,12 @@ class c_base_return_array extends c_base_return_value { * * @see: unserialize() */ - public function set_value_serialized($string) { - if (!is_string($string)) { + public function set_value_serialized($serialized) { + if (!is_string($serialized)) { return FALSE; } - $unserialized = unserialize($this->value); + $unserialized = unserialize($serialized); if (is_array($unserialized)) { $this->value = $unserialized; unset($unserialized); @@ -1180,8 +1298,8 @@ class c_base_return_array extends c_base_return_value { /** * Returns the data as a json-serialized array string. * - * @param string - * A serialized string to convert to an array. + * @param string $jsonized + * A jsonized string to convert to an array. * @param bool $associative * (optional) When TRUE array is return as an associative array. * @param int $options @@ -1195,8 +1313,8 @@ class c_base_return_array extends c_base_return_value { * * @see: json_decode() */ - public function set_value_jsonized($string, $associative = TRUE, $options = 0, $depth = 512) { - if (!is_string($string)) { + public function set_value_jsonized($jsonized, $associative = TRUE, $options = 0, $depth = 512) { + if (!is_string($jsonized)) { return FALSE; } @@ -1212,7 +1330,7 @@ class c_base_return_array extends c_base_return_value { $depth = 512; } - $decoded = json_decode($this->data, $associative, $options, $depth); + $decoded = json_decode($jsonized, $associative, $options, $depth); if (is_array($decoded)) { $this->value = $decoded; unset($decoded); @@ -1262,7 +1380,7 @@ class c_base_return_array extends c_base_return_value { * No c_base_return_* type should use another c_base_return_* as their return values for their non-static functions. * @todo: This design might be reviewed and changed before this project is finalized. * - * @param string $key + * @param int|string $key * A key to assign a specific value to. * @param string $type * (optional) When key is not NULL, a specific known type to assign. @@ -1287,7 +1405,7 @@ class c_base_return_array extends c_base_return_value { * Warning: There is no way to distinguish a return value of FALSE for an error to a valid FALSE when $type is set to 'bool'. */ public function get_value_at($key, $type = NULL) { - if (!is_string($key) || empty($key)) { + if (!is_int($key) && !is_string($key)) { return FALSE; } @@ -1432,7 +1550,7 @@ class c_base_return_array extends c_base_return_value { $depth = 512; } - return json_encode($this->data, $options, $depth); + return json_encode($this->value, $options, $depth); } } @@ -1460,11 +1578,10 @@ class c_base_return_object extends c_base_return_value { /** * Assign the value. * - * This calls PHP's clone() function to prevent potential security/integrirty issues. - * * @param object $value * Any value so long as it is an object. * NULL is not allowed. + * This does perform clone(). * * @return bool * TRUE on success, FALSE otherwise. diff --git a/common/base/classes/base_rfc_string.php b/common/base/classes/base_rfc_string.php index 9bbe479..7889582 100644 --- a/common/base/classes/base_rfc_string.php +++ b/common/base/classes/base_rfc_string.php @@ -218,7 +218,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::SLASH_BACKWARD) { + if ($code === c_base_ascii::SLASH_BACKWARD) { if ($quote_closed) { // only comments and FWS are allowed after $closing_quote is reached. $result['invalid'] = TRUE; @@ -233,19 +233,19 @@ abstract class c_base_rfc_string extends c_base_rfc_char { // check for and handle delimiters. $result['current']++; - if ($ordinals[$result['current']] == c_base_ascii::QUOTE_DOUBLE) { + if ($ordinals[$result['current']] === c_base_ascii::QUOTE_DOUBLE) { $result['text'] .= $characters[$result['current']]; continue; } - if ($ordinals[$result['current']] == c_base_ascii::SLASH_BACKWARD) { + if ($ordinals[$result['current']] === c_base_ascii::SLASH_BACKWARD) { $result['text'] .= $characters[$result['current']]; continue; } $result['current']--; } - elseif ($code == c_base_ascii::QUOTE_DOUBLE) { + elseif ($code === c_base_ascii::QUOTE_DOUBLE) { if ($quote_closed) { // double quote may be supplied only once. $result['invalid'] = TRUE; @@ -259,7 +259,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $quote_closed = TRUE; continue; } - elseif ($code == c_base_ascii::PARENTHESIS_OPEN) { + elseif ($code === c_base_ascii::PARENTHESIS_OPEN) { if ($comment_first || $comment_last) { // there may be only 1 comment at the start and only 1 comment at the end. $result['invalid'] = TRUE; @@ -285,7 +285,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } unset($parsed); } - elseif ($code == c_base_ascii::PARENTHESIS_CLOSE) { + elseif ($code === c_base_ascii::PARENTHESIS_CLOSE) { // an isolated parenthesis is invald. $result['invalid'] = TRUE; break; @@ -373,7 +373,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::QUOTE_DOUBLE) { + if ($code === c_base_ascii::QUOTE_DOUBLE) { break; } elseif (!$this->pr_rfc_char_is_vchar($code)) { @@ -434,17 +434,17 @@ abstract class c_base_rfc_string extends c_base_rfc_char { for (; $result['current'] < $stop; $result['current']++) { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::SLASH_BACKWARD) { + if ($code === c_base_ascii::SLASH_BACKWARD) { // check for and handle delimiters. $result['current']++; - if ($ordinals[$result['current']] == c_base_ascii::QUOTE_DOUBLE) { + if ($ordinals[$result['current']] === c_base_ascii::QUOTE_DOUBLE) { $result['comment'] .= $characters[$result['current']]; continue; } - if ($ordinals[$result['current']] == c_base_ascii::SLASH_BACKWARD) { + if ($ordinals[$result['current']] === c_base_ascii::SLASH_BACKWARD) { $result['comment'] .= $characters[$result['current']]; continue; @@ -452,11 +452,11 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $result['current']--; } - elseif ($code == c_base_ascii::PARENTHESIS_OPEN) { + elseif ($code === c_base_ascii::PARENTHESIS_OPEN) { // look for open-parenthesis to handle comments within a comment. $comment_depth++; } - elseif ($code == c_base_ascii::PARENTHESIS_CLOSE) { + elseif ($code === c_base_ascii::PARENTHESIS_CLOSE) { // handle end of comment. if ($comment_depth == 0) { // the current position will remain on the closing ')'. @@ -721,7 +721,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::QUOTE_DOUBLE) { + if ($code === c_base_ascii::QUOTE_DOUBLE) { if ($not_quoted) { // if the first, non-whitespace, character is not a quote, then a quote anywhere else is invalid. $result['invalid'] = TRUE; @@ -900,7 +900,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // load the parameter value. - if ($ordinals[$result['current']] == c_base_ascii::QUOTE_DOUBLE) { + if ($ordinals[$result['current']] === c_base_ascii::QUOTE_DOUBLE) { $result['current']++; if ($result['current'] >= $stop) { $result['invalid'] = TRUE; @@ -947,7 +947,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { // A comma designates a new entry - if ($ordinals[$result['current']] == c_base_ascii::COMMA) { + if ($ordinals[$result['current']] === c_base_ascii::COMMA) { $result['current']++; if ($result['current'] >= $stop) { $result['invalid'] = TRUE; @@ -1401,7 +1401,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { for (; $result['current'] < $stop; $result['current']++) { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::COLON_SEMI) { + if ($code === c_base_ascii::COLON_SEMI) { $result['current']++; if ($result['current'] >= $stop) { $result['invalid'] = TRUE; @@ -1412,12 +1412,12 @@ abstract class c_base_rfc_string extends c_base_rfc_char { // search for the "q" character. for (; $result['current'] < $stop; $result['current']++) { // allow uppercase "Q" but force it to become lowercase "q". - if ($ordinals[$result['current']] == c_base_ascii::UPPER_Q) { + if ($ordinals[$result['current']] === c_base_ascii::UPPER_Q) { $ordinals[$result['current']] = c_base_ascii::LOWER_Q; $characters[$result['current']] = c_base_ascii::LOWER_Q; } - if ($ordinals[$result['current']] == c_base_ascii::LOWER_Q) { + if ($ordinals[$result['current']] === c_base_ascii::LOWER_Q) { break; } @@ -1444,7 +1444,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { // search for the "=" character. for (; $result['current'] < $stop; $result['current']++) { - if ($ordinals[$result['current']] == c_base_ascii::EQUAL) { + if ($ordinals[$result['current']] === c_base_ascii::EQUAL) { break; } @@ -1503,7 +1503,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $period = FALSE; $base = 1; for (; $result['current'] < $stop; $result['current']++) { - if ($ordinals[$result['current']] == c_base_ascii::PERIOD) { + if ($ordinals[$result['current']] === c_base_ascii::PERIOD) { if ($period) { $result['invalid'] = TRUE; break; @@ -1519,7 +1519,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } if (!$this->pr_rfc_char_is_digit($ordinals[$result['current']])) { - if ($ordinals[$result['current']] == c_base_ascii::COMMA) { + if ($ordinals[$result['current']] === c_base_ascii::COMMA) { break; } @@ -1585,14 +1585,14 @@ abstract class c_base_rfc_string extends c_base_rfc_char { // look for comma, which will designate that another pass is allowed, otherwise the string is invalid. - if ($ordinals[$result['current']] == c_base_ascii::COMMA) { + if ($ordinals[$result['current']] === c_base_ascii::COMMA) { continue; } $result['invalid'] = TRUE; break; } - elseif ($code == c_base_ascii::COMMA) { + elseif ($code === c_base_ascii::COMMA) { // this is an unweighted choice. $choice['weight'] = NULL; if (!isset($result['choices'][NULL])) { @@ -1696,7 +1696,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { for (; $result['current'] < $stop; $result['current']++) { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::SLASH_FORWARD) { + if ($code === c_base_ascii::SLASH_FORWARD) { if (!$process_parameters) { if ($found_slash) { $result['invalid'] = TRUE; @@ -1708,13 +1708,13 @@ abstract class c_base_rfc_string extends c_base_rfc_char { continue; } } - elseif ($code == c_base_ascii::COLON_SEMI || $found_slash && $this->pr_rfc_char_is_wsp($code)) { + elseif ($code === c_base_ascii::COLON_SEMI || $found_slash && $this->pr_rfc_char_is_wsp($code)) { if ($found_slash && $this->pr_rfc_char_is_wsp($code)) { // in this case, the semi-colon has yet to be found, so seek until a semi-colon is found. // any and all non-semi-colon and non-whitespace means that the string is invalid. for (; $result['current'] < $stop; $result['current']++) { if (!$this->pr_rfc_char_is_wsp($ordinals[$result['current']])) { - if ($ordinals[$result['current']] == c_base_ascii::COLON_SEMI) { + if ($ordinals[$result['current']] === c_base_ascii::COLON_SEMI) { break; } @@ -1752,7 +1752,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $processed_token = TRUE; continue; } - elseif ($subcode == c_base_ascii::EQUAL) { + elseif ($subcode === c_base_ascii::EQUAL) { if ($found_equal || $process_whitespace) { // it cannot start with an equal sign, so if $process_whitespace is TRUE, then this is an invalid equal sign. $result['invalid'] = TRUE; @@ -1778,7 +1778,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for quoted_string, which must begin with a double quote. - if ($subcode == c_base_ascii::QUOTE_DOUBLE) { + if ($subcode === c_base_ascii::QUOTE_DOUBLE) { // skip past the initial double quote. $result['current']++; if ($result['current'] >= $stop) { @@ -1849,7 +1849,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } elseif (!$this->pr_rfc_char_is_tchar($subcode)) { if ($found_equal) { - if ($subcode == c_base_ascii::COLON_SEMI) { + if ($subcode === c_base_ascii::COLON_SEMI) { // save parameter and value and continue. $result['parameters'][$parameter_name] = $parameter_value; @@ -1993,7 +1993,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { break; } - if ($ordinals[$result['current']] == c_base_ascii::COLON_SEMI) { + if ($ordinals[$result['current']] === c_base_ascii::COLON_SEMI) { $result['tokens'][$token_name] = $token_value; $token_name = NULL; @@ -2014,7 +2014,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { continue; } - elseif ($ordinals[$result['current']] == c_base_ascii::EQUAL && !$processed_name) { + elseif ($ordinals[$result['current']] === c_base_ascii::EQUAL && !$processed_name) { $processed_name = TRUE; // skip past all whitespace following the equal. @@ -2035,7 +2035,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $result['invalid'] = TRUE; break; } - elseif ($code == c_base_ascii::COLON_SEMI) { + elseif ($code === c_base_ascii::COLON_SEMI) { $result['tokens'][$token_name] = $token_value; $token_name = NULL; $token_value = NULL; @@ -2055,7 +2055,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { continue; } - elseif ($code == c_base_ascii::QUOTE_DOUBLE) { + elseif ($code === c_base_ascii::QUOTE_DOUBLE) { if (!$processed_name) { // the token name is not allowed to be a quoted string. $result['invalid'] = TRUE; @@ -2193,7 +2193,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { break; } - if ($ordinals[$result['current']] == c_base_ascii::COLON_SEMI) { + if ($ordinals[$result['current']] === c_base_ascii::COLON_SEMI) { $result['tokens'][$token_name] = $token_value; $token_name = NULL; @@ -2214,7 +2214,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { continue; } - elseif ($ordinals[$result['current']] == c_base_ascii::EQUAL && !$processed_name) { + elseif ($ordinals[$result['current']] === c_base_ascii::EQUAL && !$processed_name) { $processed_name = TRUE; // skip past all whitespace following the equal. @@ -2235,7 +2235,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $result['invalid'] = TRUE; break; } - elseif ($code == c_base_ascii::COMMA) { + elseif ($code === c_base_ascii::COMMA) { $result['tokens'][$token_name] = $token_value; $token_name = NULL; $token_value = NULL; @@ -2255,7 +2255,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { continue; } - elseif ($code == c_base_ascii::QUOTE_DOUBLE) { + elseif ($code === c_base_ascii::QUOTE_DOUBLE) { if (!$processed_name) { // the token name is not allowed to be a quoted string. $result['invalid'] = TRUE; @@ -2386,7 +2386,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } } - if ($ordinals[$result['current']] == c_base_ascii::COMMA) { + if ($ordinals[$result['current']] === c_base_ascii::COMMA) { if (is_null($token_value)) { // empty values separated by commas are to be ignored. continue; @@ -2400,7 +2400,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $result['invalid'] = TRUE; break; } - elseif ($code == c_base_ascii::COMMA) { + elseif ($code === c_base_ascii::COMMA) { if (is_null($token_value)) { // empty values separated by commas are to be ignored. continue; @@ -2470,7 +2470,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { for (; $result['current'] < $stop; $result['current']++) { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::PERCENT) { + if ($code === c_base_ascii::PERCENT) { // valid only if two hex digits immediately follow. $result['current']++; if ($result['current'] >= $stop) { @@ -2501,7 +2501,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { elseif (self::pr_rfc_char_is_pchar($code)) { // do nothing, valid. } - elseif ($code == c_base_ascii::SLASH_FORWARD) { + elseif ($code === c_base_ascii::SLASH_FORWARD) { // do nothing, valid. } else { @@ -2560,7 +2560,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { for (; $result['current'] < $stop; $result['current']++) { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::PERCENT) { + if ($code === c_base_ascii::PERCENT) { // valid only if two hex digits immediately follow. $result['current']++; if ($result['current'] >= $stop) { @@ -2591,7 +2591,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { elseif (self::pr_rfc_char_is_pchar($code)) { // do nothing, valid. } - elseif ($code == c_base_ascii::SLASH_FORWARD || $code == c_base_ascii::QUESTION_MARK) { + elseif ($code === c_base_ascii::SLASH_FORWARD || $code === c_base_ascii::QUESTION_MARK) { // do nothing, valid. } else { @@ -2654,7 +2654,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // this first character must be either a "v" or a hex digit. - if ($ordinals[$result['current']] == c_base_ascii::LOWER_V || $ordinals[$result['current']] == c_base_ascii::UPPER_V) { + if ($ordinals[$result['current']] === c_base_ascii::LOWER_V || $ordinals[$result['current']] === c_base_ascii::UPPER_V) { $result['is_future'] = TRUE; } elseif (!self::pr_rfc_char_is_hexdigit($ordinals[$result['current']])) { @@ -2712,10 +2712,10 @@ abstract class c_base_rfc_string extends c_base_rfc_char { elseif (self::pr_rfc_char_is_sub_delims($code)) { // do nothing, valid. } - elseif ($code == c_base_ascii::COLON) { + elseif ($code === c_base_ascii::COLON) { // do nothing, valid. } - elseif ($code == c_base_ascii::BRACKET_CLOSE) { + elseif ($code === c_base_ascii::BRACKET_CLOSE) { break; } else { @@ -2734,10 +2734,10 @@ abstract class c_base_rfc_string extends c_base_rfc_char { if (self::pr_rfc_char_is_hexdigit($code)) { $result['address'] .= $characters[$result['current']]; } - elseif ($code == c_base_ascii::COLON) { + elseif ($code === c_base_ascii::COLON) { $result['address'] .= $characters[$result['current']]; } - elseif ($code == c_base_ascii::BRACKET_CLOSE) { + elseif ($code === c_base_ascii::BRACKET_CLOSE) { break; } else { @@ -3245,16 +3245,42 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } - // handle path cases that begin with a forward slash because they are easy to identify. - if ($ordinals[$result['current']] == c_base_ascii::SLASH_FORWARD) { - $this->p_rfc_string_is_uri_path($ordinals, $characters, $stop, $result); - if ($result['invalid'] || $result['current'] >= $stop) { - return $result; + // handle path and authority cases that begin with a forward slash because they are easy to identify. + if ($ordinals[$result['current']] === c_base_ascii::SLASH_FORWARD) { + if ($result['current'] + 1 < $stop && $ordinals[$result['current'] + 1] === c_base_ascii::SLASH_FORWARD) { + // process authority + // first two slashes are not recorded, so skip them. + $result['current'] += 2; + if ($result['current'] >= $stop) { + $result['invalid'] = TRUE; + return $result; + } + + $this->p_rfc_string_is_uri_authority($ordinals, $characters, $stop, $result); + if ($result['invalid'] || $result['current'] >= $stop) { + return $result; + } + + + // process path + if ($ordinals[$result['current']] !== c_base_ascii::QUESTION_MARK && $ordinals[$result['current']] !== c_base_ascii::HASH) { + $this->p_rfc_string_is_uri_path($ordinals, $characters, $stop, $result); + if ($result['invalid'] || $result['current'] >= $stop) { + return $result; + } + } + } + else { + // process path + $this->p_rfc_string_is_uri_path($ordinals, $characters, $stop, $result); + if ($result['invalid'] || $result['current'] >= $stop) { + return $result; + } } // check for query. - if ($ordinals[$result['current']] == c_base_ascii::QUESTION_MARK) { + if ($ordinals[$result['current']] === c_base_ascii::QUESTION_MARK) { // the first question mark is not recorded so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3269,7 +3295,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { // check for fragment. - if ($ordinals[$result['current']] == c_base_ascii::HASH) { + if ($ordinals[$result['current']] === c_base_ascii::HASH) { // only the first hash is supported in the fragment (and it is not recorded) so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3287,7 +3313,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { // handle fragment cases first because they are easy to identify. - if ($ordinals[$result['current']] == c_base_ascii::HASH) { + if ($ordinals[$result['current']] === c_base_ascii::HASH) { for (; $result['current'] < $stop; $result['current']++) { if (!array_key_exists($result['current'], $ordinals) || !array_key_exists($result['current'], $characters)) { // @fixme: should error be reported? do some debugging with this. @@ -3330,7 +3356,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { elseif ($this->pr_rfc_char_is_digit($code)) { // allowed in: scheme, authority, path } - elseif ($code == c_base_ascii::COLON) { + elseif ($code === c_base_ascii::COLON) { $not_path = TRUE; if ($not_scheme) { @@ -3350,20 +3376,29 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $not_authority = TRUE; } } - elseif ($code == c_base_ascii::PLUS || $code == c_base_ascii::MINUS || $code == c_base_ascii::PERIOD) { + elseif ($code === c_base_ascii::PLUS || $code === c_base_ascii::MINUS || $code === c_base_ascii::PERIOD) { // allowed in: scheme, authority, path } - elseif ($code == c_base_ascii::AT || $code == c_base_ascii::SLASH_FORWARD) { + elseif ($code === c_base_ascii::AT) { // allowed in: authority, path $not_scheme = TRUE; } + elseif ($code === c_base_ascii::SLASH_FORWARD) { + // allowed in: path + + $not_scheme = TRUE; + $not_authority = TRUE; // because the areas where // is used is handled earlier in this function. + + // the slash is part of the path. + $processed_string .= $characters[$result['current']]; + } elseif ($this->pr_rfc_char_is_unreserved($code)) { // allowed in: authority, path $not_scheme = TRUE; } - elseif ($code == c_base_ascii::BRACKET_OPEN) { + elseif ($code === c_base_ascii::BRACKET_OPEN) { // allowed in: authority $not_scheme = TRUE; @@ -3396,6 +3431,12 @@ abstract class c_base_rfc_string extends c_base_rfc_char { return $result; } + // if unable to determine if is path or not, assume path. + if (!$not_authority && !$not_path) { + // @todo: a warning of some sort should be performed here. + $not_authority = TRUE; + } + if ($not_authority && $not_path) { unset($not_scheme); unset($not_authority); @@ -3411,7 +3452,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { // check to see if '/' immediately follows, if not then this is a urn. $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::SLASH_FORWARD) { + if ($code === c_base_ascii::SLASH_FORWARD) { unset($code); // A second '/' should immediately follow the first to designate the authority. @@ -3419,7 +3460,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $result['current']++; $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::SLASH_FORWARD) { + if ($code === c_base_ascii::SLASH_FORWARD) { // begin processing authority. $result['current']++; @@ -3440,7 +3481,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for query. - if ($ordinals[$result['current']] == c_base_ascii::QUESTION_MARK) { + if ($ordinals[$result['current']] === c_base_ascii::QUESTION_MARK) { // the first question mark is not recorded so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3454,7 +3495,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for fragment. - if ($ordinals[$result['current']] == c_base_ascii::HASH) { + if ($ordinals[$result['current']] === c_base_ascii::HASH) { // only the first hash is supported in the fragment (and it is not recorded) so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3483,12 +3524,12 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::HASH || $code == c_base_ascii::QUESTION_MARK) { + if ($code === c_base_ascii::HASH || $code === c_base_ascii::QUESTION_MARK) { // found possible query or fragment. $result['url'] = TRUE; break; } - elseif ($code == c_base_ascii::COLON) { + elseif ($code === c_base_ascii::COLON) { $result['url'] = FALSE; } elseif (!$this->pr_rfc_char_is_pchar($code)) { @@ -3507,7 +3548,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for query. - if ($ordinals[$result['current']] == c_base_ascii::QUESTION_MARK) { + if ($ordinals[$result['current']] === c_base_ascii::QUESTION_MARK) { // the first question mark is not recorded so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3521,7 +3562,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for fragment. - if ($ordinals[$result['current']] == c_base_ascii::HASH) { + if ($ordinals[$result['current']] === c_base_ascii::HASH) { // only the first hash is supported in the fragment (and it is not recorded) so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3562,7 +3603,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for query. - if ($ordinals[$result['current']] == c_base_ascii::QUESTION_MARK) { + if ($ordinals[$result['current']] === c_base_ascii::QUESTION_MARK) { // the first question mark is not recorded so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3576,7 +3617,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for fragment. - if ($ordinals[$result['current']] == c_base_ascii::HASH) { + if ($ordinals[$result['current']] === c_base_ascii::HASH) { // only the first hash is supported in the fragment (and it is not recorded) so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3609,7 +3650,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for query. - if ($ordinals[$result['current']] == c_base_ascii::QUESTION_MARK) { + if ($ordinals[$result['current']] === c_base_ascii::QUESTION_MARK) { // the first question mark is not recorded so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3623,7 +3664,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { } // check for fragment. - if ($ordinals[$result['current']] == c_base_ascii::HASH) { + if ($ordinals[$result['current']] === c_base_ascii::HASH) { // only the first hash is supported in the fragment (and it is not recorded) so skip past it before validating the fragment. $result['current']++; if ($result['current'] >= $stop) { @@ -3774,11 +3815,11 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::SLASH_FORWARD) { + if ($code === c_base_ascii::SLASH_FORWARD) { // the slash designates the end of the authority. break; } - elseif ($code == c_base_ascii::PERCENT) { + elseif ($code === c_base_ascii::PERCENT) { // valid only if two hex digits immediately follow. $result['current']++; if ($result['current'] >= $stop) { @@ -3806,10 +3847,10 @@ abstract class c_base_rfc_string extends c_base_rfc_char { break; } } - elseif ($code == c_base_ascii::AT || $code == c_base_ascii::COLON) { + elseif ($code === c_base_ascii::AT || $code === c_base_ascii::COLON) { // this is valid. } - elseif ($code == c_base_ascii::BRACKET_OPEN || $code == c_base_ascii::BRACKET_CLOSE) { + elseif ($code === c_base_ascii::BRACKET_OPEN || $code === c_base_ascii::BRACKET_CLOSE) { // this is valid. } elseif ($this->pr_rfc_char_is_unreserved($code)) { @@ -3856,11 +3897,11 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::HASH || $code == c_base_ascii::QUESTION_MARK) { + if ($code === c_base_ascii::HASH || $code === c_base_ascii::QUESTION_MARK) { // found possible query or fragment. break; } - elseif ($code == c_base_ascii::SLASH_FORWARD) { + elseif ($code === c_base_ascii::SLASH_FORWARD) { // this is valid. } elseif (!$this->pr_rfc_char_is_pchar($code)) { @@ -3909,11 +3950,11 @@ abstract class c_base_rfc_string extends c_base_rfc_char { $code = $ordinals[$result['current']]; - if ($code == c_base_ascii::HASH) { + if ($code === c_base_ascii::HASH) { // hash is not part of the query but does mark the end of the query as it is the start of the fragment. break; } - elseif ($code == c_base_ascii::AMPERSAND) { + elseif ($code === c_base_ascii::AMPERSAND) { // The '&' designates a new name and value, separate each individual value inside the array. $result['query'][$query_name] = $query_value; @@ -3923,7 +3964,7 @@ abstract class c_base_rfc_string extends c_base_rfc_char { continue; } - elseif ($code == c_base_ascii::EQUAL) { + elseif ($code === c_base_ascii::EQUAL) { // The '=' designates a value for the current name. if ($no_value || is_null($query_name)) { $query_name .= $characters[$result['current']]; diff --git a/common/base/classes/base_session.php b/common/base/classes/base_session.php index aa8f044..994cc0a 100644 --- a/common/base/classes/base_session.php +++ b/common/base/classes/base_session.php @@ -204,6 +204,7 @@ class c_base_session extends c_base_return { * @return c_base_return_status * TRUE on success, FALSE otherwise. * FALSE with the error bit set is returned on error. + * This does perform clone(). */ public function set_cookie($cookie) { if (!is_null($cookie) && !($cookie instanceof c_base_cookie)) { @@ -212,7 +213,6 @@ class c_base_session extends c_base_return { } $this->cookie = clone($cookie); - return new c_base_return_true(); } @@ -594,6 +594,7 @@ class c_base_session extends c_base_return { * @param c_base_users_user|null $user * The current user object (generally populated from the database). * If NULL, then the user object is removed. + * This does perform clone(). * * @return c_base_return_status * TRUE on success, FALSE otherwise. @@ -621,6 +622,7 @@ class c_base_session extends c_base_return { * @param c_base_users_user|null $user * The current user object (generally populated from the database). * If NULL, then the user object is removed. + * This does perform clone(). * * @return c_base_return_status * TRUE on success, FALSE otherwise. @@ -678,6 +680,7 @@ class c_base_session extends c_base_return { * @return c_base_cookie|c_base_return_null * The session cookie or NULL if undefined. * FALSE with the error bit set is returned on error. + * This does perform clone(). */ public function get_cookie() { if (is_null($this->cookie)) { @@ -768,7 +771,7 @@ class c_base_session extends c_base_return { } if (!array_key_exists($delta, $this->settings)) { - $error = c_base_error::s_log(NULL, array('arguments' => array(':index_name' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{index_name}' => $delta, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_ARRAY_INDEX); return c_base_return_error::s_false($error); } @@ -898,9 +901,10 @@ class c_base_session extends c_base_return { * The user object is returned on success. * NULL is returned if there is no user object assigned. * The error bit set is returned on error. + * This does perform clone(). */ public function get_user_current() { - if (is_object($this->user_current)) { + if ($this->user_current instanceof c_base_users_user) { return clone($this->user_current); } @@ -914,9 +918,10 @@ class c_base_session extends c_base_return { * The user object is returned on success. * NULL is returned if there is no user object assigned. * The error bit set is returned on error. + * This does perform clone(). */ public function get_user_session() { - if (is_object($this->user_session)) { + if ($this->user_session instanceof c_base_users_user) { return clone($this->user_session); } diff --git a/common/standard/classes/standard_index.php b/common/standard/classes/standard_index.php index 52a812a..2ef1a56 100644 --- a/common/standard/classes/standard_index.php +++ b/common/standard/classes/standard_index.php @@ -17,6 +17,8 @@ require_once('common/standard/classes/standard_paths.php'); require_once('common/standard/classes/standard_users.php'); require_once('common/standard/classes/standard_database.php'); +require_once('common/theme/classes/theme_html.php'); + /** * The standard class for use in index.php or equivalent. */ @@ -262,9 +264,11 @@ class c_standard_index extends c_base_return { ini_set('opcache.enable', FALSE); ini_set('opcache.enable_cli', FALSE); - // disable output buffering. + // enable output buffering to catch any unexpected output. $this->original_output_buffering = ini_get('output_buffering'); - ini_set('output_buffering', FALSE); + ini_set('output_buffering', TRUE); + + ob_start(); $this->do_initialize_globals(); @@ -657,7 +661,16 @@ class c_standard_index extends c_base_return { $method = c_base_http::HTTP_METHOD_NONE; } - // add headers + // process any unexpected, but captured, output (if the content is a file, silently ignore output). + if (ob_get_length() > 0 && $this->http->is_response_content_file() instanceof c_base_return_false) { + $response_content = $this->http->get_response_content()->get_value_exact(); + $this->http->set_response_content(ob_get_contents(), FALSE); + $this->http->set_response_content($response_content); + unset($response_content); + } + + ob_end_clean(); + $this->http->set_response_date(); $this->http->set_response_content_type('text/html'); #$this->http->set_response_etag(); @@ -670,7 +683,6 @@ class c_standard_index extends c_base_return { $this->http->set_response_vary('Accept-Language'); #$this->http->set_response_warning('1234 This site is under active development.'); - // finalize the content prior to sending headers to ensure header accuracy. $this->http->encode_response_content(); diff --git a/common/standard/classes/standard_menu.php b/common/standard/classes/standard_menu.php new file mode 100644 index 0000000..fe62a7a --- /dev/null +++ b/common/standard/classes/standard_menu.php @@ -0,0 +1,278 @@ +, , or even breadcrumbs. + */ +class c_standard_menu extends c_base_menu { + const CSS_MENU = 'menu'; + const CSS_MENU_HEADER = 'menu-header'; + const CSS_MENU_HEADER_TEXT = 'menu-header-text'; + const CSS_MENU_ITEM = 'menu_item'; + const CSS_MENU_ITEM_CONTENT = 'menu_item-content'; + + const CSS_ITEM_LABEL = 'item_type-label'; + const CSS_ITEM_LINK = 'item_type-link'; + const CSS_ITEM_LOCAL = 'item_type-local'; + const CSS_ITEM_REMOTE = 'item_type-remote'; + const CSS_ITEM_MENU = 'item_type-menu'; + + const CSS_TEXT_HEADING = 'text-heading_'; + const CSS_TEXT_HEADINGS = 'text-headings'; + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, array()); + } + + /** + * Create a new menu HTML tag. + * + * @param string|null $name_machine + * (optional) The id of the navigation menu. + * Set to NULL to not create an id tag. + * @param string|null $name_human + * (optional) The header name to use. + * Set to NULL to not create a header. + * @param int $depth + * (optional) The number representing the header tag depth. + * This starts at 1. + * Anything beyond 6 is a simulated header. + * This is ignored when $name is NULL. + * + * @return c_base_markup_tag + * The created markup tag. + * The created markup tag with error bit set on error. + */ + protected function pr_create_html_create_menu($name_machine = NULL, $name_human = NULL, $depth = 1) { + $menu = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_NAVIGATION, $name_machine, array(self::CSS_MENU)); + + if (is_string($name_human)) { + $wrapper = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_MENU_HEADER, self::CSS_MENU_HEADER . '-' . $depth)); + + if ($depth == 1) { + $type = c_base_markup_tag::TYPE_H1; + } + elseif ($depth == 2) { + $type = c_base_markup_tag::TYPE_H2; + } + elseif ($depth == 3) { + $type = c_base_markup_tag::TYPE_H3; + } + elseif ($depth == 4) { + $type = c_base_markup_tag::TYPE_H4; + } + elseif ($depth == 5) { + $type = c_base_markup_tag::TYPE_H5; + } + elseif ($depth == 6) { + $type = c_base_markup_tag::TYPE_H6; + } + else { + $type = c_base_markup_tag::TYPE_HX; + } + + $header = c_theme_html::s_create_tag($type, NULL, array(self::CSS_MENU_HEADER_TEXT, self::CSS_MENU_HEADER_TEXT . '-' . $depth)); + unset($type); + + if ($depth > 6) { + $header->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CSS_TEXT_HEADING . ((int) $depth)); + } + + $header->set_text($name_human); + + $wrapper->set_tag($header); + $wrapper->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CSS_TEXT_HEADINGS); + unset($header); + + $menu->set_tag($wrapper); + unset($wrapper); + } + + return $menu; + } + + /** + * Create an HTML menu tag. + * + * @param string $label + * A string to display as the menu item name. + * @param string|null $tooltip + * (optional) An tooltip string to assign to the label. + * Set to NULL to not assign a tooltip. + * + * @return c_base_markup_tag + * Markup tag on success. + * Markup tag with error bit set on error. + */ + protected function pr_create_html_add_menu_item_label($label, $tooltip = NULL) { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_MENU_ITEM, self::CSS_ITEM_LABEL)); + + $tag_content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SPAN, NULL, array(self::CSS_MENU_ITEM_CONTENT)); + $tag_content->set_text($label); + + if (is_string($tooltip)) { + $tag_content->set_attribute(c_base_markup_attributes::ATTRIBUTE_TITLE, $tooltip); + } + + $tag->set_tag($tag_content); + unset($tag_content); + + return $tag; + } + + /** + * Create an HTML menu tag. + * + * @param string $label + * A string to display as the menu item name. + * @param string $uri + * A fully processed uri string. + * @param string|null $tooltip + * (optional) An tooltip string to assign to the link. + * Set to NULL to not assign a tooltip. + * @param bool $local + * (optional) If TRUE, then uri is a local uri. + * If FALSE, then uri is a remote uri. + * + * @return c_base_markup_tag + * Markup tag on success. + * Markup tag with error bit set on error. + */ + protected function pr_create_html_add_menu_item_link($label, $uri, $tooltip = NULL, $local = TRUE) { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_MENU_ITEM, self::CSS_ITEM_LINK)); + + if ($local) { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CSS_ITEM_LOCAL); + } + else { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CSS_ITEM_REMOTE); + } + + $tag_content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_A, NULL, array(self::CSS_MENU_ITEM_CONTENT)); + + $tag_content->set_text($label); + $tag_content->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $uri); + + if (is_string($tooltip)) { + $tag_content->set_attribute(c_base_markup_attributes::ATTRIBUTE_TITLE, $tooltip); + } + + $tag->set_tag($tag_content); + unset($tag_content); + + return $tag; + } + + /** + * Create an HTML menu tag. + * + * @param string $label + * A string to display as the menu item name. + * @param c_base_markup_tag $menu + * Another pre-build menu. + * @param string|null $tooltip + * (optional) An tooltip string to assign to the link. + * Set to NULL to not assign a tooltip. + * + * @return c_base_markup_tag + * Markup tag on success. + * Markup tag with error bit set on error. + */ + protected function pr_create_html_add_menu_item_menu($label, $menu, $tooltip = NULL) { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_MENU_ITEM, self::CSS_ITEM_MENU)); + + $tag->set_text($label); + + $tag_content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SPAN, NULL, array(self::CSS_MENU_ITEM_CONTENT)); + $tag_content->set_tag($menu); + + if (is_string($tooltip)) { + $tag_content->set_attribute(c_base_markup_attributes::ATTRIBUTE_TITLE, $tooltip); + } + + $tag->set_tag($tag_content); + unset($tag_content); + + return $tag; + } + + /** + * Load text for a supported language. + * + * @param int $index + * A number representing which block of text to return. + * @param array $arguments + * (optional) An array of arguments to convert into text. + */ + protected function pr_get_text($code, $arguments = array()) { + return ''; + } + + /** + * Replace all occurences of arguments within string. + * + * @todo: should this be moved into some string class as a static function? + * + * Perform sanitization based on the first character. + * If first character is ':', do not perform sanitization. + * If first character is '@', santize as HTML text. + * + * I recommend wrapping placeholders in '{' and '}' to help enforce uniqueness. + * - For example the string ':words' could be confused with two different placeholders: ':word' and ':words'. + * - By using ':{words}' and ':{word}', there there should be fewer chances of mixups. + * + * @param string &$string + * The string to perform replacements on. + * @param array $arguments + * An array of replacement arguments. + * + * @see: htmlspecialchars() + * @see: str_replace() + */ + protected function pr_process_replacements(&$string, $arguments) { + foreach ($arguments as $place_holder => $replacement) { + $type = mb_substr($place_holder, 0, 1); + + if ($type == ':') { + $sanitized = $replacement; + } + elseif ($type == '@') { + $sanitized = htmlspecialchars($replacement, $this->sanitize_html['flags'], $this->sanitize_html['encoding']); + } + else { + unset($type); + + // do not perform replacements on unknown placeholders. + continue; + } + unset($type); + + $string = str_replace($place_holder, $sanitized, $string); + } + unset($place_holder); + unset($replacement); + } +} diff --git a/common/standard/classes/standard_path.php b/common/standard/classes/standard_path.php index b2582a1..f3eaa5a 100644 --- a/common/standard/classes/standard_path.php +++ b/common/standard/classes/standard_path.php @@ -5,7 +5,7 @@ */ require_once('common/base/classes/base_error.php'); require_once('common/base/classes/base_return.php'); -require_once('common/base/classes/base_paths.php'); +require_once('common/base/classes/base_menu.php'); require_once('common/base/classes/base_markup.php'); /** @@ -29,7 +29,6 @@ class c_standard_path extends c_base_path { protected const CSS_AS_LINK_BLOCK_DESCRIPTION = 'as-link_block-description'; protected const CSS_AS_HEADER = 'as-header'; protected const CSS_AS_HEADERS = 'as-headers'; - protected const CSS_IS_JAVASCRIPT_ENABLED = 'javascript-enabled'; protected const CSS_IS_JAVASCRIPT_DISABLED = 'javascript-disabled'; protected const CSS_IS_CONTENT_TYPE = 'is-html_5'; @@ -47,6 +46,28 @@ class c_standard_path extends c_base_path { protected const CSS_PATH_PART = 'path-part-'; protected const CSS_PATH_FULL = 'path-full-'; + protected const PATH_SELF = ''; + + protected const PATH_MENU_HEADER = 'common/standard/menus/'; + protected const PATH_MENU_UTILITY = 'common/standard/menus/'; + protected const PATH_MENU_BREADCRUMBS = 'common/standard/menus/'; + protected const PATH_MENU_CONTENT = 'common/standard/menus/'; + protected const PATH_MENU_FOOTER = 'common/standard/menus/'; + + protected const NAME_MENU_HEADER = 'menu_header'; + protected const NAME_MENU_UTILITY = 'menu_utility'; + protected const NAME_MENU_BREADCRUMBS = 'menu_breadcrumbs'; + protected const NAME_MENU_CONTENT = 'menu_content'; + protected const NAME_MENU_FOOTER = 'menu_footer'; + + protected const HANDLER_MENU_HEADER = 'c_standard_menu_header'; + protected const HANDLER_MENU_UTILITY = 'c_standard_menu_utility'; + protected const HANDLER_MENU_BREADCRUMBS = 'c_standard_menu_breadcrumbs'; + protected const HANDLER_MENU_CONTENT = 'c_standard_menu_content'; + protected const HANDLER_MENU_FOOTER = 'c_standard_menu_footer'; + + protected const SCRIPT_EXTENSION = '.php'; + protected $html; protected $http; protected $database; @@ -54,8 +75,11 @@ class c_standard_path extends c_base_path { protected $settings; protected $languages; + protected $language_alias; + protected $text_type; protected $request_uri; + protected $breadcrumbs; /** @@ -70,9 +94,12 @@ class c_standard_path extends c_base_path { $this->session = NULL; $this->settings = array(); - $this->languages = array(); + $this->languages = array(); + $this->language_alias = NULL; + $this->text_type = NULL; $this->request_uri = NULL; + $this->breadcrumbs = NULL; } /** @@ -86,18 +113,43 @@ class c_standard_path extends c_base_path { unset($this->settings); unset($this->languages); + unset($this->language_alias); + unset($this->text_type); unset($this->request_uri); + unset($this->breadcrumbs); parent::__destruct(); } /** + * Get the breadcrumb for this path. + * + * The breadcrumb will be built by this function if it is not already built. + * + * @return c_base_menu_item|c_base_return_null + * The breadcrumb menu is returned on success. + * If not defined, then NULL is returned. + * NULL with the error bit set is returned on error. + */ + protected function get_breadcrumbs() { + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->pr_build_breadcrumbs(); + } + + if ($this->breadcrumbs instanceof c_base_menu_item) { + return clone($this->breadcrumbs); + } + + return new c_base_return_null(); + } + + /** * Load any default settings. * - * @param c_base_http $http + * @param c_base_http &$http * The entire HTTP information to allow for the execution to access anything that is necessary. - * @param c_base_database $database + * @param c_base_database &$database * The database object, which is usually used by form and ajax paths. * @param c_base_session &$session * The current session. @@ -139,6 +191,36 @@ class c_standard_path extends c_base_path { if (!is_array($this->languages)) { $this->languages = array(); } + + $this->pr_get_language_alias(); + + $this->pr_build_breadcrumbs(); + } + + /** + * Build the breadcrumb. + */ + protected function pr_build_breadcrumbs() { + $this->breadcrumbs = new c_base_menu_item(); + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); + $this->breadcrumbs->set_item($item); + unset($item); + + // @todo: implement a standard breadcrumb handler, that loads parents paths and any language-specific text. + // this may also need to use and load langauge-specific global path text. + + // build breadcrumbs based on current uri path. + #if ($this->path_tree instanceof c_base_path_tree) { + # $id_group = $this->path_tree->get_id_group()->get_value_exact(); + # $items = $this->path_tree->get_items()->get_value_exact(); + #} + #else { + # $id_group = 0; + # $items = array(); + #} + + #$this->get_breadcrumbs(); } /** @@ -277,7 +359,6 @@ class c_standard_path extends c_base_path { $classes[] = $extra_class; } - $type = c_base_markup_tag::TYPE_DIVIDER; if ($header == 1) { $type = c_base_markup_tag::TYPE_H1; } @@ -296,12 +377,22 @@ class c_standard_path extends c_base_path { elseif ($header == 6) { $type = c_base_markup_tag::TYPE_H6; } + else { + $type = c_base_markup_tag::TYPE_HX; + } if (is_int($text)) { - return c_theme_html::s_create_tag($type, $id, $classes, $this->pr_get_text($text, $arguments)); + $tag = c_theme_html::s_create_tag($type, $id, $classes, $this->pr_get_text($text, $arguments)); + } + else { + $tag = c_theme_html::s_create_tag($type, $id, $classes, $text); } - return c_theme_html::s_create_tag($type, $id, $classes, $text); + if ($header > 6) { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, 'text-text-heading_' . ((int) $header)); + } + + return $tag; } /** @@ -572,7 +663,6 @@ class c_standard_path extends c_base_path { else { $header_classes = array($this->settings['base_css'] . self::CSS_AS_HEADER, self::CSS_AS_HEADER, self::CSS_AS_HEADER . '-' . $header, self::CSS_AS_LINK_BLOCK_NAME); - $type = c_base_markup_tag::TYPE_DIVIDER; if ($header == 1) { $type = c_base_markup_tag::TYPE_H1; } @@ -591,10 +681,17 @@ class c_standard_path extends c_base_path { elseif ($header == 6) { $type = c_base_markup_tag::TYPE_H6; } + else { + $type = c_base_markup_tag::TYPE_HX; + } - $wrapper = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, $header_classes); + $wrapper = c_theme_html::s_create_tag($type, NULL, $header_classes); unset($header_classes); unset($type); + + if ($header > 6) { + $wrapper->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, 'text-text-heading_' . ((int) $header)); + } } if (!is_null($text)) { @@ -666,7 +763,7 @@ class c_standard_path extends c_base_path { * @see: self::pr_create_html() */ protected function pr_create_html_add_primary_ids() { - $id = $this->html->sanitize_css(self::CSS_SYSTEM_PREFIX . $this->settings['session_system'])->get_value_exact(); + $id = $this->html->sanitize_css(self::CSS_SYSTEM_PREFIX . $this->settings['system_name'])->get_value_exact(); #$this->html->set_attribute(c_base_markup_attributes::ATTRIBUTE_ID, $id); $this->html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ID, $id); @@ -748,11 +845,10 @@ class c_standard_path extends c_base_path { * @see: self::pr_create_html() */ protected function pr_create_html_add_title() { - $title = $this->pr_get_title(); + $title = $this->pr_get_text_title(); if (is_string($title)) { - $tag = new c_base_markup_tag(); - $tag->set_type(c_base_markup_tag::TYPE_TITLE); + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_TITLE); $tag->set_text($title); $this->html->set_header($tag, 0); unset($tag); @@ -903,7 +999,7 @@ class c_standard_path extends c_base_path { */ protected function pr_create_html_add_header_script() { // provide a custom javascript for detecting if javascript is enabled and storing in a css class name. - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SCRIPT); + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SCRIPT, 'f_standard_paths_hmtl_javascript_detection'); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_TYPE, c_base_mime::TYPE_TEXT_JS); $javascript = 'function f_standard_paths_hmtl_javascript_detection() {'; @@ -919,6 +1015,171 @@ class c_standard_path extends c_base_path { } /** + * Add all menus to the page. + */ + protected function pr_add_menus() { + $menu = $this->pr_build_menu_header($this->http, $this->database, $this->session, $this->settings); + if ($menu instanceof c_base_markup_tag) { + $this->html->set_tag($menu); + } + unset($menu); + + $menu = $this->pr_build_menu_utility($this->http, $this->database, $this->session, $this->settings); + if ($menu instanceof c_base_markup_tag) { + $this->html->set_tag($menu); + } + unset($menu); + + $menu = $this->pr_build_menu_breadcrumbs($this->http, $this->database, $this->session, $this->settings); + if ($menu instanceof c_base_markup_tag) { + $this->html->set_tag($menu); + } + unset($menu); + + $menu = $this->pr_build_menu_content($this->http, $this->database, $this->session, $this->settings); + if ($menu instanceof c_base_markup_tag) { + $this->html->set_tag($menu); + } + unset($menu); + + $menu = $this->pr_build_menu_footer($this->http, $this->database, $this->session, $this->settings); + if ($menu instanceof c_base_markup_tag) { + $this->html->set_tag($menu); + } + unset($menu); + } + + /** + * Load and return the header menu handler. + * + * @param c_base_http &$http + * The entire HTTP information to allow for the execution to access anything that is necessary. + * @param c_base_database &$database + * The database object, which is usually used by form and ajax paths. + * @param c_base_session &$session + * The current session. + * @param array $settings + * An array of additional settings that are usually site-specific. + * + * @return c_base_markup_tag|c_base_return_status + * A built menu markup tag. + * FALSE without error bit set is returned if no menu was built. + * FALSE with error bit set is returned on error. + */ + protected function pr_build_menu_header() { + $menu = $this->pr_include_menu(self::PATH_MENU_HEADER, self::NAME_MENU_HEADER, self::HANDLER_MENU_HEADER); + return $menu->do_build($this->http, $this->database, $this->session, $this->settings); + } + + /** + * Load and return the utility menu handler. + * + * @param c_base_http &$http + * The entire HTTP information to allow for the execution to access anything that is necessary. + * @param c_base_database &$database + * The database object, which is usually used by form and ajax paths. + * @param c_base_session &$session + * The current session. + * @param array $settings + * An array of additional settings that are usually site-specific. + * + * @return c_base_markup_tag|c_base_return_status + * A built menu markup tag. + * FALSE without error bit set is returned if no menu was built. + * FALSE with error bit set is returned on error. + */ + protected function pr_build_menu_utility(&$http, &$database, &$session, $settings) { + $menu = $this->pr_include_menu(self::PATH_MENU_UTILITY, self::NAME_MENU_UTILITY, self::HANDLER_MENU_UTILITY); + return $menu->do_build($this->http, $this->database, $this->session, $this->settings); + } + + /** + * Load and return the breadcrumbs menu handler. + * + * @param c_base_http &$http + * The entire HTTP information to allow for the execution to access anything that is necessary. + * @param c_base_database &$database + * The database object, which is usually used by form and ajax paths. + * @param c_base_session &$session + * The current session. + * @param array $settings + * An array of additional settings that are usually site-specific. + * + * @return c_base_markup_tag|c_base_return_status + * A built menu markup tag. + * FALSE without error bit set is returned if no menu was built. + * FALSE with error bit set is returned on error. + */ + protected function pr_build_menu_breadcrumbs(&$http, &$database, &$session, $settings) { + $menu = $this->pr_include_menu(self::PATH_MENU_BREADCRUMBS, self::NAME_MENU_BREADCRUMBS, self::HANDLER_MENU_BREADCRUMBS); + return $menu->do_build($http, $database, $session, $settings, $this->breadcrumbs); + } + + /** + * Load and return the content menu handler. + * + * @param c_base_http &$http + * The entire HTTP information to allow for the execution to access anything that is necessary. + * @param c_base_database &$database + * The database object, which is usually used by form and ajax paths. + * @param c_base_session &$session + * The current session. + * @param array $settings + * An array of additional settings that are usually site-specific. + * + * @return c_base_markup_tag|c_base_return_status + * A built menu markup tag. + * FALSE without error bit set is returned if no menu was built. + * FALSE with error bit set is returned on error. + */ + protected function pr_build_menu_content(&$http, &$database, &$session, $settings) { + $menu = $this->pr_include_menu(self::PATH_MENU_CONTENT, self::NAME_MENU_CONTENT, self::HANDLER_MENU_CONTENT); + return $menu->do_build($this->http, $this->database, $this->session, $this->settings); + } + + /** + * Load and return the footer menu handler. + * + * @param c_base_http &$http + * The entire HTTP information to allow for the execution to access anything that is necessary. + * @param c_base_database &$database + * The database object, which is usually used by form and ajax paths. + * @param c_base_session &$session + * The current session. + * @param array $settings + * An array of additional settings that are usually site-specific. + * + * @return c_base_markup_tag|c_base_return_status + * A built menu markup tag. + * FALSE without error bit set is returned if no menu was built. + * FALSE with error bit set is returned on error. + */ + protected function pr_build_menu_footer(&$http, &$database, &$session, $settings) { + $menu = $this->pr_include_menu(self::PATH_MENU_FOOTER, self::NAME_MENU_FOOTER, self::HANDLER_MENU_FOOTER); + return $menu->do_build($this->http, $this->database, $this->session, $this->settings); + } + + /** + * Create a single breadcrumbs item. + * + * @param string $text + * The text assigned to the breadcrumbs item. + * @param string|array|null $uri + * (optional) The URI string or array the breadcrumb points to. + * If NULL, then the uri is not assigned. + */ + protected function pr_create_breadcrumbs_item($text, $uri = NULL) { + $item = new c_base_menu_item(); + $item->set_text($text); + + if (!is_null($uri)) { + $item->set_uri($uri); + } + + return $item; + } + + /** * Load the title text associated with this page. * * This is provided here as a means for a language class to override with a custom language for the title. @@ -930,11 +1191,23 @@ class c_standard_path extends c_base_path { * A string is returned as the custom title. * NULL is returned to enforce default title. */ - protected function pr_get_title($arguments = array()) { + protected function pr_get_text_title($arguments = array()) { return NULL; } /** + * Load breadcrumbs text for a supported language. + * + * @param int $index + * A number representing which block of text to return. + * @param array $arguments + * (optional) An array of arguments to convert into text. + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + return ''; + } + + /** * Load text for a supported language. * * @param int $index @@ -945,4 +1218,79 @@ class c_standard_path extends c_base_path { protected function pr_get_text($code, $arguments = array()) { return ''; } + + /** + * Load and save the current preferred language alias. + */ + protected function pr_get_language_alias() { + $aliases = array(); + if (is_array($this->languages) && !empty($this->languages)) { + $language = reset($this->languages); + + // us-english is the default, so do not attempt to include any external files. + if ($language === i_base_languages::ENGLISH_US || $language === i_base_languages::ENGLISH) { + unset($language); + unset($aliases); + + $this->language_alias = NULL; + return; + } + + $aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id($language)->get_value_exact(); + } + unset($language); + + // use default if no aliases are found. + if (empty($aliases)) { + unset($aliases); + + $this->language_alias = NULL; + return; + } + + $this->language_alias = end($aliases); + } + + /** + * Will include a custom language path if one exists. + * + * The default language files ends in "${path}${name}.php". + * All other language files end in "${path}${language_alias}/${name}.php". + * + * The default class is the provided class name. + * All other languages use the provided class name with '_${language_alias}' appended. + * + * For example (using path='my_file'), us english is the default, so that would load the file 'my_file.php'. + * japanese language load the file 'my_file-ja.php'. + * + * @param string $path + * The path to the include file, without the file name. + * @param string $name + * The file name of the PHP file, without the '.php' extension. + * @param string $class + * The name of the class, that is an instance of c_base_menu, to execute. + * + * @return c_base_meni + * The created c_base_meni object. + */ + protected function pr_include_menu($path, $name, $class) { + require_once($path . $name . self::SCRIPT_EXTENSION); + + // use default if no aliases are found. + if (is_null($this->language_alias)) { + return new $class(); + } + + // use include_once instead of require_require to allow for failsafe behavior. + @include_once($path . $this->language_alias . '/' . $name . self::SCRIPT_EXTENSION); + + $language_class = $class . '_' . $this->language_alias; + if (class_exists($language_class)) { + return new $language_class(); + } + unset($language_class); + + // if unable to find, fallback to original class + return new $class(); + } } diff --git a/common/standard/classes/standard_paths.php b/common/standard/classes/standard_paths.php index a8048a4..560f254 100644 --- a/common/standard/classes/standard_paths.php +++ b/common/standard/classes/standard_paths.php @@ -13,17 +13,23 @@ require_once('common/standard/classes/standard_path.php'); * The standard class for use in index.php or equivalent. */ class c_standard_paths extends c_base_return { - protected const PATH_LOGIN = 'common/standard/paths/u/'; - protected const PATH_LOGOUT = 'common/standard/paths/u/'; - protected const PATH_ACCESS_DENIED = 'common/standard/internal/'; - protected const PATH_NOT_FOUND = 'common/standard/internal/'; - protected const PATH_BAD_METHOD = 'common/standard/internal/'; - protected const PATH_SERVER_ERROR = 'common/standard/internal/'; - protected const PATH_OPTIONS_METHOD = 'common/standard/internal/'; - protected const PATH_DASHBOARD_USER = 'common/standard/paths/u/'; - protected const PATH_DASHBOARD_MANAGEMENT = 'common/standard/paths/m/'; - protected const PATH_DASHBOARD_ADMINISTER = 'common/standard/paths/a/'; - protected const PATH_INDEX = 'common/standard/internal/'; + const URI_HOME = ''; + const URI_LOGIN = 'u/login'; + const URI_LOGOUT = 'u/logout'; + const URI_DASHBOARD_USER = 'u/dashboard'; + const URI_DASHBOARD_MANAGEMENT = 'm/dashboard'; + const URI_DASHBOARD_ADMINISTER = 'a/dashboard'; + const URI_USER_CREATE = 'u/create'; + const URI_USER_VIEW = 'u/view'; + const URI_USER_SETTINGS = 'u/settings'; + const URI_USER_LOCK = 'u/lock'; + const URI_USER_UNLOCK = 'u/unlock'; + const URI_USER_DELETE = 'u/create'; + + protected const PATH_INTERNAL = 'common/standard/internal/'; + protected const PATH_USER = 'common/standard/paths/u/'; + protected const PATH_MANAGEMENT = 'common/standard/paths/m/'; + protected const PATH_ADMINISTER = 'common/standard/paths/a/'; protected const NAME_LOGIN = 'login'; protected const NAME_LOGOUT = 'logout'; @@ -36,6 +42,12 @@ class c_standard_paths extends c_base_return { protected const NAME_DASHBOARD_MANAGEMENT = 'dashboard'; protected const NAME_DASHBOARD_ADMINISTER = 'dashboard'; protected const NAME_INDEX = 'index'; + protected const NAME_USER_CREATE = 'user_create'; + protected const NAME_USER_VIEW = 'user_view'; + protected const NAME_USER_SETTINGS = 'user_settings'; + protected const NAME_USER_LOCK = 'user_lock'; + protected const NAME_USER_UNLOCK = 'user_unlock'; + protected const NAME_USER_DELETE = 'user_delete'; protected const HANDLER_LOGIN = 'c_standard_path_user_login'; protected const HANDLER_LOGOUT = 'c_standard_path_user_logout'; @@ -48,17 +60,15 @@ class c_standard_paths extends c_base_return { protected const HANDLER_MANAGEMENT_DASHBOARD = 'c_standard_path_management_dashboard'; protected const HANDLER_ADMINISTER_DASHBOARD = 'c_standard_path_administer_dashboard'; protected const HANDLER_INDEX = 'c_standard_path_index'; - - protected const URI_LOGIN = '/u/login'; - protected const URI_LOGOUT = '/u/logout'; - protected const URI_DASHBOARD_USER = '/u/dashboard'; - protected const URI_DASHBOARD_MANAGEMENT = '/m/dashboard'; - protected const URI_DASHBOARD_ADMINISTER = '/a/dashboard'; + protected const HANDLER_USER_CREATE = 'c_standard_path_user_create'; + protected const HANDLER_USER_VIEW = 'c_standard_path_user_view'; + protected const HANDLER_USER_SETTINGS = 'c_standard_path_user_settings'; + protected const HANDLER_USER_LOCK = 'c_standard_path_user_lock'; + protected const HANDLER_USER_UNLOCK = 'c_standard_path_user_unlock'; + protected const HANDLER_USER_DELETE = 'c_standard_path_user_delete'; protected const SCRIPT_EXTENSION = '.php'; - - // a class name to prepend to css classes or id attributes. - protected const CSS_BASE = 'standard-'; + protected const WILDCARD_PATH = '/%'; protected $handler; protected $paths; @@ -68,7 +78,7 @@ class c_standard_paths extends c_base_return { protected $session; protected $settings; - protected $alias; + protected $language_alias; protected $output; @@ -86,7 +96,7 @@ class c_standard_paths extends c_base_return { $this->session = NULL; $this->settings = NULL; - $this->alias = NULL; + $this->language_alias = NULL; $this->output = NULL; } @@ -103,7 +113,7 @@ class c_standard_paths extends c_base_return { unset($this->session); unset($this->settings); - unset($this->alias); + unset($this->language_alias); unset($this->output); @@ -138,7 +148,7 @@ class c_standard_paths extends c_base_return { * A path object. */ public function get_handler_login() { - return $this->pr_include_path(self::PATH_LOGIN, self::NAME_LOGIN, self::HANDLER_LOGIN); + return $this->pr_include_path(self::PATH_USER, self::NAME_LOGIN, self::HANDLER_LOGIN); } /** @@ -148,7 +158,7 @@ class c_standard_paths extends c_base_return { * A path object. */ public function get_handler_logout() { - return $this->pr_include_path(self::PATH_LOGOUT, self::NAME_LOGOUT, self::HANDLER_LOGOUT); + return $this->pr_include_path(self::PATH_USER, self::NAME_LOGOUT, self::HANDLER_LOGOUT); } /** @@ -158,7 +168,7 @@ class c_standard_paths extends c_base_return { * A path object. */ public function get_handler_not_found() { - return $this->pr_include_path(self::PATH_NOT_FOUND, self::NAME_NOT_FOUND, self::HANDLER_NOT_FOUND); + return $this->pr_include_path(self::PATH_INTERNAL, self::NAME_NOT_FOUND, self::HANDLER_NOT_FOUND); } /** @@ -168,7 +178,7 @@ class c_standard_paths extends c_base_return { * A path object. */ public function get_handler_access_denied() { - return $this->pr_include_path(self::PATH_ACCESS_DENIED, self::NAME_ACCESS_DENIED, self::HANDLER_ACCESS_DENIED); + return $this->pr_include_path(self::PATH_INTERNAL, self::NAME_ACCESS_DENIED, self::HANDLER_ACCESS_DENIED); } /** @@ -178,7 +188,7 @@ class c_standard_paths extends c_base_return { * A path object. */ public function get_handler_bad_method() { - return $this->pr_include_path(self::PATH_BAD_METHOD, self::NAME_BAD_METHOD, self::HANDLER_BAD_METHOD); + return $this->pr_include_path(self::PATH_INTERNAL, self::NAME_BAD_METHOD, self::HANDLER_BAD_METHOD); } /** @@ -188,7 +198,7 @@ class c_standard_paths extends c_base_return { * A path object. */ public function get_handler_server_error() { - return $this->pr_include_path(self::PATH_SERVER_ERROR, self::NAME_SERVER_ERROR, self::HANDLER_SERVER_ERROR); + return $this->pr_include_path(self::PATH_INTERNAL, self::NAME_SERVER_ERROR, self::HANDLER_SERVER_ERROR); } /** @@ -198,7 +208,7 @@ class c_standard_paths extends c_base_return { * A path object. */ public function get_handler_options_method() { - return $this->pr_include_path(self::PATH_OPTIONS_METHOD, self::NAME_OPTIONS_METHOD, self::HANDLER_OPTIONS_METHOD); + return $this->pr_include_path(self::PATH_INTERNAL, self::NAME_OPTIONS_METHOD, self::HANDLER_OPTIONS_METHOD); } /** @@ -208,7 +218,7 @@ class c_standard_paths extends c_base_return { * A path object. */ public function get_handler_index() { - return $this->pr_include_path(self::PATH_INDEX, self::NAME_INDEX, self::HANDLER_INDEX); + return $this->pr_include_path(self::PATH_INTERNAL, self::NAME_INDEX, self::HANDLER_INDEX); } /** @@ -233,27 +243,27 @@ class c_standard_paths extends c_base_return { // @todo: these parameter errors might need a custom service unavailable and system log support. if (!($http instanceof c_base_http)) { $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'http', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); - return c_base_return_error::s_value(array(), 'c_base_path_executed', $error); + return c_base_return_error::s_return('c_base_path_executed', $error); } if (!($database instanceof c_base_database)) { $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); - return c_base_return_error::s_value(array(), 'c_base_path_executed', $error); + return c_base_return_error::s_return('c_base_path_executed', $error); } if (!($session instanceof c_base_session)) { $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); - return c_base_return_error::s_value(array(), 'c_base_path_executed', $error); + return c_base_return_error::s_return('c_base_path_executed', $error); } if (!is_array($settings)) { $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); - return c_base_return_error::s_value(array(), 'c_base_path_executed', $error); + return c_base_return_error::s_return('c_base_path_executed', $error); } if (!($session instanceof c_base_session)) { $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); - return c_base_return_error::s_value(array(), 'c_base_path_executed', $error); + return c_base_return_error::s_return('c_base_path_executed', $error); } $this->http = &$http; @@ -268,9 +278,16 @@ class c_standard_paths extends c_base_return { // require HTTPS for access to any part of this website. if (!isset($_SERVER["HTTPS"])) { // @todo: redirect to https version of requested uri. - $failure_path = $this->get_handler_not_found(); + $path_not_found = $this->get_handler_not_found(); + + $path_tree = new c_base_path_tree(); + $path_tree->set_id_group(0); + $path_tree->set_items(array()); + + $path_not_found->set_path_tree($path_tree); + unset($path_tree); - return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings); + return $path_not_found->do_execute($this->http, $this->database, $this->session, $this->settings); } @@ -280,7 +297,7 @@ class c_standard_paths extends c_base_return { // load the http method. $method = $this->http->get_request(c_base_http::REQUEST_METHOD)->get_value_exact(); - if (isset($method['data']) && is_int($method['data'])) { + if (isset($method['data']) && is_int($method['data'])) { $method = $method['data']; } else { @@ -293,29 +310,62 @@ class c_standard_paths extends c_base_return { $handler_settings = $this->paths->find_path($path)->get_value(); unset($path); - if (!is_array($handler_settings)) { - // for all invalid pages, report bad method if not HTTP GET or HTTP POST. + if (!isset($handler_settings['handler'])) { if ($method !== c_base_http::HTTP_METHOD_GET && $method !== c_base_http::HTTP_METHOD_POST) { - unset($method); + // for all invalid pages, report bad method if not HTTP GET or HTTP POST. + $path_failsafe = $this->get_handler_bad_method(); + } + else { + $path_failsafe = $this->get_handler_not_found(); + } + unset($method); - $failure_path = $this->get_handler_bad_method(); + $path_tree = new c_base_path_tree(); + $path_tree->set_id_group(0); + if (isset($handler_settings['path_tree'])) { + $path_tree->set_items($handler_settings['path_tree']); - return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings); + if (isset($handler_settings['id_group'])) { + $path_tree->set_id_group($handler_settings['id_group']); + } } - unset($method); + else { + $path_tree->set_items(array()); + } + + $path_failsafe->set_path_tree($path_tree); + unset($path_tree); - $not_found = $this->get_handler_not_found(); - return $not_found->do_execute($this->http, $this->database, $this->session, $this->settings); + return $path_failsafe->do_execute($this->http, $this->database, $this->session, $this->settings); } + + // prepare the path tree object. + $path_tree = new c_base_path_tree(); + if (isset($handler_settings['path_tree'])) { + $path_tree->set_items($handler_settings['path_tree']); + } + else { + $path_tree->set_items(array()); + } + + if (isset($handler_settings['id_group'])) { + $path_tree->set_id_group($handler_settings['id_group']); + } + else { + $path_tree->set_id_group(0); + } + + // validate allowed methods. if (isset($handler_settings['methods']) && is_array($handler_settings['methods'])) { if (!array_key_exists($method, $handler_settings['methods'])) { unset($method); - $failure_path = $this->get_handler_bad_method(); + $path_bad_method = $this->get_handler_bad_method(); + $path_bad_method->set_path_tree($path_tree); - return $failure_path->do_execute($this->http, $this->database, $this->session, $this->settings); + return $path_bad_method->do_execute($this->http, $this->database, $this->session, $this->settings); } } @@ -333,6 +383,11 @@ class c_standard_paths extends c_base_return { $options_method_path->set_allowed_methods(array()); } + $options_method_path->set_path_tree($path_tree); + + unset($handler_settings); + unset($path_tree); + return $options_method_path->do_execute($this->http, $this->database, $this->session, $this->settings); } @@ -349,7 +404,28 @@ class c_standard_paths extends c_base_return { $handler_settings['code'] = c_base_http_status::MOVED_PERMANENTLY; } - $redirect = c_standard_path::s_create_redirect($handler_settings['redirect'], $handler_settings['code'], FALSE); + + $redirect_path = $handler_settings['redirect']; + if (isset($handler_settings['redirect_partial']) && $handler_settings['redirect_partial']) { + if (isset($handler_settings['extra_slashes']) && $handler_settings['extra_slashes']) { + $path_original = $this->http->get_request_uri_relative('')->get_value_exact(); + $path_modified = $this->http->get_request_uri_relative($settings['base_path'])->get_value_exact(); + + // if path orignal and modified are the same, then the provided base url has extra '/' in it. + if ($path_original == $path_modified) { + $redirect_path = preg_replace('@^' . preg_quote($this->settings['base_path'], '@') . '@i', '', '/' . $redirect_path); + $redirect_path = preg_replace('@/$@', '', $redirect_path); + } + unset($path_original); + unset($path_modified); + } + + $redirect_path = $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . $redirect_path; + } + + $redirect = c_standard_path::s_create_redirect($redirect_path, $handler_settings['code'], FALSE); + unset($redirect_path); + return $redirect->do_execute($this->http, $this->database, $this->session, $this->settings); } else { @@ -359,12 +435,18 @@ class c_standard_paths extends c_base_return { // execute path handler, using custom-language if defined. if (empty($handler_settings['handler'])) { - return $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_server_error = $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_server_error->set_path_tree($path_tree); + + unset($handler_settings); + unset($path_tree); + + return $path_server_error; } - elseif (is_string($this->alias)) { - @include_once($handler_settings['include_directory'] . $this->alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); + elseif (is_string($this->language_alias)) { + @include_once($handler_settings['include_directory'] . $this->language_alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - $handler_class = $handler_settings['handler'] . '_' . $this->alias; + $handler_class = $handler_settings['handler'] . '_' . $this->language_alias; if (class_exists($handler_class)) { $this->handler = new $handler_class(); @@ -375,19 +457,33 @@ class c_standard_paths extends c_base_return { // attempt to fallback to default handler if the language-specific handler class is not found. if (!class_exists($handler_settings['handler'])) { - return $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_server_error = $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_server_error->set_path_tree($path_tree); + + unset($handler_settings); + unset($path_tree); + + return $path_server_error; } else { $this->handler = new $handler_settings['handler'](); + $this->handler->set_path_tree($path_tree); } } } else { if (class_exists($handler_settings['handler'])) { $this->handler = new $handler_settings['handler'](); + $this->handler->set_path_tree($path_tree); } else { - return $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_server_error = $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_server_error->set_path_tree($path_tree); + + unset($handler_settings); + unset($path_tree); + + return $path_server_error; } } @@ -400,6 +496,7 @@ class c_standard_paths extends c_base_return { } } unset($handler_settings); + unset($path_tree); return $this->pr_paths_normal($method); @@ -416,17 +513,31 @@ class c_standard_paths extends c_base_return { protected function pr_paths_create() { $this->paths = new c_base_paths(); - // set root path to be the user dashboard. - $this->paths->add_path('', self::HANDLER_INDEX, self::PATH_INDEX, self::NAME_INDEX); + // set root path. + $this->paths->add_path(self::URI_HOME, self::HANDLER_INDEX, self::PATH_INTERNAL, self::NAME_INDEX); // create login/logout paths - $this->paths->add_path(self::URI_LOGIN, self::HANDLER_LOGIN, self::PATH_LOGIN, self::NAME_LOGIN); - $this->paths->add_path(self::URI_LOGOUT, self::HANDLER_LOGOUT, self::PATH_LOGOUT, self::NAME_LOGOUT); + $this->paths->add_path(self::URI_LOGIN, self::HANDLER_LOGIN, self::PATH_USER, self::NAME_LOGIN); + $this->paths->add_path(self::URI_LOGOUT, self::HANDLER_LOGOUT, self::PATH_USER, self::NAME_LOGOUT); // dashboards - $this->paths->add_path(self::URI_DASHBOARD_USER, self::HANDLER_USER_DASHBOARD, self::PATH_DASHBOARD_USER, self::NAME_DASHBOARD_USER); - $this->paths->add_path(self::URI_DASHBOARD_MANAGEMENT, self::HANDLER_MANAGEMENT_DASHBOARD, self::PATH_DASHBOARD_MANAGEMENT, self::NAME_DASHBOARD_MANAGEMENT); - $this->paths->add_path(self::URI_DASHBOARD_ADMINISTER, self::HANDLER_ADMINISTER_DASHBOARD, self::PATH_DASHBOARD_ADMINISTER, self::NAME_DASHBOARD_ADMINISTER); + $this->paths->add_path(self::URI_DASHBOARD_USER, self::HANDLER_USER_DASHBOARD, self::PATH_USER, self::NAME_DASHBOARD_USER); + $this->paths->add_path(self::URI_DASHBOARD_MANAGEMENT, self::HANDLER_MANAGEMENT_DASHBOARD, self::PATH_MANAGEMENT, self::NAME_DASHBOARD_MANAGEMENT); + $this->paths->add_path(self::URI_DASHBOARD_ADMINISTER, self::HANDLER_ADMINISTER_DASHBOARD, self::PATH_ADMINISTER, self::NAME_DASHBOARD_ADMINISTER); + + // user paths + $this->paths->add_path(self::URI_USER_CREATE, self::HANDLER_USER_CREATE, self::PATH_USER, self::NAME_USER_CREATE); + $this->paths->add_path(self::URI_USER_CREATE, self::HANDLER_USER_CREATE, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_CREATE); + $this->paths->add_path(self::URI_USER_VIEW, self::HANDLER_USER_VIEW, self::PATH_USER, self::NAME_USER_VIEW); + $this->paths->add_path(self::URI_USER_VIEW, self::HANDLER_USER_VIEW, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_VIEW); + $this->paths->add_path(self::URI_USER_SETTINGS, self::HANDLER_USER_SETTINGS, self::PATH_USER, self::NAME_USER_SETTINGS); + $this->paths->add_path(self::URI_USER_SETTINGS, self::HANDLER_USER_SETTINGS, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_SETTINGS); + $this->paths->add_path(self::URI_USER_LOCK, self::HANDLER_USER_LOCK, self::PATH_USER, self::NAME_USER_LOCK); + $this->paths->add_path(self::URI_USER_LOCK, self::HANDLER_USER_LOCK, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_LOCK); + $this->paths->add_path(self::URI_USER_UNLOCK, self::HANDLER_USER_UNLOCK, self::PATH_USER, self::NAME_USER_UNLOCK); + $this->paths->add_path(self::URI_USER_UNLOCK, self::HANDLER_USER_UNLOCK, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_UNLOCK); + $this->paths->add_path(self::URI_USER_DELETE, self::HANDLER_USER_DELETE, self::PATH_USER, self::NAME_USER_DELETE); + $this->paths->add_path(self::URI_USER_DELETE, self::HANDLER_USER_DELETE, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_DELETE); } /** @@ -459,8 +570,12 @@ class c_standard_paths extends c_base_return { $this->http->set_response_status(c_base_http_status::FORBIDDEN); - $login_path = $this->get_handler_login(); - return $login_path->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_login = $this->get_handler_login(); + if ($this->handler->get_path_tree() instanceof c_base_path_tree) { + $path_login->set_path_tree($this->handler->get_path_tree()); + } + + return $path_login->do_execute($this->http, $this->database, $this->session, $this->settings); } else { if ($id_group === c_base_ascii::LOWER_U) { @@ -470,15 +585,23 @@ class c_standard_paths extends c_base_return { if (class_exists(self::HANDLER_LOGOUT) && (is_subclass_of($this->handler, self::HANDLER_LOGOUT) || is_a($this->handler, self::HANDLER_LOGOUT, TRUE))) { // if the user is not logged in. then provide a page not found for logout path. if (!$this->session->is_logged_in()->get_value_exact()) { + $path_not_found = $this->get_handler_not_found(); + if ($this->handler->get_path_tree() instanceof c_base_path_tree) { + $path_not_found->set_path_tree($this->handler->get_path_tree()); + } - return $this->get_handler_not_found()->do_execute($this->http, $this->database, $this->session, $this->settings); + return $path_not_found->do_execute($this->http, $this->database, $this->session, $this->settings);; } } $this->http->set_response_status(c_base_http_status::FORBIDDEN); - $login_path = $this->get_handler_login(); - return $login_path->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_login = $this->get_handler_login(); + if ($this->handler->get_path_tree() instanceof c_base_path_tree) { + $path_login->set_path_tree($this->handler->get_path_tree()); + } + + return $path_login->do_execute($this->http, $this->database, $this->session, $this->settings); } // some special case paths always provide login prompt along with access denied. @@ -487,8 +610,12 @@ class c_standard_paths extends c_base_return { $this->http->set_response_status(c_base_http_status::FORBIDDEN); - $login_path = $this->get_handler_login(); - return $login_path->do_execute($this->http, $this->database, $this->session, $this->settings); + $path_login = $this->get_handler_login(); + if ($this->handler->get_path_tree() instanceof c_base_path_tree) { + $path_login->set_path_tree($this->handler->get_path_tree()); + } + + return $path_login->do_execute($this->http, $this->database, $this->session, $this->settings); } } } @@ -500,19 +627,23 @@ class c_standard_paths extends c_base_return { // return access denied or page not found depending on path and privacy settings. if ($id_group === c_base_ascii::LOWER_C || $id_group === c_base_ascii::LOWER_D || $id_group === c_base_ascii::LOWER_T || $id_group === c_base_ascii::LOWER_X || $id_group === c_base_ascii::LOWER_F) { // these always return not found for these paths. - $failsafe_path = $this->get_handler_not_found(); + $path_failsafe = $this->get_handler_not_found(); } elseif ($this->handler->is_private()->get_value_exact() && $id_group !== c_base_ascii::NULL) { // non private, and non-special case paths should return access denied as per normal behavior. - $failsafe_path = $this->get_handler_access_denied(); + $path_failsafe = $this->get_handler_access_denied(); } else { // all other case, return not found. - $failsafe_path = $this->get_handler_not_found(); + $path_failsafe = $this->get_handler_not_found(); } unset($id_group); - return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings); + if ($this->handler->get_path_tree() instanceof c_base_path_tree) { + $path_failsafe->set_path_tree($this->handler->get_path_tree()); + } + + return $path_failsafe->do_execute($this->http, $this->database, $this->session, $this->settings); } /** @@ -526,9 +657,13 @@ class c_standard_paths extends c_base_return { // @todo // always return not found, do not inform user if the access is denied. - $failsafe_path = $this->get_handler_not_found(); + $path_failsafe = $this->get_handler_not_found(); + + if ($this->handler->get_path_tree() instanceof c_base_path_tree) { + $path_failsafe->set_path_tree($this->handler->get_path_tree()); + } - return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings); + return $path_failsafe->do_execute($this->http, $this->database, $this->session, $this->settings); } /** @@ -542,15 +677,17 @@ class c_standard_paths extends c_base_return { // @todo // always return not found, do not inform user if the access is denied. - $failsafe_path = $this->get_handler_not_found(); + $path_failsafe = $this->get_handler_not_found(); - return $failsafe_path->do_execute($this->http, $this->database, $this->session, $this->settings); + if ($this->handler->get_path_tree() instanceof c_base_path_tree) { + $path_failsafe->set_path_tree($this->handler->get_path_tree()); + } + + return $path_failsafe->do_execute($this->http, $this->database, $this->session, $this->settings); } /** * Load and save the current preferred language alias. - * - * This will be stored in $this->alias. */ protected function pr_get_language_alias() { $aliases = array(); @@ -564,7 +701,7 @@ class c_standard_paths extends c_base_return { unset($aliases); unset($languages); - $this->alias = NULL; + $this->language_alias = NULL; return; } @@ -577,11 +714,11 @@ class c_standard_paths extends c_base_return { unset($aliases); unset($languages); - $this->alias = NULL; + $this->language_alias = NULL; return; } - $this->alias = end($aliases); + $this->language_alias = end($aliases); } /** @@ -610,14 +747,14 @@ class c_standard_paths extends c_base_return { require_once($path . $name . self::SCRIPT_EXTENSION); // use default if no aliases are found. - if (is_null($this->alias)) { + if (is_null($this->language_alias)) { return new $class(); } // use include_once instead of require_require to allow for failsafe behavior. - @include_once($path . $this->alias . '/' . $name . self::SCRIPT_EXTENSION); + @include_once($path . $this->language_alias . '/' . $name . self::SCRIPT_EXTENSION); - $language_class = $class . '_' . $this->alias; + $language_class = $class . '_' . $this->language_alias; if (class_exists($language_class)) { return new $language_class(); } diff --git a/common/standard/internal/access_denied.php b/common/standard/internal/access_denied.php index ea2d64a..d72501c 100644 --- a/common/standard/internal/access_denied.php +++ b/common/standard/internal/access_denied.php @@ -14,6 +14,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_access_denied extends c_standard_path { /** + * Build the breadcrumb. + */ + protected function pr_build_breadcrumbs() { + $this->breadcrumbs = new c_base_menu_item(); + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); + $this->breadcrumbs->set_item($item); + unset($item); + + // @todo: check the url path and attempt to get a breadcrumb for the current path. + // this will require external functions because the breadcrumb language specific text must be loaded. + } + + /** * Implements do_execute(). */ public function do_execute(&$http, &$database, &$session, $settings = array()) { @@ -34,6 +48,8 @@ class c_standard_path_access_denied extends c_standard_path { $this->html->set_tag($wrapper); unset($wrapper); + $this->pr_add_menus(); + $executed->set_output($this->html); unset($this->html); @@ -46,13 +62,31 @@ class c_standard_path_access_denied extends c_standard_path { } /** - * Implements pr_get_title(). + * Implements pr_get_text_title(). */ - protected function pr_get_title($arguments = array()) { + protected function pr_get_text_title($arguments = array()) { return $this->pr_get_text(0, $arguments); } /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = ''; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/bad_method.php b/common/standard/internal/bad_method.php index 99e051c..3b276d9 100644 --- a/common/standard/internal/bad_method.php +++ b/common/standard/internal/bad_method.php @@ -14,6 +14,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_bad_method extends c_standard_path { /** + * Build the breadcrumb. + */ + protected function pr_build_breadcrumbs() { + $this->breadcrumbs = new c_base_menu_item(); + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); + $this->breadcrumbs->set_item($item); + unset($item); + + // @todo: check the url path and attempt to get a breadcrumb for the current path. + // this will require external functions because the breadcrumb language specific text must be loaded. + } + + /** * Implements do_execute(). */ public function do_execute(&$http, &$database, &$session, $settings = array()) { @@ -36,6 +50,8 @@ class c_standard_path_bad_method extends c_standard_path { $this->html->set_tag($wrapper); unset($wrapper); + $this->pr_add_menus(); + $executed->set_output($this->html); unset($this->html); @@ -48,6 +64,31 @@ class c_standard_path_bad_method extends c_standard_path { } /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = ''; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/index.php b/common/standard/internal/index.php index 57a2bfb..7ae67ef 100644 --- a/common/standard/internal/index.php +++ b/common/standard/internal/index.php @@ -15,6 +15,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_index extends c_standard_path { /** + * Build the breadcrumb. + */ + protected function pr_build_breadcrumbs() { + $this->breadcrumbs = new c_base_menu_item(); + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); + $this->breadcrumbs->set_item($item); + unset($item); + + // @todo: check the url path and attempt to get a breadcrumb for the current path. + // this will require external functions because the breadcrumb language specific text must be loaded. + } + + /** * Implements do_execute(). */ public function do_execute(&$http, &$database, &$session, $settings = array()) { @@ -35,6 +49,8 @@ class c_standard_path_index extends c_standard_path { $this->html->set_tag($wrapper); unset($wrapper); + $this->pr_add_menus(); + $executed->set_output($this->html); unset($this->html); @@ -42,16 +58,35 @@ class c_standard_path_index extends c_standard_path { } /** - * Implements pr_get_title(). + * Implements pr_get_text_title(). */ - protected function pr_get_title($arguments = array()) { + protected function pr_get_text_title($arguments = array()) { return $this->pr_get_text(0, $arguments); } /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Home'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { + $string = ''; switch ($code) { case 0: $string = 'Standard System'; diff --git a/common/standard/internal/ja/access_denied.php b/common/standard/internal/ja/access_denied.php index c8b3eb9..8abe4a9 100644 --- a/common/standard/internal/ja/access_denied.php +++ b/common/standard/internal/ja/access_denied.php @@ -10,6 +10,23 @@ final class c_standard_path_access_denied_ja extends c_standard_path_access_denied { /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + switch ($code) { + case 0: + $string = 'ホームページ'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/ja/bad_method.php b/common/standard/internal/ja/bad_method.php index 3cb3abb..3f2ce15 100644 --- a/common/standard/internal/ja/bad_method.php +++ b/common/standard/internal/ja/bad_method.php @@ -10,6 +10,23 @@ final class c_standard_path_bad_method_ja extends c_standard_path_bad_method { /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + switch ($code) { + case 0: + $string = 'ホームページ'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/ja/index.php b/common/standard/internal/ja/index.php index 0f7b496..24ac131 100644 --- a/common/standard/internal/ja/index.php +++ b/common/standard/internal/ja/index.php @@ -10,6 +10,23 @@ final class c_standard_path_index_ja extends c_standard_path_index { /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + switch ($code) { + case 0: + $string = 'ホームページ'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/ja/not_found.php b/common/standard/internal/ja/not_found.php index b3a776c..1edf33a 100644 --- a/common/standard/internal/ja/not_found.php +++ b/common/standard/internal/ja/not_found.php @@ -10,6 +10,23 @@ final class c_standard_path_not_found_ja extends c_standard_path_not_found { /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + switch ($code) { + case 0: + $string = 'ホームページ'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/ja/server_error.php b/common/standard/internal/ja/server_error.php index 97f5fe9..8e9cf5f 100644 --- a/common/standard/internal/ja/server_error.php +++ b/common/standard/internal/ja/server_error.php @@ -10,6 +10,23 @@ final class c_standard_path_server_error_ja extends c_standard_path_server_error { /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + switch ($code) { + case 0: + $string = 'ホームページ'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/not_found.php b/common/standard/internal/not_found.php index 9dbb7b8..4b94b24 100644 --- a/common/standard/internal/not_found.php +++ b/common/standard/internal/not_found.php @@ -14,6 +14,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_not_found extends c_standard_path { /** + * Build the breadcrumb. + * + protected function pr_build_breadcrumbs() { + $this->breadcrumbs = new c_base_menu_item(); + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); + $this->breadcrumbs->set_item($item); + unset($item); + + // @todo: check the url path and attempt to get a breadcrumb for the current path. + // this will require external functions because the breadcrumb language specific text must be loaded. + } + + /** * Implements do_execute(). */ public function do_execute(&$http, &$database, &$session, $settings = array()) { @@ -34,6 +48,8 @@ class c_standard_path_not_found extends c_standard_path { $this->html->set_tag($wrapper); unset($wrapper); + $this->pr_add_menus(); + $executed->set_output($this->html); unset($this->html); @@ -46,13 +62,31 @@ class c_standard_path_not_found extends c_standard_path { } /** - * Implements pr_get_title(). + * Implements pr_get_text_title(). */ - protected function pr_get_title($arguments = array()) { + protected function pr_get_text_title($arguments = array()) { return $this->pr_get_text(0, $arguments); } /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = ''; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/server_error.php b/common/standard/internal/server_error.php index 8087694..ac43c4b 100644 --- a/common/standard/internal/server_error.php +++ b/common/standard/internal/server_error.php @@ -14,6 +14,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_server_error extends c_standard_path { /** + * Build the breadcrumb. + */ + protected function pr_build_breadcrumbs() { + $this->breadcrumbs = new c_base_menu_item(); + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); + $this->breadcrumbs->set_item($item); + unset($item); + + // @todo: check the url path and attempt to get a breadcrumb for the current path. + // this will require external functions because the breadcrumb language specific text must be loaded. + } + + /** * Implements do_execute(). */ public function do_execute(&$http, &$database, &$session, $settings = array()) { @@ -34,6 +48,8 @@ class c_standard_path_server_error extends c_standard_path { $this->html->set_tag($wrapper); unset($wrapper); + $this->pr_add_menus(); + $executed->set_output($this->html); unset($this->html); @@ -46,13 +62,31 @@ class c_standard_path_server_error extends c_standard_path { } /** - * Implements pr_get_title(). + * Implements pr_get_text_title(). */ - protected function pr_get_title($arguments = array()) { + protected function pr_get_text_title($arguments = array()) { return $this->pr_get_text(0, $arguments); } /** + * Implements pr_get_text_breadcrumbs(). + */ + protected function pr_get_text_breadcrumbs($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = ''; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/menus/ja/menu_breadcrumbs.php b/common/standard/menus/ja/menu_breadcrumbs.php new file mode 100644 index 0000000..60726b1 --- /dev/null +++ b/common/standard/menus/ja/menu_breadcrumbs.php @@ -0,0 +1,30 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/ja/menu_content.php b/common/standard/menus/ja/menu_content.php new file mode 100644 index 0000000..8c77554 --- /dev/null +++ b/common/standard/menus/ja/menu_content.php @@ -0,0 +1,30 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/ja/menu_footer.php b/common/standard/menus/ja/menu_footer.php new file mode 100644 index 0000000..ce1c3c9 --- /dev/null +++ b/common/standard/menus/ja/menu_footer.php @@ -0,0 +1,30 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/ja/menu_header.php b/common/standard/menus/ja/menu_header.php new file mode 100644 index 0000000..18446d8 --- /dev/null +++ b/common/standard/menus/ja/menu_header.php @@ -0,0 +1,30 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/ja/menu_utility.php b/common/standard/menus/ja/menu_utility.php new file mode 100644 index 0000000..8f06519 --- /dev/null +++ b/common/standard/menus/ja/menu_utility.php @@ -0,0 +1,51 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/menu_breadcrumbs.php b/common/standard/menus/menu_breadcrumbs.php new file mode 100644 index 0000000..0f7e34c --- /dev/null +++ b/common/standard/menus/menu_breadcrumbs.php @@ -0,0 +1,91 @@ +pr_create_html_create_menu($settings['base_css'] . self::CLASS_NAME, $this->pr_get_text(0)); + foreach ($items->get_items()->get_value_exact() as $item) { + if (!($item instanceof c_base_menu_item)) { + continue; + } + + $item_text = $item->get_text()->get_value_exact(); + $item_uri = $item->get_uri()->get_value(); + if (is_string($item_uri) || is_array($item_uri)) { + // @fixme: handle if $item_uri is an array. + $tag = $this->pr_create_html_add_menu_item_link($item_text, $settings['base_path'] . $item_uri); + } + else { + $tag = $this->pr_create_html_add_menu_item_label($item_text); + } + unset($item_uri); + unset($item_text); + + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_ITEM); + + $item_attributes = $item->get_attributes()->get_value_exact(); + if (is_array($item_attributes) && !empty($item_attributes)) { + foreach ($item_attributes as $attribute_key => $attribute_value) { + $tag->set_attribute($attribute_key, $attribute_value); + } + unset($attribute_key); + unset($attribute_value); + } + unset($item_attributes); + + $menu->set_tag($tag); + unset($tag); + } + unset($item); + + return $menu; + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Breadcrumb Menu'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/menu_content.php b/common/standard/menus/menu_content.php new file mode 100644 index 0000000..d5e3eec --- /dev/null +++ b/common/standard/menus/menu_content.php @@ -0,0 +1,37 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/menu_footer.php b/common/standard/menus/menu_footer.php new file mode 100644 index 0000000..0d92d38 --- /dev/null +++ b/common/standard/menus/menu_footer.php @@ -0,0 +1,37 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/menu_header.php b/common/standard/menus/menu_header.php new file mode 100644 index 0000000..4376550 --- /dev/null +++ b/common/standard/menus/menu_header.php @@ -0,0 +1,37 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/menu_utility.php b/common/standard/menus/menu_utility.php new file mode 100644 index 0000000..0cfcbb7 --- /dev/null +++ b/common/standard/menus/menu_utility.php @@ -0,0 +1,132 @@ +get_user_current(); + if ($session_user instanceof c_base_session) { + $roles = $session_user->get_roles()->get_value_exact(); + } + unset($session_user); + + $menu = $this->pr_create_html_create_menu($settings['base_css'] . self::CLASS_NAME, $this->pr_get_text(0)); + + if ($session->is_logged_in() instanceof c_base_return_true) { + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(3), $settings['base_path'] . c_standard_paths::URI_DASHBOARD_USER); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_DASHBOARD_USER); + $menu->set_tag($item); + unset($item); + + if (array_key_exists(c_base_roles::MANAGER, $roles) || array_key_exists(c_base_roles::ADMINISTER, $roles)) { + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(4), $settings['base_path'] . c_standard_paths::URI_DASHBOARD_MANAGEMENT); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_DASHBOARD_MANAGEMENT); + $menu->set_tag($item); + unset($item); + } + + if (array_key_exists(c_base_roles::ADMINISTER, $roles)) { + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(5), $settings['base_path'] . c_standard_paths::URI_DASHBOARD_ADMINISTER); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_DASHBOARD_ADMINISTER); + $menu->set_tag($item); + unset($item); + } + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(6), $settings['base_path'] . c_standard_paths::URI_USER_SETTINGS); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_USER_SETTINGS); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(7), $settings['base_path'] . c_standard_paths::URI_LOGOUT); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_LOGOUT); + $menu->set_tag($item); + unset($item); + } + else { + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(1), $settings['base_path'] . c_standard_paths::URI_HOME); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_HOME); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(2), $settings['base_path'] . c_standard_paths::URI_LOGIN); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_LOGIN); + $menu->set_tag($item); + unset($item); + } + unset($roles); + + return $menu; + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Utility Menu'; + break; + case 1: + $string = 'Home'; + break; + case 2: + $string = 'Login'; + break; + case 3: + $string = 'Dashboard'; + break; + case 4: + $string = 'Management'; + break; + case 5: + $string = 'Administration'; + break; + case 6: + $string = 'Settings'; + break; + case 7: + $string = 'Logout'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/dashboard.php b/common/standard/paths/u/dashboard.php index e2ea8ca..61b0568 100644 --- a/common/standard/paths/u/dashboard.php +++ b/common/standard/paths/u/dashboard.php @@ -105,6 +105,7 @@ class c_standard_path_user_dashboard extends c_standard_path { // initialize the content as HTML. $this->pr_create_html(); $this->html->set_tag($wrapper); + unset($wrapper); $executed->set_output($this->html); unset($this->html); @@ -125,9 +126,9 @@ class c_standard_path_user_dashboard extends c_standard_path { } /** - * Implements pr_get_title(). + * Implements pr_get_text_title(). */ - protected function pr_get_title($arguments = array()) { + protected function pr_get_text_title($arguments = array()) { return $this->pr_get_text(0, $arguments); } @@ -135,6 +136,7 @@ class c_standard_path_user_dashboard extends c_standard_path { * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { + $string = ''; switch ($code) { case 0: $string = 'Dashboard'; diff --git a/common/standard/paths/u/ja/user_create.php b/common/standard/paths/u/ja/user_create.php new file mode 100644 index 0000000..90d41cd --- /dev/null +++ b/common/standard/paths/u/ja/user_create.php @@ -0,0 +1,29 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_delete.php b/common/standard/paths/u/ja/user_delete.php new file mode 100644 index 0000000..90d41cd --- /dev/null +++ b/common/standard/paths/u/ja/user_delete.php @@ -0,0 +1,29 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_lock.php b/common/standard/paths/u/ja/user_lock.php new file mode 100644 index 0000000..90d41cd --- /dev/null +++ b/common/standard/paths/u/ja/user_lock.php @@ -0,0 +1,29 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_settings.php b/common/standard/paths/u/ja/user_settings.php new file mode 100644 index 0000000..afad815 --- /dev/null +++ b/common/standard/paths/u/ja/user_settings.php @@ -0,0 +1,74 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_unlock.php b/common/standard/paths/u/ja/user_unlock.php new file mode 100644 index 0000000..90d41cd --- /dev/null +++ b/common/standard/paths/u/ja/user_unlock.php @@ -0,0 +1,29 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_view.php b/common/standard/paths/u/ja/user_view.php new file mode 100644 index 0000000..afad815 --- /dev/null +++ b/common/standard/paths/u/ja/user_view.php @@ -0,0 +1,74 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/login.php b/common/standard/paths/u/login.php index e3ba871..889385a 100644 --- a/common/standard/paths/u/login.php +++ b/common/standard/paths/u/login.php @@ -27,9 +27,6 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_user_login extends c_standard_path { protected const USER_PUBLIC = 'u_standard_public'; - protected const PATH_LOGIN = 'u/login'; - protected const PATH_LOGOUT = 'u/logout'; - /** * Implements do_execute(). */ @@ -78,7 +75,7 @@ class c_standard_path_user_login extends c_standard_path { $href = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_A); $href->set_text($this->pr_get_text(6)); - $href->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $settings['base_path'] . self::PATH_LOGOUT); + $href->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $settings['base_path'] . c_standard_paths::URI_LOGOUT); $block->set_tag($href); unset($href); @@ -210,8 +207,9 @@ class c_standard_path_user_login extends c_standard_path { // label: username - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LABEL, NULL, array('login_form-label-username')); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_FOR, 'login_form-username'); + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LABEL, NULL, array('login_form-label-user_name')); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_FOR, 'login_form-user_name'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, 'field-label-user_name'); $tag->set_text($this->pr_get_text(1)); $form->set_tag($tag); unset($tag); @@ -219,17 +217,18 @@ class c_standard_path_user_login extends c_standard_path { // field: username $class = array( - 'login_form-input-username', + 'login_form-input-user_name', ); - if (array_key_exists('login_form-username', $problem_fields)) { + if (array_key_exists('login_form-user_name', $problem_fields)) { $class[] = 'field_has_problem'; } - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_TEXT, 'login_form-username', $class); + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_TEXT, 'login_form-user_name', $class); unset($class); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REQUIRED, TRUE); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_VALUE, $this->pr_sanitize('login_form-username', 0)->get_value()); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_VALUE, $this->pr_sanitize('login_form-user_name', 0)->get_value()); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, 'field-input-user_name'); $form->set_tag($tag); unset($tag); @@ -238,6 +237,7 @@ class c_standard_path_user_login extends c_standard_path { $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LABEL, NULL, array('login_form-label-password')); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_FOR, 'login_form-password'); $tag->set_text($this->pr_get_text(2)); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, 'field-label-password'); $form->set_tag($tag); unset($tag); @@ -255,6 +255,7 @@ class c_standard_path_user_login extends c_standard_path { $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REQUIRED, TRUE); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_VALUE, $this->pr_sanitize('login_form-password', 0)->get_value()); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, 'field-input-password'); $form->set_tag($tag); unset($tag); @@ -262,6 +263,7 @@ class c_standard_path_user_login extends c_standard_path { // button: reset $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_RESET, 'login_form-reset', array('login_form-button-reset')); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_VALUE, $this->pr_get_text(11)); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, 'field-button-reset'); $form->set_tag($tag); unset($tag); @@ -270,6 +272,7 @@ class c_standard_path_user_login extends c_standard_path { $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SUBMIT, 'login_form-login', array('login_form-button-login')); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_VALUE, $this->pr_get_text(12)); #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_ACTION, $settings['base_path'] . 's/u/login'); // custom submit destination, but would require /s/u/login to redirect back to here. + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, 'field-button-submit'); $form->set_tag($tag); unset($tag); unset($problem_fields); @@ -308,15 +311,14 @@ class c_standard_path_user_login extends c_standard_path { */ protected function pr_do_login(&$http, &$database, &$session, $settings) { $problems = array(); - if (empty($_POST['login_form-username']) || !is_string($_POST['login_form-username'])) { - $problems[] = c_base_form_problem::s_create_error('login_form-username', self::pr_get_text(10)); + if (empty($_POST['login_form-user_name']) || !is_string($_POST['login_form-user_name'])) { + $problems[] = c_base_form_problem::s_create_error('login_form-user_name', self::pr_get_text(10)); } - elseif ($_POST['login_form-username'] == self::USER_PUBLIC) { + elseif ($_POST['login_form-user_name'] == self::USER_PUBLIC) { // explicitly deny access to internal user accounts - $problems[] = c_base_form_problem::s_create_error('login_form-username', self::pr_get_text(10)); + $problems[] = c_base_form_problem::s_create_error('login_form-user_name', self::pr_get_text(10)); } - - if (empty($_POST['login_form-password']) || !is_string($_POST['login_form-username'])) { + elseif (empty($_POST['login_form-password']) || !is_string($_POST['login_form-user_name'])) { $problems[] = c_base_form_problem::s_create_error('login_form-password', self::pr_get_text(10)); } @@ -331,7 +333,7 @@ class c_standard_path_user_login extends c_standard_path { } $connection_string = $database->get_connection_string(); - $connection_string->set_user($_POST['login_form-username']); + $connection_string->set_user($_POST['login_form-user_name']); $connection_string->set_password($_POST['login_form-password']); $database->set_connection_string($connection_string); @@ -383,7 +385,7 @@ class c_standard_path_user_login extends c_standard_path { if ($access_denied) { // it is possible the user name might not exist, so try to auto-create the username if the username does not exist. - $ensure_result = $this->pr_do_ensure_user_account($settings, $_POST['login_form-username']); + $ensure_result = $this->pr_do_ensure_user_account($settings, $_POST['login_form-user_name']); if ($ensure_result instanceof c_base_return_int) { $ensure_result = $ensure_result->get_value_exact(); @@ -395,7 +397,7 @@ class c_standard_path_user_login extends c_standard_path { c_standard_index::s_do_initialize_database($database); if ($database instanceof c_standard_database) { - $database->do_log_user(c_base_log::TYPE_CREATE, c_base_http_status::OK, array('user_name' => $_POST['login_form-username'])); + $database->do_log_user(c_base_log::TYPE_CREATE, c_base_http_status::OK, array('user_name' => $_POST['login_form-user_name'])); $database->do_log_user(c_base_log::TYPE_CONNECT, c_base_http_status::OK, array('expires' => $session->get_timeout_expire()->get_value_exact())); } } @@ -441,7 +443,7 @@ class c_standard_path_user_login extends c_standard_path { c_standard_index::s_do_initialize_database($database); // if LDAP is available, make sure the account information exists. - $ldap = $this->pr_load_ldap_data($settings, $_POST['login_form-username']); + $ldap = $this->pr_load_ldap_data($settings, $_POST['login_form-user_name']); if ($ldap['status']) { $this->pr_update_user_data($database, $ldap); } @@ -458,7 +460,7 @@ class c_standard_path_user_login extends c_standard_path { if (c_base_return::s_has_error($connected) || $connected instanceof c_base_return_false) { // @todo: rewrite this to handle multiple errors. if ($access_denied) { - $problems[] = c_base_form_problem::s_create_error('login_form-username', self::pr_get_text(10)); + $problems[] = c_base_form_problem::s_create_error('login_form-user_name', self::pr_get_text(10)); } else { $errors = $connected->get_error(); @@ -495,7 +497,7 @@ class c_standard_path_user_login extends c_standard_path { // @todo: load and store custom settings (loaded from the database and/or ldap). #$session->set_settings($user_data); - $session->set_name($_POST['login_form-username']); + $session->set_name($_POST['login_form-user_name']); $session->set_password($_POST['login_form-password']); // the session needs to be opened and the data needs to be saved on successful login. @@ -511,9 +513,9 @@ class c_standard_path_user_login extends c_standard_path { unset($socket_error); } else { - $ldap = $this->pr_load_ldap_data($settings, $_POST['login_form-username']); + $ldap = $this->pr_load_ldap_data($settings, $_POST['login_form-user_name']); if (!$ldap['status']) { - $problems[] = c_base_form_problem::s_create_error('login_form-username', 'Failed to retrieve ldap information for specified user.'); + $problems[] = c_base_form_problem::s_create_error('login_form-user_name', 'Failed to retrieve ldap information for specified user.'); } $pushed = $session->do_push($settings['session_expire'], $settings['session_max']); @@ -873,16 +875,16 @@ class c_standard_path_user_login extends c_standard_path { protected function pr_create_html_add_header_link_canonical() { $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_LOGIN); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . c_standard_paths::URI_LOGIN); $this->html->set_header($tag); unset($tag); } /** - * Implements pr_get_title(). + * Implements pr_get_text_title(). */ - protected function pr_get_title($arguments = array()) { + protected function pr_get_text_title($arguments = array()) { return $this->pr_get_text(0, $arguments); } diff --git a/common/standard/paths/u/logout.php b/common/standard/paths/u/logout.php index 85afd22..c7537c3 100644 --- a/common/standard/paths/u/logout.php +++ b/common/standard/paths/u/logout.php @@ -118,9 +118,9 @@ class c_standard_path_user_logout extends c_standard_path { } /** - * Implements pr_get_title(). + * Implements pr_get_text_title(). */ - protected function pr_get_title($arguments = array()) { + protected function pr_get_text_title($arguments = array()) { return $this->pr_get_text(0, $arguments); } diff --git a/common/standard/paths/u/user_create.php b/common/standard/paths/u/user_create.php new file mode 100644 index 0000000..3149671 --- /dev/null +++ b/common/standard/paths/u/user_create.php @@ -0,0 +1,79 @@ +pr_assign_defaults($http, $database, $session, $settings); + + $wrapper = $this->pr_create_tag_section(array(1 => 0)); + + // initialize the content as HTML. + $this->pr_create_html(); + $this->html->set_tag($wrapper); + unset($wrapper); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Create User'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_delete.php b/common/standard/paths/u/user_delete.php new file mode 100644 index 0000000..cf6ad90 --- /dev/null +++ b/common/standard/paths/u/user_delete.php @@ -0,0 +1,79 @@ +pr_assign_defaults($http, $database, $session, $settings); + + $wrapper = $this->pr_create_tag_section(array(1 => 0)); + + // initialize the content as HTML. + $this->pr_create_html(); + $this->html->set_tag($wrapper); + unset($wrapper); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Delete User'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_lock.php b/common/standard/paths/u/user_lock.php new file mode 100644 index 0000000..73b3fdd --- /dev/null +++ b/common/standard/paths/u/user_lock.php @@ -0,0 +1,79 @@ +pr_assign_defaults($http, $database, $session, $settings); + + $wrapper = $this->pr_create_tag_section(array(1 => 0)); + + // initialize the content as HTML. + $this->pr_create_html(); + $this->html->set_tag($wrapper); + unset($wrapper); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Lock User'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_settings.php b/common/standard/paths/u/user_settings.php new file mode 100644 index 0000000..4cced3f --- /dev/null +++ b/common/standard/paths/u/user_settings.php @@ -0,0 +1,124 @@ +pr_assign_defaults($http, $database, $session, $settings); + + $wrapper = $this->pr_create_tag_section(array(1 => 0)); + + // initialize the content as HTML. + $this->pr_create_html(); + $this->html->set_tag($wrapper); + unset($wrapper); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'User Settings'; + break; + case 1: + $string = ''; + break; + case 2: + $string = ''; + break; + case 3: + $string = ''; + break; + case 4: + $string = 'Public'; + break; + case 5: + $string = 'User'; + break; + case 6: + $string = 'Requester'; + break; + case 7: + $string = 'Drafter'; + break; + case 8: + $string = 'Editor'; + break; + case 9: + $string = 'Reviewer'; + break; + case 10: + $string = 'Financer'; + break; + case 11: + $string = 'Insurer'; + break; + case 12: + $string = 'Publisher'; + break; + case 13: + $string = 'Auditor'; + break; + case 14: + $string = 'Manager'; + break; + case 15: + $string = 'Administer'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_unlock.php b/common/standard/paths/u/user_unlock.php new file mode 100644 index 0000000..a945891 --- /dev/null +++ b/common/standard/paths/u/user_unlock.php @@ -0,0 +1,79 @@ +pr_assign_defaults($http, $database, $session, $settings); + + $wrapper = $this->pr_create_tag_section(array(1 => 0)); + + // initialize the content as HTML. + $this->pr_create_html(); + $this->html->set_tag($wrapper); + unset($wrapper); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Unlock User'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_view.php b/common/standard/paths/u/user_view.php new file mode 100644 index 0000000..ba09ba0 --- /dev/null +++ b/common/standard/paths/u/user_view.php @@ -0,0 +1,124 @@ +pr_assign_defaults($http, $database, $session, $settings); + + $wrapper = $this->pr_create_tag_section(array(1 => 0)); + + // initialize the content as HTML. + $this->pr_create_html(); + $this->html->set_tag($wrapper); + unset($wrapper); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'View User'; + break; + case 1: + $string = ''; + break; + case 2: + $string = ''; + break; + case 3: + $string = ''; + break; + case 4: + $string = 'Public'; + break; + case 5: + $string = 'User'; + break; + case 6: + $string = 'Requester'; + break; + case 7: + $string = 'Drafter'; + break; + case 8: + $string = 'Editor'; + break; + case 9: + $string = 'Reviewer'; + break; + case 10: + $string = 'Financer'; + break; + case 11: + $string = 'Insurer'; + break; + case 12: + $string = 'Publisher'; + break; + case 13: + $string = 'Auditor'; + break; + case 14: + $string = 'Manager'; + break; + case 15: + $string = 'Administer'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/theme/classes/theme_html.php b/common/theme/classes/theme_html.php index 3344273..d7f5cb3 100644 --- a/common/theme/classes/theme_html.php +++ b/common/theme/classes/theme_html.php @@ -128,21 +128,11 @@ class c_theme_html extends c_base_return { $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, $id); } - // populate default class names based on tag type. - $class = array(); - self::s_p_populate_default_class_names($type, $id, $class); - if (is_array($classes)) { - foreach ($classes as $class_string) { - if (is_string($class_string)) { - $class[] = $class_string; - } - } - unset($class_string); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $classes); } - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $class); - unset($class); + self::s_p_populate_tag_class_names($tag, $type, $id); if (is_string($text)) { $tag->set_text($text); @@ -178,6 +168,7 @@ class c_theme_html extends c_base_return { * @return c_base_return_status * TRUE on success, FALSE otherwise. * FALSE with error bit set is returned on error. + * This does perform clone(). */ public function set_html($html) { if (!($html instanceof c_base_html)) { @@ -196,6 +187,7 @@ class c_theme_html extends c_base_return { * The markup html object. * FALSE is returned if no id is assigned. * FALSE with error bit set is returned on error. + * This does perform clone(). */ public function get_html() { if (!($this->html instanceof c_base_html)) { @@ -269,6 +261,7 @@ class c_theme_html extends c_base_return { * The markup tags object. * FALSE is returned if no id is assigned. * FALSE with error bit set is returned on error. + * This does perform clone(). */ public function get_http() { if (!($this->http instanceof c_base_http)) { @@ -317,1152 +310,557 @@ class c_theme_html extends c_base_return { /** * Generate a common list of class names for a given tag type. * + * @param c_base_markup_tag &$tag + * The tag to operate on. * @param int $type * A c_base_markup_tag type id. * @param string|null $id * A unique ID field associated with the tag. * If null, then this is ignored. - * @param array &$classes - * An array of class names. */ - private static function s_p_populate_default_class_names($type, $id, &$class) { - if ($type === c_base_markup_tag::TYPE_A) { - $class[] = 'text'; - $class[] = 'text-link'; + private static function s_p_populate_tag_class_names(&$tag, $type, $id) { + $class_1 = NULL; + $class_2 = NULL; + $class_3 = NULL; - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-link'; - } + if ($type === c_base_markup_tag::TYPE_A) { + $class_1 = 'text'; + $class_2 = 'text-link'; } elseif ($type === c_base_markup_tag::TYPE_ABBR) { - $class[] = 'text'; - $class[] = 'text-abbreviation'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-abbreviation'; - } + $class_1 = 'text'; + $class_2 = 'text-abbreviation'; } elseif ($type === c_base_markup_tag::TYPE_ADDRESS) { - $class[] = 'structure'; - $class[] = 'structure-address'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-address'; - } + $class_1 = 'structure'; + $class_2 = 'structure-address'; } elseif ($type === c_base_markup_tag::TYPE_AREA) { - $class[] = 'datum'; - $class[] = 'datum-area'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-area'; - } + $class_1 = 'datum'; + $class_2 = 'datum-area'; } elseif ($type === c_base_markup_tag::TYPE_ARTICLE) { - $class[] = 'structure'; - $class[] = 'structure-article'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-article'; - } + $class_1 = 'structure'; + $class_2 = 'structure-article'; } elseif ($type === c_base_markup_tag::TYPE_ASIDE) { - $class[] = 'structure'; - $class[] = 'structure-aside'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-aside'; - } + $class_1 = 'structure'; + $class_2 = 'structure-aside'; } elseif ($type === c_base_markup_tag::TYPE_AUDIO) { - $class[] = 'media'; - $class[] = 'media-audio'; - - if (!is_null($id)) { - $class[] = $id . '-media'; - $class[] = $id . '-media-audio'; - } + $class_1 = 'media'; + $class_2 = 'media-audio'; } elseif ($type === c_base_markup_tag::TYPE_BOLD) { - $class[] = 'format'; - $class[] = 'format-strong'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-strong'; - } + $class_1 = 'format'; + $class_2 = 'format-strong'; } elseif ($type === c_base_markup_tag::TYPE_BDI) { - $class[] = 'text'; - $class[] = 'text-bdi'; - $class[] = 'text-direction'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-bdi'; - $class[] = $id . '-text-direction'; - } + $class_1 = 'text'; + $class_2 = 'text-bdi'; + $class_3 = 'text-direction'; } elseif ($type === c_base_markup_tag::TYPE_BDO) { - $class[] = 'text'; - $class[] = 'text-bdo'; - $class[] = 'text-direction'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-bdo'; - $class[] = $id . '-text-direction'; - } + $class_1 = 'text'; + $class_2 = 'text-bdo'; + $class_3 = 'text-direction'; } elseif ($type === c_base_markup_tag::TYPE_BLOCKQUOTE) { - $class[] = 'text'; - $class[] = 'text-blockquote'; - $class[] = 'text-quote'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-blockquote'; - $class[] = $id . '-text-quote'; - } + $class_1 = 'text'; + $class_2 = 'text-blockquote'; + $class_3 = 'text-quote'; } elseif ($type === c_base_markup_tag::TYPE_BREAK) { - $class[] = 'structure'; - $class[] = 'structure-break'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-break'; - } + $class_1 = 'structure'; + $class_2 = 'structure-break'; } elseif ($type === c_base_markup_tag::TYPE_BUTTON) { - $class[] = 'field'; - $class[] = 'field-button'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-button'; - } + $class_1 = 'field'; + $class_2 = 'field-button'; } elseif ($type === c_base_markup_tag::TYPE_CANVAS) { - $class[] = 'structure'; - $class[] = 'structure-canvas'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-canvas'; - } + $class_1 = 'structure'; + $class_2 = 'structure-canvas'; } elseif ($type === c_base_markup_tag::TYPE_CHECKBOX) { - $class[] = 'field'; - $class[] = 'field-checkbox'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-checkbox'; - } + $class_1 = 'field'; + $class_2 = 'field-checkbox'; } elseif ($type === c_base_markup_tag::TYPE_CITE) { - $class[] = 'text'; - $class[] = 'text-cite'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-cite'; - } + $class_1 = 'text'; + $class_2 = 'text-cite'; } elseif ($type === c_base_markup_tag::TYPE_CODE) { - $class[] = 'text'; - $class[] = 'text-code'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-code'; - } + $class_1 = 'text'; + $class_2 = 'text-code'; } elseif ($type === c_base_markup_tag::TYPE_COL) { - $class[] = 'structure'; - $class[] = 'structure-column'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-column'; - } + $class_1 = 'structure'; + $class_2 = 'structure-column'; } elseif ($type === c_base_markup_tag::TYPE_COLOR) { - $class[] = 'field'; - $class[] = 'field-color'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-color'; - } + $class_1 = 'field'; + $class_2 = 'field-color'; } elseif ($type === c_base_markup_tag::TYPE_COL_GROUP) { - $class[] = 'structure'; - $class[] = 'structure-column_group'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-column_group'; - } + $class_1 = 'structure'; + $class_2 = 'structure-column_group'; } elseif ($type === c_base_markup_tag::TYPE_DATA) { - $class[] = 'datum'; - $class[] = 'datum-data'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-data'; - } + $class_1 = 'datum'; + $class_2 = 'datum-data'; } elseif ($type === c_base_markup_tag::TYPE_DATA) { - $class[] = 'datum'; - $class[] = 'datum-data_list'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-data_list'; - } + $class_1 = 'datum'; + $class_2 = 'datum-data_list'; } elseif ($type === c_base_markup_tag::TYPE_DATE) { - $class[] = 'field'; - $class[] = 'field-date'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-date'; - } + $class_1 = 'field'; + $class_2 = 'field-date'; } elseif ($type === c_base_markup_tag::TYPE_DATE_TIME_LOCAL) { - $class[] = 'field'; - $class[] = 'field-date_local_time'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-date_local_time'; - } + $class_1 = 'field'; + $class_2 = 'field-date_local_time'; } elseif ($type === c_base_markup_tag::TYPE_TERM_DESCRIPTION) { - $class[] = 'text'; - $class[] = 'text-term_description'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-term_description'; - } + $class_1 = 'text'; + $class_2 = 'text-term_description'; } elseif ($type === c_base_markup_tag::TYPE_DEL) { - $class[] = 'format'; - $class[] = 'format-delete'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-format'; - } + $class_1 = 'format'; + $class_2 = 'format-delete'; } elseif ($type === c_base_markup_tag::TYPE_DETAILS) { - $class[] = 'structure'; - $class[] = 'structure-details'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-details'; - } + $class_1 = 'structure'; + $class_2 = 'structure-details'; } elseif ($type === c_base_markup_tag::TYPE_DFN) { - $class[] = 'text'; - $class[] = 'text-definition'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-definition'; - } + $class_1 = 'text'; + $class_2 = 'text-definition'; } elseif ($type === c_base_markup_tag::TYPE_DIALOG) { - $class[] = 'structure'; - $class[] = 'structure-dialog'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-dialog'; - } + $class_1 = 'structure'; + $class_2 = 'structure-dialog'; } elseif ($type === c_base_markup_tag::TYPE_DIVIDER) { - $class[] = 'structure'; - $class[] = 'structure-divider'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-divider'; - } + $class_1 = 'structure'; + $class_2 = 'structure-divider'; } elseif ($type === c_base_markup_tag::TYPE_DIVIDER) { - $class[] = 'structure'; - $class[] = 'structure-divider'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-divider'; - } + $class_1 = 'structure'; + $class_2 = 'structure-divider'; } elseif ($type === c_base_markup_tag::TYPE_DEFINITION_LIST) { - $class[] = 'structure'; - $class[] = 'structure-definition_list'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-definition_list'; - } + $class_1 = 'structure'; + $class_2 = 'structure-definition_list'; } elseif ($type === c_base_markup_tag::TYPE_TERM_NAME) { - $class[] = 'text'; - $class[] = 'text-term_name'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-term_name'; - } + $class_1 = 'text'; + $class_2 = 'text-term_name'; } elseif ($type === c_base_markup_tag::TYPE_EM) { - $class[] = 'format'; - $class[] = 'format-emphasis'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-emphasis'; - } + $class_1 = 'format'; + $class_2 = 'format-emphasis'; } elseif ($type === c_base_markup_tag::TYPE_EMAIL) { - $class[] = 'field'; - $class[] = 'field-email'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-email'; - } + $class_1 = 'field'; + $class_2 = 'field-email'; } elseif ($type === c_base_markup_tag::TYPE_EMBED) { - $class[] = 'media'; - $class[] = 'media-embed'; - - if (!is_null($id)) { - $class[] = $id . '-media'; - $class[] = $id . '-media-embed'; - } + $class_1 = 'media'; + $class_2 = 'media-embed'; } elseif ($type === c_base_markup_tag::TYPE_FIELD_SET) { - $class[] = 'structure'; - $class[] = 'structure-field_set'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-field_set'; - } + $class_1 = 'structure'; + $class_2 = 'structure-field_set'; } elseif ($type === c_base_markup_tag::TYPE_FIGURE) { - $class[] = 'structure'; - $class[] = 'structure-figure'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-figure'; - } + $class_1 = 'structure'; + $class_2 = 'structure-figure'; } elseif ($type === c_base_markup_tag::TYPE_FIGURE_CAPTION) { - $class[] = 'text'; - $class[] = 'text-figure_caption'; - $class[] = 'text-caption'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-figure_caption'; - $class[] = $id . '-text-caption'; - } + $class_1 = 'text'; + $class_2 = 'text-figure_caption'; + $class_3 = 'text-caption'; } elseif ($type === c_base_markup_tag::TYPE_FILE) { - $class[] = 'field'; - $class[] = 'field-file'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-file'; - } + $class_1 = 'field'; + $class_2 = 'field-file'; } elseif ($type === c_base_markup_tag::TYPE_FOOTER) { - $class[] = 'structure'; - $class[] = 'structure-footer'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-footer'; - } + $class_1 = 'structure'; + $class_2 = 'structure-footer'; } elseif ($type === c_base_markup_tag::TYPE_FORM) { - $class[] = 'structure'; - $class[] = 'structure-form'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-form'; - } + $class_1 = 'structure'; + $class_2 = 'structure-form'; } elseif ($type === c_base_markup_tag::TYPE_H1) { - $class[] = 'text'; - $class[] = 'text-heading'; - $class[] = 'text-heading_1'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-heading'; - $class[] = $id . '-text-heading_1'; - } + $class_1 = 'text'; + $class_2 = 'text-heading'; + $class_3 = 'text-heading_1'; } elseif ($type === c_base_markup_tag::TYPE_H2) { - $class[] = 'text'; - $class[] = 'text-heading'; - $class[] = 'text-heading_2'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-heading'; - $class[] = $id . '-text-heading_2'; - } + $class_1 = 'text'; + $class_2 = 'text-heading'; + $class_3 = 'text-heading_2'; } elseif ($type === c_base_markup_tag::TYPE_H3) { - $class[] = 'text'; - $class[] = 'text-heading'; - $class[] = 'text-heading_3'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-heading'; - $class[] = $id . '-text-heading_3'; - } + $class_1 = 'text'; + $class_2 = 'text-heading'; + $class_3 = 'text-heading_3'; } elseif ($type === c_base_markup_tag::TYPE_H4) { - $class[] = 'text'; - $class[] = 'text-heading'; - $class[] = 'text-heading_4'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-heading'; - $class[] = $id . '-text-heading_4'; - } + $class_1 = 'text'; + $class_2 = 'text-heading'; + $class_3 = 'text-heading_4'; } elseif ($type === c_base_markup_tag::TYPE_H5) { - $class[] = 'text'; - $class[] = 'text-heading'; - $class[] = 'text-heading_5'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-heading'; - $class[] = $id . '-text-heading_5'; - } + $class_1 = 'text'; + $class_2 = 'text-heading'; + $class_3 = 'text-heading_5'; } elseif ($type === c_base_markup_tag::TYPE_H6) { - $class[] = 'text'; - $class[] = 'text-heading'; - $class[] = 'text-heading_6'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-heading'; - $class[] = $id . '-text-heading_6'; - } + $class_1 = 'text'; + $class_2 = 'text-heading'; + $class_3 = 'text-heading_6'; + } + elseif ($type === c_base_markup_tag::TYPE_HX) { + $class_1 = 'text'; + $class_2 = 'text-heading'; } elseif ($type === c_base_markup_tag::TYPE_HEADER) { - $class[] = 'structure'; - $class[] = 'structure-header'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-header'; - } + $class_1 = 'structure'; + $class_2 = 'structure-header'; } elseif ($type === c_base_markup_tag::TYPE_HIDDEN) { - $class[] = 'field'; - $class[] = 'field-hidden'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-hidden'; - } + $class_1 = 'field'; + $class_2 = 'field-hidden'; } elseif ($type === c_base_markup_tag::TYPE_HORIZONTAL_RULER) { - $class[] = 'structure'; - $class[] = 'structure-horizontal_ruler'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-horizontal_ruler'; - } + $class_1 = 'structure'; + $class_2 = 'structure-horizontal_ruler'; } elseif ($type === c_base_markup_tag::TYPE_ITALICS) { - $class[] = 'format'; - $class[] = 'format-emphasis'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-emphasis'; - } + $class_1 = 'format'; + $class_2 = 'format-emphasis'; } elseif ($type === c_base_markup_tag::TYPE_HORIZONTAL_RULER) { - $class[] = 'structure'; - $class[] = 'structure-horizontal_ruler'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-horizontal_ruler'; - } + $class_1 = 'structure'; + $class_2 = 'structure-horizontal_ruler'; } elseif ($type === c_base_markup_tag::TYPE_INLINE_FRAME) { - $class[] = 'structure'; - $class[] = 'structure-inline_frame'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-inline_frame'; - } + $class_1 = 'structure'; + $class_2 = 'structure-inline_frame'; } elseif ($type === c_base_markup_tag::TYPE_IMAGE) { - $class[] = 'media'; - $class[] = 'media-image'; - - if (!is_null($id)) { - $class[] = $id . '-media'; - $class[] = $id . '-media-image'; - } + $class_1 = 'media'; + $class_2 = 'media-image'; } elseif ($type === c_base_markup_tag::TYPE_INPUT) { - $class[] = 'field'; - $class[] = 'field-input'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-input'; - } + $class_1 = 'field'; + $class_2 = 'field-input'; } elseif ($type === c_base_markup_tag::TYPE_INS) { - $class[] = 'text'; - $class[] = 'text-insert'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-insert'; - } + $class_1 = 'text'; + $class_2 = 'text-insert'; } elseif ($type === c_base_markup_tag::TYPE_KEYBOARD) { - $class[] = 'text'; - $class[] = 'text-keyboard'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-keyboard'; - } + $class_1 = 'text'; + $class_2 = 'text-keyboard'; } elseif ($type === c_base_markup_tag::TYPE_KEY_GEN) { - $class[] = 'field'; - $class[] = 'field-key_generator'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-key_generator'; - } + $class_1 = 'field'; + $class_2 = 'field-key_generator'; } elseif ($type === c_base_markup_tag::TYPE_LABEL) { - $class[] = 'field'; - $class[] = 'field-label'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-label'; - } + $class_1 = 'field'; + $class_2 = 'field-label'; } elseif ($type === c_base_markup_tag::TYPE_LEGEND) { - $class[] = 'text'; - $class[] = 'text-legend'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-legend'; - } + $class_1 = 'text'; + $class_2 = 'text-legend'; } elseif ($type === c_base_markup_tag::TYPE_LIST_ITEM) { - $class[] = 'text'; - $class[] = 'text-list_item'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-list_item'; - } + $class_1 = 'text'; + $class_2 = 'text-list_item'; } elseif ($type === c_base_markup_tag::TYPE_MAIN) { - $class[] = 'structure'; - $class[] = 'structure-main'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-main'; - } + $class_1 = 'structure'; + $class_2 = 'structure-main'; } elseif ($type === c_base_markup_tag::TYPE_MAP) { - $class[] = 'structure'; - $class[] = 'structure-image_map'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-image_map'; - } + $class_1 = 'structure'; + $class_2 = 'structure-image_map'; } elseif ($type === c_base_markup_tag::TYPE_MARK) { - $class[] = 'format'; - $class[] = 'format-mark'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-mark'; - } + $class_1 = 'format'; + $class_2 = 'format-mark'; } elseif ($type === c_base_markup_tag::TYPE_MENU) { - $class[] = 'structure'; - $class[] = 'structure-menu'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-menu'; - } + $class_1 = 'structure'; + $class_2 = 'structure-menu'; } elseif ($type === c_base_markup_tag::TYPE_MENU_ITEM) { - $class[] = 'structure'; - $class[] = 'structure-menu_item'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-menu_item'; - } + $class_1 = 'structure'; + $class_2 = 'structure-menu_item'; } elseif ($type === c_base_markup_tag::TYPE_METER) { - $class[] = 'field'; - $class[] = 'field-meter'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-meter'; - } + $class_1 = 'field'; + $class_2 = 'field-meter'; } elseif ($type === c_base_markup_tag::TYPE_MONTH) { - $class[] = 'field'; - $class[] = 'field-month'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-month'; - } + $class_1 = 'field'; + $class_2 = 'field-month'; } elseif ($type === c_base_markup_tag::TYPE_NAVIGATION) { - $class[] = 'structure'; - $class[] = 'structure-navigation'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-navigation'; - } + $class_1 = 'structure'; + $class_2 = 'structure-navigation'; } elseif ($type === c_base_markup_tag::TYPE_NO_SCRIPT) { - $class[] = 'structure'; - $class[] = 'structure-no_script'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-no_script'; - } + $class_1 = 'structure'; + $class_2 = 'structure-no_script'; } elseif ($type === c_base_markup_tag::TYPE_NUMBER) { - $class[] = 'field'; - $class[] = 'field-number'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-number'; - } + $class_1 = 'field'; + $class_2 = 'field-number'; } elseif ($type === c_base_markup_tag::TYPE_OBJECT) { - $class[] = 'media'; - $class[] = 'media-object'; - - if (!is_null($id)) { - $class[] = $id . '-media'; - $class[] = $id . '-media-object'; - } + $class_1 = 'media'; + $class_2 = 'media-object'; } elseif ($type === c_base_markup_tag::TYPE_ORDERED_LIST) { - $class[] = 'structure'; - $class[] = 'structure-ordered_list'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-ordered_list'; - } + $class_1 = 'structure'; + $class_2 = 'structure-ordered_list'; } elseif ($type === c_base_markup_tag::TYPE_OPTIONS_GROUP) { - $class[] = 'structure'; - $class[] = 'structure-options_group'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-options_group'; - } + $class_1 = 'structure'; + $class_2 = 'structure-options_group'; } elseif ($type === c_base_markup_tag::TYPE_OPTION) { - $class[] = 'datum'; - $class[] = 'datum-option'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-option'; - } + $class_1 = 'datum'; + $class_2 = 'datum-option'; } elseif ($type === c_base_markup_tag::TYPE_OUTPUT) { - $class[] = 'datum'; - $class[] = 'datum-output'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-output'; - } + $class_1 = 'datum'; + $class_2 = 'datum-output'; } elseif ($type === c_base_markup_tag::TYPE_PARAGRAPH) { - $class[] = 'text'; - $class[] = 'text-paragraph'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-paragraph'; - } + $class_1 = 'text'; + $class_2 = 'text-paragraph'; } elseif ($type === c_base_markup_tag::TYPE_PARAM) { - $class[] = 'datum'; - $class[] = 'datum-parameter'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-parameter'; - } + $class_1 = 'datum'; + $class_2 = 'datum-parameter'; } elseif ($type === c_base_markup_tag::TYPE_PASSWORD) { - $class[] = 'field'; - $class[] = 'field-password'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-password'; - } + $class_1 = 'field'; + $class_2 = 'field-password'; } elseif ($type === c_base_markup_tag::TYPE_PICTURE) { - $class[] = 'structure'; - $class[] = 'structure-picture'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-picture'; - } + $class_1 = 'structure'; + $class_2 = 'structure-picture'; } elseif ($type === c_base_markup_tag::TYPE_PREFORMATTED) { - $class[] = 'format'; - $class[] = 'format-preformatted'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-preformatted'; - } + $class_1 = 'format'; + $class_2 = 'format-preformatted'; } elseif ($type === c_base_markup_tag::TYPE_PROGRESS) { // note: 'media' is the closest thing I can think of for this tag (as in, it is like an image). - $class[] = 'media'; - $class[] = 'media-progress'; - - if (!is_null($id)) { - $class[] = $id . '-media'; - $class[] = $id . '-media-progress'; - } + $class_1 = 'media'; + $class_2 = 'media-progress'; } elseif ($type === c_base_markup_tag::TYPE_PREFORMATTED) { - $class[] = 'format'; - $class[] = 'format-preformatted'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-preformatted'; - } + $class_1 = 'format'; + $class_2 = 'format-preformatted'; } elseif ($type === c_base_markup_tag::TYPE_Q) { - $class[] = 'text'; - $class[] = 'text-quote'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-quote'; - } + $class_1 = 'text'; + $class_2 = 'text-quote'; } elseif ($type === c_base_markup_tag::TYPE_RADIO) { - $class[] = 'field'; - $class[] = 'field-radio'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-radio'; - } + $class_1 = 'field'; + $class_2 = 'field-radio'; } elseif ($type === c_base_markup_tag::TYPE_RANGE) { - $class[] = 'field'; - $class[] = 'field-range'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-range'; - } + $class_1 = 'field'; + $class_2 = 'field-range'; } elseif ($type === c_base_markup_tag::TYPE_RESET) { - $class[] = 'field'; - $class[] = 'field-reset'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-reset'; - } + $class_1 = 'field'; + $class_2 = 'field-reset'; } elseif ($type === c_base_markup_tag::TYPE_RUBY_PARENTHESIS) { - $class[] = 'format'; - $class[] = 'format-ruby_parenthesis'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-ruby_parenthesis'; - } + $class_1 = 'format'; + $class_2 = 'format-ruby_parenthesis'; } elseif ($type === c_base_markup_tag::TYPE_RUBY_PRONUNCIATION) { - $class[] = 'format'; - $class[] = 'format-ruby_pronunciation'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-ruby_pronunciation'; - } + $class_1 = 'format'; + $class_2 = 'format-ruby_pronunciation'; } elseif ($type === c_base_markup_tag::TYPE_RUBY) { - $class[] = 'format'; - $class[] = 'format-ruby'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-ruby'; - } + $class_1 = 'format'; + $class_2 = 'format-ruby'; } elseif ($type === c_base_markup_tag::TYPE_STRIKE_THROUGH) { - $class[] = 'format'; - $class[] = 'format-strike_through'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-strike_through'; - } + $class_1 = 'format'; + $class_2 = 'format-strike_through'; } elseif ($type === c_base_markup_tag::TYPE_SAMPLE) { - $class[] = 'text'; - $class[] = 'text-sample'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-sample'; - } + $class_1 = 'text'; + $class_2 = 'text-sample'; } elseif ($type === c_base_markup_tag::TYPE_SEARCH) { - $class[] = 'field'; - $class[] = 'field-search'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-search'; - } + $class_1 = 'field'; + $class_2 = 'field-search'; } elseif ($type === c_base_markup_tag::TYPE_SECTION) { - $class[] = 'structure'; - $class[] = 'structure-section'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-section'; - } + $class_1 = 'structure'; + $class_2 = 'structure-section'; } elseif ($type === c_base_markup_tag::TYPE_SELECT) { - $class[] = 'field'; - $class[] = 'field-select'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-select'; - } + $class_1 = 'field'; + $class_2 = 'field-select'; } elseif ($type === c_base_markup_tag::TYPE_SMALL) { - $class[] = 'format'; - $class[] = 'format-small'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-small'; - } + $class_1 = 'format'; + $class_2 = 'format-small'; } elseif ($type === c_base_markup_tag::TYPE_SOURCE) { - $class[] = 'datum'; - $class[] = 'datum-source'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-source'; - } + $class_1 = 'datum'; + $class_2 = 'datum-source'; } elseif ($type === c_base_markup_tag::TYPE_SPAN) { - $class[] = 'structure'; - $class[] = 'structure-span'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-span'; - } + $class_1 = 'structure'; + $class_2 = 'structure-span'; } elseif ($type === c_base_markup_tag::TYPE_STRONG) { - $class[] = 'format'; - $class[] = 'format-strong'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-strong'; - } + $class_1 = 'format'; + $class_2 = 'format-strong'; } elseif ($type === c_base_markup_tag::TYPE_SUB_SCRIPT) { - $class[] = 'format'; - $class[] = 'format-sub_script'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-sub_script'; - } + $class_1 = 'format'; + $class_2 = 'format-sub_script'; } elseif ($type === c_base_markup_tag::TYPE_SUBMIT) { - $class[] = 'field'; - $class[] = 'field-submit'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-submit'; - } + $class_1 = 'field'; + $class_2 = 'field-submit'; } elseif ($type === c_base_markup_tag::TYPE_SUPER_SCRIPT) { - $class[] = 'format'; - $class[] = 'format-super_script'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-super_script'; - } + $class_1 = 'format'; + $class_2 = 'format-super_script'; } elseif ($type === c_base_markup_tag::TYPE_SVG) { - $class[] = 'media'; - $class[] = 'media-svg'; - - if (!is_null($id)) { - $class[] = $id . '-media'; - $class[] = $id . '-media-svg'; - } + $class_1 = 'media'; + $class_2 = 'media-svg'; } elseif ($type === c_base_markup_tag::TYPE_TABLE) { - $class[] = 'structure'; - $class[] = 'structure-table'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-table'; - } + $class_1 = 'structure'; + $class_2 = 'structure-table'; } elseif ($type === c_base_markup_tag::TYPE_TABLE_BODY) { - $class[] = 'structure'; - $class[] = 'structure-table_body'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-table_body'; - } + $class_1 = 'structure'; + $class_2 = 'structure-table_body'; } elseif ($type === c_base_markup_tag::TYPE_TABLE_CELL) { - $class[] = 'structure'; - $class[] = 'structure-table_cell'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-table_cell'; - } + $class_1 = 'structure'; + $class_2 = 'structure-table_cell'; } elseif ($type === c_base_markup_tag::TYPE_TABLE_FOOTER) { - $class[] = 'structure'; - $class[] = 'structure-table_footer'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-table_footer'; - } + $class_1 = 'structure'; + $class_2 = 'structure-table_footer'; } elseif ($type === c_base_markup_tag::TYPE_TABLE_HEADER) { - $class[] = 'structure'; - $class[] = 'structure-table_header'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-table_header'; - } + $class_1 = 'structure'; + $class_2 = 'structure-table_header'; } elseif ($type === c_base_markup_tag::TYPE_TABLE_HEADER_CELL) { - $class[] = 'structure'; - $class[] = 'structure-table_header_cell'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-table_header_cell'; - } + $class_1 = 'structure'; + $class_2 = 'structure-table_header_cell'; } elseif ($type === c_base_markup_tag::TYPE_TABLE_ROW) { - $class[] = 'structure'; - $class[] = 'structure-table_row'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-table_row'; - } + $class_1 = 'structure'; + $class_2 = 'structure-table_row'; } elseif ($type === c_base_markup_tag::TYPE_TELEPHONE) { - $class[] = 'field'; - $class[] = 'field-telephone'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-telephone'; - } + $class_1 = 'field'; + $class_2 = 'field-telephone'; } elseif ($type === c_base_markup_tag::TYPE_TEMPLATE) { - $class[] = 'datum'; - $class[] = 'datum-template'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-template'; - } + $class_1 = 'datum'; + $class_2 = 'datum-template'; } elseif ($type === c_base_markup_tag::TYPE_TEXT) { - $class[] = 'field'; - $class[] = 'field-text'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-text'; - } + $class_1 = 'field'; + $class_2 = 'field-text'; } elseif ($type === c_base_markup_tag::TYPE_TEXT_AREA) { - $class[] = 'field'; - $class[] = 'field-text_area'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-text_area'; - } + $class_1 = 'field'; + $class_2 = 'field-text_area'; } elseif ($type === c_base_markup_tag::TYPE_TIME) { - $class[] = 'field'; - $class[] = 'field-time'; - - if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-time'; - } + $class_1 = 'field'; + $class_2 = 'field-time'; } elseif ($type === c_base_markup_tag::TYPE_TRACK) { - $class[] = 'datum'; - $class[] = 'datum-track'; - - if (!is_null($id)) { - $class[] = $id . '-datum'; - $class[] = $id . '-datum-track'; - } + $class_1 = 'datum'; + $class_2 = 'datum-track'; } elseif ($type === c_base_markup_tag::TYPE_UNDERLINE) { - $class[] = 'format'; - $class[] = 'format-underline'; - - if (!is_null($id)) { - $class[] = $id . '-format'; - $class[] = $id . '-format-underline'; - } + $class_1 = 'format'; + $class_2 = 'format-underline'; } elseif ($type === c_base_markup_tag::TYPE_UNORDERED_LIST) { - $class[] = 'structure'; - $class[] = 'structure-unordered_list'; - - if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-unordered_list'; - } + $class_1 = 'structure'; + $class_2 = 'structure-unordered_list'; } elseif ($type === c_base_markup_tag::TYPE_URL) { - $class[] = 'text'; - $class[] = 'text-url'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-url'; - } + $class_1 = 'text'; + $class_2 = 'text-url'; } elseif ($type === c_base_markup_tag::TYPE_VARIABLE) { - $class[] = 'text'; - $class[] = 'text-variable'; - - if (!is_null($id)) { - $class[] = $id . '-text'; - $class[] = $id . '-text-variable'; - } + $class_1 = 'text'; + $class_2 = 'text-variable'; } elseif ($type === c_base_markup_tag::TYPE_VIDEO) { - $class[] = 'media'; - $class[] = 'media-video'; + $class_1 = 'media'; + $class_2 = 'media-video'; + } + elseif ($type === c_base_markup_tag::TYPE_WEEK) { + $class_1 = 'field'; + $class_2 = 'field-week'; + } + elseif ($type === c_base_markup_tag::TYPE_WIDE_BREAK) { + $class_1 = 'structure'; + $class_2 = 'structure-wide_break'; + } + + if (!is_null($class_1)) { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $class_1); if (!is_null($id)) { - $class[] = $id . '-media'; - $class[] = $id . '-media-video'; + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $id . '-' . $class_1); } } - elseif ($type === c_base_markup_tag::TYPE_WEEK) { - $class[] = 'field'; - $class[] = 'field-week'; + unset($class_1); + + if (!is_null($class_2)) { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $class_2); if (!is_null($id)) { - $class[] = $id . '-field'; - $class[] = $id . '-field-week'; + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $id . '-' . $class_2); } } - elseif ($type === c_base_markup_tag::TYPE_WIDE_BREAK) { - $class[] = 'structure'; - $class[] = 'structure-wide_break'; + unset($class_2); + + if (!is_null($class_3)) { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $class_3); if (!is_null($id)) { - $class[] = $id . '-structure'; - $class[] = $id . '-structure-wide_break'; + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, $id . '-' . $class_3); } } + unset($class_3); } /** @@ -2562,6 +1960,12 @@ class c_theme_html extends c_base_return { $markup .= $child_markup; $markup .= ''; } + elseif ($type === c_base_markup_tag::TYPE_HX) { + $markup .= 'p_render_markup_attributes_global($tag) . $this->p_render_markup_attributes_event_handler($tag) . '>'; + $markup .= $tag->get_text()->get_value_exact(); + $markup .= $child_markup; + $markup .= ''; + } elseif ($type === c_base_markup_tag::TYPE_HEADER) { $markup .= 'p_render_markup_attributes_global($tag) . $this->p_render_markup_attributes_event_handler($tag) . '>'; $markup .= $tag->get_text()->get_value_exact(); diff --git a/documentation/loops.txt b/documentation/loops.txt index d267ef7..f443b41 100644 --- a/documentation/loops.txt +++ b/documentation/loops.txt @@ -163,4 +163,3 @@ To help understand what all this means, say that you have the following class: By providing both a set_value()/get_value() and set_array()/get_array() function combinations, it becomes possible for both example 2 and example 3 to be used. - This allows for the person developing the final project to make decisions that best suite their goals while avoiding modifying code as much as possible. - diff --git a/program/reservation/reservation_defaults_global.php b/program/reservation/reservation_defaults_global.php index 1334bf9..1e6302c 100644 --- a/program/reservation/reservation_defaults_global.php +++ b/program/reservation/reservation_defaults_global.php @@ -42,6 +42,9 @@ class c_base_defaults_global { // default log facility (17 = c_base_error::FACILITY_LOCAL_0). const LOG_FACILITY = 17; + // default backtrace setting (TRUE = perform backtrace on error, FALSE do not perform backtrace on error). + const BACKTRACE_PERFORM = TRUE; + // Represents the current timestamp of this PHP process/session, see: self::s_get_timestamp_session(). private static $s_timestamp_session = NULL; -- 1.8.3.1