static function OutputPagination($pages, $pageKey = 'page', $spread = 2)
 {
     //$pages $pageKey
     if ($pages <= 1) {
         return 1;
     }
     $parsed = parse_url($_SERVER['REQUEST_URI']);
     $args = isset($parsed['query']) ? $parsed['query'] : '';
     if (is_string($args)) {
         parse_str($args, $args);
     }
     if (get_magic_quotes_gpc()) {
         $args = utopia::stripslashes_deep($args);
     }
     $page = isset($args[$pageKey]) ? $args[$pageKey] : 0;
     echo '<ul class="pagination">';
     if ($page > 0) {
         // previous
         $args[$pageKey] = $page - 1;
         $rel = array('prev');
         if (!$args[$pageKey]) {
             unset($args[$pageKey]);
         }
         if ($page - 1 == 0) {
             $rel[] = 'first';
         }
         echo '<li class="previous"><a rel="' . implode(' ', $rel) . '" class="btn uPaginationLink" href="' . $parsed['path'] . ($args ? '?' . http_build_query($args) : '') . '">Previous</a></li>';
     }
     $prespace = false;
     $postspace = false;
     for ($i = 0; $i < $pages; $i++) {
         $args[$pageKey] = $i;
         $rel = array();
         if (!$args[$pageKey]) {
             unset($args[$pageKey]);
         }
         if ($i < $page - $spread && $i != 0) {
             if (!$prespace) {
                 echo '<li>...</li>';
             }
             $prespace = true;
             continue;
         }
         if ($i > $page + $spread && $i != $pages - 1) {
             if (!$postspace) {
                 echo '<li>...</li>';
             }
             $postspace = true;
             continue;
         }
         if ($i == $page - 1) {
             $rel[] = 'prev';
         }
         if ($i == $page + 1) {
             $rel[] = 'next';
         }
         if ($i == 0) {
             $rel[] = 'first';
         }
         if ($i == $pages - 1) {
             $rel[] = 'last';
         }
         echo '<li><a rel="' . implode(' ', $rel) . '" class="btn uPaginationLink" href="' . $parsed['path'] . ($args ? '?' . http_build_query($args) : '') . '">' . ($i + 1) . '</a></li>';
     }
     if ($page < $pages - 1) {
         // next
         $args[$pageKey] = $page + 1;
         $rel = array('next');
         if ($page + 1 == $pages - 1) {
             $rel[] = 'last';
         }
         echo '<li class="next"><a rel="' . implode(' ', $rel) . '" class="btn uPaginationLink" href="' . $parsed['path'] . ($args ? '?' . http_build_query($args) : '') . '">Next</a></li>';
     }
     echo '</ul>';
     return $page + 1;
 }
Exemple #2
0
timer_start('full process');
timer_start('Load Files');
LoadFiles();
timer_end('Load Files');
/**
 * Strip slashes from http inputs if magic quotes is enabled
 */
if ($_POST && get_magic_quotes_gpc()) {
    $_POST = utopia::stripslashes_deep($_POST);
}
if ($_GET && get_magic_quotes_gpc()) {
    $_GET = utopia::stripslashes_deep($_GET);
}
if ($_REQUEST && get_magic_quotes_gpc()) {
    $_REQUEST = utopia::stripslashes_deep($_REQUEST);
}
ini_set('default_charset', CHARSET_ENCODING);
header('Content-type: text/html; charset=' . CHARSET_ENCODING);
header('Vary: if-none-match, accept-encoding');
ob_start('utopia::output_buffer', 2);
register_shutdown_function('utopia::Finish');
timer_start('Static Initialise');
$allmodules = utopia::GetModulesOf('iUtopiaModule');
foreach ($allmodules as $row) {
    // must run second due to requiring GLOB_MOD to be setup fully
    timer_start('Init: ' . $row['module_name']);
    $row['module_name']::Initialise();
    timer_end('Init: ' . $row['module_name']);
}
timer_end('Static Initialise');