![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magefan/module-blog/Block/Archive/ |
<?php /** * Copyright © Magefan ([email protected]). All rights reserved. * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement). * * Glory to Ukraine! Glory to the heroes! */ namespace Magefan\Blog\Block\Archive; use Magefan\Blog\Block\Post\PostList\Toolbar; use Magento\Store\Model\ScopeInterface; /** * Blog archive posts list */ class PostList extends \Magefan\Blog\Block\Post\PostList { /** * Prepare posts collection * @return \Magefan\Blog\Model\ResourceModel\Post\Collection */ protected function _preparePostCollection() { parent::_preparePostCollection(); $this->_postCollection->addArchiveFilter( $this->getYear(), $this->getMonth() ); } /** * Get archive month * @return string */ public function getMonth() { return (int)$this->_coreRegistry->registry('current_blog_archive_month'); } /** * Get archive year * @return string */ public function getYear() { return (int)$this->_coreRegistry->registry('current_blog_archive_year'); } /** * Preparing global layout * * @return $this */ protected function _prepareLayout() { $title = $this->_getTitle(); $this->_addBreadcrumbs($title, 'blog_search'); $this->pageConfig->getTitle()->set($title); if ($this->config->getDisplayCanonicalTag(\Magefan\Blog\Model\Config::CANONICAL_PAGE_TYPE_ARCHIVE)) { $canonicalUrl = $this->_url->getUrl( $this->getYear() . '-' . str_pad($this->getMonth(), 2, '0', STR_PAD_LEFT), \Magefan\Blog\Model\Url::CONTROLLER_ARCHIVE ); $page = (int)$this->_request->getParam($this->getPageParamName()); if ($page > 1) { $canonicalUrl .= ((false === strpos($canonicalUrl, '?')) ? '?' : '&') . $this->getPageParamName() . '=' . $page; } $this->pageConfig->addRemotePageAsset( $canonicalUrl, 'canonical', ['attributes' => ['rel' => 'canonical']] ); } $this->pageConfig->setRobots('NOINDEX,FOLLOW'); $pageMainTitle = $this->getLayout()->getBlock('page.main.title'); if ($pageMainTitle) { $pageMainTitle->setPageTitle( $this->escapeHtml($title) ); } return parent::_prepareLayout(); } /** * Retrieve title * @return string */ protected function _getTitle() { $time = strtotime($this->getYear().'-'.$this->getMonth().'-01'); return sprintf( __('Monthly Archives: %s %s'), __(date('F', $time)), date('Y', $time) ); } }