使用PHP以编程方式将CSS注入Joomla内容编辑器(JCE)?

使用PHP以编程方式将CSS注入Joomla内容编辑器(JCE)?,php,css,joomla,editor,joomla-component,Php,Css,Joomla,Editor,Joomla Component,我只想在JCE编辑器iframe中嵌入特定页面的样式表,最好使用PHP。现在,JCE管理界面允许您为管理控制面板中加载JCE的每个实例全局设置样式表,并按单个用户配置文件设置样式表。但是,我正在创建自定义组件,以加载编辑器进行显示,如下所示: <?php $editor = JFactory::getEditor(); // JCE set by default echo $editor->display(); 我将建议您如何添加一些内联样式,您可以继续使用相同的方法 编辑器类位

我只想在JCE编辑器iframe中嵌入特定页面的样式表,最好使用PHP。现在,JCE管理界面允许您为管理控制面板中加载JCE的每个实例全局设置样式表,并按单个用户配置文件设置样式表。但是,我正在创建自定义组件,以加载编辑器进行显示,如下所示:

<?php
$editor = JFactory::getEditor();  // JCE set by default
echo $editor->display();

我将建议您如何添加一些内联样式,您可以继续使用相同的方法
编辑器类位于root/libraries/joomla/html/Editor.php中

在这条线的周围你们会发现显示功能

public function display($name, $html, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array())
    {
        ...
        ...
$width = str_replace(';', '', $width);
        $height = str_replace(';', '', $height);

        // Initialise variables.
        $return = null;

        $args['name'] = $name;
        $args['content'] = $html;
        $args['width'] = $width;
        $args['height'] = $height;
        $args['col'] = $col;
        $args['row'] = $row;
        $args['buttons'] = $buttons;
        $args['id'] = $id ? $id : $name;
        $args['event'] = 'onDisplay';
                ...
}
我将尝试传递我的内联样式

public function display($name, $html, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array(),$inlinestyles){
...
$args['inlinestyles'] = $inlinestyles;
...
}
现在我们必须编辑位于root/plugins/editors/jce/jce.php中的jce.php文件

正如您在paramaters事件中看到的,我们将更改onDisplay事件

108号线附近

public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null) {
... 
return $editor;
    }
现在我们将更改此函数并使用JDocument解析我们的样式

public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null,$inlines) {
//blah blah some code
//here comes the fun part
if($inlines){
$document =& JFactory::getDocument();
$document->addStyleDeclaration($inlines);
}

} //end of ondisplay
现在在您的组件中,您必须调用Joomla文档中记录的编辑器

$inlines= 'BODY {'
        . 'background: #00ff00;'
        . 'color: rgb(0,0,255);'
        . '}'; 
$editor = JFactory::getEditor();
echo $editor->display("jobdesc", ""/*$itemData['body']*/, "400", "100", "150", "10", 1, null, null, null, array('mode' => 'advanced'),$inlines);

您能更详细地解释这个问题吗?另外,如果我错了,请纠正我,但JCE似乎没有使用
$params
变量。更新的问题。我不确定$params数组接受什么,甚至不确定JCE是否会使用它们。我对此进行了研究,但我找不到任何接近直接实现这一点的方法。也就是说,如果JCE配置文件不够(使用配置文件,您可以使用不同的CSS集),JCE配置文件实际上不够,除非我可以将配置文件作为参数传递给某个方法。我正在为我的自定义组件使用编辑器,因此,如果有只适用于文章的东西,那么它将是不够的。
$inlines= 'BODY {'
        . 'background: #00ff00;'
        . 'color: rgb(0,0,255);'
        . '}'; 
$editor = JFactory::getEditor();
echo $editor->display("jobdesc", ""/*$itemData['body']*/, "400", "100", "150", "10", 1, null, null, null, array('mode' => 'advanced'),$inlines);