/** * Output nav * * Generate the <li> elements for a Bootstrap * navigation menu * @param array $args */ function nav($args = array()) { $args = array_merge(array('echo' => TRUE, 'start' => NULL, 'depth' => 2), $args); $sitemap = Xysti::sitemap(); $start = $sitemap; $parent = ''; // If start is not the beginning.. if ($args['start'] && is_int($args['start'])) { for ($i = 1; $i <= $args['start']; $i++) { $parent .= URI::segment($i) . '/'; $start = $start[URI::segment($i)]['/']; } } $output = nav_walker($start, $args, $parent); if ($args['echo']) { echo $output; } else { return $output; } }
$output .= '</url>' . PHP_EOL; } // If children if (isset($page['/']) && is_array($page['/'])) { $output .= sitemap_xml_walk($page['/'], $uri . '/'); } } return $output; } /** * Sitemap.xml */ Route::get(Config::get('xysti.routes.xml_sitemap'), function () { $output = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL; $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL; $output .= sitemap_xml_walk(Xysti::sitemap()); $output .= '</urlset>' . PHP_EOL; return Response::make($output, 200, array('Content-Type' => 'application/xml')); }); } // Authentication routes // ------------------------------------------------ if (Config::get('xysti.routes.auth')) { /** * Sign the user out and redirect */ if (Config::get('xysti.routes.auth.logout')) { Route::get(Config::get('xysti.routes.auth.logout', 'logout'), array('as' => 'logout', function () { $auth_driver = Config::get('xysti.auth', 'default'); // Default auth if ($auth_driver == 'default') {
/** * 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; }