EllisLab text mark
Advanced Search
     
CKFinder File Browser (CKEditor plugin) and CodeIgniter
Posted: 16 March 2012 03:34 PM   [ Ignore ]
Joined: 2010-12-16
11 posts

Hi everyone,
I’ve succesfully integrated the CKEditor WYSIWYG and the CKFinder plugin to upload local contents to the server. The problem is that the CKFinder browser just doesn’t show up. When I click on “Search on server” it opens a new popup window with the right url

(http://www.mywebsite.com/admin/pages/edit/plugins/ckfinder/ckfinder.html?type=Images&CKEditor=contentIT&CKEditorFuncNum=2&langCode=it)

but it just shows the first page of the website. No browser.
I suppose it’s because this url doesn’t have the structure “controller/function/” needed by CI, but it just has a normal URL.

Anyone had the same problem?

Thank you for your help

 
Posted: 12 September 2012 06:10 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-09-12
5 posts

I think this will help you:
i have a folder called js in the root of my app:
the folder contains 2 other folders with ckeditor and ckfinder
I also have an helper in my application folder
Hope this helps
<?php

class Ckeditor extends CI_Controller {

  public $data = array();

  public function __construct() {

      parent::__construct();

      $this->load->helper(‘url’); //You should autoload this one wink
      $this->load->helper(‘ckeditor’);
      $this->load->helper(‘form’);

      //Ckeditor’s configuration
      $this->data[‘ckeditor’] = array(
        //ID of the textarea that will be replaced
        ‘id’ => ‘content’,
        ‘path’ => ‘js/ckeditor’,
        //Optionnal values
        ‘config’ => array(
          ‘toolbar’ => “Full”, //Using the Full toolbar
          ‘width’ => “550px”, //Setting a custom width
          ‘height’ => ‘100px’, //Setting a custom height
          ‘filebrowserBrowseUrl’ => base_url() . ‘js/ckfinder/ckfinder.html’,
          ‘filebrowserImageBrowseUrl’ => base_url() . ‘js/ckfinder/ckfinder.html?Type=Images’,
          ‘filebrowserFlashBrowseUrl’ => base_url() . ‘js/ckfinder/ckfinder.html?Type=Flash’,
          ‘filebrowserUploadUrl’ => base_url() . ‘js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files’,
          ‘filebrowserImageUploadUrl’ => base_url() . ‘js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images’,
          ‘filebrowserFlashUploadUrl’ => base_url() . ‘js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash’
        ),
        //Replacing styles from the “Styles tool”
        ‘styles’ => array(
          //Creating a new style named “style 1”
          ‘style 1’ => array(
              ‘name’ => ‘Blue Title’,
              ‘element’ => ‘h2’,
              ‘styles’ => array(
                ‘color’ => ‘Blue’,
                ‘font-weight’ => ‘bold’
              )
          ),
          //Creating a new style named “style 2”
          ‘style 2’ => array(
              ‘name’ => ‘Red Title’,
              ‘element’ => ‘h2’,
              ‘styles’ => array(
                ‘color’ => ‘Red’,
                ‘font-weight’ => ‘bold’,
                ‘text-decoration’ => ‘underline’
              )
          )
        )
      );

      $this->data[‘ckeditor_2’] = array(
        //ID of the textarea that will be replaced
        ‘id’ => ‘content_2’,
        ‘path’ => ‘js/ckeditor’,
        //Optionnal values
        ‘config’ => array(
          ‘width’ => “550px”, //Setting a custom width
          ‘height’ => ‘100px’, //Setting a custom height
          ‘toolbar’ => array(//Setting a custom toolbar
              array(‘Bold’, ‘Italic’),
              array(‘Underline’, ‘Strike’, ‘FontSize’),
              array(‘Smiley’),
              ‘/’
          )
        ),
        //Replacing styles from the “Styles tool”
        ‘styles’ => array(
          //Creating a new style named “style 1”
          ‘style 3’ => array(
              ‘name’ => ‘Green Title’,
              ‘element’ => ‘h3’,
              ‘styles’ => array(
                ‘color’ => ‘Green’,
                ‘font-weight’ => ‘bold’
              )
          )
        )
      );
  }

  public function index() {

      $this->load->view(‘ckeditor’, $this->data);
  }


}
<?php
if(!defined(‘BASEPATH’)) exit(‘No direct script access allowed’);

function cke_initialize($data = array()) {

$return = ‘’;

if(!defined(‘CI_CKEDITOR_HELPER_LOADED’)) {
 
  define(‘CI_CKEDITOR_HELPER_LOADED’, TRUE);
  $return =  ‘[removed][removed]’;
  $return .= “[removed]CKEDITOR_BASEPATH = ’” . base_url() . $data[‘path’] . “/’;[removed]”;
}

return $return;

}

function cke_create_instance($data = array()) {

  $return = “[removed]
    CKEDITOR.replace(’” . $data[‘id’] . “‘, {”;
 
    //Adding config values
    if(isset($data[‘config’])) {
    foreach($data[‘config’] as $k=>$v) {
     
      // Support for extra config parameters
      if (is_array($v)) {
      $return .= $k . ” : [”;
      $return .= config_data($v);
      $return .= “]”;
     
      }
      else {
      $return .= $k . ” : ’” . $v . “’”;
      }

      if($k !== end(array_keys($data[‘config’]))) {
    $return .= “,”;
    }     
    }
    }   
     
  $return .= ‘});[removed]’;
 
  return $return;

}

function display_ckeditor($data = array())
{
// Initialization
$return = cke_initialize($data);

  // Creating a Ckeditor instance
  $return .= cke_create_instance($data);

  // Adding styles values
  if(isset($d

 
Posted: 12 September 2012 06:21 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-09-12
5 posts

Hi, here is a link with the codeigniter project including CKedior and CKfinder
http://democristi.netne.net/
I, did not test it on a real server, only on my localhost. is posible to have problemes with it because the .htaccess file