Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\Privatization\Rector as Privatization;
use Rector\Renaming\Rector as Renaming;
use Rector\Renaming\ValueObject\MethodCallRename as RenamingMethodCallRename;
use Rector\Strict\Rector as Strict;
use Rector\Transform\Rector as Transform;
use Rector\TypeDeclaration\Rector as TypeDeclaration;
Expand All @@ -40,6 +41,10 @@
__DIR__,
])
->withSkipPath(__DIR__ . '/vendor')
# Rename method calls
#->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, [
# new RenamingMethodCallRename('Mage_Core_Model_Layout', 'getBlock', 'getBlockByName'),
#])
->withRules([
Php85\ArrayDimFetch\ArrayFirstLastRector::class,
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ protected function _prepareLayout()
{
parent::_prepareLayout();
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadTinyMce(true);
}

return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ protected function _prepareLayout()
if ($this->isModuleEnabled('Mage_Cms', 'catalog')
&& Mage::getSingleton('cms/wysiwyg_config')->isEnabled()
) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadTinyMce(true);
}

return $this;
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected function _prepareLayout()
{
parent::_prepareLayout();
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadTinyMce(true);
}

return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ protected function _prepareLayout()
{
parent::_prepareLayout();
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadTinyMce(true);
}

return $this;
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ protected function _prepareLayout()
{
// Load Wysiwyg on demand and Prepare layout
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadTinyMce(true);
}

$this->setChild(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ public function getModel()
protected function _prepareLayout()
{
// Load Wysiwyg on demand and Prepare layout
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) {
$block->setCanLoadTinyMce(true);
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadTinyMce(true);
}

$this->setChild(
Expand Down
4 changes: 4 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Page/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* Adminhtml header block
*
* @package Mage_Adminhtml
*
* @method $this setCanLoadExtJs(bool $value)
* @method $this setCanLoadRulesJs(bool $value)
* @method $this setContainerCssClass(string $value)
*/
class Mage_Adminhtml_Block_Page_Head extends Mage_Page_Block_Html_Head
{
Expand Down
2 changes: 2 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Page/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*
* @package Mage_Adminhtml
*
* @method $this setActive(string $menuPath)
* @method string getActive()
* @method $this setAdditionalCacheKeyInfo(array $cacheKeyInfo)
* @method array getAdditionalCacheKeyInfo()
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ public function __construct()
*/
protected function _prepareLayout()
{
if ($head = $this->getLayout()->getBlock('head')) {
$head->setCanLoadCalendarJs(true);
}
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadCalendarJs(true);

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ class Mage_Adminhtml_Block_System_Email_Template_Edit_Form extends Mage_Adminhtm
*/
protected function _prepareLayout()
{
/** @var Mage_Page_Block_Html_Head $head */
$head = $this->getLayout()->getBlock('head');
$head = $this->getLayout()->getBlockAdminhtmlHead();
if ($head) {
$head->addItem('js', 'prototype/window.js')
->addItem('js_css', 'prototype/windows/themes/default.css')
->addCss('lib/prototype/windows/themes/magento.css')
->addItem('js', 'mage/adminhtml/variables.js');
$head->addItem('js', 'prototype/window.js');
$head->addItem('js_css', 'prototype/windows/themes/default.css');
$head->addCss('lib/prototype/windows/themes/magento.css');
$head->addItem('js', 'mage/adminhtml/variables.js');
}

return parent::_prepareLayout();
Expand Down
5 changes: 2 additions & 3 deletions app/code/core/Mage/Adminhtml/Block/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ public function getCurrentUrl($params = [])

protected function _addBreadcrumb($label, $title = null, $link = null)
{
/** @var Mage_Adminhtml_Block_Widget_Breadcrumbs $block */
$block = $this->getLayout()->getBlock('breadcrumbs');
$block->addLink($label, $title, $link);
$block = $this->getLayout()->getBlockAdminhtmlBreadcrumbs();
$block?->addLink($label, $title, $link);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date extends Mage_Adminhtml
*/
protected function _prepareLayout()
{
if ($head = $this->getLayout()->getBlock('head')) {
$head->setCanLoadCalendarJs(true);
}
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadCalendarJs(true);

return parent::_prepareLayout();
}
Expand Down
12 changes: 7 additions & 5 deletions app/code/core/Mage/Adminhtml/Controller/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ protected function _getHelper()
*
* @return $this
*/
protected function _setActiveMenu($menuPath)
protected function _setActiveMenu(string $menuPath)
{
$this->getLayout()->getBlock('menu')->setActive($menuPath);
$block = $this->getLayout()->getBlockAdminhtmlMenu();
$block?->setActive($menuPath);

return $this;
}

Expand All @@ -109,9 +111,9 @@ protected function _setActiveMenu($menuPath)
*/
protected function _addBreadcrumb($label, $title, $link = null)
{
/** @var Mage_Adminhtml_Block_Widget_Breadcrumbs $block */
$block = $this->getLayout()->getBlock('breadcrumbs');
$block->addLink($label, $title, $link);
$block = $this->getLayout()->getBlockAdminhtmlBreadcrumbs();
$block?->addLink($label, $title, $link);

return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public function editRoleAction()

$this->_addBreadcrumb($breadCrumb, $breadCrumbTitle);

$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadExtJs(true);

$this->_addLeft(
$this->getLayout()->createBlock('adminhtml/api_editroles'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,12 @@ public function editAction()

$this->loadLayout();
$this->_setActiveMenu('catalog/categories');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
->setContainerCssClass('catalog-categories');

$head = $this->getLayout()->getBlockAdminhtmlHead();
if ($head) {
$head->setCanLoadExtJs(true);
$head->setContainerCssClass('catalog-categories');
}

$this->_addBreadcrumb(
Mage::helper('catalog')->__('Manage Catalog Categories'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public function newAction()
$this->loadLayout();
$this->_setActiveMenu('catalog/reviews_ratings/reviews/all');

$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadExtJs(true);

$this->_addContent($this->getLayout()->createBlock('adminhtml/review_add'));
$this->_addContent($this->getLayout()->createBlock('adminhtml/review_product_grid'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public function editAction()

$this->loadLayout();
$this->_setActiveMenu('catalog/attributes/sets');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadExtJs(true);

$this->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog'));
$this->_addBreadcrumb(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ public function newAction()
$this->_setActiveMenu('catalog/products');
}

$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadExtJs(true);

$block = $this->getLayout()->getBlock('catalog.wysiwyg.js');
if ($block) {
Expand Down Expand Up @@ -268,7 +269,8 @@ public function editAction()
);
}

$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadExtJs(true);

$block = $this->getLayout()->getBlock('catalog.wysiwyg.js');
if ($block) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public function editAction()

$this->_title($id ? $model->getQueryText() : $this->__('New Search'));

$this->getLayout()->getBlock('head')->setCanLoadRulesJs(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadRulesJs(true);

$this->getLayout()->getBlock('catalog_search_edit')
->setData('action', $this->getUrl('*/catalog_search/save'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ public function editRoleAction()

$this->_addBreadcrumb($breadCrumb, $breadCrumbTitle);

$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadExtJs(true);

$this->_addContent(
$this->getLayout()->createBlock('adminhtml/permissions_buttons')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ public function editAction()

$this->_setActiveMenu('system/config');

/** @var Mage_Adminhtml_Block_Page_Menu $block */
$block = $this->getLayout()->getBlock('menu');
$block->setAdditionalCacheKeyInfo([$current]);
$block = $this->getLayout()->getBlockAdminhtmlMenu();
$block?->setAdditionalCacheKeyInfo([$current]);

$this->_addBreadcrumb(
Mage::helper('adminhtml')->__('System'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ public function editAction()

$this->loadLayout();
$this->_setActiveMenu('system/design');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

$id = (int) $this->getRequest()->getParam('id');
$design = Mage::getModel('core/design');
$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadExtJs(true);

$id = (int) $this->getRequest()->getParam('id');
$design = Mage::getModel('core/design');

if ($id) {
$design->load($id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public function editAction()
$this->loadLayout();
$this->_setActiveMenu('catalog/urlrewrite');
$this->_addContent($this->getLayout()->createBlock('adminhtml/urlrewrite_edit'));
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

$head = $this->getLayout()->getBlockAdminhtmlHead();
$head?->setCanLoadExtJs(true);

$this->renderLayout();
}

Expand Down
14 changes: 6 additions & 8 deletions app/code/core/Mage/Catalog/Block/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ public function getTitleSeparator($store = null)
*/
protected function _prepareLayout()
{
/** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbsBlock */
$breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs');
if ($breadcrumbsBlock) {
$breadcrumbsBlock->addCrumb('home', [
$breadcrumbs = $this->getLayout()->getBlockBreadcrumbs();
if ($breadcrumbs) {
$breadcrumbs->addCrumb('home', [
'label' => Mage::helper('catalog')->__('Home'),
'title' => Mage::helper('catalog')->__('Go to Home Page'),
'link' => Mage::getBaseUrl(),
Expand All @@ -46,13 +45,12 @@ protected function _prepareLayout()
$path = Mage::helper('catalog')->getBreadcrumbPath();

foreach ($path as $name => $breadcrumb) {
$breadcrumbsBlock->addCrumb($name, $breadcrumb);
$breadcrumbs->addCrumb($name, $breadcrumb);
$title[] = $breadcrumb['label'];
}

if ($headBlock = $this->getLayout()->getBlock('head')) {
$headBlock->setTitle(implode($this->getTitleSeparator(), array_reverse($title)));
}
$head = $this->getLayout()->getBlockHead();
$head?->setTitle(implode($this->getTitleSeparator(), array_reverse($title)));
}

return parent::_prepareLayout();
Expand Down
15 changes: 7 additions & 8 deletions app/code/core/Mage/Catalog/Block/Category/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,33 @@ protected function _prepareLayout()

$this->getLayout()->createBlock('catalog/breadcrumbs');

/** @var Mage_Page_Block_Html_Head $headBlock */
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
$head = $this->getLayout()->getBlockHead();
if ($head) {
$category = $this->getCurrentCategory();
if ($title = $category->getMetaTitle()) {
$headBlock->setTitle($title);
$head->setTitle($title);
}

if ($description = $category->getMetaDescription()) {
$headBlock->setDescription($description);
$head->setDescription($description);
}

if ($keywords = $category->getMetaKeywords()) {
$headBlock->setKeywords($keywords);
$head->setKeywords($keywords);
}

/** @var Mage_Catalog_Helper_Category $helper */
$helper = $this->helper('catalog/category');
if ($helper->canUseCanonicalTag()) {
$headBlock->addLinkRel('canonical', $category->getUrl());
$head->addLinkRel('canonical', $category->getUrl());
}

/*
want to show rss feed in the url
*/
if ($this->isRssCatalogEnable() && $this->isTopCategory()) {
$title = $this->helper('rss')->__('%s RSS Feed', $this->getCurrentCategory()->getName());
$headBlock->addItem('rss', $this->getRssLink(), 'title="' . $title . '"');
$head->addItem('rss', $this->getRssLink(), 'title="' . $title . '"');
}
}

Expand Down
6 changes: 2 additions & 4 deletions app/code/core/Mage/Catalog/Block/Product/Compare/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ public function getAddToWishlistUrl($product)
*/
protected function _prepareLayout()
{
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
$headBlock->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $headBlock->getDefaultTitle());
}
$head = $this->getLayout()->getBlockHead();
$head?->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $head->getDefaultTitle());

return parent::_prepareLayout();
}
Expand Down
Loading
Loading