public function DisplayAllOpensprawdzaczCaches($OpensprawdzaczSetup, $opt)
 {
     /**
      * Displays initial form for cache waypoint (OPXXXX) input
      *
      * and
      *
      * display list of caches in Opensprawdzacz.
      */
     /**
      *  if isset $_GET['op_keszynki'] means that user entered cache OP, and want search for this
      *  cache through Opensprawdzacz.
      *  This part get cache waypoint from url, check if cache owner allow specified cahe for check by
      *  OpenSprawdzacz
      *
      */
     if (isset($_GET['op_keszynki'])) {
         $this->cache_wp = mysql_real_escape_string($_GET['op_keszynki']);
         $this->cache_wp = strtoupper($this->cache_wp);
     } else {
         $formularz = '
                 <form action="' . $OpensprawdzaczSetup->scriptname . '" method="get">
                 ' . tr('os_podaj_waypoint') . ':
                         <input type="text" name="op_keszynki" maxlength="6"/>
                         <button type="submit" name="przeslanie_waypointa" value="' . tr('submit') . '" style="font-size:14px;width:160px"><b>' . tr('submit') . '</b></button>
                 </form>
                                 ';
         if (isset($_GET['sort'])) {
             $sort_tmp = mysql_real_escape_string($_GET['sort']);
             switch ($sort_tmp) {
                 case 'autor':
                     $sortowanie = '`user`.`username`';
                     break;
                 case 'nazwa':
                     $sortowanie = '`caches`.`name`';
                     break;
                 case 'wpt':
                     $sortowanie = '`caches`.`wp_oc`';
                     break;
                 case 'szczaly':
                     $sortowanie = '`opensprawdzacz`.`proby`';
                     break;
                 case 'sukcesy':
                     $sortowanie = '`opensprawdzacz`.`sukcesy`';
                     break;
                 default:
                     $sortowanie = '`caches`.`name`';
                     break;
             }
         } else {
             $sortowanie = '`caches`.`name`';
         }
         $zapytajka = "\n\n        SELECT `waypoints`.`cache_id`,\n        `waypoints`.`type`,\n        `waypoints`.`stage`,\n        `waypoints`.`desc`,\n        `caches`.`name`,\n        `caches`.`wp_oc`,\n        `caches`.`user_id`,\n        `caches`.`type`,\n        `caches`.`status`,\n        `user`.`username`,\n        `cache_type`.`sort`,\n        `cache_type`.`icon_small`,\n        `opensprawdzacz`.`proby`,\n        `opensprawdzacz`.`sukcesy`\n        FROM   `waypoints`\n        LEFT JOIN   `opensprawdzacz`\n        ON   `waypoints`.`cache_id` = `opensprawdzacz`.`cache_id`,\n        `caches`, `user`, `cache_type`\n        WHERE   `waypoints`.`opensprawdzacz` = 1\n        AND   `waypoints`.`type` = 3\n        AND   `caches`.`type` = `cache_type`.`id`\n        AND   `caches`.`user_id` = `user`.`user_id`\n        AND   `waypoints`.`cache_id` = `caches`.`cache_id`\n        ORDER BY   {$sortowanie}\n        LIMIT   0, 1000\n\n        ";
         $status = array('1' => '<img src="tpl/stdstyle/images/log/16x16-found.png" border="0" alt="Gotowa do szukania">', '2' => '<img src="tpl/stdstyle/images/log/16x16-temporary.png" border="0" alt="Tymczasowo niedost�pna">', '3' => '<img src="tpl/stdstyle/images/log/16x16-dnf.png" border="0" alt="zarchiwizowana">', '4' => '<img src="tpl/stdstyle/images/log/16x16-temporary.png" border="0" alt="Ukryta do czasu weryfikacji">', '5' => '<img src="tpl/stdstyle/images/log/16x16-temporary.png" border="0" alt="jeszcze niedost�pna">', '6' => '<img src="tpl/stdstyle/images/log/16x16-dnf.png" border="0" alt="Zablokowana przez COG">');
         $conn = new PDO("mysql:host=" . $opt['db']['server'] . ";dbname=" . $opt['db']['name'], $opt['db']['username'], $opt['db']['password']);
         $conn->query('SET CHARSET utf8');
         $keszynki_opensprawdzacza = $conn->query($zapytajka)->fetchAll();
         $ile_keszynek = count($keszynki_opensprawdzacza);
         $pag = new Pagination();
         // $dane = array("hej","dupa","laska", "scierwo");
         $numbers = $pag->Paginate($keszynki_opensprawdzacza, $OpensprawdzaczSetup->caches_on_page);
         $result = $pag->fetchResult();
         /*
          foreach ($result as $r)
          {
          echo "<div>aa$r</div>";
          }
         */
         $paginacja = ' ';
         if (isset($_GET["sort"])) {
             $sort = '&sort=' . $_GET["sort"];
         } else {
             $sort = '';
         }
         if (isset($_GET["page"])) {
             $tPage = sql_escape($_GET["page"]);
         } else {
             $tPage = 1;
         }
         if ($tPage > 1) {
             $paginacja .= '<a href="' . $OpensprawdzaczSetup->scriptname . '?page=' . ($num - 1) . $sort . '">[<' . tr('os_f02') . ']</a> ';
         }
         foreach ($numbers as $num) {
             if ($num == $tPage) {
                 $paginacja .= '<b>[' . $num . ']</b>';
             } else {
                 $paginacja .= '<a href="' . $OpensprawdzaczSetup->scriptname . '?page=' . $num . $sort . '">[' . $num . ']</a> ';
             }
         }
         if ($tPage < count($numbers)) {
             $paginacja .= '<a href="' . $OpensprawdzaczSetup->scriptname . '?page=' . ($tPage + 1) . $sort . '">[' . tr('os_f01') . ' &#62;]</a> ';
         }
         $tabelka_keszynek = '';
         $proby = 0;
         $trafienia = 0;
         // foreach ($keszynki_opensprawdzacza as $dane_keszynek )
         foreach ($result as $dane_keszynek) {
             // $dane_keszynek = mysql_fetch_array($keszynki_opensprawdzacza);
             $proby = $proby + $dane_keszynek['proby'];
             $trafienia = $trafienia + $dane_keszynek['sukcesy'];
             if ($dane_keszynek['status'] == 1 || $dane_keszynek['status'] == 2) {
                 $tabelka_keszynek .= '
                         <tr>
     <td><a class="links" href="viewcache.php?wp=' . $dane_keszynek['wp_oc'] . '">' . $dane_keszynek['wp_oc'] . '</a></td>
     <td><a class="links" href="' . $OpensprawdzaczSetup->scriptname . '?op_keszynki=' . $dane_keszynek['wp_oc'] . '"> ' . $dane_keszynek['name'] . '</a> </td>
     <td><a href="viewcache.php?wp=' . $dane_keszynek['wp_oc'] . '"><img src="tpl/stdstyle/images/' . $dane_keszynek['icon_small'] . '" /></a></td>
     <td align="center">' . $status[$dane_keszynek['status']] . '</td>
     <td><a href="viewprofile.php?userid=' . $dane_keszynek['user_id'] . '">' . $dane_keszynek['username'] . '</td>
             <td align="center">' . $dane_keszynek['proby'] . '</td>
                         <td align="center">' . $dane_keszynek['sukcesy'] . '</td>
                     </tr>';
             }
         }
         $tabelka_keszynek .= '
             <tr><td colspan="7"><img src="tpl/stdstyle/images/blue/dot_blue.png" height="1" width="100%"/></td></tr><tr>
                 <td><img src="/tpl/stdstyle/images/misc/16x16-info.png" /></td>
                 <td>' . tr('os_f00') . ': </td>
                 <td>' . $ile_keszynek . '</td>
                 <td align="center">
                     ' . $status[1] . '<br />' . $status[2] . '
                 </td>
                             <td>
                             (' . tr('log_type_available') . ')<br />
                     (' . tr('temp_unavailables') . ')
                 </td>
                 <td align="center">' . $proby . '</td>
                 <td align="center">' . $trafienia . '</td>
             </tr>
         </table>';
         $tabelka_keszynek .= '<br /><p align="center">' . $paginacja . '</p>';
         tpl_set_var("sekcja_1_start", '');
         tpl_set_var("sekcja_1_stop", '');
         tpl_set_var("sekcja_2_start", '<!--');
         tpl_set_var("sekcja_2_stop", '-->');
         tpl_set_var("sekcja_3_start", '<!--');
         tpl_set_var("sekcja_3_stop", '-->');
         tpl_set_var("sekcja_4_start", '<!--');
         tpl_set_var("sekcja_4_stop", '-->');
         tpl_set_var("sekcja_formularz_opensprawdzacza_start", '<!--');
         tpl_set_var("sekcja_formularz_opensprawdzacza_stop", '');
         tpl_set_var("formularz", $formularz);
         tpl_set_var("keszynki", $tabelka_keszynek);
         $this->endzik();
     }
 }
Example #2
0
            $current_page = $_GET['page'];
        } else {
            $current_page = 1;
        }
        $counts = ceil($total_values / $per_page);
        $param1 = ($current_page - 1) * $per_page;
        $this->data = array_slice($values, $param1, $per_page);
        for ($x = 1; $x <= $counts; $x++) {
            $numbers[] = $x;
        }
        return $numbers;
    }
    function fetchResult()
    {
        $resultsValues = $this->data;
        return $resultsValues;
    }
}
// Sample Usage
$pag = new Pagination();
$data = array("Hello", "Rex", "Prosper", "Adrivan", "Hehe");
$numbers = $pag->Paginate($data, 2);
$result = $pag->fetchResult();
foreach ($result as $r) {
    echo '<div>' . $r . '</div>';
}
echo '<a href="nav.php?page=1"><</a>';
foreach ($numbers as $num) {
    echo '<a href="nav.php?page=' . $num . '">' . $num . '</a>';
}
echo '<a href="">></a>';