function uri_pairs($start = 3) { $allSegments = uri_segments(); $segments = array_slice($allSegments, $start - 1); $i = 0; $lastval = ''; $retval = array(); foreach ($segments as $seg) { if ($i % 2) { $retval[$lastval] = $seg; } else { $retval[$seg] = FALSE; $lastval = $seg; } $i++; } return $retval; }
<?php $segs = array_slice(uri_segments(), 2); $size = array_shift($segs); $file = implode('/', $segs); $path = BASEPATH . 'assets/' . $file; if (file_exists($path)) { $size = explode('x', $size); $size = array_pad($size, 1, $size[0]); thumbify($path, $size[0], $size[1]); } exit;
function breadcrumb() { $segments = uri_segments(); $default = get_config('default'); $current = array_pop($segments); $html = ''; $uris = array(); if (count($segments) == 0 && $current != $default) { $html .= sprintf('<li><a href="%s" data-push="1">%s</a></li>', site_url($default), $default); } foreach ($segments as $seg) { $uris[] = $seg; $html .= sprintf('<li><a href="%s" data-push="1">%s</a></li>', site_url(implode('/', $uris)), $seg); } if (!empty($current)) { $html .= sprintf('<li class="active">%s</li>', $current); } return '<ol class="breadcrumb" style="padding: 8px 0; margin-bottom: 0;">' . $html . '</ol><hr style="margin: 5px 0;">'; }
/** * Application entry point */ function start() { load_config(); load_libraries(); validate_uri($_SERVER['REQUEST_URI']); $url = parse_url($_SERVER['REQUEST_URI']); if (isset($url['path'])) { $uri = $url['path']; } else { $uri = $_SERVER['REQUEST_URI']; $pos = strpos($uri, '?'); $uri = $pos !== FALSE ? substr($uri, 0, $pos) : $uri; } $qry = isset($url['query']) ? $url['query'] : ''; $svc = $_SERVER['SCRIPT_NAME']; if (isset($svc[0])) { $dir = str_replace('\\', '/', dirname($svc)); if ($dir != '/') { if (strpos($uri, $svc) === 0) { $uri = (string) substr($uri, strlen($svc)); } else { if (strpos($uri, $dir) === 0) { $uri = (string) substr($uri, strlen($dir)); } } } } if (trim($uri, '/') === '' && strncmp($qry, '/', 1) === 0) { $tmp = explode('?', $qry, 2); $uri = $tmp[0]; $_SERVER['QUERY_STRING'] = isset($tmp[1]) ? $tmp[1] : ''; } else { $_SERVER['QUERY_STRING'] = $qry; } parse_str($_SERVER['QUERY_STRING'], $_GET); if ($uri == '') { $uri = '/'; } set_var('uri', $uri); set_var('qry', $qry); $segments = uri_segments(); $segments = array_pad($segments, 1, ''); $module = $segments[0]; if ($uri == '/') { $segments = explode('/', get_config('default')); $segments = array_pad($segments, 1, ''); $module = $segments[0]; } $layout = 'main.php'; if ($module != '') { $module = init_module($module); if ($module) { $layout = $module->layout . '.php'; $page = array_shift($segments); while (count($segments) > 0) { $path = implode('/', $segments); if (file_exists($module->path . $path . '.php')) { $page = $path; break; } array_pop($segments); } if (empty($page) || !file_exists($module->path . $page . '.php')) { $page = $module->name; } $page = $module->path . $page . '.php'; set_content('file', $page); } } if (!is_ajax()) { include BASEPATH . 'layouts/' . $layout; } else { echo get_content(); } }