From 0c030f8769e5f464a726f94cdcd4fc33f0105715 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 3 May 2017 16:01:21 -0500 Subject: [PATCH] Progress: standard path structure and functionality and other changes Made changes to the standard path structure and functionality. It should be more extensible because the create html function has been exploded into multiple sub-parts via protected functions. Additional changes and fixes. --- common/base/classes/base_html.php | 27 +- common/base/classes/base_http.php | 2 +- common/base/classes/base_languages.php | 56 ++ common/base/classes/base_markup.php | 19 +- common/standard/classes/standard_index.php | 1 + common/standard/classes/standard_path.php | 762 ++++++++++++++++----- common/standard/classes/standard_paths.php | 37 +- common/standard/internal/access_denied.php | 18 +- common/standard/internal/bad_method.php | 11 +- common/standard/internal/index.php | 18 +- common/standard/internal/ja/access_denied.php | 7 - common/standard/internal/ja/bad_method.php | 7 - common/standard/internal/ja/index.php | 7 - common/standard/internal/ja/not_found.php | 7 - common/standard/internal/ja/server_error.php | 7 - common/standard/internal/not_found.php | 18 +- common/standard/internal/server_error.php | 18 +- common/standard/paths/u/dashboard.php | 31 +- common/standard/paths/u/ja/login.php | 6 + common/standard/paths/u/login.php | 59 +- common/standard/paths/u/logout.php | 20 +- common/theme/classes/theme_html.php | 37 +- .../sql/reservation/reservation-permissions.sql | 6 - 23 files changed, 895 insertions(+), 286 deletions(-) diff --git a/common/base/classes/base_html.php b/common/base/classes/base_html.php index fdc07d5..46e4b24 100644 --- a/common/base/classes/base_html.php +++ b/common/base/classes/base_html.php @@ -612,7 +612,6 @@ class c_base_html extends c_base_return { case c_base_markup_attributes::ATTRIBUTE_D: case c_base_markup_attributes::ATTRIBUTE_DATA: case c_base_markup_attributes::ATTRIBUTE_DATE_TIME: - case c_base_markup_attributes::ATTRIBUTE_DIRECTION: case c_base_markup_attributes::ATTRIBUTE_DIRECTION_NAME: case c_base_markup_attributes::ATTRIBUTE_DOWNLOAD: case c_base_markup_attributes::ATTRIBUTE_DURATION: @@ -918,6 +917,25 @@ class c_base_html extends c_base_return { return c_base_return_int::s_new($this->attributes[$attribute]); } + case c_base_markup_attributes::ATTRIBUTE_DIRECTION: + if ($body) { + if (is_int($this->attributes_body[$attribute])) { + return c_base_return_int::s_new($this->attributes_body[$attribute]); + } + elseif (is_null($this->attributes_body[$attribute])) { + return new c_base_return_null(); + } + } + else { + if (is_int($this->attributes[$attribute])) { + return c_base_return_int::s_new($this->attributes[$attribute]); + } + elseif (is_null($this->attributes[$attribute])) { + return new c_base_return_null(); + } + } + break; + case c_base_markup_attributes::ATTRIBUTE_CENTER_X: case c_base_markup_attributes::ATTRIBUTE_CENTER_Y: case c_base_markup_attributes::ATTRIBUTE_COLUMNS: @@ -1026,7 +1044,6 @@ class c_base_html extends c_base_return { case c_base_markup_attributes::ATTRIBUTE_D: case c_base_markup_attributes::ATTRIBUTE_DATA: case c_base_markup_attributes::ATTRIBUTE_DATE_TIME: - case c_base_markup_attributes::ATTRIBUTE_DIRECTION: case c_base_markup_attributes::ATTRIBUTE_DIRECTION_NAME: case c_base_markup_attributes::ATTRIBUTE_DOWNLOAD: case c_base_markup_attributes::ATTRIBUTE_DURATION: @@ -1320,6 +1337,12 @@ class c_base_html extends c_base_return { } break; + case c_base_markup_attributes::ATTRIBUTE_DIRECTION: + if (!is_null($value) && !is_int($value)) { + return new c_base_return_false(); + } + break; + case c_base_markup_attributes::ATTRIBUTE_CENTER_X: case c_base_markup_attributes::ATTRIBUTE_CENTER_Y: case c_base_markup_attributes::ATTRIBUTE_COLUMNS: diff --git a/common/base/classes/base_http.php b/common/base/classes/base_http.php index 950bb6f..076d03e 100644 --- a/common/base/classes/base_http.php +++ b/common/base/classes/base_http.php @@ -7829,7 +7829,7 @@ class c_base_http extends c_base_rfc_string { unset($lower_piece_2); } elseif ($total_pieces == 1) { - $lower_piece = preg_replace('/(^\s+)|(\s+$)/us', '', c_base_utf8::s_lowercase($pieces[0]))->get_value_exact(); + $lower_piece = preg_replace('/(^\s+)|(\s+$)/us', '', c_base_utf8::s_lowercase($pieces[0])->get_value_exact()); if ($lower_piece == 'links') { $result['engine_name_machine'] = 'links'; diff --git a/common/base/classes/base_languages.php b/common/base/classes/base_languages.php index 6850a67..ee2ffb1 100644 --- a/common/base/classes/base_languages.php +++ b/common/base/classes/base_languages.php @@ -622,6 +622,18 @@ interface i_base_languages { * An empty array with error bit set is returned on error. */ public static function s_get_names(); + + /** + * Get the language direction using the id. + * + * @param int $id + * The id of the language to process. + * + * @return c_base_return_status + * TRUE if LTR, FALSE if RTL. + * Error bit is set on error. + */ + public static function s_get_ltr_by_id($id); } /** @@ -653,6 +665,9 @@ final class c_base_languages_us_only implements i_base_languages { 'zxx' => self::NOT_APPLICABLE, ); + private static $s_rtl_ids = array( + ); + /** * Implementation of s_get_names_by_id(). @@ -791,6 +806,17 @@ final class c_base_languages_us_only implements i_base_languages { public static function s_get_names() { return c_base_return_array::s_new(self::$s_names); } + + /** + * Implementation of s_get_ltr_by_id(). + */ + public static function s_get_ltr_by_id($id) { + if (array_key_exists($id, self::$s_rtl_ids)) { + return new c_base_return_false(); + } + + return new c_base_return_true(); + } } /** @@ -856,6 +882,10 @@ final class c_base_languages_limited implements i_base_languages { 'zxx' => self::NOT_APPLICABLE, ); + private static $s_rtl_ids = array( + // @todo: populate this with $id => $id. + ); + /** * Implementation of s_get_names_by_id(). @@ -994,6 +1024,17 @@ final class c_base_languages_limited implements i_base_languages { public static function s_get_names() { return c_base_return_array::s_new(self::$s_names); } + + /** + * Implementation of s_get_ltr_by_id(). + */ + public static function s_get_ltr_by_id($id) { + if (array_key_exists($id, self::$s_rtl_ids)) { + return new c_base_return_false(); + } + + return new c_base_return_true(); + } } /** @@ -2675,6 +2716,10 @@ final class c_base_languages_all implements i_base_languages { 'zza' => self::ZAZA, ); + private static $s_rtl_ids = array( + // @todo: populate this with $id => $id. + ); + /** * Implementation of s_get_names_by_id(). @@ -2813,4 +2858,15 @@ final class c_base_languages_all implements i_base_languages { public static function s_get_names() { return c_base_return_array::s_new(self::$s_names); } + + /** + * Implementation of s_get_ltr_by_id(). + */ + public static function s_get_ltr_by_id($id) { + if (array_key_exists($id, self::$s_rtl_ids)) { + return new c_base_return_false(); + } + + return new c_base_return_true(); + } } diff --git a/common/base/classes/base_markup.php b/common/base/classes/base_markup.php index dff4ed8..a588388 100644 --- a/common/base/classes/base_markup.php +++ b/common/base/classes/base_markup.php @@ -56,7 +56,7 @@ class c_base_markup_attributes { const ATTRIBUTE_DATE_TIME = 34; // text const ATTRIBUTE_DEFAULT = 35; // default, use TRUE/FALSE const ATTRIBUTE_DEFER = 36; // defer, use TRUE/FALSE - const ATTRIBUTE_DIRECTION = 37; // ltr, rtl, auto + const ATTRIBUTE_DIRECTION = 37; // number representing id of language, may use NULL for 'auto'. const ATTRIBUTE_DIRECTION_NAME = 38; // text, inputname.dir const ATTRIBUTE_DISABLED = 39; // disabled, use TRUE/FALSE const ATTRIBUTE_DOWNLOAD = 40; // text @@ -637,7 +637,6 @@ class c_base_markup_tag extends c_base_rfc_string { case c_base_markup_attributes::ATTRIBUTE_D: case c_base_markup_attributes::ATTRIBUTE_DATA: case c_base_markup_attributes::ATTRIBUTE_DATE_TIME: - case c_base_markup_attributes::ATTRIBUTE_DIRECTION: case c_base_markup_attributes::ATTRIBUTE_DIRECTION_NAME: case c_base_markup_attributes::ATTRIBUTE_DOWNLOAD: case c_base_markup_attributes::ATTRIBUTE_DURATION: @@ -931,6 +930,12 @@ class c_base_markup_tag extends c_base_rfc_string { } break; + case c_base_markup_attributes::ATTRIBUTE_DIRECTION: + if (!is_null($value) && !is_int($value)) { + return new c_base_return_false(); + } + break; + case c_base_markup_attributes::ATTRIBUTE_CENTER_X: case c_base_markup_attributes::ATTRIBUTE_CENTER_Y: case c_base_markup_attributes::ATTRIBUTE_COLUMNS: @@ -1055,7 +1060,6 @@ class c_base_markup_tag extends c_base_rfc_string { case c_base_markup_attributes::ATTRIBUTE_D: case c_base_markup_attributes::ATTRIBUTE_DATA: case c_base_markup_attributes::ATTRIBUTE_DATE_TIME: - case c_base_markup_attributes::ATTRIBUTE_DIRECTION: case c_base_markup_attributes::ATTRIBUTE_DIRECTION_NAME: case c_base_markup_attributes::ATTRIBUTE_DOWNLOAD: case c_base_markup_attributes::ATTRIBUTE_DURATION: @@ -1331,6 +1335,15 @@ class c_base_markup_tag extends c_base_rfc_string { case c_base_markup_attributes::ATTRIBUTE_CHARACTER_SET: return c_base_return_int::s_new($this->attributes[$attribute]); + case c_base_markup_attributes::ATTRIBUTE_DIRECTION: + if (is_int($this->attributes[$attribute])) { + return c_base_return_int::s_new($this->attributes[$attribute]); + } + elseif (is_null($this->attributes[$attribute])) { + return new c_base_return_null(); + } + break; + case c_base_markup_attributes::ATTRIBUTE_CENTER_X: case c_base_markup_attributes::ATTRIBUTE_CENTER_Y: case c_base_markup_attributes::ATTRIBUTE_COLUMNS: diff --git a/common/standard/classes/standard_index.php b/common/standard/classes/standard_index.php index 79f37f9..52a812a 100644 --- a/common/standard/classes/standard_index.php +++ b/common/standard/classes/standard_index.php @@ -79,6 +79,7 @@ class c_standard_index extends c_base_return { // base settings $this->settings['base_scheme'] = 'https'; $this->settings['base_host'] = 'localhost'; + $this->settings['base_port'] = ''; // @todo: implement support for thus such that base_port is something like: ':8080' (as opposed to '8080'). $this->settings['base_path'] = $this->settings['cookie_path']; // must end in a trailing slash. if (!isset($_SERVER["HTTPS"])) { diff --git a/common/standard/classes/standard_path.php b/common/standard/classes/standard_path.php index 410ad1c..f3a447b 100644 --- a/common/standard/classes/standard_path.php +++ b/common/standard/classes/standard_path.php @@ -10,20 +10,32 @@ require_once('common/base/classes/base_markup.php'); /** * Provides standard extensions to base paths. + * + * This is used primarily for generating HTML5 pages. */ class c_standard_path extends c_base_path { - protected const CSS_NAME = 'content-wrapper'; - - protected const CSS_AS_TITLE = 'as-title'; - protected const CSS_AS_TEXT = 'as-text'; - protected const CSS_AS_TEXT_BLOCK = 'as-text-block'; - protected const CSS_AS_PARAGRAPH = 'as-paragraph'; - protected const CSS_AS_PARAGRAPH_BLOCK = 'as-paragraph-block'; - - 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 - '; + protected const CSS_AS_SECTION = 'as-section'; + protected const CSS_AS_SECTION_HEADERS = 'as-section-headers'; + protected const CSS_AS_WRAPPER = 'as-wrapper'; + protected const CSS_AS_BREAK = 'as-break'; + protected const CSS_AS_TITLE = 'as-title'; + protected const CSS_AS_TEXT = 'as-text'; + protected const CSS_AS_TEXT_BLOCK = 'as-text-block'; + protected const CSS_AS_PARAGRAPH = 'as-paragraph'; + protected const CSS_AS_PARAGRAPH_BLOCK = 'as-paragraph-block'; + protected const CSS_AS_LINK_BLOCK = 'as-link_block'; + protected const CSS_AS_LINK_BLOCK_NAME = 'as-link_block-name'; + protected const CSS_AS_LINK_BLOCK_LINK = 'as-link_block-link'; + 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'; + + protected const CSS_SYSTEM_PREFIX = 'system-'; + protected const CSS_DATE_YEAR = 'date-year-'; protected const CSS_DATE_MONTH = 'date-month-'; protected const CSS_DATE_WEEK_DAY = 'date-week_day-'; @@ -35,11 +47,16 @@ class c_standard_path extends c_base_path { protected const CSS_PATH_PART = 'path-part-'; protected const CSS_PATH_FULL = 'path-full-'; + protected $html; protected $http; protected $database; protected $session; protected $settings; + protected $languages; + protected $text_type; + protected $request_uri; + /** * Class constructor. @@ -47,21 +64,31 @@ class c_standard_path extends c_base_path { public function __construct() { parent::__construct(); + $this->html = NULL; $this->http = NULL; $this->database = NULL; $this->session = NULL; $this->settings = array(); + + $this->languages = array(); + $this->text_type = NULL; + $this->request_uri = NULL; } /** * Class destructor. */ public function __destruct() { + unset($this->html); unset($this->http); unset($this->database); unset($this->session); unset($this->settings); + unset($this->languages); + unset($this->text_type); + unset($this->request_uri); + parent::__destruct(); } @@ -82,69 +109,241 @@ class c_standard_path extends c_base_path { $this->database = $database; $this->session = $session; $this->settings = $settings; + + $this->text_type = c_base_markup_tag::TYPE_SPAN; + if (isset($this->settings['standards_issue-use_p_tags']) && $this->settings['standards_issue-use_p_tags']) { + $this->text_type = c_base_markup_tag::TYPE_PARAGRAPH; + } + + $request_uri = $this->http->get_request(c_base_http::REQUEST_URI)->get_value_exact(); + if (isset($request_uri['data']) && is_string($request_uri['data'])) { + $request_uri = $request_uri['data']; + unset($request_uri['current']); + unset($request_uri['invalid']); + + $this->request_uri = $request_uri; + } + else { + $this->request_uri = array( + 'scheme' => $this->settings['base_scheme'], + 'authority' => $this->settings['base_host'], + 'path' => $this->settings['base_path'], + 'query' => NULL, + 'fragment' => NULL, + 'url' => TRUE, + ); + } + unset($request_uri); + + $this->languages = $this->http->get_response_content_language()->get_value_exact(); + if (!is_array($this->languages)) { + $this->languages = array(); + } + } + + /** + * Creates the standard section. + * + * @param array|null $headers + * An array of headers, whose keys are the header number and values are the header names. + * If NULL, then the headers are not assigned. + * @param array $arguments + * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. + * + * @return c_base_markup_tag + * The generated markup tag. + */ + protected function pr_create_tag_section($headers = NULL, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_SECTION, self::CSS_AS_SECTION); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SECTION, $id, $classes); + unset($classes); + + if (is_array($headers)) { + $header = $this->pr_create_tag_headers($headers, $arguments, NULL, self::CSS_AS_SECTION_HEADERS); + $tag->set_tag($header); + unset($header); + } + + return $tag; } /** * Creates the standard wrapper. * + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. + * * @return c_base_markup_tag * The generated markup tag. */ - protected function pr_create_tag_wrapper() { - return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_SECTION, $this->settings['base_css'] . self::CSS_NAME, array($this->settings['base_css'] . self::CSS_NAME, self::CSS_NAME)); + protected function pr_create_tag_wrapper($id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_WRAPPER, self::CSS_AS_WRAPPER); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + + return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, $id, $classes); } /** * Creates the standard break tag. * + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. + * * @return c_base_markup_tag * The generated markup tag. */ - protected function pr_create_tag_break() { - return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_BREAK); + protected function pr_create_tag_break($id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_BREAK, self::CSS_AS_BREAK); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + + return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_BREAK, $id, $classes); } /** - * Creates the standard title. + * Creates the standard text. * * @param int|string $text * The text or the text code to use. * @param array $arguments * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. * * @return c_base_markup_tag * The generated markup tag. */ - protected function pr_create_tag_title($text, $arguments = array()) { + protected function pr_create_tag_text($text, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_TEXT, self::CSS_AS_TEXT); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + if (is_int($text)) { - return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_H1, NULL, array(self::CSS_AS_TITLE), $this->pr_get_text($text, $arguments)); + return c_theme_html::s_create_tag($this->text_type, $id, $classes, $this->pr_get_text($text, $arguments)); } - return c_theme_html::s_create_tag(c_base_markup_tag::TYPE_H1, NULL, array(self::CSS_AS_TITLE), $text); + return c_theme_html::s_create_tag($this->text_type, $id, $classes, $text); } /** - * Creates the standard text. + * Creates the standard header text. * * @param int|string $text * The text or the text code to use. + * @param int $header + * May be any number greater than 0, but only H1-H6 are used. + * All other cases a div tag is substituted as a simulated H7+. * @param array $arguments * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. * * @return c_base_markup_tag * The generated markup tag. */ - protected function pr_create_tag_text($text, $arguments = array()) { - $type = c_base_markup_tag::TYPE_SPAN; - if (isset($this->settings['standards_issue-use_p_tags']) && $this->settings['standards_issue-use_p_tags']) { - $type = c_base_markup_tag::TYPE_PARAGRAPH; + protected function pr_create_tag_header($text, $header, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_HEADER, self::CSS_AS_HEADER, self::CSS_AS_HEADER . '-' . $header); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + + $type = c_base_markup_tag::TYPE_DIVIDER; + if ($header == 1) { + $type = c_base_markup_tag::TYPE_H1; + } + elseif ($header == 2) { + $type = c_base_markup_tag::TYPE_H2; + } + elseif ($header == 3) { + $type = c_base_markup_tag::TYPE_H3; + } + elseif ($header == 4) { + $type = c_base_markup_tag::TYPE_H4; + } + elseif ($header == 5) { + $type = c_base_markup_tag::TYPE_H5; + } + elseif ($header == 6) { + $type = c_base_markup_tag::TYPE_H6; } if (is_int($text)) { - return c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_TEXT), $this->pr_get_text($text, $arguments)); + return c_theme_html::s_create_tag($type, $id, $classes, $this->pr_get_text($text, $arguments)); } - return c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_TEXT), $text); + return c_theme_html::s_create_tag($type, $id, $classes, $text); + } + + /** + * Creates the standard headers block. + * + * This is the HTML
tag and not the html tag. + * + * @param array|null $headers + * An array of headers, whose keys are the header number and values are the header names. + * If NULL, then the headers are not assigned. + * @param array $arguments + * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. + * + * @return c_base_markup_tag + * The generated markup tag. + */ + protected function pr_create_tag_headers($headers, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_HEADERS, self::CSS_AS_HEADERS); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_HEADER, $id, $classes); + unset($classes); + + if (is_array($headers)) { + foreach ($headers as $header_id => $header_text) { + $header = $this->pr_create_tag_header($header_text, $header_id, $arguments); + $tag->set_tag($header); + unset($header); + } + unset($header_id); + unset($header_text); + } + + return $tag; } /** @@ -154,21 +353,27 @@ class c_standard_path extends c_base_path { * The text or the text code to use. * @param array $arguments * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. * * @return c_base_markup_tag * The generated markup tag. */ - protected function pr_create_tag_paragraph($text, $arguments = array()) { - $type = c_base_markup_tag::TYPE_SPAN; - if (isset($this->settings['standards_issue-use_p_tags']) && $this->settings['standards_issue-use_p_tags']) { - $type = c_base_markup_tag::TYPE_PARAGRAPH; + protected function pr_create_tag_paragraph($text, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_PARAGRAPH, self::CSS_AS_PARAGRAPH); + if (is_string($extra_class)) { + $classes[] = $extra_class; } if (is_int($text)) { - return c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_PARAGRAPH), $this->pr_get_text($text, $arguments)); + return c_theme_html::s_create_tag($this->text_type, $id, $classes, $this->pr_get_text($text, $arguments)); } - return c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_PARAGRAPH), $text); + return c_theme_html::s_create_tag($this->text_type, $id, $classes, $text); } /** @@ -179,26 +384,32 @@ class c_standard_path extends c_base_path { * If NULL, only the block is created. * @param array $arguments * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. * * @return c_base_markup_tag * The generated markup tag. */ - protected function pr_create_tag_text_block($text, $arguments = array()) { - $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_AS_TEXT_BLOCK)); + protected function pr_create_tag_text_block($text, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_TEXT_BLOCK, self::CSS_AS_TEXT_BLOCK); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } - if (!is_null($text)) { - $type = c_base_markup_tag::TYPE_SPAN; - if (isset($this->settings['standards_issue-use_p_tags']) && $this->settings['standards_issue-use_p_tags']) { - $type = c_base_markup_tag::TYPE_PARAGRAPH; - } + $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, $id, $classes); + unset($classes); + if (!is_null($text)) { if (is_int($text)) { - $tag = c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_TEXT), $this->pr_get_text($text, $arguments)); + $tag = c_theme_html::s_create_tag($this->text_type, NULL, array(self::CSS_AS_TEXT), $this->pr_get_text($text, $arguments)); } else { - $tag = c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_TEXT), $text); + $tag = c_theme_html::s_create_tag($this->text_type, NULL, array(self::CSS_AS_TEXT), $text); } - unset($type); $block->set_tag($tag); unset($tag); @@ -210,31 +421,39 @@ class c_standard_path extends c_base_path { /** * Creates the standard text, wrapped in a block. * + * This is intended to be used as a paragraph (this is not the same as the

tag). + * * @param int|string|null $text * The text or the text code to use. * If NULL, only the block is created. * @param array $arguments * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. * * @return c_base_markup_tag * The generated markup tag. */ - protected function pr_create_tag_paragraph_block($text, $arguments = array()) { - $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_AS_PARAGRAPH_BLOCK)); + protected function pr_create_tag_paragraph_block($text, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_PARAGRAPH_BLOCK, self::CSS_AS_PARAGRAPH_BLOCK); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } - if (!is_null($text)) { - $type = c_base_markup_tag::TYPE_SPAN; - if (isset($this->settings['standards_issue-use_p_tags']) && $this->settings['standards_issue-use_p_tags']) { - $type = c_base_markup_tag::TYPE_PARAGRAPH; - } + $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, $id, $classes); + unset($classes); + if (!is_null($text)) { if (is_int($text)) { - $tag = c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_PARAGRAPH_BLOCK), $this->pr_get_text($text, $arguments)); + $tag = c_theme_html::s_create_tag($this->text_type, NULL, array(self::CSS_AS_PARAGRAPH_BLOCK), $this->pr_get_text($text, $arguments)); } else { - $tag = c_theme_html::s_create_tag($type, NULL, array(self::CSS_AS_PARAGRAPH_BLOCK), $text); + $tag = c_theme_html::s_create_tag($this->text_type, NULL, array(self::CSS_AS_PARAGRAPH_BLOCK), $text); } - unset($type); $block->set_tag($tag); unset($tag); @@ -244,95 +463,252 @@ class c_standard_path extends c_base_path { } /** - * 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. + * Creates the standard dashboard text block. * + * @param int|string|null $text + * The text or the text code to use as the link text. + * If NULL, the link text is not created. + * @param int|string|null $tooltip + * The text that describes the code to use as the link tooltip. + * If NULL, the description text is not created. + * @param string|array|null $destination + * The destination url to send the link to. + * If an array, must be a url array. + * If NULL, the no destination is provided and the link is displayed instead as a label. * @param array $arguments * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. * - * @return string|null - * A string is returned as the custom title. - * NULL is returned to enforce default title. + * @return c_base_markup_tag + * The generated markup tag. */ - protected function pr_get_title($arguments = array()) { - return NULL; + protected function pr_create_tag_link($text, $tooltip, $destination, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_LINK, self::CSS_AS_LINK); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + + $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, $id, $classes); + unset($classes); + + if (is_int($text)) { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_A, NULL, $classes, $this->pr_get_text($text, $arguments)); + } + else { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_A, NULL, $classes, $text); + } + + if (is_array($destination)) { + $uri = $this->pr_rfc_string_combine_uri_array($destination); + if (is_string($uri)) { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $uri); + } + unset($uri); + } + else { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $destination); + } + + // the HTML title attribute is a tooltip. + if (is_int($tooltip)) { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_TITLE, $this->pr_get_text($tooltip, $arguments)); + } + elseif (is_string($tooltip)) { + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_TITLE, $tooltip); + } } /** - * Load text for a supported language. + * Creates the standard dashboard text block. * - * @param int $index - * A number representing which block of text to return. + * @param int|string|null $text + * The text or the text code to use as the link text. + * If NULL, the link text is not created. + * @param int|string|null $tooltip + * The text that describes the code to use as the link tooltip. + * If NULL, the description text is not created. + * @param string|array|null $destination + * The destination url to send the link to. + * If an array, must be a url array. + * If NULL, the no destination is provided and the link is displayed instead as a label. + * @param int|string|null $description + * The text that describes the code to use. + * If NULL, the description text is not created. * @param array $arguments * (optional) An array of arguments to convert into text. + * @param int $header + * (optional) A header id to use instead of a div to wrap the link. + * Set to 0 to disable. + * May be any number greater than or equal to 0, but only H1-H6 are used. + * All other cases a div tag is substituted as a simulated H7+. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * If NULL, then this is not assigned. + * + * @return c_base_markup_tag + * The generated markup tag. */ - protected function pr_get_text($code, $arguments = array()) { - return ''; + protected function pr_create_tag_link_block($text, $tooltip, $destination, $description, $arguments = array(), $header = 0, $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_LINK_BLOCK, self::CSS_AS_LINK_BLOCK); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + + $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, $id, $classes); + unset($classes); + + if (!is_null($text)) { + if ($header < 1) { + $wrapper = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, array(self::CSS_AS_TEXT, self::CSS_AS_LINK_BLOCK_NAME)); + } + 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; + } + elseif ($header == 2) { + $type = c_base_markup_tag::TYPE_H2; + } + elseif ($header == 3) { + $type = c_base_markup_tag::TYPE_H3; + } + elseif ($header == 4) { + $type = c_base_markup_tag::TYPE_H4; + } + elseif ($header == 5) { + $type = c_base_markup_tag::TYPE_H5; + } + elseif ($header == 6) { + $type = c_base_markup_tag::TYPE_H6; + } + + $wrapper = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, NULL, $header_classes); + unset($header_classes); + unset($type); + } + + if (!is_null($text)) { + $tag = $this->pr_create_tag_link($text, $tooltip, $destination, $arguments, self::CSS_AS_LINK_BLOCK_LINK); + $wrapper->set_tag($tag); + unset($tag); + } + + $block->set_tag($wrapper); + unset($wrapper); + } + + if (!is_null($description)) { + $tag = $this->pr_create_tag_text_block($description, $arguments, self::CSS_AS_LINK_BLOCK_DESCRIPTION); + $block->set_tag($tag); + unset($tag); + } + + return $block; } /** * Create a new HTML markup class with default settings populated. * - * @return c_base_html - * The generated html is returned on success. - * The generated html with error bit set is returned on error. + * @param bool $real_page + * (optional) A real page is a page where content is being provided. + * Examples of non-real pages are 404 pages. + * Certain headers and settings are discluded on non-real pages, such as canonical urls. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set on error. + * + * @see: self::pr_create_html_add_primary_ids() + * @see: self::pr_create_html_add_primary_classes() + * @see: self::pr_create_html_add_lanaguages() + * @see: self::pr_create_html_add_title() + * @see: self::pr_create_html_add_header_base() + * @see: self::pr_create_html_add_header_meta() + * @see: self::pr_create_html_add_header_link_canonical() + * @see: self::pr_create_html_add_header_link_shortlink() + * @see: self::pr_create_html_add_header_script() */ - protected function pr_create_html() { - $title = $this->pr_get_title(); + protected function pr_create_html($real_page = TRUE) { + $this->html = new c_base_html(); + + $this->pr_create_html_add_primary_ids(); + $this->pr_create_html_add_primary_classes(); + $this->pr_create_html_add_lanaguages(); + $this->pr_create_html_add_title(); + $this->pr_create_html_add_header_base(); + $this->pr_create_html_add_header_meta(); + + if ($real_page) { + // @todo: redesign these to accept the $request_uri array instead of trying to build them directly here. + $this->pr_create_html_add_header_link_canonical(); + $this->pr_create_html_add_header_link_shortlink(); + } - $html = new c_base_html(); + $this->pr_create_html_add_header_script(); - $request_uri = $this->http->get_request(c_base_http::REQUEST_URI)->get_value_exact(); - if (isset($request_uri['data']) && is_string($request_uri['data'])) { - $request_uri = $request_uri['data']; - unset($request_uri['current']); - unset($request_uri['invalid']); + return new c_base_return_true(); + } - $request_path = $this->http->get_request_uri_relative($this->settings['base_path'])->get_value_exact(); - } - else { - $request_uri = array( - 'scheme' => $this->settings['base_scheme'], - 'authority' => $this->settings['base_host'], - 'path' => $this->settings['base_path'], - 'query' => NULL, - 'fragment' => NULL, - 'url' => TRUE, - ); - $request_path = '/'; - } + /** + * Create an HTML primary id attributes. + * + * @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(); + #$this->html->set_attribute(c_base_markup_attributes::ATTRIBUTE_ID, $id); + $this->html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ID, $id); + + unset($id); + } + + /** + * Create an HTML primary classes. + * + * @see: self::pr_create_html() + */ + protected function pr_create_html_add_primary_classes() { // add date/time classes. $instance = c_base_defaults_global::s_get_timestamp_session()->get_value_exact(); - $class[] = self::CSS_DATE_YEAR . $html->sanitize_css(date('Y', $instance))->get_value_exact(); - $class[] = self::CSS_DATE_MONTH . $html->sanitize_css(strtolower(date('F', $instance)))->get_value_exact(); - $class[] = self::CSS_DATE_WEEK_DAY . $html->sanitize_css(strtolower(date('l', $instance)))->get_value_exact(); - $class[] = self::CSS_DATE_DAY . $html->sanitize_css(date('d', $instance))->get_value_exact(); - $class[] = self::CSS_DATE_HOUR . $html->sanitize_css(date('H', $instance))->get_value_exact(); - $class[] = self::CSS_DATE_MINUTE . $html->sanitize_css(date('m', $instance))->get_value_exact(); - $class[] = self::CSS_DATE_SECOND . $html->sanitize_css(date('s', $instance))->get_value_exact(); + $class[] = self::CSS_DATE_YEAR . $this->html->sanitize_css(date('Y', $instance))->get_value_exact(); + $class[] = self::CSS_DATE_MONTH . $this->html->sanitize_css(strtolower(date('F', $instance)))->get_value_exact(); + $class[] = self::CSS_DATE_WEEK_DAY . $this->html->sanitize_css(strtolower(date('l', $instance)))->get_value_exact(); + $class[] = self::CSS_DATE_DAY . $this->html->sanitize_css(date('d', $instance))->get_value_exact(); + $class[] = self::CSS_DATE_HOUR . $this->html->sanitize_css(date('H', $instance))->get_value_exact(); + $class[] = self::CSS_DATE_MINUTE . $this->html->sanitize_css(date('m', $instance))->get_value_exact(); + $class[] = self::CSS_DATE_SECOND . $this->html->sanitize_css(date('s', $instance))->get_value_exact(); unset($instance); // add path classes - $path = $this->http->get_request_uri_relative($request_uri['path'])->get_value_exact(); + $path = $this->http->get_request_uri_relative($this->request_uri['path'])->get_value_exact(); $path_parts = explode('/', $path); if (is_array($path_parts)) { $sanitized = NULL; $delta = 0; foreach ($path_parts as $path_part) { - $sanitized_part = $html->sanitize_css($path_part, TRUE)->get_value_exact(); + $sanitized_part = $this->html->sanitize_css($path_part, TRUE)->get_value_exact(); $sanitized .= '-' . $sanitized_part; - $class[] = self::CSS_PATH_PART . $delta . '-' . $html->sanitize_css($sanitized_part)->get_value_exact(); + $class[] = self::CSS_PATH_PART . $delta . '-' . $this->html->sanitize_css($sanitized_part)->get_value_exact(); $delta++; } unset($path_part); unset($sanitized_part); - $class[] = self::CSS_PATH_FULL . $html->sanitize_css(substr($sanitized, 1))->get_value_exact(); + $class[] = self::CSS_PATH_FULL . $this->html->sanitize_css(substr($sanitized, 1))->get_value_exact(); unset($sanitized); } unset($path_parts); @@ -340,48 +716,62 @@ class c_standard_path extends c_base_path { $class[] = self::CSS_IS_CONTENT_TYPE; $class[] = self::CSS_IS_JAVASCRIPT_DISABLED; - $html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_CLASS, $class); - unset($class); - - - // assign id attribute - $id = $html->sanitize_css('system-' . $this->settings['session_system'])->get_value_exact(); - #$html->set_attribute(c_base_markup_attributes::ATTRIBUTE_ID, $id); - $html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ID, $id); - unset($id); + $this->html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_CLASS, $class); + unset($class); + } + /** + * Create an HTML primary classes. + * + * @see: self::pr_create_html() + */ + protected function pr_create_html_add_lanaguages() { // assign language attribute. $language = i_base_languages::ENGLISH_US; - $languages = $this->http->get_response_content_language()->get_value_exact(); - if (is_array($languages) && !empty($languages)) { - $language = reset($languages); + if (!empty($this->languages)) { + $language = reset($this->languages); } - $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, $language); - unset($language); + $this->html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, $language); + + // assign default direction attribute. + $this->html->set_attribute(c_base_markup_attributes::ATTRIBUTE_DIRECTION, $language); - // assign default direction attribute (@todo: this needs to come from the language attribute (when possible)). - $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_DIRECTION, 'ltr'); + unset($language); + } + /** + * Create an HTML title tag. + * + * @see: self::pr_create_html() + */ + protected function pr_create_html_add_title() { + $title = $this->pr_get_title(); - // assign title header tag (setting title tag at delta 0 so that it can easily be overriden as needed). if (is_string($title)) { $tag = new c_base_markup_tag(); $tag->set_type(c_base_markup_tag::TYPE_TITLE); $tag->set_text($title); - $html->set_header($tag, 0); + $this->html->set_header($tag, 0); unset($tag); } + unset($title); + } - // assign base header tag - if (isset($request_uri['path']) && is_string($request_uri['path']) && mb_strlen($request_uri['scheme']) > 0) { + /** + * Create an HTML base header tag. + * + * @see: self::pr_create_html() + */ + protected function pr_create_html_add_header_base() { + if (isset($this->request_uri['path']) && is_string($this->request_uri['path']) && mb_strlen($this->request_uri['scheme']) > 0) { $href = ''; - if (isset($request_uri['scheme']) && is_string($request_uri['scheme']) && mb_strlen($request_uri['scheme']) > 0) { - if (isset($request_uri['authority']) && is_string($request_uri['authority']) && mb_strlen($request_uri['authority']) > 0) { - $href .= $request_uri['scheme'] . '://' . $request_uri['authority']; + if (isset($this->request_uri['scheme']) && is_string($this->request_uri['scheme']) && mb_strlen($this->request_uri['scheme']) > 0) { + if (isset($this->request_uri['authority']) && is_string($this->request_uri['authority']) && mb_strlen($this->request_uri['authority']) > 0) { + $href .= $this->request_uri['scheme'] . '://' . $this->request_uri['authority'] . $this->settings['base_port']; } } @@ -389,51 +779,39 @@ class c_standard_path extends c_base_path { $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_BASE); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $href); - $html->set_header($tag); + $this->html->set_header($tag); + unset($tag); unset($href); } + } - + /** + * Create an HTML header meta tags. + * + * @see: self::pr_create_html() + */ + protected function pr_create_html_add_header_meta() { // assign http-equiv header tag $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'Content-Type'); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'text/html; charset=utf-8'); - $html->set_header($tag); + $this->html->set_header($tag); unset($tag); // assign charset header tag $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CHARACTER_SET, c_base_charset::UTF_8); - $html->set_header($tag); - unset($tag); - - - // assign canonical header tag - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $request_uri['scheme'] . '://' . $request_path); - $html->set_header($tag); - unset($tag); - - - // assign shortlink header tag - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'shortlink'); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $request_path); - $html->set_header($tag); + $this->html->set_header($tag); unset($tag); - unset($request_path); - unset($request_uri); - // assign distribution header tag $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'distribution'); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'web'); - $html->set_header($tag); + $this->html->set_header($tag); unset($tag); @@ -441,7 +819,7 @@ class c_standard_path extends c_base_path { $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'robots'); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'INDEX,FOLLOW'); - $html->set_header($tag); + $this->html->set_header($tag); unset($tag); @@ -449,21 +827,21 @@ class c_standard_path extends c_base_path { $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_NAME, 'viewport'); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, 'width=device-width, initial-scale=1'); - $html->set_header($tag); + $this->html->set_header($tag); unset($tag); // assign content http-equiv header tag $aliases = array(); - if (is_array($languages) && !empty($languages)) { + if (!empty($this->languages)) { // assign the primary language. - $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id(reset($languages))->get_value_exact(); + $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id(reset($this->languages))->get_value_exact(); if (is_array($language_aliases) && !empty($language_aliases)) { - $html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, reset($language_aliases)); + $this->html->set_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE, reset($language_aliases)); } unset($language_aliases); - foreach ($languages as $language) { + foreach ($this->languages as $language) { $language_aliases = c_base_defaults_global::s_get_languages()::s_get_aliases_by_id($language)->get_value_exact(); if (is_array($language_aliases) && !empty($language_aliases)) { $aliases[] = array_pop($language_aliases); @@ -472,18 +850,58 @@ class c_standard_path extends c_base_path { } unset($language); } - unset($languages); if (!empty($aliases)) { $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_META); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HTTP_EQUIV, 'content-language'); $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_CONTENT, implode(', ', $aliases)); - $html->set_header($tag); + $this->html->set_header($tag); unset($tag); } unset($aliases); + } + + /** + * Create an HTML canonical header link tag. + * + * @see: self::pr_create_html() + */ + 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->request_uri['scheme'] . '://' . $this->request_uri['authority'] . $this->request_uri['path']); + $this->html->set_header($tag); + + unset($tag); + } + /** + * Create an HTML shortlink header link tag. + * + * @see: self::pr_create_html() + */ + protected function pr_create_html_add_header_link_shortlink() { + // shortlink is not provided by default, but below is an example implementation. + #$request_path = $this->http->get_request_uri_relative($this->settings['base_path'])->get_value_exact(); + #if ($request_path == '') { + # $request_path = '/'; + #} + + #$tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'shortlink'); + #$tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $request_path); + #$this->html->set_header($tag); + + #unset($request_path); + #unset($tag); + } + /** + * Create an HTML script header tags. + * + * @see: self::pr_create_html() + */ + 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->set_attribute(c_base_markup_attributes::ATTRIBUTE_TYPE, c_base_mime::TYPE_TEXT_JS); @@ -495,10 +913,36 @@ class c_standard_path extends c_base_path { $tag->set_text($javascript); unset($javascript); - $html->set_header($tag); - $html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ON_LOAD, 'f_standard_paths_hmtl_javascript_detection();'); + $this->html->set_header($tag); + $this->html->set_attribute_body(c_base_markup_attributes::ATTRIBUTE_ON_LOAD, 'f_standard_paths_hmtl_javascript_detection();'); unset($tag); + } + + /** + * 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. + * + * @param array $arguments + * (optional) An array of arguments to convert into text. + * + * @return string|null + * A string is returned as the custom title. + * NULL is returned to enforce default title. + */ + protected function pr_get_title($arguments = array()) { + return NULL; + } - return $html; + /** + * 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 ''; } } diff --git a/common/standard/classes/standard_paths.php b/common/standard/classes/standard_paths.php index 0b13cb0..a8048a4 100644 --- a/common/standard/classes/standard_paths.php +++ b/common/standard/classes/standard_paths.php @@ -362,7 +362,7 @@ class c_standard_paths extends c_base_return { return $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); } elseif (is_string($this->alias)) { - @include_once($handler_settings['include_directory'] . $this->alias . '/' . $handler_settings['include_name']); + @include_once($handler_settings['include_directory'] . $this->alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); $handler_class = $handler_settings['handler'] . '_' . $this->alias; if (class_exists($handler_class)) { @@ -448,21 +448,8 @@ class c_standard_paths extends c_base_return { } - if (class_exists('c_standard_path_user_login') && $this->handler instanceof c_standard_path_user_login) { - unset($id_group); - return $this->handler->do_execute($this->http, $this->database, $this->session, $this->settings); - } - elseif (class_exists('c_standard_path_user_logout') && $this->handler instanceof c_standard_path_user_logout) { - // 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()) { - unset($id_group); - return $this->get_handler_not_found()->do_execute($this->http, $this->database, $this->session, $this->settings); - } - } - - // if the request is private, make sure the user is logged in. - if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M || $id_group === c_base_ascii::LOWER_U || $this->handler->is_private()->get_value_exact()) { + if ($this->handler->is_private()->get_value_exact()) { if ($this->session->is_logged_in()->get_value_exact()) { unset($id_group); return $this->handler->do_execute($this->http, $this->database, $this->session, $this->settings); @@ -476,8 +463,26 @@ class c_standard_paths extends c_base_return { return $login_path->do_execute($this->http, $this->database, $this->session, $this->settings); } else { + if ($id_group === c_base_ascii::LOWER_U) { + unset($id_group); + + // PHP's instanceof does not support strings, so is_subclass_of() and is_a() must instead be used. + 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()) { + + return $this->get_handler_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); + } + // some special case paths always provide login prompt along with access denied. - if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M || $id_group === c_base_ascii::LOWER_U) { + if ($id_group === c_base_ascii::LOWER_A || $id_group === c_base_ascii::LOWER_M) { unset($id_group); $this->http->set_response_status(c_base_http_status::FORBIDDEN); diff --git a/common/standard/internal/access_denied.php b/common/standard/internal/access_denied.php index f970501..ea2d64a 100644 --- a/common/standard/internal/access_denied.php +++ b/common/standard/internal/access_denied.php @@ -25,18 +25,17 @@ class c_standard_path_access_denied extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_wrapper(); - $wrapper->set_tag($this->pr_create_tag_title(0)); + $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); // initialize the content as HTML. - $html = $this->pr_create_html(); - $html->set_tag($wrapper); + $this->pr_create_html(FALSE); + $this->html->set_tag($wrapper); unset($wrapper); - $executed->set_output($html); - unset($html); + $executed->set_output($this->html); + unset($this->html); // assign HTTP response status. @@ -47,6 +46,13 @@ class c_standard_path_access_denied extends c_standard_path { } /** + * Implements pr_get_title(). + */ + protected function pr_get_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** * 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 8c580c3..99e051c 100644 --- a/common/standard/internal/bad_method.php +++ b/common/standard/internal/bad_method.php @@ -27,18 +27,17 @@ class c_standard_path_bad_method extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_wrapper(); - $wrapper->set_tag($this->pr_create_tag_title(0)); + $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); // initialize the content as HTML. - $html = $this->pr_create_html(); - $html->set_tag($wrapper); + $this->pr_create_html(FALSE); + $this->html->set_tag($wrapper); unset($wrapper); - $executed->set_output($html); - unset($html); + $executed->set_output($this->html); + unset($this->html); // assign HTTP response status. diff --git a/common/standard/internal/index.php b/common/standard/internal/index.php index fed9814..57a2bfb 100644 --- a/common/standard/internal/index.php +++ b/common/standard/internal/index.php @@ -26,23 +26,29 @@ class c_standard_path_index extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_wrapper(); - $wrapper->set_tag($this->pr_create_tag_title(0)); + $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); // initialize the content as HTML. - $html = $this->pr_create_html(); - $html->set_tag($wrapper); + $this->pr_create_html(); + $this->html->set_tag($wrapper); unset($wrapper); - $executed->set_output($html); - unset($html); + $executed->set_output($this->html); + unset($this->html); return $executed; } /** + * Implements pr_get_title(). + */ + protected function pr_get_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/ja/access_denied.php b/common/standard/internal/ja/access_denied.php index 2f66b0f..c8b3eb9 100644 --- a/common/standard/internal/ja/access_denied.php +++ b/common/standard/internal/ja/access_denied.php @@ -10,13 +10,6 @@ final class c_standard_path_access_denied_ja extends c_standard_path_access_denied { /** - * Implements pr_get_title(). - */ - protected function pr_get_title($arguments = array()) { - return '予約システム'; - } - - /** * 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 c8faa0b..3cb3abb 100644 --- a/common/standard/internal/ja/bad_method.php +++ b/common/standard/internal/ja/bad_method.php @@ -10,13 +10,6 @@ final class c_standard_path_bad_method_ja extends c_standard_path_bad_method { /** - * Implements pr_get_title(). - */ - protected function pr_get_title($arguments = array()) { - return '予約システム'; - } - - /** * 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 0001f66..0f7b496 100644 --- a/common/standard/internal/ja/index.php +++ b/common/standard/internal/ja/index.php @@ -10,13 +10,6 @@ final class c_standard_path_index_ja extends c_standard_path_index { /** - * Implements pr_get_title(). - */ - protected function pr_get_title($arguments = array()) { - return '予約システム'; - } - - /** * 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 f204d18..b3a776c 100644 --- a/common/standard/internal/ja/not_found.php +++ b/common/standard/internal/ja/not_found.php @@ -10,13 +10,6 @@ final class c_standard_path_not_found_ja extends c_standard_path_not_found { /** - * Implements pr_get_title(). - */ - protected function pr_get_title($arguments = array()) { - return '予約システム'; - } - - /** * 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 54f7b9e..97f5fe9 100644 --- a/common/standard/internal/ja/server_error.php +++ b/common/standard/internal/ja/server_error.php @@ -10,13 +10,6 @@ final class c_standard_path_server_error_ja extends c_standard_path_server_error { /** - * Implements pr_get_title(). - */ - protected function pr_get_title($arguments = array()) { - return '予約システム'; - } - - /** * 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 73533e4..9dbb7b8 100644 --- a/common/standard/internal/not_found.php +++ b/common/standard/internal/not_found.php @@ -25,18 +25,17 @@ class c_standard_path_not_found extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_wrapper(); - $wrapper->set_tag($this->pr_create_tag_title(0)); + $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); // initialize the content as HTML. - $html = $this->pr_create_html(); - $html->set_tag($wrapper); + $this->pr_create_html(FALSE); + $this->html->set_tag($wrapper); unset($wrapper); - $executed->set_output($html); - unset($html); + $executed->set_output($this->html); + unset($this->html); // assign HTTP response status. @@ -47,6 +46,13 @@ class c_standard_path_not_found extends c_standard_path { } /** + * Implements pr_get_title(). + */ + protected function pr_get_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** * 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 25a484a..8087694 100644 --- a/common/standard/internal/server_error.php +++ b/common/standard/internal/server_error.php @@ -25,18 +25,17 @@ class c_standard_path_server_error extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_wrapper(); - $wrapper->set_tag($this->pr_create_tag_title(0)); + $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); // initialize the content as HTML. - $html = $this->pr_create_html(); - $html->set_tag($wrapper); + $this->pr_create_html(FALSE); + $this->html->set_tag($wrapper); unset($wrapper); - $executed->set_output($html); - unset($html); + $executed->set_output($this->html); + unset($this->html); // assign HTTP response status. @@ -47,6 +46,13 @@ class c_standard_path_server_error extends c_standard_path { } /** + * Implements pr_get_title(). + */ + protected function pr_get_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/dashboard.php b/common/standard/paths/u/dashboard.php index 12e3819..d02790d 100644 --- a/common/standard/paths/u/dashboard.php +++ b/common/standard/paths/u/dashboard.php @@ -13,6 +13,7 @@ require_once('common/standard/classes/standard_path.php'); require_once('common/theme/classes/theme_html.php'); class c_standard_path_user_dashboard extends c_standard_path { + protected const PATH_DASHBOARD_USER = 'u/dashboard'; /** * Implements do_execute(). @@ -26,8 +27,7 @@ class c_standard_path_user_dashboard extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_wrapper(); - $wrapper->set_tag($this->pr_create_tag_title(0)); + $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); $roles = array(); @@ -103,16 +103,35 @@ class c_standard_path_user_dashboard extends c_standard_path { unset($block); // initialize the content as HTML. - $html = $this->pr_create_html(); - $html->set_tag($wrapper); + $this->pr_create_html(); + $this->html->set_tag($wrapper); - $executed->set_output($html); - unset($html); + $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_DASHBOARD_USER); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_title(). + */ + protected function pr_get_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/ja/login.php b/common/standard/paths/u/ja/login.php index a0be78f..a9afc91 100644 --- a/common/standard/paths/u/ja/login.php +++ b/common/standard/paths/u/ja/login.php @@ -49,6 +49,12 @@ class c_standard_path_user_login_ja extends c_standard_path_user_login { case 10: $string = 'ログインできません。間違ったユーザー名またはパスワードが指定されています。'; break; + case 11: + $string = 'フォームをリセット'; + break; + case 12: + $string = 'ログイン'; + break; } if (!empty($arguments)) { diff --git a/common/standard/paths/u/login.php b/common/standard/paths/u/login.php index 09e17f0..e3ba871 100644 --- a/common/standard/paths/u/login.php +++ b/common/standard/paths/u/login.php @@ -27,8 +27,8 @@ 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_LOGOUT = 'u/logout'; - protected const PATH_DASHBOARD = 'u/dashboard'; + protected const PATH_LOGIN = 'u/login'; + protected const PATH_LOGOUT = 'u/logout'; /** * Implements do_execute(). @@ -43,8 +43,7 @@ class c_standard_path_user_login extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); // initialize the content as HTML. - $html = $this->pr_create_html(); - $wrapper = $this->pr_create_tag_wrapper(); + $this->pr_create_html(); $logged_in = $session->is_logged_in()->get_value_exact(); if ($logged_in) { @@ -59,7 +58,7 @@ class c_standard_path_user_login extends c_standard_path { // Content - $wrapper->set_tag($this->pr_create_tag_title(8)); + $wrapper = $this->pr_create_tag_section(array(1 => 8)); $wrapper->set_tag($this->pr_create_tag_text_block(9)); } else { @@ -67,7 +66,7 @@ class c_standard_path_user_login extends c_standard_path { // Content - $wrapper->set_tag($this->pr_create_tag_title(3)); + $wrapper = $this->pr_create_tag_section(array(1 => 3)); $wrapper->set_tag($this->pr_create_tag_text_block(4, array('@{user}' => $session->get_name()->get_value_exact()))); $wrapper->set_tag($this->pr_create_tag_break()); @@ -88,14 +87,17 @@ class c_standard_path_user_login extends c_standard_path { unset($block); } - $html->set_tag($wrapper); + $this->html->set_tag($wrapper); unset($wrapper); - $executed->set_output($html); - unset($html); + $executed->set_output($this->html); + unset($this->html); return $executed; } + else { + $wrapper = $this->pr_create_tag_section(array(1 => 0)); + } // handle any resulting errors. @@ -169,7 +171,7 @@ class c_standard_path_user_login extends c_standard_path { unset($problem_message); unset($problem_delta); - $html->set_tag($messages); + $this->html->set_tag($messages); unset($messages); } unset($problem_messages); @@ -185,8 +187,6 @@ class c_standard_path_user_login extends c_standard_path { $form->set_attribute(c_base_markup_attributes::ATTRIBUTE_ROLE, 'form'); $form->set_attribute(c_base_markup_attributes::ATTRIBUTE_ACCEPT_CHARACTER_SET, c_base_charset::UTF_8); - $form->set_tag($this->pr_create_tag_title(0)); - // form id: represents the form. $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_HIDDEN, 'form_id', array('form-id', 'login_form-id')); @@ -261,14 +261,14 @@ 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, 'Reset'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_VALUE, $this->pr_get_text(11)); $form->set_tag($tag); unset($tag); // button: submit $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, '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. $form->set_tag($tag); unset($tag); @@ -281,11 +281,11 @@ class c_standard_path_user_login extends c_standard_path { // assing the content. - $html->set_tag($wrapper); + $this->html->set_tag($wrapper); unset($wrapper); - $executed->set_output($html); - unset($html); + $executed->set_output($this->html); + unset($this->html); return $executed; } @@ -868,6 +868,25 @@ class c_standard_path_user_login extends c_standard_path { } /** + * 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_LOGIN); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_title(). + */ + protected function pr_get_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { @@ -906,6 +925,12 @@ class c_standard_path_user_login extends c_standard_path { case 10: $string = 'Unable to login, an incorrect user name or password has been specified.'; break; + case 11: + $string = 'Reset'; + break; + case 12: + $string = 'Login'; + break; } if (!empty($arguments)) { diff --git a/common/standard/paths/u/logout.php b/common/standard/paths/u/logout.php index f700090..85afd22 100644 --- a/common/standard/paths/u/logout.php +++ b/common/standard/paths/u/logout.php @@ -33,20 +33,21 @@ class c_standard_path_user_logout extends c_standard_path { return $executed; } + $this->pr_assign_defaults($http, $database, $session, $settings); + $this->pr_do_logout($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_wrapper(); - $wrapper->set_tag($this->pr_create_tag_title(0)); + $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); // initialize the content as HTML. - $html = $this->pr_create_html(); - $html->set_tag($wrapper); + $this->pr_create_html(); + $this->html->set_tag($wrapper); unset($wrapper); - $executed->set_output($html); - unset($html); + $executed->set_output($this->html); + unset($this->html); return $executed; } @@ -117,6 +118,13 @@ class c_standard_path_user_logout extends c_standard_path { } /** + * Implements pr_get_title(). + */ + protected function pr_get_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/theme/classes/theme_html.php b/common/theme/classes/theme_html.php index c89ad17..3344273 100644 --- a/common/theme/classes/theme_html.php +++ b/common/theme/classes/theme_html.php @@ -1503,6 +1503,7 @@ class c_theme_html extends c_base_return { $attribute = $tag->get_attribute(c_base_markup_attributes::ATTRIBUTE_LANGUAGE)->get_value_exact(); } + $ltr = TRUE; if (!empty($attribute)) { $language_array = c_base_defaults_global::s_get_languages()->s_get_aliases_by_id($attribute)->get_value_exact(); @@ -1526,8 +1527,20 @@ class c_theme_html extends c_base_return { $attribute = $tag->get_attribute(c_base_markup_attributes::ATTRIBUTE_DIRECTION)->get_value_exact(); } - if (!empty($attribute)) { - $markup .= ' dir="' . $attribute . '"'; + if (is_int($attribute)) { + $is_ltr = c_base_defaults_global::s_get_languages()->s_get_ltr_by_id($attribute)->get_value_exact(); + + if ($is_ltr) { + $markup .= ' dir="ltr"'; + } + else { + $markup .= ' dir="rtl"'; + } + + unset($is_ltr); + } + elseif (is_null($attribute)) { + $markup .= ' dir="auto"'; } unset($attribute); @@ -1873,10 +1886,23 @@ class c_theme_html extends c_base_return { unset($attribute); - // attribute: dir + // attribute: direction $attribute = $this->html->get_attribute_body(c_base_markup_attributes::ATTRIBUTE_DIRECTION)->get_value_exact(); - if (!empty($attribute)) { - $markup .= ' dir="' . $attribute . '"'; + + if (is_int($attribute)) { + $is_ltr = c_base_defaults_global::s_get_languages()->s_get_ltr_by_id($attribute)->get_value_exact(); + + if ($is_ltr) { + $markup .= ' dir="ltr"'; + } + else { + $markup .= ' dir="rtl"'; + } + + unset($is_ltr); + } + elseif (is_null($attribute)) { + $markup .= ' dir="auto"'; } unset($attribute); @@ -5597,6 +5623,7 @@ class c_theme_html extends c_base_return { } unset($attribute); + return $markup; } diff --git a/database/sql/reservation/reservation-permissions.sql b/database/sql/reservation/reservation-permissions.sql index 7e661a3..759e832 100644 --- a/database/sql/reservation/reservation-permissions.sql +++ b/database/sql/reservation/reservation-permissions.sql @@ -84,12 +84,6 @@ alter function s_administers.f_users_insert_as_administer() owner to u_reservati alter function s_administers.f_users_update_as_administer() owner to u_reservation_grant_roles; alter function s_administers.f_users_update_materialized_views() owner to r_reservation_administer; -/** Special Cases: manually add the postgresql and public users first before with all triggers disabled (because some of the triggers depend on this table, recursively). **/ -alter table s_tables.t_users disable trigger all; -insert into s_tables.t_users (id, name_machine, name_human, is_private, is_public) values (1, 'u_reservation_public', (null, 'Unknown', null, null, null, 'Unknown'), false, true); -insert into s_tables.t_users (id, name_machine, name_human, is_private, is_system) values (2, 'postgres', (null, 'Database', null, 'Administer', null, 'Database (Administer)'), true, true); -alter table s_tables.t_users enable trigger all; - /* attempt to auto-manage postgresql standard roles with the standard database user roles. */ /* user ids 1 and 2 are explicitly reserved for anonymous/public and the database postgresql accounts. */ -- 1.8.3.1