CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • ckeditor config
Pages: 1 2 3 [4]

Author Topic: ckeditor config  (Read 88862 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: ckeditor config
October 17, 2010, 01:44:46 pm
@westy,

BTW, please note I've backed away from trying to make CKeditor/IMCE force absolute URLs. Relative URLs should be the default (imagine a secure contributions page containing non-secure URLs for images: the client's browser will report the insecure content, potentially undermining their confidence in the security).

Ken

westy

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 1
  • CiviCRM version: CiviCRM 4.5.0
  • CMS version: Drupal 7.31
  • MySQL version: 5.5.38
  • PHP version: Ubuntu Linux 12.04.3
Re: ckeditor config
October 18, 2010, 03:52:34 am
@ Lobo
On reflection, you're absolutely right. This should be a run-time decision not an installation option.
As you may have gathered I'm a user rather than a professional developer but I'll have look at the question of how to do this and get back to you.
Oh! and I don't know anything about Joomla!

westy

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: ckeditor config
October 19, 2010, 06:47:49 pm
Quote from: westy on October 17, 2010, 04:40:34 am
•   Thanks to FatherShawn for his wiki posting but I think there is an alternative, possibly more logical approach, as posted above by several writers, i.e. to use the Drupal text editor.

I have no problem with being able to leverage the Drupal install.  I just did it this way because I needed the function for a project today!

Absolute urls are a CKFinder config option, and I've updated the wiki accordingly.  To summarize, if you set up the base url in CKFinder to be absolute, you will get absolute urls:
Code: [Select]
$baseUrl = 'http://example.tld/path/to_images/';
$baseDir = '/full/path/to_images/'; 
« Last Edit: October 19, 2010, 07:16:04 pm by FatherShawn »
Lead Developer, C3 Design.
Twitter: @FatherShawn

westy

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 1
  • CiviCRM version: CiviCRM 4.5.0
  • CMS version: Drupal 7.31
  • MySQL version: 5.5.38
  • PHP version: Ubuntu Linux 12.04.3
Re: ckeditor config
October 20, 2010, 02:05:23 am
Thanks for that. Saved me a lot.
The lesson is read the documentation!

westy

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 1
  • CiviCRM version: CiviCRM 4.5.0
  • CMS version: Drupal 7.31
  • MySQL version: 5.5.38
  • PHP version: Ubuntu Linux 12.04.3
Re: ckeditor config
October 28, 2010, 07:59:41 am
Well I had a bit of a go at coming up with some code to include in future versions and had partial success,
As I mentioned in my earlier posts there seems to be two changes required



•to make CiviCRM point to the Drupal CKEditor if it exists, if not point to the packaged version
This was relatively straightforward and involved inserting the following code snippet into the civicrm/templates/CRM/common/drupal.tpl file.
This works correctly and can be tested very simply by enabling and disabling the Drupal CKEditor module.

Code: [Select]
{* temporary hack to fix wysiysg editor failure if js compression is on *}
{if $defaultWysiwygEditor eq 1}
<script type=text/javascript src={$config->resourceBase}packages/tinymce/jscripts/tiny_mce/jquery.tinymce.js></script>
<script type=text/javascript src={$config->resourceBase}packages/tinymce/jscripts/tiny_mce/tiny_mce.js></script>
{elseif $defaultWysiwygEditor eq 2}

{* We want to use the Drupal CKEditor if it exists, if not we will use the CiviCRM packaged version (currently 3.3.1) *}
{*using the Drupal API module_exists($module) function *}


{if (module_exists('ckeditor')) eq 0}
{* module does not exist point to CiviCRM packaged version of CKEditor *}
<script type="text/javascript" src="{$config->resourceBase}packages/ckeditor/ckeditor.js"></script>

{elseif  (module_exists('ckeditor')) eq 1}
{* module does exist so point to Drupal version of CKEditor *}


<script type="text/javascript" src="/sites/all/modules/ckeditor/ckeditor/ckeditor.js?I"></script>
{/if}

    Code:{/if}[/li]

  • •Having got the editor working, the second change is to enable File Browsing.
    Or, in words, 'if the File Browser exists in Drupal then use it'.
    We ned to change civicrm/packages/HTML/QuickForm/ckeditor.php
    This is a bit more problematic, I would have liked to have used the Drupal API module_exists($module) call that I used in the civicrm/templates/CRM/common/drupal.tpl   as described above, but could not get the call to work in the drupal.php file.
    So I tried an alternative approach (bodge) which does work!
    Instead of checking for the module, this checks if the ckfinder.html file exists.
    I’m not completely happy with this part. it is not very elegant as it does not check if the module is disabled. But it has the big advantage that it works!
    Maybe the author of ckeditor.php could help solve this. Here's the relevent replacement code
    Code:

Code: [Select]
function toHtml()
    {
        if ($this->_flagFrozen) {
            return $this->getFrozenHtml();
        } else {
            $name = $this->getAttribute('name');
         if( file_exists($_SERVER{'DOCUMENT_ROOT'} . "/sites/all/modules/ckeditor/ckfinder/ckfinder.html"))
  //   if {module_exists(ckeditor)} {


           { $html = parent::toHtml() . "<script type='text/javascript'>
                cj( function( ) {
                    cj('#{$name}').removeClass();
                    if ( CKEDITOR.instances['{$name}'] ) {
                        CKEDITOR.remove(CKEDITOR.instances['{$name}']);
                    }
                    CKEDITOR.replace( '{$name}',
                    { filebrowserBrowseUrl : '/sites/all/modules/ckeditor/ckfinder/ckfinder.html',
                      filebrowserImageBrowseUrl : '/sites/all/modules/ckeditor/ckfinder/ckfinder.html?Type=Images',
                      filebrowserFlashBrowseUrl : '/sites/all/modules/ckeditor/ckfinder/ckfinder.html?Type=Flash',
                      filebrowserUploadUrl : '/sites/default/files/',
                      filebrowserImageUploadUrl : '/sites/default/files/',
                      filebrowserFlashUploadUrl : '/sites/default/files/'
                    });
                    var editor = CKEDITOR.instances['{$name}'];
                    if ( editor ) {
                        editor.on( 'key', function( evt ){
                            global_formNavigate = false;
                        } );
                        editor.config.width  = '".$this->width."';
                        editor.config.height = '".$this->height."';
                    }
                });
              </script>";
            }
            else
            { $html = parent::toHtml() . "<script type='text/javascript'>
                cj( function( ) {
                    cj('#{$name}').removeClass();
                    if ( CKEDITOR.instances['{$name}'] ) {
                        CKEDITOR.remove(CKEDITOR.instances['{$name}']);
                    }
                    CKEDITOR.replace( '{$name}' );
                    var editor = CKEDITOR.instances['{$name}'];
                    if ( editor ) {
                        editor.on( 'key', function( evt ){
                            global_formNavigate = false;
                        } );
                        editor.config.width  = '".$this->width."';
                        editor.config.height = '".$this->height."';
                    }
                });
              </script>";
              }
            return $html;
        }
    }
   
    li]
Sorry the post is so long

Regards

Peter
« Last Edit: October 28, 2010, 08:01:51 am by westy »

FatherShawn

  • Ask me questions
  • ****
  • Posts: 372
  • Karma: 25
    • C3 Design
  • CiviCRM version: 4.2.11
  • CMS version: Drupal 7.23
  • MySQL version: 5.5.32
  • PHP version: 5.3.10
Re: ckeditor config
November 10, 2010, 08:01:41 am
Quote from: westy on October 28, 2010, 07:59:41 am
{* We want to use the Drupal CKEditor if it exists, if not we will use the CiviCRM packaged version (currently 3.3.1) *}
{*using the Drupal API module_exists($module) function *}

As often happens in Drupal, there is more than one module to enable CKEditor.  It also may be enabled via the WYSIWYG module...
The WYSIWYG module expects its editors to be in sites/all/libraries.  This more elegant solution than a subdirectory in the module prevents having to reinstall the editor code on module update.  Does the ckeditor module support this file structure?  If so, we could use file_exists() to test for sites/all/libraries/ckeditor/ckeditor.php.  If either of these tests is true, we could also store the path to the Drupal ckeditor dir and use that path to test for /ckfinder/ckfinder.php.

Lead Developer, C3 Design.
Twitter: @FatherShawn

westy

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 1
  • CiviCRM version: CiviCRM 4.5.0
  • CMS version: Drupal 7.31
  • MySQL version: 5.5.38
  • PHP version: Ubuntu Linux 12.04.3
Re: ckeditor config
November 11, 2010, 08:16:39 am
I tried almost every combination of Drupal modules to get an editor to run with a file browser. None was straightforward to install nor worked totally to my satisfaction.
For me the best combination was the CKEditor module, CKeditor and CKFinder. But installation was tricky to say the least.
When I first got this to run, the installation instructions for the module were pretty minimalist, CKEditor and CKFinder instructions were confusing and, like many others, it took me a lot of head-scratching to get it to work. Now however the latest instructions, README.txt and two screencasts make this very clear. http://drupal.ckeditor.com/installation

For these reasons, this is the combination I have now settled on.

To get back to the point, the new README.txt,v 1.3.2.10 2010/06/25 starts with
“Note: this instruction assumes that you install CKEditor in sites/all/modules directory (recommended)."
However, in the Troubleshooting section, it says
“Alternative directory can be sites/all/libraries/ckeditor, module automatically recognize proper path to editor.
Libraries directory is default path when drush is used to download editor javascript."
So it looks like we can take our pick, either is OK
For me, it seems unlikely that the Drupal module will be updated more frequently than the editor itself so I’m happy with the recommended directory.
The new README.txt,v 1.3.2. also includes info on installing CKFinder. Worth reading as is the ‘Tips and Tricks’ section http://drupal.ckeditor.com/tricks

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: ckeditor config
December 20, 2010, 12:43:07 pm
Also check http://civicrm.org/blogs/kurund/enable-image-uploads-and-server-browsing-for-ckeditor

Kurund
Found this reply helpful? Support CiviCRM

Pages: 1 2 3 [4]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • ckeditor config

This forum was archived on 2017-11-26.