本文整理汇总了PHP中SmartyPaginate::getCurrentItem方法的典型用法代码示例。如果您正苦于以下问题:PHP SmartyPaginate::getCurrentItem方法的具体用法?PHP SmartyPaginate::getCurrentItem怎么用?PHP SmartyPaginate::getCurrentItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartyPaginate
的用法示例。
在下文中一共展示了SmartyPaginate::getCurrentItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assign
/**
* assign $paginate var values
*
* @param obj &$smarty the smarty object reference
* @param string $var the name of the assigned var
* @param string $id the pagination id
*/
public static function assign(&$smarty, $var = 'paginate', $id = 'default')
{
if (is_object($smarty) && (strtolower(get_class($smarty)) == 'smarty' || is_subclass_of($smarty, 'smarty'))) {
$_paginate['total'] = SmartyPaginate::getTotal($id);
$_paginate['first'] = SmartyPaginate::getCurrentItem($id);
$_paginate['last'] = SmartyPaginate::getLastItem($id);
$_paginate['page_current'] = ceil(SmartyPaginate::getLastItem($id) / SmartyPaginate::getLimit($id));
$_paginate['page_total'] = ceil(SmartyPaginate::getTotal($id) / SmartyPaginate::getLimit($id));
$_paginate['size'] = $_paginate['last'] - $_paginate['first'];
$_paginate['url'] = SmartyPaginate::getUrl($id);
$_paginate['urlvar'] = SmartyPaginate::getUrlVar($id);
$_paginate['current_item'] = SmartyPaginate::getCurrentItem($id);
$_paginate['prev_text'] = SmartyPaginate::getPrevText($id);
$_paginate['next_text'] = SmartyPaginate::getNextText($id);
$_paginate['limit'] = SmartyPaginate::getLimit($id);
$_item = 1;
$_page = 1;
while ($_item <= $_paginate['total']) {
$_paginate['page'][$_page]['number'] = $_page;
$_paginate['page'][$_page]['item_start'] = $_item;
$_paginate['page'][$_page]['item_end'] = $_item + $_paginate['limit'] - 1 <= $_paginate['total'] ? $_item + $_paginate['limit'] - 1 : $_paginate['total'];
$_paginate['page'][$_page]['is_current'] = $_item == $_paginate['current_item'];
$_item += $_paginate['limit'];
$_page++;
}
$smarty->assign($var, $_paginate);
} else {
trigger_error("SmartyPaginate: [assign] I need a valid Smarty object.");
return false;
}
}
示例2: smarty_function_paginate_middle
/**
* Project: SmartyPaginate: Pagination for the Smarty Template Engine
* File: function.paginate_middle.php
* Author: Monte Ohrt <monte at newdigitalgroup dot com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.phpinsider.com/php/code/SmartyPaginate/
* @copyright 2001-2005 New Digital Group, Inc.
* @author Monte Ohrt <monte at newdigitalgroup dot com>
* @package SmartyPaginate
* @version 1.6-dev
*/
function smarty_function_paginate_middle($params, &$smarty)
{
$_id = 'default';
$_prefix = '[';
$_suffix = ']';
$_link_prefix = '';
$_link_suffix = '';
$_page_limit = null;
$_attrs = array();
if (!class_exists('SmartyPaginate')) {
$smarty->trigger_error("paginate_middle: missing SmartyPaginate class");
return;
}
if (!isset($_SESSION['SmartyPaginate'])) {
$smarty->trigger_error("paginate_middle: SmartyPaginate is not initialized, use connect() first");
return;
}
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'id':
if (!SmartyPaginate::isConnected($_val)) {
$smarty->trigger_error("paginate_middle: unknown id '{$_val}'");
return;
}
$_id = $_val;
break;
case 'prefix':
$_prefix = $_val;
break;
case 'suffix':
$_suffix = $_val;
break;
case 'link_prefix':
$_link_prefix = $_val;
break;
case 'link_suffix':
$_link_suffix = $_val;
break;
case 'page_limit':
$_page_limit = $_val;
break;
case 'format':
break;
default:
$_attrs[] = $_key . '="' . $_val . '"';
break;
}
}
if (!isset($_SESSION['SmartyPaginate'][$_id]['item_total'])) {
$smarty->trigger_error("paginate_middle: total was not set");
return;
}
if (!isset($_page_limit) && isset($_SESSION['SmartyPaginate'][$_id]['page_limit'])) {
$_page_limit = $_SESSION['SmartyPaginate'][$_id]['page_limit'];
}
$_url = $_SESSION['SmartyPaginate'][$_id]['url'];
// $_url = full_url();
$_total = SmartyPaginate::getTotal($_id);
$_curr_item = SmartyPaginate::getCurrentItem($_id);
$_limit = SmartyPaginate::getLimit($_id);
$_item = 1;
$_page = 1;
$_display_pages = 0;
$_ret = '';
$_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';
if (isset($_page_limit)) {
// find halfway point
$_page_limit_half = floor($_page_limit / 2);
// determine what item/page we start with
$_item_start = $_curr_item - $_limit * $_page_limit_half;
if (($_view = ceil(($_total - $_item_start) / $_limit)) < $_page_limit) {
$_item_start -= $_limit * ($_page_limit - $_view);
}
$_item = $_item_start >= 1 ? $_item_start : 1;
$_page = ceil($_item / $_limit);
//.........这里部分代码省略.........
示例3: smarty_function_paginate_middle
/**
* Project: SmartyPaginate: Pagination for the Smarty Template Engine
* File: function.paginate_middle.php
* Author: Monte Ohrt <monte at newdigitalgroup dot com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.phpinsider.com/php/code/SmartyPaginate/
* @copyright 2001-2005 New Digital Group, Inc.
* @author Monte Ohrt <monte at newdigitalgroup dot com>
* @package SmartyPaginate
* @version 1.6-dev
*/
function smarty_function_paginate_middle($params, &$smarty)
{
global $startUp, $conf, $cat_id;
$_id = 'default';
$_prefix = '[';
$_suffix = ']';
$_link_prefix = '';
$_link_suffix = '';
$_page_limit = null;
$_attrs = array();
if (!class_exists('SmartyPaginate')) {
$smarty->trigger_error("paginate_middle: missing SmartyPaginate class");
return;
}
if (!isset($_SESSION['SmartyPaginate'])) {
$smarty->trigger_error("paginate_middle: SmartyPaginate is not initialized, use connect() first");
return;
}
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'id':
if (!SmartyPaginate::isConnected($_val)) {
$smarty->trigger_error("paginate_middle: unknown id '{$_val}'");
return;
}
$_id = $_val;
break;
case 'prefix':
$_prefix = $_val;
break;
case 'suffix':
$_suffix = $_val;
break;
case 'link_prefix':
$_link_prefix = $_val;
break;
case 'link_suffix':
$_link_suffix = $_val;
break;
case 'page_limit':
$_page_limit = $_val;
break;
case 'format':
break;
default:
$_attrs[] = $_key . '="' . $_val . '"';
break;
}
}
if (!isset($_SESSION['SmartyPaginate'][$_id]['item_total'])) {
$smarty->trigger_error("paginate_middle: total was not set");
return;
}
if (!isset($_page_limit) && isset($_SESSION['SmartyPaginate'][$_id]['page_limit'])) {
$_page_limit = $_SESSION['SmartyPaginate'][$_id]['page_limit'];
}
$_url = $_SESSION['SmartyPaginate'][$_id]['url'];
$_total = SmartyPaginate::getTotal($_id);
$_curr_item = SmartyPaginate::getCurrentItem($_id);
$_limit = SmartyPaginate::getLimit($_id);
$_item = 1;
$_page = 1;
$_display_pages = 0;
$_ret = '';
$_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';
if (isset($_page_limit)) {
// find halfway point
$_page_limit_half = floor($_page_limit / 2);
// determine what item/page we start with
$_item_start = $_curr_item - $_limit * $_page_limit_half;
if (($_view = ceil(($_total - $_item_start) / $_limit)) < $_page_limit) {
$_item_start -= $_limit * ($_page_limit - $_view);
}
$_item = $_item_start >= 1 ? $_item_start : 1;
$_page = ceil($_item / $_limit);
//.........这里部分代码省略.........