当前位置: 首页>>代码示例>>PHP>>正文


PHP Pagination::generate方法代码示例

本文整理汇总了PHP中Pagination::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Pagination::generate方法的具体用法?PHP Pagination::generate怎么用?PHP Pagination::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagination的用法示例。


在下文中一共展示了Pagination::generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 protected function compile()
 {
     if (\Input::get('isAjax') == '1') {
         return;
     }
     $objFilter = new Articlefilter($this->getRootIdFromUrl(), $this->imgSize);
     $objFilter->selectedFilter = \Input::get('articlefilter_filter');
     $objFilter->afstype = \Input::get('afstype');
     $objFilter->sorting = $this->articlefilter_sorting;
     $objFilter->showAll = true;
     $objFilter->run();
     /* search articles matching filter */
     if ($objFilter->resultCount > 0) {
         $resultCount = $objFilter->resultCount;
         $results = $objFilter->results;
         if ($this->perPage > 0 && $resultCount > $this->perPage) {
             $objPagination = new \Pagination($resultCount, $this->perPage);
             $this->Template->pagination = $objPagination->generate();
             $page = \Input::get('page');
             if ($page == '' || $page < 1) {
                 $page = 1;
             }
             $offset = ($page - 1) * $this->perPage;
             $results = array_slice($results, $offset, $this->perPage);
         }
         $this->Template->resultCount = $resultCount;
         $this->Template->results = $results;
         $this->Template->showFilter = $this->articlefilter_showfilter;
         $this->Template->selectedFilter = $objFilter->searchStrings;
         $this->Template->selectedFilterHeadline = sprintf($GLOBALS['TL_LANG']['articlefilter']['selectedFilterHeadline'], $resultCount);
     } else {
         $this->Template->no_filter = true;
     }
 }
开发者ID:kozi,项目名称:contao-articlefilter,代码行数:34,代码来源:ModuleFilterResults.php

示例2: compile

 /**
  * Generate content element
  */
 protected function compile()
 {
     global $objPage;
     $this->import('String');
     $arrDownloadFiles = array();
     $time = time();
     foreach ($this->arrDownloadfiles as $k => $archive) {
         $objArchive = \FelixPfeiffer\Downloadarchive\DownloadarchiveModel::findByPk($k);
         $strLightboxId = 'lightbox[' . substr(md5($objArchive->title . '_' . $objArchive->id), 0, 6) . ']';
         foreach ($archive as $f => $arrFile) {
             #$objFile = \FilesModel::findByUuid($arrFile['singleSRC']);
             $objFile = new \File($f, true);
             // Clean the RTE output
             if ($objPage->outputFormat == 'xhtml') {
                 $arrFile['description'] = \String::toXhtml($arrFile['description']);
             } else {
                 $arrFile['description'] = \String::toHtml5($arrFile['description']);
             }
             $arrFile['description'] = \String::encodeEmail($arrFile['description']);
             $arrFile['css'] = $objArchive->class != "" ? $objArchive->class . ' ' : '';
             $arrFile['ctime'] = $objFile->ctime;
             $arrFile['ctimeformated'] = date($GLOBALS['TL_CONFIG']['dateFormat'], $objFile->ctime);
             $arrFile['mtime'] = $objFile->mtime;
             $arrFile['mtimeformated'] = date($GLOBALS['TL_CONFIG']['dateFormat'], $objFile->mtime);
             $arrFile['atime'] = $objFile->mtime;
             $arrFile['atimeformated'] = date($GLOBALS['TL_CONFIG']['dateFormat'], $objFile->atime);
             // Add an image
             if ($arrFile['addImage'] && $arrFile['imgSRC'] != '') {
                 $objModel = \FilesModel::findByUuid($arrFile['imgSRC']);
                 if (is_file(TL_ROOT . '/' . $objModel->path)) {
                     $size = deserialize($arrFile['size']);
                     $arrFile['imgSRC'] = $arrFile['imgSrc'] = \Image::get($objModel->path, $size[0], $size[1], $size[2]);
                     // Image dimensions
                     if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($arrFile['imgSRC']))) !== false) {
                         $arrFile['arrSize'] = $imgSize;
                         $arrFile['imageSize'] = ' ' . $imgSize[3];
                     }
                     $arrFile['imgHref'] = $objModel->path;
                     $arrFile['alt'] = specialchars($arrFile['alt']);
                     $arrFile['imagemargin'] = $this->generateMargin(deserialize($arrFile['imagemargin']), 'padding');
                     $arrFile['floating'] = in_array($arrFile['floating'], array('left', 'right')) ? sprintf(' float:%s;', $arrFile['floating']) : '';
                     $arrFile['addImage'] = true;
                     $arrFile['lightbox'] = $objPage->outputFormat == 'xhtml' || VERSION < 2.11 ? ' rel="' . $strLightboxId . '"' : ' data-lightbox="' . substr($strLightboxId, 9, -1) . '"';
                 }
             }
             $arrFile['size'] = $this->getReadableSize($objFile->filesize);
             $src = TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon;
             if (($imgSize = @getimagesize(TL_ROOT . '/' . $src)) !== false) {
                 $arrFile['iconSize'] = ' ' . $imgSize[3];
             }
             $arrFile['icon'] = $src;
             $arrFile['href'] = $this->Environment->request . (stristr($this->Environment->request, '?') ? '&' : '?') . 'file=' . $this->urlEncode($f);
             $arrFile['archive'] = $objArchive->title;
             $strSorting = str_replace(array(' ASC', ' DESC'), '', $this->downloadSorting);
             $arrDownloadFiles[$arrFile[$strSorting]][] = $arrFile;
         }
     }
     if (stristr($this->downloadSorting, 'DESC')) {
         krsort($arrDownloadFiles);
     } else {
         ksort($arrDownloadFiles);
     }
     $arrFiles = array();
     foreach ($arrDownloadFiles as $row) {
         foreach ($row as $file) {
             $arrFiles[] = $file;
         }
     }
     if ($this->downloadNumberOfItems > 0) {
         $arrFiles = array_slice($arrFiles, 0, $this->downloadNumberOfItems);
     }
     $i = 0;
     $length = count($arrFiles);
     if ($this->perPage > 0) {
         // Get the current page
         $page = $this->Input->get('page') ? $this->Input->get('page') : 1;
         if ($page > $length / $this->perPage) {
             $page = ceil($length / $this->perPage);
         }
         $offset = (($page > 1 ? $page : 1) - 1) * $this->perPage;
         $arrFiles = array_slice($arrFiles, $offset, $this->perPage);
         // Add pagination menu
         $objPagination = new Pagination($length, $this->perPage);
         $this->Template->pagination = $objPagination->generate("\n  ");
         $length = count($arrFiles);
     }
     foreach ($arrFiles as $file) {
         $class = "";
         if ($i++ == 0) {
             $class = "first ";
         }
         $class .= $i % 2 == 0 ? "even" : "odd";
         if ($i == $length) {
             $class .= " last";
         }
         $arrFiles[$i - 1]['css'] .= $class;
     }
//.........这里部分代码省略.........
开发者ID:felixpfeiffer,项目名称:contao-downloadarchive,代码行数:101,代码来源:ModuleDownloadarchive.php

示例3: addCommentsToTemplate

 /**
  * Add comments to a template
  * @param FrontendTemplate
  * @param stdClass
  * @param string
  * @param integer
  * @param array
  */
 public function addCommentsToTemplate(FrontendTemplate $objTemplate, stdClass $objConfig, $strSource, $intParent, $arrNotifies)
 {
     global $objPage;
     $this->import('String');
     $limit = null;
     $arrComments = array();
     // Pagination
     if ($objConfig->perPage > 0) {
         // Get the total number of comments
         $objTotal = $this->Database->prepare("SELECT COUNT(*) AS count FROM tl_comments WHERE source=? AND parent=?" . (!BE_USER_LOGGED_IN ? " AND published=1" : ""))->execute($strSource, $intParent);
         $total = $objTotal->count;
         // Get the current page
         $page = $this->Input->get('page') ? $this->Input->get('page') : 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $objConfig->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             $objTemplate->allowComments = false;
             $objTemplate->comments = array();
             // see #4064
             return;
         }
         // Set limit and offset
         $limit = $objConfig->perPage;
         $offset = ($page - 1) * $objConfig->perPage;
         // Initialize the pagination menu
         $objPagination = new Pagination($objTotal->count, $objConfig->perPage);
         $objTemplate->pagination = $objPagination->generate("\n  ");
     }
     $objTemplate->allowComments = true;
     // Get all published comments
     $objCommentsStmt = $this->Database->prepare("SELECT c.*, u.name as authorName FROM tl_comments c LEFT JOIN tl_user u ON c.author=u.id WHERE c.source=? AND c.parent=?" . (!BE_USER_LOGGED_IN ? " AND c.published=1" : "") . " ORDER BY c.date" . ($objConfig->order == 'descending' ? " DESC" : ""));
     if ($limit) {
         $objCommentsStmt->limit($limit, $offset);
     }
     $objComments = $objCommentsStmt->execute($strSource, $intParent);
     $total = $objComments->numRows;
     if ($total > 0) {
         $count = 0;
         if ($objConfig->template == '') {
             $objConfig->template = 'com_default';
         }
         $objPartial = new FrontendTemplate($objConfig->template);
         while ($objComments->next()) {
             $objPartial->setData($objComments->row());
             // Clean the RTE output
             if ($objPage->outputFormat == 'xhtml') {
                 $objComments->comment = $this->String->toXhtml($objComments->comment);
             } else {
                 $objComments->comment = $this->String->toHtml5($objComments->comment);
             }
             $objPartial->comment = trim(str_replace(array('{{', '}}'), array('&#123;&#123;', '&#125;&#125;'), $objComments->comment));
             $objPartial->datim = $this->parseDate($objPage->datimFormat, $objComments->date);
             $objPartial->date = $this->parseDate($objPage->dateFormat, $objComments->date);
             $objPartial->class = ($count < 1 ? ' first' : '') . ($count >= $total - 1 ? ' last' : '') . ($count % 2 == 0 ? ' even' : ' odd');
             $objPartial->by = $GLOBALS['TL_LANG']['MSC']['comment_by'];
             $objPartial->id = 'c' . $objComments->id;
             $objPartial->timestamp = $objComments->date;
             $objPartial->datetime = date('Y-m-d\\TH:i:sP', $objComments->date);
             $objPartial->addReply = false;
             // Reply
             if ($objComments->addReply && $objComments->reply != '' && $objComments->authorName != '') {
                 $objPartial->addReply = true;
                 $objPartial->rby = $GLOBALS['TL_LANG']['MSC']['reply_by'];
                 $objPartial->reply = $this->replaceInsertTags($objComments->reply);
                 // Clean the RTE output
                 if ($objPage->outputFormat == 'xhtml') {
                     $objPartial->reply = $this->String->toXhtml($objPartial->reply);
                 } else {
                     $objPartial->reply = $this->String->toHtml5($objPartial->reply);
                 }
             }
             $arrComments[] = $objPartial->parse();
             ++$count;
         }
     }
     $objTemplate->comments = $arrComments;
     $objTemplate->addComment = $GLOBALS['TL_LANG']['MSC']['addComment'];
     $objTemplate->name = $GLOBALS['TL_LANG']['MSC']['com_name'];
     $objTemplate->email = $GLOBALS['TL_LANG']['MSC']['com_email'];
     $objTemplate->website = $GLOBALS['TL_LANG']['MSC']['com_website'];
     $objTemplate->commentsTotal = $limit ? $objTotal->count : $total;
     // Get the front end user object
     $this->import('FrontendUser', 'User');
     // Access control
     if ($objConfig->requireLogin && !BE_USER_LOGGED_IN && !FE_USER_LOGGED_IN) {
         $objTemplate->requireLogin = true;
         return;
     }
//.........这里部分代码省略.........
开发者ID:jens-wetzel,项目名称:use2,代码行数:101,代码来源:Comments.php

示例4: paginationMenu

 /**
  * Return a pagination menu to browse results
  *
  * @return string
  */
 protected function paginationMenu()
 {
     $session = $this->Session->getData();
     $filter = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 4 ? $this->strTable . '_' . CURRENT_ID : $this->strTable;
     list($offset, $limit) = explode(',', $this->limit);
     // Set the limit filter based on the page number
     if (isset($_GET['lp'])) {
         $lp = intval(\Input::get('lp')) - 1;
         if ($lp >= 0 && $lp < ceil($this->total / $limit)) {
             $session['filter'][$filter]['limit'] = $lp * $limit . ',' . $limit;
             $this->Session->setData($session);
         }
         $this->redirect(preg_replace('/&(amp;)?lp=[^&]+/i', '', \Environment::get('request')));
     }
     if ($limit) {
         \Input::setGet('lp', $offset / $limit + 1);
     }
     $objPagination = new \Pagination($this->total, $limit, 7, 'lp', new \BackendTemplate('be_pagination'), true);
     return $objPagination->generate();
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:25,代码来源:DC_Table.php

示例5: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     if ($this->rss_template != 'rss_default') {
         $this->strTemplate = $this->rss_template;
         $this->Template = new \FrontendTemplate($this->strTemplate);
         $this->Template->setData($this->arrData);
     }
     $this->Template->link = $this->objFeed->get_link();
     $this->Template->title = $this->objFeed->get_title();
     $this->Template->language = $this->objFeed->get_language();
     $this->Template->description = $this->objFeed->get_description();
     $this->Template->copyright = $this->objFeed->get_copyright();
     // Add image
     if ($this->objFeed->get_image_url()) {
         $this->Template->image = true;
         $this->Template->src = $this->objFeed->get_image_url();
         $this->Template->alt = $this->objFeed->get_image_title();
         $this->Template->href = $this->objFeed->get_image_link();
         $this->Template->height = $this->objFeed->get_image_height();
         $this->Template->width = $this->objFeed->get_image_width();
     }
     // Get items
     $arrItems = $this->objFeed->get_items(intval($this->skipFirst), intval($this->numberOfItems));
     $limit = count($arrItems);
     $offset = 0;
     // Split pages
     if ($this->perPage > 0) {
         // Get the current page
         $id = 'page_r' . $this->id;
         $page = \Input::get($id) ?: 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > ceil(count($arrItems) / $this->perPage)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             $this->Template->items = array();
             return;
         }
         // Set limit and offset
         $offset = ($page - 1) * $this->perPage;
         $limit = $this->perPage + $offset;
         $objPagination = new \Pagination(count($arrItems), $this->perPage, 7, $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $items = array();
     $last = min($limit, count($arrItems)) - 1;
     for ($i = $offset; $i < $limit && $i < count($arrItems); $i++) {
         $items[$i] = array('link' => $arrItems[$i]->get_link(), 'title' => $arrItems[$i]->get_title(), 'permalink' => $arrItems[$i]->get_permalink(), 'description' => str_replace(array('<?', '?>'), array('&lt;?', '?&gt;'), $arrItems[$i]->get_description()), 'class' => ($i == 0 ? ' first' : '') . ($i == $last ? ' last' : '') . ($i % 2 == 0 ? ' even' : ' odd'), 'pubdate' => $this->parseDate($objPage->datimFormat, $arrItems[$i]->get_date('U')), 'category' => $arrItems[$i]->get_category(0));
         // Add author
         if (($objAuthor = $arrItems[$i]->get_author(0)) != false) {
             $items[$i]['author'] = trim($objAuthor->name . ' ' . $objAuthor->email);
         }
         // Add enclosure
         if (($objEnclosure = $arrItems[$i]->get_enclosure(0)) != false) {
             $items[$i]['enclosure'] = $objEnclosure->get_link();
         }
     }
     $this->Template->items = array_values($items);
 }
开发者ID:rikaix,项目名称:core,代码行数:65,代码来源:ModuleRssReader.php

示例6: addToTemplate

 /**
  * Add a list of versions to a template
  *
  * @param \BackendTemplate|object $objTemplate
  */
 public static function addToTemplate(\BackendTemplate $objTemplate)
 {
     $arrVersions = array();
     $objUser = \BackendUser::getInstance();
     $objDatabase = \Database::getInstance();
     // Get the total number of versions
     $objTotal = $objDatabase->prepare("SELECT COUNT(*) AS count FROM tl_version WHERE version>1" . (!$objUser->isAdmin ? " AND userid=?" : ""))->execute($objUser->id);
     $intLast = ceil($objTotal->count / 30);
     $intPage = \Input::get('vp') !== null ? \Input::get('vp') : 1;
     $intOffset = ($intPage - 1) * 30;
     // Validate the page number
     if ($intPage < 1 || $intLast > 0 && $intPage > $intLast) {
         header('HTTP/1.1 404 Not Found');
     }
     // Create the pagination menu
     $objPagination = new \Pagination($objTotal->count, 30, 7, 'vp', new \BackendTemplate('be_pagination'));
     $objTemplate->pagination = $objPagination->generate();
     // Get the versions
     $objVersions = $objDatabase->prepare("SELECT pid, tstamp, version, fromTable, username, userid, description, editUrl, active FROM tl_version" . (!$objUser->isAdmin ? " WHERE userid=?" : "") . " ORDER BY tstamp DESC, pid, version DESC")->limit(30, $intOffset)->execute($objUser->id);
     while ($objVersions->next()) {
         $arrRow = $objVersions->row();
         // Add some parameters
         $arrRow['from'] = max($objVersions->version - 1, 1);
         // see #4828
         $arrRow['to'] = $objVersions->version;
         $arrRow['date'] = date(\Config::get('datimFormat'), $objVersions->tstamp);
         $arrRow['description'] = \String::substr($arrRow['description'], 32);
         $arrRow['shortTable'] = \String::substr($arrRow['fromTable'], 18);
         // see #5769
         if ($arrRow['editUrl'] != '') {
             $arrRow['editUrl'] = preg_replace('/&(amp;)?rt=[a-f0-9]+/', '&amp;rt=' . REQUEST_TOKEN, ampersand($arrRow['editUrl']));
         }
         $arrVersions[] = $arrRow;
     }
     $intCount = -1;
     $arrVersions = array_values($arrVersions);
     // Add the "even" and "odd" classes
     foreach ($arrVersions as $k => $v) {
         $arrVersions[$k]['class'] = ++$intCount % 2 == 0 ? 'even' : 'odd';
         try {
             // Mark deleted versions (see #4336)
             $objDeleted = $objDatabase->prepare("SELECT COUNT(*) AS count FROM " . $v['fromTable'] . " WHERE id=?")->execute($v['pid']);
             $arrVersions[$k]['deleted'] = $objDeleted->count < 1;
         } catch (\Exception $e) {
             // Probably a disabled module
             --$intCount;
             unset($arrVersions[$k]);
         }
     }
     $objTemplate->versions = $arrVersions;
 }
开发者ID:juergen83,项目名称:contao,代码行数:56,代码来源:Versions.php

示例7: compile


//.........这里部分代码省略.........
                 if (!empty($images)) {
                     $arrOrder = array_merge($arrOrder, $images);
                 }
                 // Remove empty or numeric (not replaced) entries
                 foreach ($arrOrder as $k => $v) {
                     if ($v == '' || is_numeric($v)) {
                         unset($arrOrder[$k]);
                     }
                 }
                 $images = $arrOrder;
                 unset($arrOrder);
             }
             break;
         case 'random':
             shuffle($images);
             break;
     }
     $images = array_values($images);
     // Limit the total number of items (see #2652)
     if ($this->numberOfItems > 0) {
         $images = array_slice($images, 0, $this->numberOfItems);
     }
     $offset = 0;
     $total = count($images);
     $limit = $total;
     // Pagination
     if ($this->perPage > 0) {
         // Get the current page
         $id = 'page_g' . $this->id;
         $page = \Input::get($id) ?: 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             return;
         }
         // Set limit and offset
         $offset = ($page - 1) * $this->perPage;
         $limit = min($this->perPage + $offset, $total);
         $objPagination = new \Pagination($total, $this->perPage, 7, $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $rowcount = 0;
     $colwidth = floor(100 / $this->perRow);
     $intMaxWidth = TL_MODE == 'BE' ? floor(640 / $this->perRow) : floor($GLOBALS['TL_CONFIG']['maxImageWidth'] / $this->perRow);
     $strLightboxId = 'lightbox[lb' . $this->id . ']';
     $body = array();
     // Rows
     for ($i = $offset; $i < $limit; $i = $i + $this->perRow) {
         $class_tr = '';
         if ($rowcount == 0) {
             $class_tr .= ' row_first';
         }
         if ($i + $this->perRow >= $limit) {
             $class_tr .= ' row_last';
         }
         $class_eo = $rowcount % 2 == 0 ? ' even' : ' odd';
         // Columns
         for ($j = 0; $j < $this->perRow; $j++) {
             $class_td = '';
             if ($j == 0) {
                 $class_td = ' col_first';
             }
             if ($j == $this->perRow - 1) {
                 $class_td = ' col_last';
             }
             $objCell = new \stdClass();
             $key = 'row_' . $rowcount . $class_tr . $class_eo;
             // Empty cell
             if (!is_array($images[$i + $j]) || $j + $i >= $limit) {
                 $objCell->class = 'col_' . $j . $class_td;
             } else {
                 // Add size and margin
                 $images[$i + $j]['size'] = $this->size;
                 $images[$i + $j]['imagemargin'] = $this->imagemargin;
                 $images[$i + $j]['fullsize'] = $this->fullsize;
                 $this->addImageToTemplate($objCell, $images[$i + $j], $intMaxWidth, $strLightboxId);
                 // Add column width and class
                 $objCell->colWidth = $colwidth . '%';
                 $objCell->class = 'col_' . $j . $class_td;
             }
             $body[$key][$j] = $objCell;
         }
         ++$rowcount;
     }
     $strTemplate = 'gallery_default';
     // Use a custom template
     if (TL_MODE == 'FE' && $this->galleryTpl != '') {
         $strTemplate = $this->galleryTpl;
     }
     $objTemplate = new \FrontendTemplate($strTemplate);
     $objTemplate->setData($this->arrData);
     $objTemplate->body = $body;
     $objTemplate->headline = $this->headline;
     // see #1603
     $this->Template->images = $objTemplate->parse();
 }
开发者ID:rikaix,项目名称:core,代码行数:101,代码来源:ContentGallery.php

示例8: compile

 /**
  * Generate the content element
  */
 protected function compile()
 {
     $images = $this->facebookAlbum->getImages($this->facebook_album_order, $GLOBALS['objPage']->language, $this->metaIgnore, $GLOBALS['objPage']->rootFallbackLanguage);
     if (empty($images)) {
         return;
     }
     $images = array_values($images);
     // Limit the total number of items
     if ($this->numberOfItems > 0) {
         $images = array_slice($images, 0, $this->numberOfItems);
     }
     $offset = 0;
     $total = count($images);
     $limit = $total;
     // Pagination
     if ($this->perPage > 0) {
         // Get the current page
         $id = 'page_g' . $this->id;
         $page = \Input::get($id) !== null ? \Input::get($id) : 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             /** @var \PageError404 $objHandler */
             $handler = new $GLOBALS['TL_PTY']['error_404']();
             $handler->generate($GLOBALS['objPage']->id);
         }
         // Set limit and offset
         $offset = ($page - 1) * $this->perPage;
         $limit = min($this->perPage + $offset, $total);
         $pagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
         $this->Template->pagination = $pagination->generate("\n  ");
     }
     $this->Template->images = $this->generatePartial($images, $offset, $limit);
     // Add the album information
     if ($this->facebook_album_info) {
         $this->compileAlbumInfo($total);
     }
 }
开发者ID:terminal42,项目名称:contao-facebook-albums,代码行数:40,代码来源:AlbumContentElement.php

示例9: compile


//.........这里部分代码省略.........
                 }
                 if ($this->calConf[$event['pid']]['foreground']) {
                     $event['fgstyle'] = $this->calConf[$event['pid']]['foreground'];
                 }
                 $arrEvents[] = $event;
             }
         }
     }
     unset($arrAllEvents, $days);
     $total = count($arrEvents);
     $limit = $total;
     $offset = 0;
     // Overall limit
     if ($this->cal_limit > 0) {
         $total = min($this->cal_limit, $total);
         $limit = $total;
     }
     // Pagination
     if ($this->perPage > 0) {
         $id = 'page_e' . $this->id;
         $page = \Input::get($id) ?: 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             return;
         }
         $offset = ($page - 1) * $this->perPage;
         $limit = min($this->perPage + $offset, $total);
         $objPagination = new \Pagination($total, $this->perPage, 7, $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $strMonth = '';
     $strDate = '';
     $strEvents = '';
     $dayCount = 0;
     $eventCount = 0;
     $headerCount = 0;
     $imgSize = false;
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0) {
             $imgSize = $this->imgSize;
         }
     }
     // Parse events
     for ($i = $offset; $i < $limit; $i++) {
         $event = $arrEvents[$i];
         $blnIsLastEvent = false;
         // Last event on the current day
         if ($i + 1 == $limit || !isset($arrEvents[$i + 1]['firstDate']) || $event['firstDate'] != $arrEvents[$i + 1]['firstDate']) {
             $blnIsLastEvent = true;
         }
         $objTemplate = new \FrontendTemplate($this->cal_template);
         $objTemplate->setData($event);
         // Month header
         if ($strMonth != $event['month']) {
             $objTemplate->newMonth = true;
             $strMonth = $event['month'];
         }
         // Day header
         if ($strDate != $event['firstDate']) {
开发者ID:rolandschuetz,项目名称:calendar_extended,代码行数:67,代码来源:ModuleEventListExt.php

示例10: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $arrArchives = deserialize($this->videobox_archives, true);
     if (empty($arrArchives)) {
         return '';
     }
     // basic template variables
     $this->Template->hasVideos = true;
     // prepare the sql
     $strSQL = '';
     if ($this->videobox_sql) {
         $strSQL = ' ' . trim($this->videobox_sql);
     }
     $intTotal = (int) $this->Database->query('SELECT COUNT(id) AS total FROM tl_videobox WHERE pid IN (' . implode(',', $arrArchives) . ')' . $strSQL)->total;
     if ($intTotal == 0) {
         $this->Template->hasVideos = false;
         $this->Template->msg = $GLOBALS['TL_LANG']['VideoBox']['no_videos'];
         return;
     }
     $limit = $intTotal;
     $offset = 0;
     // Pagination
     if ($this->perPage > 0) {
         $page = $this->Input->get('page') ? $this->Input->get('page') : 1;
         $offset = ($page - 1) * $this->perPage;
         $limit = min($this->perPage + $offset, $intTotal);
         $objPagination = new Pagination($intTotal, $this->perPage);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     // videobox statement
     $objVideosStmt = $this->Database->prepare('SELECT id FROM tl_videobox WHERE pid IN (' . implode(',', $arrArchives) . ')' . $strSQL);
     // Limit the result
     if (isset($limit)) {
         $objVideosStmt->limit($limit, $offset);
     }
     $objVideos = $objVideosStmt->execute();
     $arrVideos = array();
     $count = 0;
     $this->import('VideoBoxHelpers', 'VBHelper');
     while ($objVideos->next()) {
         $arrVideoData = $this->VBHelper->prepareVideoTemplateData($objVideos->id, $this->videobox_jumpTo);
         $arrVideos[$objVideos->id] = array_merge($arrVideoData, array('count' => ++$count, 'cssClass' => ($count == 1 ? ' first' : '') . ($count == $limit ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even')));
     }
     $this->Template->videos = $arrVideos;
 }
开发者ID:laemmi,项目名称:contao-module-videobox,代码行数:48,代码来源:ModuleVideoBoxList.php

示例11: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $offset = intval($this->skipFirst);
     $limit = null;
     // Maximum number of items
     if ($this->numberOfItems > 0) {
         $limit = $this->numberOfItems;
     }
     // Maximum number of items
     if ($this->numberOfItems > 0) {
         $limit = $this->numberOfItems;
     }
     $this->Template->carpets = array();
     $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyCategory'];
     $intTotal = \CarpetModel::countPublishedByPids($this->carpet_categories, $this->carpet_status);
     if ($intTotal < 1) {
         return;
     }
     $total = $intTotal - $offset;
     // Split the results
     if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage)) {
         // Adjust the overall limit
         if (isset($limit)) {
             $total = min($limit, $total);
         }
         // Get the current page
         $id = 'page_n' . $this->id;
         $page = \Input::get($id) ?: 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             return;
         }
         // Set limit and offset
         $limit = $this->perPage;
         $offset += (max($page, 1) - 1) * $this->perPage;
         $skip = intval($this->skipFirst);
         // Overall limit
         if ($offset + $limit > $total + $skip) {
             $limit = $total + $skip - $offset;
         }
         // Add the pagination menu
         $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $arrOptions = array();
     if ($this->carpet_sortBy) {
         switch ($this->carpet_sortBy) {
             case 'title_asc':
                 $arrOptions['order'] = "title ASC";
                 break;
             case 'title_desc':
                 $arrOptions['order'] = "title DESC";
                 break;
             case 'alias_asc':
                 $arrOptions['order'] = "alias ASC";
                 break;
             case 'alias_desc':
                 $arrOptions['order'] = "alias DESC";
                 break;
             case 'date_asc':
                 $arrOptions['order'] = "date ASC";
                 break;
             case 'date_desc':
                 $arrOptions['order'] = "date DESC";
                 break;
             case 'custom':
                 $arrOptions['order'] = "sorting ASC";
                 break;
         }
     }
     // Get the items
     if (isset($limit)) {
         $objCarpets = \CarpetModel::findPublishedByPids($this->carpet_categories, $limit, $offset, $this->carpet_status, $arrOptions);
     } else {
         $objCarpets = \CarpetModel::findPublishedByPids($this->carpet_categories, 0, $offset, $this->carpet_status, $arrOptions);
     }
     // Add the Carpets
     if ($objCarpets !== null) {
         $this->Template->carpets = $this->parseCarpets($objCarpets);
     }
     $this->Template->gategories = $this->carpet_categories;
 }
开发者ID:respinar,项目名称:contao-carpet,代码行数:90,代码来源:ModuleCarpetList.php

示例12: loadEventData

 /**
  * 
  * @param int $id
  * @return Template
  */
 public function loadEventData($id = 0)
 {
     $evt = $this->getEvent($id);
     $sub = $this->getEventSubscription($id);
     $num_sub = $this->countEventSubscription($id);
     //			print_r($evt);
     $objTemplate = new BackendTemplate('mod_event_subscribe');
     $objTemplate->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $objTemplate->referer = 'javascript:history.go(-1)';
     $objTemplate->wildcard = '### EVENT LIST ###';
     $objTemplate->title = $evt['title'];
     $objTemplate->headline = $evt['teaser'];
     $objTemplate->id = $this->id;
     $objTemplate->date_from = date('d/m/Y', $evt['startDate']);
     $objTemplate->date_to = date('d/m/Y', $evt['endDate']);
     $objTemplate->calendar = 'test';
     $objTemplate->link = 'link';
     $objTemplate->entries = $evt;
     $objTemplate->num_sub = $num_sub;
     $objTemplate->sub = $sub;
     //			$objTemplate->referer = 'typolight/main.php?do=tl_calendar_events_subscribe';
     $objTemplate->href = 'typolight/main.php?do=modules&amp;act=edit&amp;id=' . $this->id;
     // Pagination
     if ($this->perPage > 0) {
         $limit = $this->perPage;
         // Get total number of events
         //				$this->num_events = $this->countEvents();
         // Add pagination menu
         $objPagination = new Pagination($num_sub, $this->perPage);
         $objTemplate->pagination = $objPagination->generate("\n  ");
     }
     return $objTemplate->parse();
 }
开发者ID:noodleagency,项目名称:xkn_event_subscribe,代码行数:38,代码来源:ModuleEventSubscribeXML.php

示例13: compile


//.........这里部分代码省略.........
                     } else {
                         $arrSort[] = preg_replace('/\\b' . $arrMatch[1][0] . '\\b/i', '(SELECT value FROM tl_formdata_details WHERE ff_name="' . $arrMatch[1][0] . '" AND pid=f.id)', $strSort);
                     }
                 } else {
                     if (in_array($GLOBALS['TL_DCA']['tl_formdata']['fields'][$arrMatch[1][0]]['eval']['rgxp'], $arrSortSigned)) {
                         $arrSort[] = preg_replace('/\\b' . $arrMatch[1][0] . '\\b/i', 'CAST(' . $arrMatch[1][0] . ' AS DECIMAL)', $strSort);
                     } else {
                         $arrSort[] = $strSort;
                     }
                 }
             }
         }
         if (count($arrSort) > 0) {
             $strListSort = 'ORDER BY ' . implode(',', $arrSort);
         } else {
             $strListSort = '';
         }
         $strQuery .= $strListSort;
     }
     $objDataStmt = $this->Database->prepare($strQuery);
     // Limit
     if (!$blnExport) {
         if (intval($this->Input->get('per_page')) > 0) {
             $objDataStmt->limit($this->Input->get('per_page'), ($page - 1) * $per_page);
         } elseif (intval($this->perPage) > 0) {
             $objDataStmt->limit($this->perPage, ($page - 1) * $per_page);
         }
     }
     $objData = $objDataStmt->execute($varKeyword);
     /**
      * Prepare URL
      */
     //$strUrl = preg_replace('/\?.*$/', '', urldecode($this->Environment->request));
     $strUrl = $this->generateFrontendUrl($objPage->row());
     if ($strUrl == '/' || $strUrl == '//') {
         $strUrl = '';
     }
     $strUrlParams = '';
     $strUrlSuffix = $GLOBALS['TL_CONFIG']['urlSuffix'];
     if (!$blnExport) {
         $this->Template->url = $strUrl;
     }
     $blnQuery = false;
     foreach (preg_split('/&(amp;)?/', urldecode($_SERVER['QUERY_STRING'])) as $fragment) {
         if (strlen($fragment)) {
             if (strncasecmp($fragment, 'file', 5) !== 0 && strncasecmp($fragment, 'act', 3) !== 0 && strncasecmp($fragment, 'order_by', 8) !== 0 && strncasecmp($fragment, 'sort', 4) !== 0 && strncasecmp($fragment, 'page', 4) !== 0) {
                 $strUrlParams .= (!$blnQuery ? '' : '&amp;') . $fragment;
                 $blnQuery = true;
             }
         }
     }
     /**
      * Prepare data arrays
      */
     $arrTh = array();
     $arrTd = array();
     $arrFields = $arrListFields;
     $intRowCounter = -1;
     $intColCounter = 0;
     $intRowCounter++;
     $ignoreFields = array('id', 'pid', 'sorting');
     // THEAD
     if (!$blnExport) {
         for ($i = 0; $i < count($arrFields); $i++) {
             // do not display some special fields
             if (in_array($arrFields[$i], $ignoreFields) || $GLOBALS['TL_DCA'][$this->list_table]['fields'][$arrFields[$i]]['inputType'] == 'password') {
开发者ID:jens-wetzel,项目名称:use2,代码行数:67,代码来源:ModuleFormdataListing.php

示例14: compile


//.........这里部分代码省略.........
     $this->ratedUser->ratingEnities = $this->getRatingEnities($this->ratedUser->id);
     $this->ratedUser->gradeLabel = $this->getGrade($this->ratedUser->id, 'label');
     $this->ratedUser->gradeIcon = $this->getGrade($this->ratedUser->id, 'icon');
     // add data to template
     $keys = array('firstname', 'lastname', 'avatar', 'socialmediaLinks', 'deleteSocialmediaLinkIcon', 'score', 'gradeLabel', 'gradeIcon');
     foreach ($keys as $key) {
         $this->Template->{$key} = $this->ratedUser->{$key};
     }
     if ($this->showTop3) {
         $this->Template->showTop3 = true;
         // ***** TOP 3 SECTION *****
         $objRatings = $this->Database->prepare("SELECT * FROM tl_comments WHERE comment != '' AND source = ? AND parent = ? AND published = ? AND owner > 0 ORDER BY score DESC, dateOfCreation DESC")->limit(3)->execute('tl_member', $this->ratedUser->id, 1);
         $arrTop3 = array();
         while ($row = $objRatings->fetchAssoc()) {
             $objMember = \MemberModel::findByPk($row['owner']);
             $row['time'] = \Date::parse(\Config::get('datimFormat'), $row['dateOfCreation']);
             if ($objMember !== null) {
                 foreach (\MemberModel::findByPk($objMember->id)->row() as $k => $v) {
                     if ($k == 'id' || $k == 'tstamp' || $k == 'password') {
                         continue;
                     }
                     $row[$k] = $v;
                 }
                 // avatar
                 $arrSize = deserialize($this->avatarSizeListing);
                 $title = $objMember->firstname . ' ' . $objMember->lastname;
                 $row['avatar'] = $this->getAvatar($objMember->id, $arrSize, 'avatar', $title, 'avatar_thumb', $this);
             }
             $arrTop3[] = $row;
         }
         $this->Template->top3 = count($arrTop3) > 2 ? $arrTop3 : false;
     }
     // ***** ALL RATINGS SECTION *****
     if ($this->ratedUser->id == $this->loggedInUser->id) {
         $strSql = "SELECT * FROM tl_comments WHERE comment != '' AND source = ? AND parent = ? AND owner > 0 ORDER BY dateOfCreation DESC, score DESC";
     } else {
         $strSql = "SELECT * FROM tl_comments WHERE comment != '' AND source = ? AND parent = ? AND published = '1' AND owner > 0 ORDER BY dateOfCreation DESC, score DESC";
     }
     $objRatings = $this->Database->prepare($strSql)->execute('tl_member', $this->ratedUser->id);
     $arrAllRatings = array();
     while ($row = $objRatings->fetchAssoc()) {
         $objMember = \MemberModel::findByPk($row['owner']);
         // Show only Members from a selected group
         if ($this->limitUsers) {
             $arrGroups = deserialize($this->listedGroups);
             if (count(array_intersect(deserialize($objMember->groups), $arrGroups)) < 1) {
                 continue;
             }
         }
         $row['time'] = \Date::parse(\Config::get('datimFormat'), $row['dateOfCreation']);
         if ($objMember !== null) {
             foreach (\MemberModel::findByPk($objMember->id)->row() as $k => $v) {
                 if ($k == 'id' || $k == 'tstamp' || $k == 'password') {
                     continue;
                 }
                 $row[$k] = $v;
             }
             // avatar
             $arrSize = deserialize($this->avatarSizeListing);
             $title = $objMember->firstname . ' ' . $objMember->lastname;
             $row['avatar'] = $this->getAvatar($objMember->id, $arrSize, 'avatar', $title, 'avatar_thumb', $this);
             // toggle visibility icon
             $visibility = $row['published'] ? 'visible.png' : 'invisible.png';
             $row['visibility_icon_src'] = TL_FILES_URL . sprintf($this->getImageDir() . '/%s', $visibility);
         }
         $arrAllRatings[] = $row;
     }
     // Pagination
     $total = count($arrAllRatings);
     $limit = $total;
     $offset = 0;
     if ($this->perPage > 0) {
         $id = 'page_e' . $this->id;
         $page = \Input::get($id) ?: 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             return;
         }
         $offset = ($page - 1) * $this->perPage;
         $limit = min($this->perPage + $offset, $total);
         $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $arrRatings = array();
     for ($i = $offset; $i < $limit; $i++) {
         $arrRatings[] = $arrAllRatings[$i];
     }
     $this->Template->allRatings = count($arrRatings) ? $arrRatings : false;
     // generate forms
     if (FE_USER_LOGGED_IN) {
         if ($this->loggedInUser->id != $this->ratedUser->id) {
             $this->generateVotingForm();
         }
     }
 }
开发者ID:markocupic,项目名称:member_rating,代码行数:101,代码来源:MemberRatingDetail.php

示例15: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $offset = intval($this->skipFirst);
     $limit = null;
     $this->Template->recipes = array();
     // Maximum number of items
     if ($this->numberOfItems > 0) {
         $limit = $this->numberOfItems;
     }
     // Get the total number of items
     $intTotal = \SimpleRecipesEntriesModel::countRecipesByOpen();
     // Filter anwenden um die Gesamtanzahl zuermitteln
     if ($intTotal > 0) {
         $filterObj = \SimpleRecipesEntriesModel::findRecipes($intTotal, 0);
         $counter = 0;
         $idArr = array();
         while ($filterObj->next()) {
             //wenn alle Filter stimmen -> Werte setzen
             $idArr[] = $filterObj->id;
             $counter++;
         }
         if ((int) $intTotal > $counter) {
             $intTotal = $counter;
         }
     }
     if ((int) $intTotal < 1) {
         $this->Template = new \FrontendTemplate('mod_simple_recipes_entries_empty');
         $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyBmList'];
         return;
     }
     $total = $intTotal - $offset;
     // Split the results
     if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage)) {
         // Adjust the overall limit
         if (isset($limit)) {
             $total = min($limit, $total);
         }
         // Get the current page
         $id = 'page_n' . $this->id;
         $page = \Input::get($id) ?: 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             $objTarget = \PageModel::findByPk($objPage->id);
             if ($objTarget !== null) {
                 $reloadUrl = ampersand($this->generateFrontendUrl($objTarget->row()));
             }
             $this->redirect($reloadUrl);
         }
         // Set limit and offset
         $limit = $this->perPage;
         $offset += (max($page, 1) - 1) * $this->perPage;
         $skip = intval($this->skipFirst);
         // Overall limit
         if ($offset + $limit > $total + $skip) {
             $limit = $total + $skip - $offset;
         }
         // Add the pagination menu
         $objPagination = new \Pagination($total, $this->perPage, $GLOBALS['TL_CONFIG']['maxPaginationLinks'], $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     // Get the items
     if (isset($limit)) {
         $recipesObj = \SimpleRecipesEntriesModel::findRecipes($limit, $offset, $idArr);
     } else {
         $recipesObj = \SimpleRecipesEntriesModel::findRecipes(0, $offset, $idArr);
     }
     // No items found
     if ($recipesObj === null) {
         $this->Template = new \FrontendTemplate('mod_simple_recipes_entries_empty');
         $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptySimpleRecipesList'];
     } else {
         $this->Template->recipes = $this->parseRecipes($recipesObj);
     }
     $this->Template->totalItems = $intTotal;
 }
开发者ID:srhinow,项目名称:simple_recipes,代码行数:81,代码来源:ModuleSimpleRecipesList.php


注:本文中的Pagination::generate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。