News

MOST COMMENTED

1/17/2013 1:35 AM Eastern

function pagination_array($array, $page = 1, $link_prefix = false, $link_suffix = false, $limit_page = 10, $limit_number = 10)
{
$panel = NULL;
//print'

'; print_r($array); print'

';
if (empty($page) or !$limit_page) $page = 1;

$num_rows = count($array);
//print 'Number rows: ' . $num_rows;
if (!$num_rows or $limit_page >= $num_rows) return false;
$num_pages = ceil($num_rows / $limit_page);
$page_offset = ($page - 1) * $limit_page;

//Calculating the first number to show.
if ($limit_number)
{
$limit_number_start = $page - ceil($limit_number / 2);
$limit_number_end = ceil($page + $limit_number / 2) - 1;
if ($limit_number_start //In case if the current page is at the beginning.
$dif = ($limit_number_end - $limit_number_start);
if ($dif if ($limit_number_end > $num_pages) $limit_number_end = $num_pages;
//In case if the current page is at the ending.
$dif = ($limit_number_end - $limit_number_start);
if ($limit_number_start }
else
{
$limit_number_start = 1;
$limit_number_end = $num_pages;
}
//Generating page links.
for ($i = $limit_number_start; $i {
$page_cur = "$i";
if ($page == $i) $page_cur = "$i";
else $page_cur = "$i";

$panel .= " $page_cur";
}

$panel = trim($panel);
//Navigation arrows.
if ($limit_number_start > 1) $panel = "<< < $panel";
if ($limit_number_end > >>";

$output['panel'] = $panel; //Panel HTML source.
$output['offset'] = $page_offset; //Current page number.
$output['limit'] = $limit_page; //Number of resuts per page.
$output['array'] = array_slice($array, $page_offset, $limit_page, false); //Array of current page results.

return $output;
}

$api_key = 'pmk420ZlgmQ5OQrjWfVLpq01CqgpK2rUHu9kqWx88tuDm2gk31KMvJLq2XdK1r5D';
$interval = '90d';
$forum = 'multichannel';
$limit = 50;

$url_call = "http://disqus.com/api/3.0/threads/listPopular.json?api_key=" . $api_key . "&forum=" . $forum . "&interval=" . $interval . "&limit=" . $limit;

$get_contents = file_get_contents( $url_call );

$call = json_decode($get_contents);

//print'

'; print_r($call); print'

';

//print '

MOST COMMENTED

';

for($i =0; $i response); $i++) {
//print '

";
$disqus_array [$i]['title'] = $call->response[$i]->title;
$disqus_array [$i]['link'] = $call->response[$i]->link;
}

//Getting current page.
//print $_GET['page'] . 'hi';
if (!isset($_GET['page'])) {
$page = 1;
}
else {
$page = $_GET['page'];
}

//Applying pagination.
$pagination = pagination_array($disqus_array, $page, "?page=");

//Page link panel.
//echo $pagination['panel'];

//echo "
";
//Displayed page results.
print '

';
for($k =0; $k print '

';
}
print '

';
//echo "
";

//Page Footer link panel.
echo '

';

September