}
/**
+ * Return the first item in the array after calling reset().
+ *
+ * @return c_base_return_status|c_base_return_value
+ * Value on success, FALSE otherwise.
+ * FALSE without error bit set is returned if no items are defined.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function get_item_reset() {
+ if (!is_array($this->items) || empty($this->items)) {
+ return new c_base_return_false();
+ }
+
+ return c_base_return_value::s_new(reset($this->items));
+ }
+
+ /**
+ * Return the first item in the array after calling current().
+ *
+ * @return c_base_return_status|c_base_return_value
+ * Value on success, FALSE otherwise.
+ * FALSE without error bit set is returned if no items are defined.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function get_item_current() {
+ if (!is_array($this->items) || empty($this->items)) {
+ return new c_base_return_false();
+ }
+
+ return c_base_return_value::s_new(current($this->items));
+ }
+
+ /**
+ * Return the first item in the array after calling each().
+ *
+ * @return c_base_return_status|c_base_return_value
+ * Value on success, FALSE otherwise.
+ * FALSE without error bit set is returned if no items are defined.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function get_item_each() {
+ if (!is_array($this->items) || empty($this->items)) {
+ return new c_base_return_false();
+ }
+
+ return c_base_return_value::s_new(each($this->items));
+ }
+
+ /**
+ * Return the first item in the array after calling next().
+ *
+ * @return c_base_return_status|c_base_return_value
+ * Value on success, FALSE otherwise.
+ * FALSE without error bit set is returned if no items are defined.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function get_item_next() {
+ if (!is_array($this->items) || empty($this->items)) {
+ return new c_base_return_false();
+ }
+
+ return c_base_return_value::s_new(next($this->items));
+ }
+
+ /**
+ * Return the first item in the array after calling prev().
+ *
+ * @return c_base_return_status|c_base_return_value
+ * Value on success, FALSE otherwise.
+ * FALSE without error bit set is returned if no items are defined.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function get_item_previous() {
+ if (!is_array($this->items) || empty($this->items)) {
+ return new c_base_return_false();
+ }
+
+ return c_base_return_value::s_new(prev($this->items));
+ }
+
+ /**
+ * Return the first item in the array after calling end().
+ *
+ * @return c_base_return_status|c_base_return_value
+ * Value on success, FALSE otherwise.
+ * FALSE without error bit set is returned if no items are defined.
+ * FALSE with the error bit set is returned on error.
+ */
+ public function get_item_end() {
+ if (!is_array($this->items) || empty($this->items)) {
+ return new c_base_return_false();
+ }
+
+ return c_base_return_value::s_new(end($this->items));
+ }
+
+ /**
* Return the item at a specific index in the array.
*
* @param string $key
$path_tree = &$this->paths[$id_group];
$path_tree_history = array();
+ if (is_array($this->root)) {
+ $path_tree_history[] = $this->root;
+ }
+
// @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);
if (is_array($path_tree) && (array_key_exists($path_part, $path_tree) || array_key_exists('%', $path_tree))) {
* If not defined, then NULL is returned.
* NULL with the error bit set is returned on error.
*/
- protected function get_breadcrumbs() {
+ public function get_breadcrumbs() {
if (!($this->breadcrumbs instanceof c_base_menu_item)) {
$this->pr_build_breadcrumbs();
}
* 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);
+ $menu = $this->pr_include_path(self::PATH_MENU_HEADER, self::NAME_MENU_HEADER, self::HANDLER_MENU_HEADER);
return $menu->do_build($this->http, $this->database, $this->session, $this->settings);
}
* 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);
+ $menu = $this->pr_include_path(self::PATH_MENU_UTILITY, self::NAME_MENU_UTILITY, self::HANDLER_MENU_UTILITY);
return $menu->do_build($this->http, $this->database, $this->session, $this->settings);
}
* 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);
+ $menu = $this->pr_include_path(self::PATH_MENU_BREADCRUMBS, self::NAME_MENU_BREADCRUMBS, self::HANDLER_MENU_BREADCRUMBS);
return $menu->do_build($http, $database, $session, $settings, $this->breadcrumbs);
}
* 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);
+ $menu = $this->pr_include_path(self::PATH_MENU_CONTENT, self::NAME_MENU_CONTENT, self::HANDLER_MENU_CONTENT);
return $menu->do_build($this->http, $this->database, $this->session, $this->settings);
}
* 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);
+ $menu = $this->pr_include_path(self::PATH_MENU_FOOTER, self::NAME_MENU_FOOTER, self::HANDLER_MENU_FOOTER);
return $menu->do_build($this->http, $this->database, $this->session, $this->settings);
}
* @return c_base_meni
* The created c_base_meni object.
*/
- protected function pr_include_menu($path, $name, $class) {
+ protected function pr_include_path($path, $name, $class) {
require_once($path . $name . self::SCRIPT_EXTENSION);
// use default if no aliases are found.
return new $class();
}
}
+
}
else {
$path_tree->set_items(array());
+
+ $handler_settings_index = $this->paths->find_path('')->get_value();
+ if (isset($handler_settings_index['handler'])) {
+ $path_tree->set_item_append($handler_settings_index);
+ }
+ unset($handler_settings_index);
}
$path_failsafe->set_path_tree($path_tree);
* Build the breadcrumb.
*/
protected function pr_build_breadcrumbs() {
- $this->breadcrumbs = new c_base_menu_item();
+ $handler_settings = $this->path_tree->get_item_reset()->get_value();
- $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), '');
- $this->breadcrumbs->set_item($item);
- unset($item);
+ if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION);
+
+
+ $handler = NULL;
+ if (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->language_alias;
+ if (class_exists($handler_class)) {
+ $handler = new $handler_class();
+ }
+ unset($handler_class);
+ }
+
+ if (is_null($handler)) {
+ if (class_exists($handler_settings['handler'])) {
+ $handler = new $handler_settings['handler']();
+ }
+ else {
+ unset($handler);
+ return parent::pr_build_breadcrumbs();
+ }
+ }
- // @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.
+ $this->breadcrumbs = $handler->get_breadcrumbs();
+ unset($handler);
}
/**
* Build the breadcrumb.
*/
protected function pr_build_breadcrumbs() {
- $this->breadcrumbs = new c_base_menu_item();
+ $handler_settings = $this->path_tree->get_item_reset()->get_value();
- $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), '');
- $this->breadcrumbs->set_item($item);
- unset($item);
+ if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION);
+
+
+ $handler = NULL;
+ if (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->language_alias;
+ if (class_exists($handler_class)) {
+ $handler = new $handler_class();
+ }
+ unset($handler_class);
+ }
+
+ if (is_null($handler)) {
+ if (class_exists($handler_settings['handler'])) {
+ $handler = new $handler_settings['handler']();
+ }
+ else {
+ unset($handler);
+ return parent::pr_build_breadcrumbs();
+ }
+ }
- // @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.
+ $this->breadcrumbs = $handler->get_breadcrumbs();
+ unset($handler);
}
/**
$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.
}
/**
/**
* Build the breadcrumb.
- *
+ */
protected function pr_build_breadcrumbs() {
- $this->breadcrumbs = new c_base_menu_item();
+ $handler_settings = $this->path_tree->get_item_reset()->get_value();
+
+ if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) {
+ return parent::pr_build_breadcrumbs();
+ }
- $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), '');
- $this->breadcrumbs->set_item($item);
- unset($item);
+ require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION);
+
+
+ $handler = NULL;
+ if (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->language_alias;
+ if (class_exists($handler_class)) {
+ $handler = new $handler_class();
+ }
+ unset($handler_class);
+ }
+
+ if (is_null($handler)) {
+ if (class_exists($handler_settings['handler'])) {
+ $handler = new $handler_settings['handler']();
+ }
+ else {
+ unset($handler);
+ return parent::pr_build_breadcrumbs();
+ }
+ }
- // @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.
+ $this->breadcrumbs = $handler->get_breadcrumbs();
+ unset($handler);
}
/**
* Build the breadcrumb.
*/
protected function pr_build_breadcrumbs() {
- $this->breadcrumbs = new c_base_menu_item();
+ $handler_settings = $this->path_tree->get_item_reset()->get_value();
- $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), '');
- $this->breadcrumbs->set_item($item);
- unset($item);
+ if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) {
+ return parent::pr_build_breadcrumbs();
+ }
+
+ require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION);
+
+
+ $handler = NULL;
+ if (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->language_alias;
+ if (class_exists($handler_class)) {
+ $handler = new $handler_class();
+ }
+ unset($handler_class);
+ }
+
+ if (is_null($handler)) {
+ if (class_exists($handler_settings['handler'])) {
+ $handler = new $handler_settings['handler']();
+ }
+ else {
+ unset($handler);
+ return parent::pr_build_breadcrumbs();
+ }
+ }
- // @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.
+ $this->breadcrumbs = $handler->get_breadcrumbs();
+ unset($handler);
}
/**