3

できれば PHP を使用して、特定のページに対してのみ、JCE エディタの iframe にスタイルシートを埋め込みたいと考えています。現在、JCE 管理インターフェースを使用すると、管理コントロール パネルで JCE がロードされているすべてのインスタンスに対して、スタイルシートをグローバルに設定したり、個々のユーザー プロファイルごとに設定したりできます。ただし、次のように表示用にエディターをロードするカスタム コンポーネントを作成しています。

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

コンポーネントのさまざまなセクションに基づいて、さまざまなスタイルシートをロードできるようにしたいと考えています。私の知る限り、これはそのままでは存在しないので、これを実現するのに役立つ API メソッドがあるかどうかを確認したいと思います。

何かのようなもの:

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

// calculate whether additional styles may be needed...
if (true === $needs_more_stylesheets_bool) {
   // Would be nice to do something like
   $editor->addStylesheet('specific_styles.css');
   // Or
   $editor->addInlineStyle('body{background:green}');
   // Or
   $editor->removeStylesheet('general_styles.css'); 

   // Or... with adding/editing user profiles... 
   $editor->loadUserProfile('user_2_with_different_stylesheets');
}
4

1 に答える 1

0

インライン スタイルを追加する方法を提案します。同じメソッドを使用して先に進むことができます。 Editor クラスは 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);

http://docs.joomla.org/JFactory/getEditor

于 2013-02-21T01:55:23.367 に答える