/** * Output <title> * * Generate <title> * @param array $args */ function head_title($args = array()) { $args = array_merge(array('echo' => TRUE, 'home' => NULL, 'sep' => ' › '), $args); $output = ''; if ($args['home'] && URI::is('home')) { $output = $args['home']; } else { for ($i = Xysti::uri_count(); $i > 0; $i--) { $output .= Xysti::page('title', $i) . $args['sep']; } } if ($args['echo']) { echo $output; } else { return $output; } }
/** * Walk the sitemap to find the requested page meta * * @param array $segments * @param int $segment_count Number of segments * @return array Page meta */ private static function sitemap_page_walk($segments, $segment_count = NULL) { if (is_null($segment_count)) { $segment_count = Xysti::uri_count(); } $walk = Xysti::sitemap(); // Traverse the sitemap up to the $segment_count for ($depth = 1; $depth <= $segment_count; $depth++) { $this_segment = $segments[$depth - 1]; // If we have reached the $segment_count if ($depth == $segment_count) { // Return item or if (isset($walk[$this_segment])) { $walk[$this_segment]['slug'] = $this_segment; return $walk[$this_segment]; } break; // If there are still children } elseif (isset($walk[$this_segment]['/'])) { // If ['/'] is an array keep traversing if (is_array($walk[$this_segment]['/'])) { $walk = $walk[$this_segment]['/']; // If ['/'] == dynamic then all children equal this segment } elseif ($walk[$this_segment]['/'] == 'dynamic') { return $walk[$this_segment]; break; // ['/'] is set but has clearly been done so incorrectly so end the loop } else { break; } // If no children then break the loop } else { break; } } $page['slug'] = $this_segment; $page['not_found'] = TRUE; return $page; }