• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeExtinguisher 2.0 Release Candidate 14.2

[eluser]hyeteck[/eluser]
I saw a couple posts about people having issues with the editor not working so here is what i did to get mine to work.

1. Download the TinyMCE main package from http://tinymce.moxiecode.com/download.php. Unzip the contents into 'codex/assets/js'. The full directory to the TinyMCE javascript would be 'codex/assets/js/tiny_mce/tiny_mce.js';

2. put the following code in your 'editor.php' plugin file located in the 'codex/application/plugins' folder.
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Editor extends codexForms

{

    function Editor($name,$params) {

        codexForms::initiate($name,$params);

    }

    function prepForDb($value){

        return $value;

    }

    function getHTML()

    {

        $CI = &get;_instance();  

        $CI->codextemplates->js('js-tinymce', base_url() . 'codex/assets/js/tiny_mce/tiny_mce.js');



        $html = "";

        $this->params['theme'] = !isset($this->params['theme'])? "simple" : $this->params['theme'];

        $html .='

                '<' . 'script language="javascript" type="text/javascript"' . '>' .

                tinyMCE.init({
                
                ';
                
        foreach($this->params as $mce_param => $value)
        {
            $html .= $mce_param . ' : "' . $value . '",
            ';
        }
        
        $html .='
            mode : "exact",
            elements : "'.$this->name.'"
                 })
                </' . 'script' . '>';

        $html .= $this->prefix;

        $html .= $this->getMessage($this->name);

        $html .= '

            <label for="'.$this->name.'">

                '.$this->label.'

            </label>

            &lt;textarea id="'.$this-&gt;name.'" name="'.$this->name.'" '.$this->getAttributes($this->attributes).'>'.$this->value.'&lt;/textarea&gt;

        ';

        $html .= $this->suffix;



        return $html;

    }

}

?&gt;

the only reason i concatenated the open and close brackets for the javascript tags was because it was automatically being removed when i made the post.

3. Now just setup your yaml file and put it in the 'codex/application/definitions' folder. You can use any of the params available to TinyMCE in your yaml file. The available params can be found here: http://wiki.moxiecode.com/index.php/Tiny...figuration

Below is an example of my yaml file.
Code:
form_setup:
    title:
        class: TextBox
    body:
        class: Editor
        label: Article Body
        attributes:
            rows:20
            cols:100
        params:
            theme: advanced
            theme_advanced_toolbar_location : top
            theme_advanced_toolbar_align: left

[eluser]webberoo[/eluser]
[quote author="dbelanger" date="1218187188"]Hi Paul,

Thanks for your input here. I've updated the editor plugin with the new code and tried the code you pasted but still can't get things going. I get a few errors:

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: class

Filename: libraries/codexforms.php

Line Number: 53

and also a:
Code:
An Error Was Encountered
Could not find proper plugin.
[/quote]

The cause of this maybe in the way you have formatted your yaml file. Can you do a print_r() of your yaml file and post it here. That way we can see if all the right options are being passed into the correct array formats.

[eluser]Majd Taby[/eluser]
if you use tabs in your yaml file , try changing them to spaces ( a couple of spaces instead of a tab)

[eluser]dbelanger[/eluser]
Hi guys,

Thanks so much for your continued help on this, honestly I'm feeling pretty dumb it's been an issue for me.

My YAML file has this code in it and I've made sure there's no tabs and only spaces:

Code:
form_setup:
  title:
   class: TextBox
  content:
   class: Editor
     attributes:
       rows:20
       cols:100
    params:
      theme: advanced
      theme_advanced_toolbar_location : top
      theme_advanced_toolbar_align: left

Now the only error I'm getting is the plugin not found error and I think that's because my path is somehow not set right. In the editor.php file I have:
Code:
$CI->codextemplates->js('js-tinymce', base_url() . 'codex/assets/js/tiny_mce/tiny_mce.js');

Which tells me it can't find the file. My tinymce is in codex/assets/js/tiny_mce/ but I haven't seen anywhere to set the base_url and I'm wondering if that's it.

Thanks again everybody, you guys rock.

[eluser]webberoo[/eluser]
dbelanger,

I had the same problem as well. Heres the code I ended up using.

Code:
$CI = &get;_instance();  
        $CI->codextemplates->jsFromAssets('js-tinymce','tiny_mce/tiny_mce.js');
        $theme = !isset($this->params['theme'])? "simple" : $this->params['theme'];

Insert this at the start of your getHTML() function in editor.php.

Another thing I noticed is that the plugin wasn't inserting the tinyMCE config options in the head of the document. So I have passed the params[] array to the inlineJS() function. like this:
Code:
$tinyMce = "";
        $tinyMce .='
                tinyMCE.init({
                    mode : "exact",
                    elements : "'.$this->name.'",
                    theme : "'.$this->params['theme'].'",
                });
                ';
        $CI->codextemplates->inlineJS('js-editor',$tinyMce);

At the moment I'm am working on getting the extra options to show up. Once this is polished off I'll post it in the wiki

hang in there buddy.

[eluser]webberoo[/eluser]
Here is my revised editor plugin.

+adds a link to tinyMCE within the assets folder
+adds tinyMCE config options in between the html tags
+allows for custom tinyMCE options to be set using yaml files


Code:
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
* =======================================================
*
*                  
*              Editor Plugin for CodeExtinguisher
*                    Revised by webberoo
*                  -------------------------
*
*                  YAML Configuration Options:
*
*      +=============+================+================+
*      |  Required?  |      Name      |     Value      |
*      +=============+================+================+
*      |     Yes     |      class     |    Editor      |
*      |     No      |    Attributes  |  Rows, Cols    |
*      |     No      |      Label     |     Label      |
*      |     No      |      Params    | theme, options |
*      +-------------+----------------+----------------+
*
*                           Example:
*
*      field_name:
*          class: Editor
*          attributes:
*              rows: 10 <-sample row length
*              cols: 50 <-sample col length
*          label: This is a sample Label
*          params:
*              theme: advanced
*              options:
*                  tinyMCE_configuration_option: sample value
*
* =======================================================
*/
class Editor extends codexForms
{
    function Editor($name,$params) {
        codexForms::initiate($name,$params);
    }

    function prepForDb($value){
        return $value;
    }
    
    function getHTML()
    {
        $CI = &get;_instance();  
        $CI->codextemplates->jsFromAssets('js-tinymce','tiny_mce/tiny_mce.js');
        $tinyMce = $this->getTinyMCEOptions();
        $CI->codextemplates->inlineJS('js-editor',$tinyMce);
         $html = "";
        $html .= $this->prefix;
        $html .= $this->getMessage($this->name);
        $html .= '
            <label for="'.$this->name.'">
                '.$this->label.'
            </label>
            &lt;textarea id="'.$this-&gt;name.'" name="'.$this->name.'" '.$this->getAttributes($this->attributes).'>'.$this->value.'&lt;/textarea&gt;
        ';
        $html .= $this->suffix;

        return $html;
    }
    
    function getTinyMCEOptions()
    {
        $theme = '';
        $theme .= !isset($this->params['theme'])? "simple" : $this->params['theme'];
    
        $html = '';
        $html .= 'tinyMCE.init({';
        $html .= '    mode:"exact",';
        $html .= '    elements:"'.$this->name.'",';
        $html .= '    theme:"'.$theme.'",';
        foreach($this->params['options'] as $k => $v)
        {
            $html .= '    '.$k.':"'.$v.'",';    
        }
        $html .= '    });';
        
        return $html;
        
    }    
}
?&gt;

Will add to the wiki as well

[eluser]Unknown[/eluser]
I need to upload files to an FTP site after or before adding or editing a record

What is the best way to add my own functions to the postInsertHook call

i am not sure if i should extend the codexevents.php file or add a new entry to the hooks.php file eg.
Code:
$hook['postInsertHook'] = array(
             'function' => '_action',
             'filename' => 'Create.php',
             'filepath' => 'hooks',
    );

I am editing the codexevents.php file, but it dosn't seem like the best way to do it


Sorry for the dumb question, i am still new to CI.

[eluser]Majd Taby[/eluser]
have you thought about writing a plugin instead?

[eluser]Rob Stefanussen[/eluser]
CodeExtinguisher looks great, thanks for the hard work put into it. I was just skimming through this 30 page thread, it looks like a lot of code revisions have been discussed. The latest version seems to be the one on the first post. Also, SVN doesn't seem to really have any updates either. Is there any version that has some of these code revisions rolled in?

[eluser]dbelanger[/eluser]
webberoo,

Thank you so much for the work you've put in here, looks good. Will try the new plugin later tonight.

Cheers!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.