本文整理汇总了PHP中Pager::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Pager::factory方法的具体用法?PHP Pager::factory怎么用?PHP Pager::factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pager
的用法示例。
在下文中一共展示了Pager::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testClearIfVoid
function testClearIfVoid()
{
$this->assertTrue(strlen($this->pager->links) > 0);
$options = array('itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 'perPage' => 20, 'mode' => 'Sliding');
$this->pager = Pager::factory($options);
$this->assertEqual('', $this->pager->links);
}
示例2: testXSS
function testXSS()
{
$options = array('itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 'perPage' => 5, 'nextImg' => '»');
$this->pager = Pager::factory($options);
$expected = ' <a href="./">test?pageID=2" title="next page">»</a> ';
$this->assertEqual($expected, $this->pager->_getNextLink());
}
示例3: init
/**
* Initializes the pager. Must be called before using the component.
*
* Takes user configuration and creates pager object ($this->Pager)
*
* @access public
* @param array $config Configuration options for Pager::factory() method
* @see http://pear.php.net/manual/en/package.html.pager.factory.php
* @return void
*/
function init($config)
{
// Get the correct URL, even with admin routes
$here = array();
if (defined('CAKE_ADMIN') && !empty($this->Controller->params[CAKE_ADMIN])) {
$here[0] = $this->Controller->params[CAKE_ADMIN];
$here[2] = substr($this->Controller->params['action'], strlen($this->Controller->params[CAKE_ADMIN]) + 1);
} else {
$here[2] = $this->Controller->params['action'];
}
$here[1] = Inflector::underscore($this->Controller->params['controller']);
ksort($here);
$url = implode('/', $here);
// Set up the default configuration vars
$this->params = array('mode' => 'Sliding', 'perPage' => 10, 'delta' => 5, 'totalItems' => '', 'httpMethod' => 'GET', 'currentPage' => 1, 'linkClass' => 'pager', 'altFirst' => 'First page', 'altPrev ' => 'Previous page', 'altNext' => 'Next page', 'altLast' => 'Last page', 'separator' => '', 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, 'useSessions' => false, 'firstPagePre' => '', 'firstPagePost' => '', 'firstPageText' => '<img src="' . $this->Controller->base . '/img/first.gif" alt="">', 'lastPagePre' => '', 'lastPagePost' => '', 'lastPageText' => '<img src="' . $this->Controller->base . '/img/last.gif" alt="">', 'prevImg' => '<img src="' . $this->Controller->base . '/img/prev.gif" alt="">', 'nextImg' => '<img src="' . $this->Controller->base . '/img/next.gif" alt="">', 'altPage' => 'Page', 'clearIfVoid' => true, 'append' => false, 'path' => '', 'fileName' => $this->Controller->base . DS . $url . DS . '%d', 'urlVar' => '');
vendor('Pear/Pager/Pager');
// Merge with user config
$this->params = array_merge($this->params, $config);
// sanitize requested page number
if (!in_array($this->params['currentPage'], range(1, ceil($this->params['totalItems'] / $this->params['perPage'])))) {
$this->params['currentPage'] = 1;
}
$this->Pager =& Pager::factory($this->params);
// Set the template vars
$this->Controller->set('pageLinks', $this->Pager->getLinks());
$this->Controller->set('currentPage', $this->params['currentPage']);
$this->Controller->set('isFirstPage', $this->Pager->isFirstPage());
$this->Controller->set('isLastPage', $this->Pager->isLastPage());
}
示例4: testGetAndPost
function testGetAndPost()
{
$this->pager =& Pager::factory($this->options);
$this->assertNoPattern('/id=/', $this->pager->links);
$_GET['id'] = 123;
$this->pager =& Pager::factory($this->options);
$this->assertPattern('/id=123/', $this->pager->links);
}
示例5: __construct
/**
* Create a new pager
*
* @param integer $itemCount Number of items in total
* @param integer $perPage Number of items on one page
* @param integer $currentPage Current page, beginning with 1
* @param string $filename URL the page number shall be appended
*/
public function __construct($itemCount, $perPage, $currentPage, $filename)
{
$append = true;
if (strpos($filename, '%d') !== false) {
$append = false;
}
//fix non-static factory method error
error_reporting(error_reporting() & ~E_STRICT);
$this->pager = \Pager::factory(array('mode' => 'Sliding', 'perPage' => $perPage, 'delta' => 2, 'totalItems' => $itemCount, 'currentPage' => $currentPage, 'urlVar' => 'page', 'append' => $append, 'path' => '', 'fileName' => $filename, 'separator' => '###', 'spacesBeforeSeparator' => 0, 'spacesAfterSeparator' => 0, 'curPageSpanPre' => '', 'curPageSpanPost' => '', 'firstPagePre' => '', 'firstPageText' => 'first', 'firstPagePost' => '', 'lastPagePre' => '', 'lastPageText' => 'last', 'lastPagePost' => '', 'prevImg' => '« prev', 'nextImg' => 'next »'));
}
示例6: __construct
/**
* Constructor
*
* Initialize the PEAR pager object.
*
* @param array $options The Pager options to override.
* @access public
*/
public function __construct($options = array())
{
// Set default Pager options:
$finalOptions = array('mode' => 'sliding', 'path' => "", 'delta' => 2, 'perPage' => 20, 'nextImg' => translate('Next') . ' »', 'prevImg' => '« ' . translate('Prev'), 'separator' => '', 'spacesBeforeSeparator' => 0, 'spacesAfterSeparator' => 0, 'append' => false, 'clearIfVoid' => true, 'urlVar' => 'page', 'curPageSpanPre' => '<li><span>', 'curPageSpanPost' => '</span></li>', 'curPageClaas' => 'active');
// Override defaults with user-provided values:
foreach ($options as $optionName => $optionValue) {
$finalOptions[$optionName] = $optionValue;
}
// Create the pager object:
$this->pager =& Pager::factory($finalOptions);
}
示例7: pager
function pager(&$paramobject)
{
$year = $paramobject->_param['year'];
$site = $paramobject->_param['site'];
$period = $paramobject->_param['period'];
$focus = $paramobject->_param['focus'];
$rowsum = $paramobject->_rowsum;
require_once dirname(__FILE__) . '/../userlib/Pager/Pager.php';
$options = array("totalItems" => $rowsum, "delta" => 10, "perPage" => 30, "mode" => "Jumping", "altFirst" => "最初", "altPrev" => "前へ", "altNext" => "次へ", "altLast" => "最後", "altPage" => "ページ", "prevImg" => "(前へ)", "nextImg" => "(次へ)", "separator" => " ", "urlVar" => "page", "append" => 0, "fileName" => "index.php?action=list&view=list&year=" . $year . "&site=" . $site . "&period=" . $period . "&focus=" . $focus . "&page=%d");
$pager = Pager::factory($options);
$this->_html .= '<div class="pager">' . $pager->links . "</div>";
}
示例8: __construct
/**
* Constructor
*
* Initialize the PEAR pager object.
*
* @param array $options The Pager options to override.
*
* @access public
*/
public function __construct($options = array())
{
// Set default Pager options:
$perPage = isset($options['perPage']) ? $options['perPage'] : 20;
$finalOptions = array('mode' => 'sliding', 'path' => "", 'delta' => 2, 'perPage' => 20, 'nextImg' => sprintf(translate('page_link_next'), $perPage), 'prevImg' => sprintf(translate('page_link_prev'), $perPage), 'separator' => '', 'spacesBeforeSeparator' => 0, 'spacesAfterSeparator' => 0, 'append' => false, 'clearIfVoid' => true, 'urlVar' => 'page', 'curPageSpanPre' => '<span>', 'curPageSpanPost' => '</span>');
// Override defaults with user-provided values:
foreach ($options as $optionName => $optionValue) {
$finalOptions[$optionName] = $optionValue;
}
// Create the pager object:
$this->_pager =& Pager::factory($finalOptions);
$this->options = $finalOptions;
}
示例9: pager_search
function pager_search ($sql,$cate) {
//インストールしたPEARのPagerライブラリを読み込む
require_once("Pager/Pager.php");
//1ページあたりに表示するデータ数
$pagelength = "10";
//データを格納する配列
$data_array=array();
//SQLを実行する
$sql->bindValue(':CATE', $cate, PDO::PARAM_STR);
$sql->execute();
$list = $sql->fetchAll(PDO::FETCH_ASSOC);
//データ数を取得する
$total = count($list);
//ページャーライブラリに渡す設定(パラメーター
$page=array(
"itemData"=>$list, //アイテムの配列です。
"totalItems"=>$total, //合計アイテム数
"perPage"=>$pagelength, //1ページあたりの表示数
"mode"=>"Jumping",
"linkClass" => "list",
"curPageLinkClassName" => "list",
"altFirst"=>"First", //以下、文字表示設定 1ページ目のalt表示
"altPrev"=>"", //前のalt
'prevImg'=>"<< 前へ", //前へ の文字表示
"altNext"=>"", //次へ のalt
"nextImg"=>"次へ >>", //次へ の文字表示
"altLast"=>"Last", //ラストのalt表示
"altPage"=>"",
"separator"=>" ", //数字と数字の間の文字
"append"=>1,
"urlVar"=>"page",//get属性
);
//Pagerに設定した項目を読み込ませます
$pager= Pager::factory($page);
//現在のページ配列(戻り値)を取得
$data_array['data'] = $pager->getPageData();
//ページ遷移のリンクリストを取得
$data_array['links'] = $pager->links;
$data_array['total'] = $pager->numItems();
//データ配列を返す
return $data_array;
}
示例10: makeCategory
function makeCategory($config, $subcategory)
{
print "Make subcategory {$subcategory['id']} page...\n";
if (!is_dir($outputdir = "{$config->outputdir}/{$subcategory['folder']}")) {
mkdir($outputdir);
}
$item = DB_DataObject::factory("item");
$categDays = $item->getDays();
$pager =& Pager::factory(array("mode" => "Jumping", "perPage" => $config->daynum, "delta" => 10, "itemData" => $categDays, "append" => false, "path" => "../", "fileName" => "{$subcategory['folder']}/index%d.html"));
for ($i = 1; $i <= $pager->numPages(); $i++) {
$tpl = new template();
$tpl->load("templates/category.html", true, true);
$tpl->setv("category_name", $subcategory["name"]);
PagesGenerator::getCategories($tpl, "../");
$data = $pager->getPageData($i);
$links = $pager->getLinks($i);
$tpl->setBlock("pages");
$tpl->setv("pages", $links["all"]);
foreach ($data as $day) {
$res = $item->getItemsForDayCateg($subcategory["id"], $day[0], $config->itemnum);
$res1 = $item->getItemsForDayCateg($subcategory["id"], $day[0], $config->itemnum, true);
if (sizeof($res) == 0 && sizeof($res1) == 0) {
continue;
}
$tpl->setBlock("forday");
$tpl->setv("date", date("Y-m-d", strtotime($day[0])));
if (sizeof($res) > 0) {
foreach ($res as $row) {
$tpl->setBlock("rows");
$tpl->setv($row);
$tpl->parseBlock();
}
}
if (sizeof($res1) > 0) {
$numthumbs = 0;
foreach ($res1 as $row) {
$tpl->setBlock("thumb");
$tpl->setv($row);
$tpl->parseBlock();
if (++$numthumbs >= $config->numthumbs) {
$tpl->parse("rowthumbs");
$numthumbs = 0;
}
}
}
$tpl->parse("forday");
}
file::save("{$config->outputdir}/{$subcategory['folder']}/index{$i}.html", $tpl->get());
}
}
示例11: pager
function pager($itemData, $perPage = 10, $delta = 5, $mode = 'Jumping', $urlVar = 'page', $prevImg = '<', $nextImg = '>', $separator = ' |')
{
list($path, $query) = split("\\?", $_SERVER['REQUEST_URI']);
$options = array('itemData' => $itemData, 'mode' => $mode, 'path' => $path, 'append' => false, 'fileName' => '?' . $urlVar . '=%d', 'perPage' => $perPage, 'delta' => $delta, 'urlVar' => $urlVar, 'prevImg' => $prevImg, 'nextImg' => $nextImg, 'firstPageText' => '<<', 'lastPageText' => '>>', 'firstPagePre' => '', 'firstPagePost' => '', 'lastPagePre' => '', 'lastPagePost' => '', 'separator' => $separator);
$pager =& Pager::factory($options);
$links = $pager->getLinks();
$link_pager = $links['all'];
if (!$pager->isFirstPage()) {
$link_pager = $links['first'] . ' ' . $link_pager;
}
if (!$pager->isLastPage()) {
$link_pager = $link_pager . ' ' . $links['last'];
}
$pager->slider = $link_pager;
return $pager;
}
示例12: getPagesHtml
function getPagesHtml(&$rubrics, &$data, $procNum)
{
$params = array("mode" => "Sliding", "perPage" => 50, "delta" => 3, "nextImg" => "Следующая", "prevImg" => "Предыдущая", "firstPageText" => "В начало", "lastPageText" => "В конец", "append" => false, "path" => "./", "fileName" => "tasks%d.html");
if ($procNum >= 0) {
$expr = " WHERE processes.rprocess_num = {$procNum} ";
} else {
$expr = "";
}
$sql = "\n\t\tSELECT processes.id\n\t\t\tFROM processes\n\t\t\tLEFT JOIN rubrics ON rubrics.id = processes.rubric_id\n\t\t\t{$expr}\n\t\t\tORDER BY adddate DESC, name DESC\n\t";
$res =& $rubrics->db->getAll($sql);
if (!PEAR::isError($res)) {
$params["itemData"] = $res;
}
$pageId = isset($_REQUEST["pageID"]) ? $_REQUEST["pageID"] : 0;
$pager =& Pager::factory($params);
$data = $pager->getPageData($pageId);
$links = $pager->getLinks();
return $links["all"];
}
示例13: get_xsl_pager_params
function get_xsl_pager_params($xml_string)
{
$myedbsess = new MyEDB_SESSION();
//$xml = new SimpleXMLElement($xml_string);
/* Search for <a><b><c> */
//$rows = count($xml->xpath('/records/record'));
// echo "<br>MyEDB_Pager, setting rows results from Session searcres_rowcnt: ".$_SESSION['search_res_row_cnt']." time is ".microtime();
// $rows = $_SESSION['search_res_row_cnt'];
$rows = $myedbsess->search_res_row_cnt;
require_once 'Pager/Pager.php';
$data = range(1, $rows);
//an array of data to paginate
$pager_params = array('mode' => 'Jumping', 'append' => false, 'path' => '', 'fileName' => 'javascript:revealDiv(%d)', 'perPage' => myedbPager::get_num_per_page(), 'delta' => 5, 'itemData' => $data);
$pager =& Pager::factory($pager_params);
$n_pages = $pager->numPages();
//print_r($data); echo $n_pages;
$links = $pager->getLinks();
list($from_row, $to_row) = $pager->getOffsetByPageId();
return array("n_pages" => $n_pages, "page_links" => $links['all'], "numrows" => $rows, "from_row" => $from_row, "to_row" => $to_row, "total_rows" => $rows);
}
示例14: preparePager
function preparePager($obj)
{
$c = clone $obj;
$this->pagerOpts['totalItems'] = $this->totalItems = $c->count('distinct');
if ($this->hasPager) {
$obj->_pager = Pager::factory($this->pagerOpts);
$lim = $obj->_pager->getOffsetByPageId();
$obj->limit($lim[0] - 1, $lim[1] + 1 - $lim[0]);
}
if ($this->pointer['sort']) {
if (strpos($this->pointer['sort'], '.') !== false) {
$obj->orderBy($this->pointer['sort'] . ' ' . $this->pointer['direction']);
} else {
$obj->orderBy($obj->tableName() . '.' . $this->pointer['sort'] . ' ' . $this->pointer['direction']);
}
} elseif ($this->defaultSort) {
$ord = $obj->tableName() . '.' . implode(',', $this->defaultSort);
$obj->orderBy($ord);
}
}
示例15: search
function search($term)
{
if (empty($term)) {
$term = '%';
}
$this->_where = $this->getWhere($term);
$pageID = isset($_GET['p']) ? (int) $_GET['p'] : 1;
if ($pageID == 0) {
$pageID = 1;
}
// Select all results
$query = 'SELECT SQL_CALC_FOUND_ROWS name, summary FROM packages WHERE ' . $this->_where . ' ORDER BY name';
$query .= ' LIMIT ' . ($pageID - 1) * $this->_perPage . ', ' . $this->_perPage;
$this->_results = $this->_dbh->getAll($query, null, DB_FETCHMODE_ASSOC);
// Get number of overall results
$query = 'SELECT FOUND_ROWS()';
$this->_total = $this->_dbh->getOne($query);
$params = array('mode' => 'Jumping', 'perPage' => $this->_perPage, 'urlVar' => 'p', 'itemData' => range(1, $this->_total), 'extraVars' => array('q' => $term));
$this->_pager =& Pager::factory($params);
}