Haikson

[ Everything is possible. Everything takes time. ]

FCK (fckeditor) & CakePhp

В статье коротко описывается установка редактора FCK (fckeditor) как хелпера (helper) на cakephp v1.2. Шаг 1. Подготовка.
  1. Скачать cakephp с оф. сайта.
  2. Скачать FCKeditor с оф. сайта.
  3. Распаковать cakephp и FCKeditor.Дерево каталогов (расположение каталога fckeditor в cake)
    app-|
        webroot -|
    	     js -|
    		fckeditor
Шаг 2. FCK Helper.
/**
 *	/app/views/helpers/fck.php
 */
class FckHelper extends Helper {

    var $helpers = Array("Html");

    function load($field, $width = 400) {
        $field = explode(".", $field);
        if(empty($field[1])) {
            // need to know how to call a model from a helper
        } else {
            $model = $field[0];
            $controller = $field[1];
        }

        require_once WWW_ROOT.DS."js".DS."fckeditor".DS."fckeditor.php";
        $oFCKeditor = new FCKeditor("data[".$model."][".$controller."]") ;
        $oFCKeditor->BasePath    = DS."js".DS."fckeditor".DS ;
        $oFCKeditor->Value        = $this->data[$model][$controller];
        $oFCKeditor->Height        = $width;
        $oFCKeditor->Create();
    }
}
Шаг 3. Controllers. Простой контроллер
	class ArticleController extends AppController {
		public $uses = array("Article");
		public $helpers = array("Form","Html","Fck");

		/*
		 * Article model
		 * @var Article
		 */

		function edit(){
			....................
		}
Шаг 4. Вюер - еще проще
  echo $fck->load("Article.annotation");
Шаг 5. Настройка браузера файлов. В файле app/webroot/js/fckeditor/editor/filemanager/connectors/php/config.php
*********************
// SECURITY: You must explicitly enable this "connector". (Set it to "true").
// WARNING: don"t just set "$Config["Enabled"] = true ;", you must be sure that only
// authenticated users can access this file or use some kind of session checking.
$Config["Enabled"] = true ;

// Path to user files relative to the document root.
$Config["UserFilesPath"] = "/files/" ;
*********************