Xataface CKeditor Module 0.3
CKeditor Widget for Xataface
widget.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * Xataface CKeditor Module v 0.1
00004  * Copyright (C) 2011  Steve Hannah <steve@weblite.ca>
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the
00018  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
00019  * Boston, MA  02110-1301, USA.
00020  *
00021  */
00034 class Dataface_FormTool_ckeditor {
00035 
00047         function &buildWidget($record, &$field, $form, $formFieldName, $new=false){
00048                 $widget =& $field['widget'];
00049                 $factory =& Dataface_FormTool::factory();
00050                 $mod = Dataface_ModuleTool::getInstance()->loadModule('modules_ckeditor');
00051                 
00052                 $ckeditorConfig = array();
00053                 if ( @$widget['ckeditor'] ){
00054                         $ckeditorConfig = $widget['ckeditor'];
00055                 }
00056                 
00057                 if ( $record ){
00058                         $del = $record->table()->getDelegate();
00059                         if ( isset($del) and method_exists($del, 'ckeditor_decorateConfig') ){
00060                                 $del->ckeditor_decorateConfig($record, $ckeditorConfig);
00061                         }
00062                 }       
00063                 
00064                 $atts = array(
00065                         'class' => 'xf-ckeditor',
00066                         'data-xf-ckeditor-base-path' => $mod->getBaseURL().'/lib/ckeditor/',
00067                         'data-xf-ckeditor-config' => json_encode($ckeditorConfig)
00068                 );
00069                 
00070                 $el =& $factory->addElement('textarea', $formFieldName, $widget['label'], $atts);
00071                 if ( PEAR::isError($el) ) return $el;
00072                 $el->setProperties($widget);
00073                 
00074                 $jt = Dataface_JavascriptTool::getInstance();
00075                 $jt->addPath(dirname(__FILE__).DIRECTORY_SEPARATOR.'js',
00076                         $mod->getBaseURL().'/js');
00077                 
00078                 $ct = Dataface_CSSTool::getInstance();
00079                 $ct->addPath(dirname(__FILE__).DIRECTORY_SEPARATOR.'css',
00080                         $mod->getBaseURL().'/css');
00081                 //$jt->import('ckeditor.js');
00082                 $jt->import('xataface/modules/ckeditor/ckeditor-widget.js');
00083                 
00084                 
00085         
00086                 return $el;
00087         }
00088         
00089 
00090 }
 All Data Structures Files Functions Variables