Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Commit

Permalink
TinyMCE integration (maked by Slava Plaksiy)
Browse files Browse the repository at this point in the history
  • Loading branch information
bezumkin committed Sep 10, 2012
1 parent 5f37182 commit 3997885
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
12 changes: 8 additions & 4 deletions assets/components/minishop/js/mgr/widgets/goods.grid.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
miniShop.tempids = {};

function renderImg(img) {
if (img.length > 0) {
if (!/(jpg|jpeg|png|gif|bmp)$/.test(img)) {return img;}
Expand Down Expand Up @@ -170,8 +172,10 @@ Ext.extend(miniShop.grid.Goods,MODx.grid.Grid,{
}}
}
});
w.setValues(r.object);
w.show(e.target,function() {w.setPosition(null,50)},this);
w.setValues(r.object);
var ed = Ext.getCmp('modx-'+miniShop.tempids.createGoods+'-content');
ed.setRawValue(r.object.content);
},scope:this}
}
});
Expand Down Expand Up @@ -265,8 +269,8 @@ Ext.reg('minishop-grid-goods',miniShop.grid.Goods);

miniShop.window.createGoods = function(config) {
config = config || {};

this.ident = config.ident || 'qcr'+Ext.id();
this.ident = miniShop.tempids.createGoods = config.ident || 'qcr'+Ext.id();
Ext.applyIf(config,{
title: _('ms.goods.create')
,id: this.ident
Expand Down Expand Up @@ -328,7 +332,7 @@ miniShop.window.createGoods = function(config) {
,{xtype: 'xcheckbox',name: 'cacheable',id: 'modx-'+this.ident+'-cacheable',boxLabel: _('resource_cacheable'),description: _('resource_cacheable_help'),inputValue: 1,checked: MODx.config.cache_default == '1' && config.disable_categories ? 1 : 0}
]
}]
},{xtype: config.record.richtext ? 'htmleditor' : 'textarea',name: 'content',id: 'modx-'+this.ident+'-content', fieldLabel: _('content'),anchor: '100%',height: 150}
},{xtype: config.record.richtext ? (typeof Tiny!='undefined') ? 'tinymce' :'htmleditor' : 'textarea',name: 'content',id: 'modx-'+this.ident+'-content', fieldLabel: _('content'),anchor: '100%',height: 150}
,{xtype: 'xcheckbox',name: 'richtext',id: 'modx-'+this.ident+'-richtext',boxLabel: _('resource_richtext'),description: _('resource_richtext_help'),inputValue: 1,checked: MODx.config.richtext_default == '1' && config.disable_categories ? 1 : 0}
,{xtype: 'hidden',name: 'class_key',value: 'modDocument'}
,{xtype: 'hidden',name: 'context_key'}
Expand Down
38 changes: 38 additions & 0 deletions core/components/minishop/controllers/mgr/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,42 @@
});
</script>');

// RichText editors
if ($modx->getOption('use_editor') == 1) {
// TinyMCE
if (strtolower($modx->getOption('which_editor')) == 'tinymce') {
$modx->regClientStartupScript($modx->getOption('assets_url').'components/tinymce/jscripts/tiny_mce/tiny_mce.js');
for ($i=1; $i<6; $i++)
${'cb'.$i} = $modx->getOption('minishop.tiny.custom_buttons'.$i);

$height = $modx->getOption('minishop.tiny.height',null,200);
$width = $modx->getOption('minishop.tiny.width',null,400);
$plugins = $modx->getOption('minishop.tiny.custom_plugins');
$theme = $modx->getOption('minishop.tiny.editor_theme');
$bfs = $modx->getOption('minishop.tiny.theme_advanced_blockformats');
$css = $modx->getOption('minishop.tiny.css_selectors');

$tinyProperties = array(
'height' => $height,
'width' => $width,
'tiny.custom_buttons1' => (!empty($cb1)) ? $cb1 : $modx->getOption('tiny.custom_buttons1'),
'tiny.custom_buttons2' => (!empty($cb2)) ? $cb2 : $modx->getOption('tiny.custom_buttons2'),
'tiny.custom_buttons3' => (!empty($cb3)) ? $cb3 : $modx->getOption('tiny.custom_buttons3'),
'tiny.custom_buttons4' => (!empty($cb4)) ? $cb4 : $modx->getOption('tiny.custom_buttons4'),
'tiny.custom_buttons5' => (!empty($cb5)) ? $cb5 : $modx->getOption('tiny.custom_buttons5'),
'tiny.custom_plugins' => (!empty($plugins)) ? $plugins : $modx->getOption('tiny.custom_plugins'),
'tiny.editor_theme' => (!empty($theme)) ? $theme : $modx->getOption('tiny.editor_theme'),
'tiny.theme_advanced_blockformats' => (!empty($bfs)) ? $bfs : $modx->getOption('tiny.theme_advanced_blockformats'),
'tiny.css_selectors' => (!empty($css)) ? $css : $modx->getOption('tiny.css_selectors')
);

$tinyCorePath = $modx->getOption('core_path').'components/tinymce/';
require_once $tinyCorePath.'tinymce.class.php';
$tiny = new TinyMCE($modx,$tinyProperties);
$tiny->setProperties($tinyProperties);
$html = $tiny->initialize();
$modx->regClientHTMLBlock($html);
}
}

return '';

0 comments on commit 3997885

Please sign in to comment.