PHP Classes

File: tests/pagination.php

Recommend this page to a friend!
  Classes of Ali YILMAZ   Mind Framework   tests/pagination.php   Download  
File: tests/pagination.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Mind Framework
Framework that implements several design patterns
Author: By
Last change:
Date: 2 years ago
Size: 2,357 bytes
 

Contents

Class file image Download
<?php
require_once ('../src/Mind.php');

$Mind = new Mind();

// url: pagination.php?page OR pagination.php?page=1
// url: pagination.php?p OR pagination.php?p=1
$options = array(
   
'prefix'=>'page', // Default p
   
'search'=>array(
       
'scope'=>'like',
       
'keyword'=>'%iyi misin%',
       
'column'=>'text',
       
'delimiter'=>array(
           
'or'=>'AND'
       
),
       
'or'=>array(
            array(
               
'sender_id'=>1,
               
'reciver_id'=>1
           
),
            array(
               
'sender_id'=>3,
               
'reciver_id'=>3
           
)
        )
    ),
   
'column'=>array('sender_id','reciver_id','text'), // array / string
   
'limit'=>2, // Default 5
   
'format'=>'json', // json
   
'sort'=>'id:asc' // asc / ASC / desc / DESC
);
// $data = $Mind->pagination('messages');
$data = $Mind->pagination('messages', $options);


if(
$Mind->is_json($data)){

   
/* -------------------------------------------------------------------------- */
    /* JSON */
    /* -------------------------------------------------------------------------- */
   
echo '<pre>';
    echo
$data;
    echo
'</pre>';

   
$data = json_decode($data, true);

} else {

   
/* -------------------------------------------------------------------------- */
    /* ARRAY */
    /* -------------------------------------------------------------------------- */
   
echo '<pre>';
   
print_r($data['data']);
    echo
'</pre>';
}

echo
"\n";

/* -------------------------------------------------------------------------- */
/* NAVIGATION */
/* -------------------------------------------------------------------------- */
$prefix = $data['prefix'];
for (
$i=1; $i <= $data['totalPage']; $i++) {

    echo
"\n<a ";

    if(
$i == $Mind->post[$prefix] OR empty($Mind->post[$prefix])){
        echo
'class="pageSelected" ';
    }
    echo
'href="'.$Mind->base_url.'pagination.php?'.$prefix.'='.$i.'">'.$i.'</a>';
}

echo
"\n\n";

?>

<style>
a,.pageSelected{
    padding:5px;
    letter-spacing: 20px;
    text-decoration: none;
    text-align: center;
}
.pageSelected{
    background-color: #444;
    color: #fff;
}
</style>