/**
* Handles language item list management.
+ *
+ * @param integer count
+ * @param integer pageNo
*/
WCF.ACP.Language.ItemList = Class.extend({
/**
/**
* Initializes the WCF.ACP.Style.List class.
+ *
+ * @param integer count
+ * @param integer pageNo
*/
- init: function() {
+ init: function(count, pageNo) {
this._proxy = new WCF.Action.Proxy({
success: $.proxy(this._success, this)
});
var self = this;
$button.click(function() { self._click($languageItemID); });
}, this));
+
+ count = parseInt(count) || 0;
+ if (count > 100) {
+ this._createPagination(count, pageNo);
+ }
+ },
+
+ /**
+ * Creates a pagination for current search result.
+ *
+ * @param integer count
+ * @param integer pageNo
+ */
+ _createPagination: function(count, pageNo) {
+ $('.contentNavigation').each(function(index, contentNavigation) {
+ var $contentNavigation = $(contentNavigation);
+ var $nav = $('<nav />').prependTo($contentNavigation);
+
+ $nav.wcfPages({
+ activePage: parseInt(pageNo) || 1,
+ maxPage: Math.ceil(count / 100)
+ }).on('wcfpagesswitched', function(event, data) {
+ var $form = $('#languageItemSearchForm');
+ $('<input type="hidden" name="pageNo" value="' + data.activePage + '" />').appendTo($form);
+ $form.submit();
+ });
+ });
},
/**
<script data-relocate="true">
//<![CDATA[
$(function() {
- new WCF.ACP.Language.ItemList();
+ new WCF.ACP.Language.ItemList({@$count}, {@$pageNo});
});
//]]>
</script>
{include file='formError'}
-<form method="post" action="{link controller='LanguageItemList'}{/link}">
+<form method="post" action="{link controller='LanguageItemList'}{/link}" id="languageItemSearchForm">
<div class="container containerPadding marginTop">
<fieldset>
<legend>{lang}wcf.global.filter{/lang}</legend>
*/
public $activeMenuItem = 'wcf.acp.menu.link.language.item.list';
+ /**
+ * number of matching phrases
+ * @var integer
+ */
+ public $count = 0;
+
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
*/
public $availableLanguageCategories = array();
+ /**
+ * current page no
+ * @var integer
+ */
+ public $pageNo = 1;
+
/**
* @see \wcf\page\IPage::readParameters()
*/
if (isset($_REQUEST['languageItem'])) $this->languageItem = StringUtil::trim($_REQUEST['languageItem']);
if (isset($_REQUEST['languageItemValue'])) $this->languageItemValue = $_REQUEST['languageItemValue'];
if (!empty($_REQUEST['hasCustomValue'])) $this->hasCustomValue = 1;
+ if (isset($_REQUEST['pageNo'])) $this->pageNo = intval($_REQUEST['pageNo']);
}
/**
if ($this->languageItemValue) $this->languageItemList->getConditionBuilder()->add('((languageUseCustomValue = 0 AND languageItemValue LIKE ?) OR languageCustomItemValue LIKE ?)', array('%'.$this->languageItemValue.'%', '%'.$this->languageItemValue.'%'));
if ($this->hasCustomValue) $this->languageItemList->getConditionBuilder()->add("languageCustomItemValue IS NOT NULL");
if (!$this->languageCategoryID) $this->languageItemList->sqlLimit = 100;
+
+ if (!empty($_POST)) {
+ $this->count = $this->languageItemList->countObjects();
+ $maxPages = ceil($this->count / 100);
+ $this->pageNo = max(min($this->pageNo, $maxPages), 1);
+
+ if ($this->pageNo > 1) {
+ $this->languageItemList->sqlOffset = ($this->pageNo - 1) * 100;
+ }
+ }
+
$this->languageItemList->readObjects();
}
WCF::getTPL()->assign(array(
'objects' => $this->languageItemList,
+ 'count' => $this->count,
+ 'pageNo' => $this->pageNo,
'languageID' => $this->languageID,
'languageCategoryID' => $this->languageCategoryID,
'languageItem' => $this->languageItem,