Last active
October 5, 2022 10:08
-
-
Save andronex/2d17b753a3a62bd16d4fc1f5b6c43cf6 to your computer and use it in GitHub Desktop.
Кастомизация админки
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$eventName = $modx->event->name; | |
switch($eventName) { | |
case 'OnDocFormPrerender': | |
$script = ' | |
if (MODx.loadRTE && Ext.getCmp(\'modx-resource-introtext\')) { | |
MODx.loadRTE(\'modx-resource-introtext\'); | |
} | |
'; | |
$modx->controller->addHtml('<script> | |
Ext.onReady(function() { | |
' . $script . '; | |
}); | |
</script>'); | |
break; | |
case 'OnManagerPageInit': | |
$modx->regClientStartupHTMLBlock("<script> | |
Ext.onReady(function() { | |
if(tabs = Ext.get(\"clientconfig-header\")){ | |
var myEl = { | |
tag: 'div', | |
html: '<div class=\"x-panel-body main-wrapper\"><h3>Памятка</h3><h4><a style=\"color:#9c27b0\" href=\"/manager/?a=mgr/manage&namespace=zregional\">Создание, удаление филиалов, регионов и прочих структурных подразделений компании</a></h4><h4><a style=\"color:#9c27b0\" href=\"/manager/?a=resource/update&id=5&tab=tvs\">Редактирование часов работы / ближайших веток метро</a></h4></div>'}; | |
Ext.DomHelper.insertAfter(tabs, myEl); | |
} | |
Ext.getUrlParam = function(param) { | |
var params = Ext.urlDecode(location.search.substring(1)); | |
return param ? params[param] : params; | |
}; | |
if(Ext.getUrlParam('tab') == 'tvs'){ | |
Ext.getCmp('modx-resource-tabs').setActiveTab('modx-panel-resource-tv'); | |
} | |
//console.log(Ext.getCmp('modx-resource-vtabs')); | |
if(Ext.getUrlParam('id') == 5 && Ext.getUrlParam('a') == 'resource/update'){ | |
//var resource = document.createElement('script'); | |
//resource.async = \"true\"; | |
//resource.src = \"//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"; | |
//var script = document.getElementsByTagName('script')[0]; | |
//script.parentNode.insertBefore(resource, script); | |
if(tabs = Ext.get(\"modx-resource-header\")){ | |
var myEl = { | |
tag: 'div', | |
html: '<div class=\"x-panel-body main-wrapper\"><h3>Памятка</h3><h4><a style=\"color:#9c27b0\" href=\"/manager/?a=mgr/manage&namespace=zregional\">Создание, удаление филиалов, регионов и прочих структурных подразделений компании</a></h4><h4><a style=\"color:#9c27b0\" href=\"/manager/?a=home&namespace=clientconfig&context=web\">Прочие настройки филиалов</a></h4></div>'}; | |
Ext.DomHelper.insertAfter(tabs, myEl); | |
} | |
var cont = Ext.select('#modx-resource-content'); | |
if(cont){ | |
cont.hide(); | |
} | |
var intro = Ext.getCmp('modx-resource-introtext'); | |
if(intro){ | |
intro.hide(); | |
} | |
var r_vis = Ext.select('#x-form-el-modx-resource-richtext'); | |
if(r_vis){ | |
r_vis.hide(); | |
} | |
} | |
if(MODx.config['clientconfig.hide_adminbuttons'] == 1 && Ext.getUrlParam('namespace') == 'clientconfig'){ | |
var fff = Ext.getCmp('modx-action-buttons'); | |
if(fff){ | |
fff.items.items[5].hide = true; | |
fff.items.items[5].disabled = true; | |
Ext.get(fff.items.items[5].id).hide(); | |
} | |
} | |
if(Ext.getUrlParam('a') == 'resource/update'){ | |
var tmpl = Ext.getCmp(\"modx-resource-template\"); | |
if(tmpl.getValue() == 5 || tmpl.getValue() == 9 || tmpl.getValue() == 11 || tmpl.getValue() == 15 || tmpl.getValue() == 17){ | |
var cont = Ext.select('#modx-resource-content'); | |
if(cont){ | |
cont.hide(); | |
} | |
var intro = Ext.getCmp('modx-resource-introtext'); | |
if(intro){ | |
intro.hide(); | |
} | |
var r_vis = Ext.select('#x-form-el-modx-resource-richtext'); | |
if(r_vis){ | |
r_vis.hide(); | |
} | |
} | |
if(tmpl.getValue() == 8 || tmpl.getValue() == 10){ | |
var resource = document.createElement('script'); | |
resource.async = \"true\"; | |
resource.src = \"//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"; | |
var script = document.getElementsByTagName('script')[0]; | |
script.parentNode.insertBefore(resource, script); | |
} | |
if(tmpl.getValue() == 14){ | |
if(tabs = Ext.get(\"modx-resource-header\")){ | |
var myEl = { | |
tag: 'div', | |
html: '<div class=\"x-panel-body main-wrapper\"><h2>Памятка</h2>\ | |
<h3>Для загрузки личных фото и фото работ используйте вкладку \"Галерея\".<br>\ | |
Для фото работ используйте тег \"Работа\", как показано на скрине, чтобы эти фото вывоились в нужном блоке <img src=\"/assets/template/images/2019-12-27_012316.png\"><br>\ | |
Теги можно менять массово, для этого выделите все нужные фото, зажав [Shift], и щёлкните правой кнопкой мышки по ним.</h3></div>'}; | |
Ext.DomHelper.insertAfter(tabs, myEl); | |
} | |
} | |
} | |
}); | |
</script>"); | |
break; | |
case 'OnMODXInit': | |
case 'OnManagerPageInit': | |
$modx->regClientStartupHTMLBlock("<script> | |
var HTTP_HOST = '".$modx->getOption('http_host')."'; | |
console.log('%c Author Programming part: i.modx@ya.ru', 'background: #222; color: #bada55; font-size:200%;'); | |
</script>"); | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$eventName = $modx->event->name; | |
switch($eventName) { | |
case 'OnDocFormPrerender': | |
$script = 'var Andron = {"seo_title":""}'; | |
if($mode == 'upd'){ | |
$seo_title = str_replace(['\''], ['\\\''], $resource->seo_title?:''); | |
$script = "var Andron = {'seo_title':'".$seo_title."'};"; | |
} | |
$script .= ' | |
var seo_title = { | |
xtype: \'textfield\' | |
,name: \'seo_title\' | |
,anchor:\'100%\' | |
,hiddenName: \'seo_title\' | |
,fieldLabel: \'TITLE (Заголовок страницы) <span class="modx-tv-label-description">Если не заполнено - выводится расширенный заголовок H1</span>\' | |
,description: \'<b>{$_modx->resource.seo_title}</b><br>Если не заполнено - выводится расширенный заголовок H1\' | |
,value: Andron.seo_title ? Andron.seo_title : \'\' | |
} | |
Ext.getCmp(\'modx-resource-description\').label.update(\'META description\'); | |
Ext.getCmp(\'modx-resource-longtitle\').label.update(\'H1 тег\'); | |
Ext.getCmp(\'modx-resource-main-left\').add(seo_title); | |
Ext.getCmp(\'modx-resource-pagetitle\').label.update(\'Заголовок <span class="required">*</span>\'); | |
var desc = Ext.get(\'tv13-tr\'); | |
if(desc){ | |
desc.child(\'.modx-tv-label-description\').update(\'Блок с широкой картинкой сверху и текстом в два столбца с возможностью вывода списка. На картинке текст с возможностью добавить кнопку-ссылку / модальное окно. Для вставки в текст используйте сформированный плейсхолдер.\'); | |
} | |
if(Ext.getCmp(\'minishop2-product-tabs\')){ | |
MODx.addTab("minishop2-product-tabs",{title:"Параметры товара / Характеристики",id:"modx-resource-table-sizes"}); | |
a = Ext.getCmp(\'modx-resource-table-sizes\'); | |
/*if(b = Ext.getCmp(\'minishop2-options-vtabs\')){ | |
a.add(b); | |
}*/ | |
price = Ext.getCmp(\'modx-resource-price\'); | |
article = Ext.getCmp(\'modx-resource-article\'); | |
color = Ext.getCmp(\'modx-resource-color\'); | |
old_price = Ext.getCmp(\'modx-resource-old_price\'); | |
sizes = Ext.getCmp(\'modx-resource-size\'); | |
weight = Ext.getCmp(\'modx-resource-weight\'); | |
made_in = Ext.getCmp(\'modx-resource-made_in\'); | |
//vendor = Ext.getCmp(\'modx-resource-vendor\'); | |
new_field = Ext.getCmp(\'modx-resource-new\'); | |
favorite = Ext.getCmp(\'modx-resource-favorite\'); | |
popular = Ext.getCmp(\'modx-resource-popular\'); | |
tags = Ext.getCmp(\'modx-resource-tags\'); | |
searchable = Ext.getCmp(\'modx-resource-searchable\').initialConfig; | |
searchable.checked = Ext.getCmp(\'modx-panel-resource\').record.searchable; | |
searchable.description = \'Товар в наличии или нет\'; | |
Ext.getCmp(\'modx-resource-searchable\').destroy(); | |
thickness = Ext.getCmp(\'modx-resource-thickness\') || {}; | |
//price.fieldLabel = price.fieldLabel + \' (установится минимальная цена из таблицы доступных опций)\'; | |
//price.setReadOnly(true); | |
//old_price.fieldLabel = old_price.fieldLabel + \' (установится минимальная цена из таблицы доступных опций)\'; | |
//old_price.setReadOnly(true); | |
//old_price.hide(); | |
//sizes.fieldLabel = sizes.fieldLabel + \' (установятся при сохранении из таблицы доступных опций)\'; | |
//sizes.setReadOnly(true); | |
//color.fieldLabel = color.fieldLabel + \' (установятся при сохранении из таблицы доступных опций)\'; | |
//color.setReadOnly(true); | |
//weight.fieldLabel = weight.fieldLabel + \' (установится максимальный вес из таблицы доступных опций)\'; | |
//weight.setReadOnly(true); | |
//article.fieldLabel = \'Основной артикул (отдельные можно задать в таблице доступных опций)\'; | |
made_in.fieldLabel = \'Производитель\'; | |
//tab_tv = Ext.getCmp(\'modx-tv-tab13\'); | |
Ext.getCmp(\'ta\').label.update(\'Описание товара\'); | |
var myPanel = new Ext.Panel({ | |
//renderTo : \'modx-resource-table-sizes\', | |
title : \'Основные свойства товара\', | |
//frame : true, | |
//width:\'100%\', | |
autoWidth: true, | |
id : \'modx-resource-table-sizes2\', | |
cls: \'x-panel-body main-wrapper x-panel-body-noheader x-panel-body-noborder\', | |
layout:\'column\', | |
items: [ | |
{ | |
xtype: \'container\', | |
layout: \'form\', | |
width:\'48%\', | |
//autoWidth: true, | |
labelAlign: "top", | |
cls:\'x-column\', | |
id:\'left-shop-panel\', | |
items:[ | |
article,price,old_price,color,sizes,thickness | |
]},{ | |
xtype: \'container\', | |
layout: \'form\', | |
width:\'48%\', | |
//autoWidth: true, | |
labelAlign: "top", | |
cls:\'x-column\', | |
id:\'right-shop-panel\', | |
items:[ | |
weight,made_in,tags,searchable,new_field,popular,favorite | |
]},{ | |
xtype: \'container\',cls:\'x-clear\' | |
},{ | |
xtype: \'container\', | |
layout: \'form\', | |
width:\'99%\', | |
//autoWidth: true, | |
labelAlign: "top", | |
id:\'center-shop-panel\'}] | |
}); | |
//MODx.addTab("modx-resource-table-sizes",{title:"Размеры 2",id:"modx-resource-table-sizes2"}); | |
//myPanel.insert(2,article); | |
//myPanel.insert(3,color); | |
//console.log(myPanel); | |
//myPanel.items.items[0].items.add(0,price); | |
//myPanel.doLayout(); | |
a.insert(0,myPanel); | |
//Ext.getCmp(\'minishop2-options-vtabs\').insert(1,tab_tv); | |
a.doLayout(); | |
cto = Ext.getCmp("modx-panel-resource"); | |
if (cto) { | |
cto.setLabel(["searchable"],["В наличии"]); | |
//new Ext.ToolTip({target: \'modx-resource-searchable\',html: \'[[*title_gallery]]\'}); | |
} | |
MODx.moveTV(["tv15"],"left-shop-panel"); | |
MODx.moveTV(["tv14"],"right-shop-panel"); | |
MODx.moveTV(["tv16"],"center-shop-panel"); | |
//MODx.moveTV(["tv19"],"center-shop-panel"); | |
//MODx.moveTV(["tv19"],"center-shop-panel"); | |
//MODx.moveTV(["tv20"],"center-shop-panel"); | |
//MODx.moveTV(["tv1"],"modx-resource-main-left"); | |
a.doLayout(); | |
//MODx.hideRegion("minishop2-product-tabs", 1); | |
tabs_product = Ext.getCmp(\'minishop2-product-tab\'); | |
//MODx.hiddenTabs.push(tabs_product.items.items[0].items.items[2]); | |
//console.log(tabs_product.items.items[0].getItem(3).getId()); | |
//Ext.getCmp(tabs_product.items.items[0].getItem(3).getId()).doLayout(); | |
Ext.select(\'#minishop2-product-tabs__\'+tabs_product.items.items[0].getItem(2).getId()).remove(); | |
Ext.select(\'#minishop2-product-tabs__\'+tabs_product.items.items[0].getItem(3).getId()).remove(); | |
//tabs_product.doLayout(); | |
/*if (MODx.loadRTE) { | |
MODx.loadRTE(\'modx-resource-material_text\'); | |
}*/ | |
console.log(\'%c Перестроение полей карточки товара\', \'background: #222; color: #bada55; font-size:130%\'); | |
} | |
var tmpl = Ext.getCmp("modx-resource-template"); | |
if(tmpl.getValue() == 8){ | |
ms2gal = Ext.get(\'modx-resource-tabs__ms2gallery-page\'); | |
ms2gal.child(\'span\').update(\'Галерея работ\'); | |
} | |
if(tmpl.getValue() == 10 || tmpl.getValue() == 9 || tmpl.getValue() == 4){ | |
ms2gal = Ext.get(\'modx-resource-tabs__modx-panel-resource-tv\'); | |
if(ms2gal){ | |
ms2gal.child(\'span\').update(\'Блоки страницы\'); | |
} | |
ms2gal = Ext.get(\'modx-resource-tabs__ms2gallery-page\'); | |
if(ms2gal){ | |
ms2gal.child(\'span\').update(\'Галерея в шапке\'); | |
} | |
ms2gal = Ext.get(\'modx-resource-tabs__modx-resource-access-permissions\'); | |
if(ms2gal){ | |
ms2gal.remove(); | |
} | |
} | |
Ext.getUrlParam = function(param) { | |
var params = Ext.urlDecode(location.search.substring(1)); | |
return param ? params[param] : params; | |
}; | |
if((Ext.getUrlParam(\'id\') == 18 || Ext.getUrlParam(\'id\') == 11) && Ext.getUrlParam(\'a\') == \'resource/update\'){ | |
if(tabs = Ext.get("modx-resource-header")){ | |
var myEl = { | |
tag: \'div\', | |
html: \'<div class=\"x-panel-body main-wrapper\"><h3>Памятка</h3><h4>Эта страница является категорией (просто для структуризации дочерних ресурсов) и не подлежит редактированию</h4></div>\'}; | |
Ext.DomHelper.insertAfter(tabs, myEl); | |
} | |
} | |
'; | |
$modx->controller->addHtml('<style>.ms2gallery-thumb-wrap {min-height: 145px;}</style><script> | |
Ext.onReady(function() { | |
' . $script . '; | |
}); | |
</script>'); | |
//для youtube поля | |
$modx->controller->addLastJavascript('/assets/components/ms2gallery/js/mgr/my.js?v=9'); | |
break; | |
case 'OnMODXInit': | |
$modx->map['modResource']['fields']['seo_title'] = ''; | |
$modx->map['modResource']['fieldMeta']['seo_title'] = array( | |
'dbtype' => 'varchar', | |
'precision' => 191, | |
'phptype' => 'string', | |
'null' => false, | |
'default' => '', | |
); | |
case 'OnManagerPageInit': | |
$modx->regClientStartupHTMLBlock("<script> | |
var HTTP_HOST = '".$modx->getOption('http_host')."'; | |
console.log('%c Author Programming part: i.modx@ya.ru', 'background: #222; color: #bada55; font-size:200%;'); | |
</script>"); | |
break; | |
} | |
return true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment