本文整理匯總了PHP中Images::FindLastPage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::FindLastPage方法的具體用法?PHP Images::FindLastPage怎麽用?PHP Images::FindLastPage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Images
的用法示例。
在下文中一共展示了Images::FindLastPage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: FindByPagination
function FindByPagination($perpage, $pagenum)
{
// Check to see if there is a page number. If not, set it to page 1
if (!isset($pagenum)) {
$pagenum = 1;
}
$last = Images::FindLastPage($perpage);
// Ensure the page number isn't below one, or more than the maximum pages
if ($pagenum < 1) {
$pagenum = 1;
} elseif ($pagenum > $last) {
$pagenum = $last;
}
// Sets the limit value for the query
$max = 'LIMIT ' . ($pagenum - 1) * $perpage . ', ' . $perpage;
return MyActiveRecord::FindBySQL('Images', "SELECT * FROM images ORDER BY id DESC {$max}");
}
示例2: display_page_content
function display_page_content()
{
//$images = Images::FindAll();
//$images = array_reverse($images);
$pagenum = getRequestVarAtIndex(2);
$imagesperpage = 12;
$lastpage = Images::FindLastPage($imagesperpage);
$images = Images::FindByPagination($imagesperpage, $pagenum);
$numbernav = "";
if (count($images) > 0) {
$pagenum = $pagenum == "" ? 1 : $pagenum;
if ($pagenum > 1) {
$numbernav .= "<a class=\"pageprev\" href=\"" . get_link("admin/list_images/" . ($pagenum - 1)) . "\">Newer</a>";
}
$counter = 1;
while ($counter <= $lastpage) {
$thispage = $counter == $pagenum ? " class=\"thispage\"" : "";
$numbernav .= "<a{$thispage} href=\"" . get_link("admin/list_images/" . $counter) . "\">{$counter}</a>";
$counter++;
}
if ($pagenum != $lastpage) {
$numbernav .= "<a class=\"pagenext\" href=\"" . get_link("admin/list_images/" . ($pagenum + 1)) . "\">Older</a>";
}
}
?>
<div id="edit-header" class="imagenav">
<div class="nav-left column">
<h1>Choose an Image to Edit</h1>
</div>
<div class="nav-right column">
<a href="<?php
echo get_link("admin/add_image");
?>
" class="hcd_button">Add a New Image</a>
</div>
<div class="clearleft"></div>
</div>
<div class="page-numbers">
<?php
echo $numbernav;
?>
</div>
<?php
if (count($images) > 0) {
?>
<div id="imageDisplay">
<?php
foreach ($images as $image) {
echo "\t\t<div class=\"image\"><a href=\"" . get_link("/admin/edit_image/{$image->id}") . "\">";
//$image->displayThumbnail();
echo '<img src="' . get_link('images/view/' . $image->id) . '" alt="' . $image->name . '">';
echo "</a>{$image->name}</div>\n";
}
?>
<div class="clearleft"></div>
</div>
<?php
} else {
echo '<h3>There are no images yet! <a href="' . get_link("admin/add_image") . '">Add one if you like</a>.</h3>';
}
?>
<div class="page-numbers">
<?php
echo $numbernav;
?>
</div>
<?php
}