![]() |
Xataface CKeditor Module 0.1
CKeditor Widget for Xataface
|
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 $atts = array( 00058 'class' => 'xf-ckeditor', 00059 'data-xf-ckeditor-base-path' => $mod->getBaseURL().'/lib/ckeditor/', 00060 'data-xf-ckeditor-config' => json_encode($ckeditorConfig) 00061 ); 00062 00063 $el =& $factory->addElement('textarea', $formFieldName, $widget['label'], $atts); 00064 if ( PEAR::isError($el) ) return $el; 00065 $el->setProperties($widget); 00066 00067 $jt = Dataface_JavascriptTool::getInstance(); 00068 $jt->addPath(dirname(__FILE__).DIRECTORY_SEPARATOR.'js', 00069 $mod->getBaseURL().'/js'); 00070 //$jt->import('ckeditor.js'); 00071 $jt->import('xataface/modules/ckeditor/ckeditor-widget.js'); 00072 00073 00074 00075 return $el; 00076 } 00077 00078 00079 }
1.7.4