本文整理汇总了PHP中Pagination::doPagination方法的典型用法代码示例。如果您正苦于以下问题:PHP Pagination::doPagination方法的具体用法?PHP Pagination::doPagination怎么用?PHP Pagination::doPagination使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagination
的用法示例。
在下文中一共展示了Pagination::doPagination方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: osc_pagination
/**
* Gets generic pagination links
*
* @array $params
* 'total' => number of total pages (default osc_search_total_pages())
* 'selected' => number of the page selected (starting at 0) (default osc_search_page())
* 'class_first' => css class for the first link (default 'searchPaginationFirst')
* 'class_last' => css class for the last link (default 'searchPaginationLast')
* 'class_prev' => css class for the prev link (default 'searchPaginationPrev')
* 'class_next' => css class for the next link (default 'searchPaginationNext')
* 'text_first' => text for the first link ('<<', 'First', ...) (default '«')
* 'text_prev' => text for the first link ('<', 'Previous.', ...) (default '»')
* 'text_next' => text for the first link ('>', 'Next', ...) (default '<')
* 'text_last' => text for the lastst link ('>>', 'Last', ...) (default '>')
* 'class_selected' => css class for the selected link (default 'searchPaginationSelected')
* 'class_non_selected' => css class for non selected links (default 'searchPaginationNonSelected')
* 'delimiter' => delimiter between links (default " ")
* 'force_limits' => Always show the first/last links even if you're already on first/last page (default false)
* 'sides' => How many pages to show (default 2)
* 'url' => Format of the URL of the links, put "{PAGE}" on the page variable. Example http://www.example.com/index.php?page=search&sCategory=2&iPage={PAGE} (default osc_update_search_url(array('iPage' => '{PAGE}'))
*
* @return string pagination links
*/
function osc_pagination($params = null)
{
$pagination = new Pagination($params);
return $pagination->doPagination();
}
示例2: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case('plugins'):
case('themes'):
case('languages'):
$section = $this->action;
$title = array(
'plugins' => __('Recommended plugins for You'),
'themes' => __('Recommended themes for You'),
'languages' => __('Languages for this version')
);
// page number
$marketPage = Params::getParam("mPage");
$url_actual = osc_admin_base_url(true) . '?page=market&action='.$section.'&mPage='.$marketPage;
if($marketPage>=1) $marketPage--;
// api
$url = osc_market_url($section)."page/".$marketPage.'/length/9/';
// default sort
$sort_actual = '';
$sort_download = $url_actual.'&sort=downloads&order=desc';
$sort_updated = $url_actual.'&sort=updated&order=desc';
// sorting options (default)
$_order = 'desc';
$order_download = $_order;
$order_updated = $_order;
$sort = Params::getParam("sort");
$order = Params::getParam("order");
if($sort=='') {
$sort = 'updated';
}
if($order=='') {
$order = $_order;
}
$aux = ($order=='desc')?'asc':'desc';
switch ($sort) {
case 'downloads':
$sort_actual = '&sort=downloads&order=';
$sort_download = $url_actual.$sort_actual.$aux;
$sort_actual .= $order;
$order_download = $order;
// market api call
$url .= 'order/downloads/'.$order;
break;
case 'updated':
$sort_actual = '&sort=updated&order=';
$sort_updated = $url_actual.$sort_actual.$aux;
$sort_actual .= $order;
$order_updated = $order;
// market api call
$url .= 'order/updated/'.$order;
break;
default:
break;
}
// pageSize or length attribute is hardcoded
$out = osc_file_get_contents($url);
$array = json_decode($out, true);
$output_pagination = '';
if( is_numeric($array['total']) && $array['total']>0 ) {
$totalPages = ceil( $array['total'] / $array['sizePage'] );
$pageActual = $array['page'];
$params = array(
'total' => $totalPages,
'selected' => $pageActual,
'url' => osc_admin_base_url(true).'?page=market'.'&action='.$section.'&mPage={PAGE}'.$sort_actual,
'sides' => 5
);
// set pagination
$pagination = new Pagination($params);
$output_pagination = $pagination->doPagination();
} else {
$array['total'] = 0;
}
// export variable to view
$this->_exportVariableToView("sort" , $sort);
$this->_exportVariableToView("title" , $title);
$this->_exportVariableToView("section" , $section);
$this->_exportVariableToView("array" , $array);
$this->_exportVariableToView("sort_download" , $sort_download);
$this->_exportVariableToView("sort_updated" , $sort_updated);
$this->_exportVariableToView("order_download" , $order_download);
$this->_exportVariableToView("order_updated" , $order_updated);
$this->_exportVariableToView('pagination', $output_pagination);
//.........这里部分代码省略.........
示例3: doModel
//.........这里部分代码省略.........
if (!isset($data['s_source_file']) || !isset($data['s_update_url'])) {
$data = array('error' => 2, 'error_msg' => __('Invalid code'));
}
} else {
$data = array('error' => 1, 'error_msg' => __('No code was submitted'));
}
echo json_encode($data);
break;
case 'market_data':
$section = Params::getParam('section');
$page = Params::getParam("mPage");
$featured = Params::getParam("featured");
$sort = Params::getParam("sort");
$order = Params::getParam("order");
// for the moment this value is static
$length = 9;
if ($page >= 1) {
$page--;
}
$url = osc_market_url($section) . "page/" . $page . '/';
if ($length != '' && is_numeric($length)) {
$url .= 'length/' . $length . '/';
}
if ($sort != '') {
$url .= 'order/' . $sort;
if ($order != '') {
$url .= '/' . $order;
}
}
if ($featured != '') {
$url = osc_market_featured_url($section);
}
$data = array();
$data = json_decode(osc_file_get_contents($url), true);
if (!isset($data[$section])) {
$data = array('error' => 1, 'error_msg' => __('No market data'));
}
echo 'var market_data = window.market_data || {}; market_data.' . $section . ' = ' . json_encode($data) . ';';
break;
case 'local_market':
// AVOID CROSS DOMAIN PROBLEMS OF AJAX REQUEST
$marketPage = Params::getParam("mPage");
if ($marketPage >= 1) {
$marketPage--;
}
$out = osc_file_get_contents(osc_market_url(Params::getParam("section")) . "page/" . $marketPage);
$array = json_decode($out, true);
// do pagination
$pageActual = $array['page'];
$totalPages = ceil($array['total'] / $array['sizePage']);
$params = array('total' => $totalPages, 'selected' => $pageActual, 'url' => '#{PAGE}', 'sides' => 5);
// set pagination
$pagination = new Pagination($params);
$aux = $pagination->doPagination();
$array['pagination_content'] = $aux;
// encode to json
echo json_encode($array);
break;
case 'dashboardbox_market':
$error = 0;
// make market call
$url = getPreference('marketURL') . 'dashboardbox/';
$content = '';
if (false === ($json = @osc_file_get_contents($url))) {
$error = 1;
} else {
$content = $json;
}
if ($error == 1) {
echo json_encode(array('error' => 1));
} else {
// replace content with correct urls
$content = str_replace('{URL_MARKET_THEMES}', osc_admin_base_url(true) . '?page=market&action=themes', $content);
$content = str_replace('{URL_MARKET_PLUGINS}', osc_admin_base_url(true) . '?page=market&action=plugins', $content);
echo json_encode(array('html' => $content));
}
break;
case 'location_stats':
osc_csrf_check(false);
$workToDo = osc_update_location_stats();
if ($workToDo > 0) {
$array['status'] = 'more';
$array['pending'] = $workToDo;
echo json_encode($array);
} else {
$array['status'] = 'done';
echo json_encode($array);
}
break;
case 'error_permissions':
echo json_encode(array('error' => __("You don't have the necessary permissions")));
break;
default:
echo json_encode(array('error' => __('no action defined')));
break;
}
// clear all keep variables into session
Session::newInstance()->_dropKeepForm();
Session::newInstance()->_clearVariables();
}
示例4: doModel
function doModel()
{
parent::doModel();
if (time() - (int) osc_market_data_update() > 86400) {
//84600 = 24*60*60
$json = osc_file_get_contents(osc_market_url() . 'categories/', array('api_key' => osc_market_api_connect()));
$data = @json_decode($json, true);
if (is_array($data)) {
osc_set_preference('marketCategories', $json);
osc_set_preference('marketDataUpdate', time());
osc_reset_preferences();
}
}
switch ($this->action) {
case 'buy':
osc_csrf_check();
$json = osc_file_get_contents(osc_market_url() . 'token/', array('api_key' => osc_market_api_connect()));
$data = json_decode($json, true);
osc_redirect_to(Params::getParam('url') . '?token=' . @$data['token']);
break;
case 'purchases':
case 'plugins':
case 'themes':
case 'languages':
$section = $this->action;
$title = array('plugins' => __('Recommended plugins for You'), 'themes' => __('Recommended themes for You'), 'languages' => __('Languages for this version'), 'purchases' => __('My purchases'));
// page number
$marketPage = Params::getParam("mPage");
$url_actual = osc_admin_base_url(true) . '?page=market&action=' . $section . '&mPage=' . $marketPage;
if ($marketPage >= 1) {
$marketPage--;
}
// api
$url = osc_market_url($section) . (Params::getParam('sCategory') != '' ? 'category/' . Params::getParam('sCategory') . '/' : '') . "page/" . $marketPage . '/length/9/';
// default sort
$sort_actual = '';
$sort_download = $url_actual . '&sort=downloads&order=desc';
$sort_updated = $url_actual . '&sort=updated&order=desc';
// sorting options (default)
$_order = 'desc';
$order_download = $_order;
$order_updated = $_order;
$sort = Params::getParam("sort");
$order = Params::getParam("order");
if ($sort == '') {
$sort = 'updated';
}
if ($order == '') {
$order = $_order;
}
$aux = $order == 'desc' ? 'asc' : 'desc';
switch ($sort) {
case 'downloads':
$sort_actual = '&sort=downloads&order=';
$sort_download = $url_actual . $sort_actual . $aux;
$sort_actual .= $order;
$order_download = $order;
// market api call
$url .= 'order/downloads/' . $order;
break;
case 'updated':
$sort_actual = '&sort=updated&order=';
$sort_updated = $url_actual . $sort_actual . $aux;
$sort_actual .= $order;
$order_updated = $order;
// market api call
$url .= 'order/updated/' . $order;
break;
default:
break;
}
// pageSize or length attribute is hardcoded
$out = osc_file_get_contents($url, array('api_key' => osc_market_api_connect()));
$array = json_decode($out, true);
$output_pagination = '';
if (is_numeric($array['total']) && $array['total'] > 0) {
$totalPages = ceil($array['total'] / $array['sizePage']);
$pageActual = $array['page'];
$params = array('total' => $totalPages, 'selected' => $pageActual, 'url' => osc_admin_base_url(true) . '?page=market' . '&action=' . $section . '&mPage={PAGE}' . $sort_actual, 'sides' => 5);
// set pagination
$pagination = new Pagination($params);
$output_pagination = $pagination->doPagination();
} else {
$array['total'] = 0;
}
// export variable to view
$this->_exportVariableToView("sort", $sort);
$this->_exportVariableToView("title", $title);
$this->_exportVariableToView("section", $section);
$this->_exportVariableToView("array", $array);
$this->_exportVariableToView("sort_download", $sort_download);
$this->_exportVariableToView("sort_updated", $sort_updated);
$this->_exportVariableToView("order_download", $order_download);
$this->_exportVariableToView("order_updated", $order_updated);
$this->_exportVariableToView("market_categories", json_decode(osc_market_categories(), true));
$this->_exportVariableToView('pagination', $output_pagination);
$this->doView("market/section.php");
break;
default:
$aPlugins = array();
//.........这里部分代码省略.........
示例5: osc_show_pagination_admin
function osc_show_pagination_admin($aData)
{
$pageActual = isset($aData['iPage']) ? $aData['iPage'] : Params::getParam('iPage');
$urlActual = osc_admin_base_url(true) . '?' . $_SERVER['QUERY_STRING'];
$urlActual = preg_replace('/&iPage=(\\d+)?/', '', $urlActual);
$pageTotal = ceil($aData['iTotalDisplayRecords'] / $aData['iDisplayLength']);
$params = array('total' => $pageTotal, 'selected' => $pageActual - 1, 'url' => $urlActual . '&iPage={PAGE}', 'sides' => 5);
?>
<div class="has-pagination">
<?php
osc_run_hook('before_show_pagination_admin');
?>
<?php
if ($pageTotal > 1) {
?>
<form method="get" action="<?php
echo $urlActual;
?>
" style="display:inline;">
<?php
foreach (Params::getParamsAsArray('get') as $key => $value) {
?>
<?php
if ($key != 'iPage') {
?>
<input type="hidden" name="<?php
echo $key;
?>
" value="<?php
echo osc_esc_html($value);
?>
" />
<?php
}
}
?>
<ul>
<li>
<span class="list-first"><?php
_e('Page');
?>
</span>
</li>
<li class="pagination-input">
<input id="gotoPage" type="text" name="iPage" value="<?php
echo osc_esc_html($pageActual);
?>
"/><button type="submit"><?php
_e('Go!');
?>
</button>
</li>
</ul>
</form>
<?php
$pagination = new Pagination($params);
$aux = $pagination->doPagination();
echo $aux;
}
osc_run_hook('after_show_pagination_admin');
?>
</div>
<?php
}
示例6: str_replace
define('ABS_PATH', dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))))) . '/');
require_once ABS_PATH . 'oc-load.php';
$dao = GzNewsDao::newInstance();
$index_url = GzNewsUtils::getIndexUrl();
$current_page = (int) Params::getParam('new_p');
$selected = 0;
if ($current_page > 0) {
$selected = $current_page - 1;
}
$total_items = $dao->count();
$total_per_page = GzNewsUtils::getMaxItemsPerPage();
$total_pages = ceil($total_items / $total_per_page);
$params = array('total' => (int) $total_pages, 'selected' => $selected, 'url' => $index_url . '?new_p={PAGE}', 'sides' => 5);
// set pagination
$pagination = new Pagination($params);
$paginator_html = $pagination->doPagination();
$options = array('page' => $current_page, 'total_per_page' => $total_per_page, 'language' => osc_current_user_locale());
$list = $dao->listItems($options);
Params::setParam('themeCustomtitle', __('Noticias', 'gz_news'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="<?php
echo str_replace('_', '-', osc_current_user_locale());
?>
">
<head>
<?php
osc_current_web_theme_path('head.php');
?>
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow" />
示例7: doModel
//.........这里部分代码省略.........
if ($length != '' && is_numeric($length)) {
$url .= 'length/' . $length . '/';
}
if ($sort != '') {
$url .= 'order/' . $sort;
if ($order != '') {
$url .= '/' . $order;
}
}
if ($featured != '') {
$url = osc_market_featured_url($section);
}
$data = array();
$data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true);
if (!isset($data[$section])) {
$data = array('error' => 1, 'error_msg' => __('No market data'));
}
echo 'var market_data = window.market_data || {}; market_data.' . $section . ' = ' . json_encode($data) . ';';
break;
case 'local_market':
// AVOID CROSS DOMAIN PROBLEMS OF AJAX REQUEST
$marketPage = Params::getParam("mPage");
if ($marketPage >= 1) {
$marketPage--;
}
$out = osc_file_get_contents(osc_market_url(Params::getParam("section")) . "page/" . $marketPage, array('api_key' => osc_market_api_connect()));
$array = json_decode($out, true);
// do pagination
$pageActual = $array['page'];
$totalPages = ceil($array['total'] / $array['sizePage']);
$params = array('total' => $totalPages, 'selected' => $pageActual, 'url' => '#{PAGE}', 'sides' => 5);
// set pagination
$pagination = new Pagination($params);
$aux = $pagination->doPagination();
$array['pagination_content'] = $aux;
// encode to json
echo json_encode($array);
break;
case 'market_connect':
$json = osc_file_get_contents(osc_market_url() . 'connect/', array('s_email' => Params::getParam('s_email'), 's_password' => Params::getParam('s_password')));
$data = json_decode($json, true);
if ($data['error'] == 0) {
osc_set_preference('marketAPIConnect', $data['api_key']);
unset($data['api_key']);
$json = json_encode($data);
}
echo $json;
break;
case 'dashboardbox_market':
$error = 0;
// make market call
$url = osc_get_preference('marketURL') . 'dashboardbox/';
$content = '';
if (false === ($json = @osc_file_get_contents($url))) {
$error = 1;
} else {
$content = $json;
}
if ($error == 1) {
echo json_encode(array('error' => 1));
} else {
// replace content with correct urls
$content = str_replace('{URL_MARKET_THEMES}', osc_admin_base_url(true) . '?page=market&action=themes', $content);
$content = str_replace('{URL_MARKET_PLUGINS}', osc_admin_base_url(true) . '?page=market&action=plugins', $content);
echo json_encode(array('html' => $content));
}