Index: site/App/ECommerce/Product/View.php =================================================================== --- site/App/ECommerce/Product/View.php (revision 5495) +++ site/App/ECommerce/Product/View.php (revision 5496) @@ -109,6 +109,7 @@ { $this->_initListRedirection(); $item = $this->_getListItem(); + $this->_initListPageNumber($item); if (empty($item['list']) && !$this->_hasSubCategories()) { $this->_do404(); } Index: site/App/Committee/CommitteeList.php =================================================================== --- site/App/Committee/CommitteeList.php (revision 5495) +++ site/App/Committee/CommitteeList.php (revision 5496) @@ -6,5 +6,6 @@ class CommitteeList extends Qs_ViewController_List { + protected $_isDisabledLimit = true; public $defaultOrderBy = 'sorter'; -} \ No newline at end of file +} \ No newline at end of file Index: site/Qs/String.php =================================================================== --- site/Qs/String.php (revision 5495) +++ site/Qs/String.php (revision 5496) @@ -33,6 +33,39 @@ }, array_keys($placeholders) ); + if (false !== strpos($string, '[')) { + $string = self::clearOptionals($string, $placeholders, $delimiters); + } return str_replace($keys, $placeholders, $string); } + + /** + * Clear placeholders wrapper in "[]" that have empty values + * @param $format string like '{var1}[ - {var2}] - {var3}' + * @param array $placeholders + * @param string $delimiters + * @return bool|string like like '{var1} - {var}' if var2 is empty + */ + public static function clearOptionals($format, array $placeholders, $delimiters = '%%') + { + if (!is_string($delimiters) || strlen($delimiters) != 2) { + trigger_error('Delimiters argument must be 2 characters string', E_USER_WARNING); + return false; + } + foreach ($placeholders as $placeholder => $value) { + if (!empty($value)) { + continue; + } + $placeholder = $delimiters[0] . $placeholder . $delimiters[1]; + $format = preg_replace('/\[[^\[]*' . preg_quote($placeholder) . '[^\]]*\]/', '', $format); + } + $chars = str_split($format); + $length = count($chars); + for ($i = 0; $i < $length; $i ++) { + if (in_array($chars[$i], ['[', ']']) && ($i == 0 || $chars[$i-1] != '\\')) { + unset($chars[$i]); + } + } + return str_replace(['\\[', '\\]'], ['[',']'], implode($chars)); + } } Index: site/Qs/ViewController.php =================================================================== --- site/Qs/ViewController.php (revision 5495) +++ site/Qs/ViewController.php (revision 5496) @@ -1128,11 +1128,22 @@ { $this->_initListRedirection(); $item = $this->_getListItem(); + $this->_initListPageNumber($item); $this->_addLinksItem(); $this->_addItem($item); return $this; } + protected function _initListPageNumber(array $listItem) + { + if ($this->getOption('groupName') == Qs_Doc::ITEM_GROUP_MAIN + && ($page = Qs_Array::get($listItem, 'paginator[current]')) && $page > 1 + ) { + $this->_doc->setPageNumber($page); + } + return $this; + } + protected function _initListRedirection() { $list = $this->_getList(); Index: site/Qs/Doc.php =================================================================== --- site/Qs/Doc.php (revision 5495) +++ site/Qs/Doc.php (revision 5496) @@ -4,6 +4,8 @@ { const POPUP = 'popup'; + const ITEM_GROUP_MAIN = 'ITEMS'; + const MESSAGE_BOX_MESSAGE = 'message'; const MESSAGE_BOX_ERROR = 'error'; const MESSAGE_BOX_ATTENTION = 'attention'; @@ -40,9 +42,10 @@ 'ctrlMenu' => null, 'ITEMS' => array(), ); - protected $_titleFormat = '%title%%separator%%siteName%'; + protected $_titleFormat = '[{title}][{separator}Page {pageNumber}]{separator}{siteName}'; protected $_titleSeparator = ' :: '; protected $_titleParts = []; + protected $_pageNumber; protected $_siteName; protected $_resourcesIgnoredAttribs = array( 'skipPacking', // якщо стилю чи скрипту в атрибутах передати 'skipPacking' => true, то Qs_Packer такі ресурси мерджити не буде @@ -441,15 +444,35 @@ return $this->_siteName; } + /** + * @param mixed $pageNumber + * @return $this + */ + public function setPageNumber($pageNumber) + { + $this->_pageNumber = (int) $pageNumber; + return $this; + } + + /** + * @return mixed + */ + public function getPageNumber() + { + return $this->_pageNumber; + } + public function getTitle() { return Qs_String::fill( $this->getTitleFormat(), [ - 'title' => implode($this->getTitleSeparator(), $this->getTitleParts()), - 'separator' => $this->getTitleSeparator(), - 'siteName' => $this->getSiteName() - ] + 'title' => implode($this->getTitleSeparator(), $this->getTitleParts()), + 'separator' => $this->getTitleSeparator(), + 'pageNumber' => $this->getPageNumber() > 1 ? $this->getPageNumber() : null, + 'siteName' => $this->getSiteName() + ], + '{}' ); } Index: site/App/Blog/View.php =================================================================== --- site/App/Blog/View.php (revision 5578) +++ site/App/Blog/View.php (revision 5579) @@ -165,7 +165,7 @@ protected function _addComments($idPost) { - $commentView = new Comment\View(); + $commentView = new Comment\View(['groupName' => $this->getOption('groupName')]); $commentView->setIdItem($this->_getCommentsItemId()); $commentView->setDoc($this->_doc); $commentView->setIdPost($idPost);