Created
January 11, 2017 19:24
-
-
Save Burick/7a38f2f6752545e13d7c04fd4e992e49 to your computer and use it in GitHub Desktop.
Modx Revo Плагин добавляет редактор к указанным полям ресурса
This file contains hidden or 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 | |
/* | |
Плагин добавляет редактор к указанным полям ресурса | |
событие OnDocFormPrerender | |
*/ | |
switch ($modx->event->name) { | |
case 'OnDocFormPrerender': | |
if (!$modx->controller->resourceArray) { | |
return; | |
} | |
// Указываем поля, для которых будет подключаться Ace | |
$fields = array('modx-resource-introtext','modx-resource-description'); | |
$mimeType = $modx->getObject('modContentType', $modx->controller->resourceArray['content_type'])->get('mime_type'); | |
if ($mimeType == 'text/html' && $modx->getOption('pdotools_fenom_parser')) { | |
$mimeType = 'text/x-smarty'; | |
} | |
$modxTags = 1; | |
$script = ''; | |
foreach($fields as $field) { | |
$script .= "MODx.ux.Ace.replaceComponent('$field', '$mimeType', $modxTags);"; | |
} | |
$script .= "MODx.ux.Ace.replaceTextAreas(Ext.query('.modx-richtext'));"; | |
// Увеличиваем поле introtext | |
$script .= "Ext.getCmp('modx-resource-introtext').setHeight(300);"; | |
$modx->controller->addHtml('<script>Ext.onReady(function() {' . $script . '});</script>'); | |
break; | |
default: | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment