Welcome Guest, Not a member yet? Register   Sign In
Adding WYSIWYG Pro to CodeIgniter
#1

[eluser]StevenW721[/eluser]
***UPDATE*** Got it working, posted my code below.


I've been trying for a while (unsuccessfully) to get WYSIWYG Pro into CodeIgniter 1.6.1

It's set up as one big class so I'm having trouble getting it to work in Codeigniter.

Has anyone else out there set it up successfully? I'm sure that since this is not a free software that there's far less people using it but it really is great (when it works). I saw all the tutorials in the wiki for the other popular editors but none seem to relate to this one.

Any help would be awesome, I'll post an update if I get it figured out.

Thanks!
#2

[eluser]systemsos[/eluser]
I use TinyMCE - works like a charm and is free.
#3

[eluser]muttlogic[/eluser]
I created a quick plug-in for Expression Engine. While not a direct answer to your question, you can have a look at that code. It may help.

http://ellislab.com/forums/viewthread/71154/

-Jeff
#4

[eluser]phpwebdev[/eluser]
try to use fckeditor , there have plugin for integration
http://www.fckeditor.net/
#5

[eluser]StevenW721[/eluser]
Thanks so much muttlogic, I was actually able to turn that into a library for CodeIgniter, you're a lifesaver! I'll share my library when i'm done setting it up so others will be able to use it in CodeIgniter as well.
#6

[eluser]kcook123[/eluser]
[quote author="StevenW721" date="1203634083"]Thanks so much muttlogic, I was actually able to turn that into a library for CodeIgniter, you're a lifesaver! I'll share my library when i'm done setting it up so others will be able to use it in CodeIgniter as well.[/quote]

Been a year StevenW721, but any chance you could post that library?
#7

[eluser]StevenW721[/eluser]
My bad, totally forgot to post it. Here's a direct copy/paste of the file I use. Just name it Wysiwygproci.php and put in the libraries folder and you should be all set.


Code:
<?php
/* ============================================================
    WysiwygPro CodeIgniter Extension by Steven Woodson
    
    Based on the FCKEditor ExpressionEngine Extension by Jitendra Shrestha
    & WysiwygPro ExpressionEngine Extension v0.1.0 by Jeff Shaffer
   =============================================================
    File: Wysiwygproci.php
   -----------------------------------------------------
    Purpose: This extension adds WysiwygPRO to the list
    of available libraries in CodeIgniter
    
    NOTES:
   ============================================================= */
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Wysiwygproci
{    
    function Wysiwygproci()
    {    // edit the field below to match your file path to the wysiwygPro.class.php include
        include_once($_SERVER['DOCUMENT_ROOT'].'/editor/wysiwygPro.class.php');        }
    
    // ---------------------------------------------------
    //  Add Ouput Code to display Editor
    // ---------------------------------------------------
    function output_tag($fieldID, $field_data, $rows)
    {    ${"editor{$fieldID}"} = new wysiwygPro();            // Instantiate the editor
        ${"editor{$fieldID}"}->name = $fieldID;    // Name the editor for the form
        ${"editor{$fieldID}"}->value = $field_data;            // Initialize the editor content

        // Configure the file browser and add any other configuration options you require:

        // Full file path of your documents folder & URL:
        ${"editor{$fieldID}"}->documentDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/file/';
        ${"editor{$fieldID}"}->documentURL = base_url().'uploads/file/';
        // Full file path of your images folder & URL:
        ${"editor{$fieldID}"}->imageDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/image/';
        ${"editor{$fieldID}"}->imageURL = base_url().'uploads/image/';
        // Full file path of your media folder & URL:
        ${"editor{$fieldID}"}->mediaDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/media/';
        ${"editor{$fieldID}"}->mediaURL = base_url().'uploads/media/';

        // set file browser editing permissions:
        ${"editor{$fieldID}"}->baseURL = base_url();
        ${"editor{$fieldID}"}->editImages = true;
        ${"editor{$fieldID}"}->renameFiles = true;
        ${"editor{$fieldID}"}->renameFolders = true;
        ${"editor{$fieldID}"}->deleteFiles = true;
        ${"editor{$fieldID}"}->deleteFolders = true;
        ${"editor{$fieldID}"}->copyFiles = true;
        ${"editor{$fieldID}"}->copyFolders = true;
        ${"editor{$fieldID}"}->moveFiles = true;
        ${"editor{$fieldID}"}->moveFolders = true;
        ${"editor{$fieldID}"}->upload = true;
        ${"editor{$fieldID}"}->overwrite = true;
        ${"editor{$fieldID}"}->createFolders = true;
        ${"editor{$fieldID}"}->addStylesheet( '/styles/editor.css');
        ${"editor{$fieldID}"}->theme = 'default';
        ${"editor{$fieldID}"}->addStyle('a class="orangeArrowLink"', 'Orange Arrow Link');
        ${"editor{$fieldID}"}->addStyle('p"', 'Paragraph');
        ${"editor{$fieldID}"}->removeStyle( 'address' );
        ${"editor{$fieldID}"}->removeStyle( 'pre' );
        
        // The following three values don't seem to work, if needed change in 'editor\conf\dialogConfig.inc.php'
        ${"editor{$fieldID}"}->maxDocSize = '1 GB';
        ${"editor{$fieldID}"}->maxImageSize = '1 GB';
        ${"editor{$fieldID}"}->maxMediaSize = '1 GB';
        // --------------------------------------------------------
        
        ${"editor{$fieldID}"}->maxImageWidth = 2000;
        ${"editor{$fieldID}"}->maxImageHeight = 2000;
        
        ${"editor{$fieldID}"}->toolbarLayout = array(
            'toolbar1' => array('fullwindow','print','find','spelling','codecleanup','documentproperties','separator1','cut','copy','paste','pastecleanup','separator2','tablemenu','ruler','specialchar','separator3','bookmark','link','image','media'),
            'toolbar2' => array('styles','font','size','separator1','bold','italic','underline','moretextformatting','separator2','fontcolor','highlight'),
            'toolbar3' => array('left','center','right','full','morealignmentformatting','separator1','numbering','bullets','morelistformatting','separator2','outdent','indent','separator3','undo','redo')
        );

        // disable unwanted buttons/features
        ${"editor{$fieldID}"}->disableFeature( 'smiley' );

        // Convert row height to pixels
        // Set a minimum height of 180px
        $height = $rows * 24;
        if ($height < 180) $height = 180;
        
        // Render the editor
        ${"editor{$fieldID}"}->display('100%', $height);
    }
    
}
?&gt;

To call this you'd use the following:

Code:
$this->load->library('Wysiwygproci');
$this->wysiwygproci->output_tag("fieldName", "Preset Content goes here", "15");

Where the '15' is the number of rows, made that an option because I found the need to specify the size of these boxes more than once.

There's a good amount of custom configurations in there that I decided to leave in just in case it ended up being helpful for someone but a lot of it can be removed if you prefer all the default features.

Hope that all makes sense, thanks for the reminder kcook123!

Steve
#8

[eluser]kcook123[/eluser]
Thanks Steve!
#9

[eluser]StevenW721[/eluser]
Let us know how it goes and if you have any questions, good luck!




Theme © iAndrew 2016 - Forum software by © MyBB