-
Emile
-
-
-
Joined on 04-23-2011
-
-
Posts 6
-
-
|
Re: Cute Editor Zend_Form_Element
I'm now trying to port the joomla plugin to a zend_form_element but i'm stuck on the onGetInsertMethod function which looks like this
onGetInsertMethod
- function onGetInsertMethod($name)
- {
- $doc = & JFactory::getDocument();
- $js= "function jInsertEditorText( text ) {
- var editor = document.getElementById('CE_".$name."_ID');
- editor.PasteHTML(text);
- }";
- $doc->addScriptDeclaration($js);
- return true;
- }
Hopefully someone knows how i can port that function to work with zend framework. This is what i have so far:
Zend_Form_Element_CuteEditor
- <?php
-
- require_once 'Zend/Registry.php';
- require_once 'ZendX/JQuery/View/Helper/UiWidget.php';
-
- class app_View_Helper_FormCuteEditor extends Zend_View_Helper_FormTextarea
- {
- public function setView(Zend_View_Interface $view)
- {
- parent::setView($view);
- $this->CuteEditor = $this->view->CuteEditor();
- $this->CuteEditor->enable();
- return $this;
- }
-
- function onGetContent($editor)
- {
- return "document.getElementById('cuteeditor').getHTML();";
- }
-
- function onSetContent($editor, $html)
- {
- return "document.getElementById('cuteeditor').setHTML(".$html.");";
- }
-
- function onSave($editor)
- {
- return "document.getElementById('cuteeditor').value=document.getElementById('cuteeditor').getHTML();";
- }
-
- public function formCuteEditor($name, $content, $width, $height, $col, $row, $buttons = true)
- {
- if (is_numeric( $width )) {
- $width .= 'px';
- }
- if (is_numeric( $height )) {
- $height .= 'px';
- }
-
- $content = str_replace("<", "<", $content);
- $content = str_replace(">", ">", $content);
- $content = str_replace("&", "&", $content);
-
- $content = str_replace(array(""","'"), array("\"", "'"), $content);
-
-
-
-
-
- include_once(ROOT_PATH . "scripts/cuteeditor_files/include_CuteEditor.php");
- $editor = new CuteEditor();
- $name = "cuteeditor";
- $editor->ID = "cuteeditor";
- $editor->Width = $this->params->get('width');
- $editor->Height = $this->params->get('height');
- $editor->Text = $content;
- $editor->FilesPath = ROOT_PATH . "scripts/cuteeditor_files";
- $templateitemList = $this->params->get( 'TemplateItemList');
-
- if ($templateitemList==""||$templateitemList==0)
- {
- $editor->AutoConfigure = $this->params->def( 'AutoConfigure', 'Simple' );
- }else{
- $editor->TemplateItemList=$templateitemList;
- }
- if ($this->params->def( 'EditorWysiwygModeCss', '' )=="")
- {
-
- $db = Zend_Registry::get('dbconnection');
-
- $query = "SELECT template_name FROM site_templates";
- $template = $db->fetchAll($query);
- $file_path = $this->HTMLPath('templates/'. $template .'/css/');
-
- if (file_exists(ROOT_PATH . '/templates' . $template . '/css/editor.css')){
- $content_css = $file_path . 'editor.css';
- }else{
- $content_css = $file_path . 'template.css';
- }
- }
- $editor->EditorWysiwygModeCss = $content_css;
- $editor->ThemeType = $this->params->def( 'ThemeType', 'Office2007' );
- $ImageGalleryPath = $this->params->def( 'ImageGalleryPath', ROOT_PATH .'/images/stories' );
- $FlashGalleryPath = $this->params->def( 'FlashGalleryPath', ROOT_PATH .'/images/stories/' );
- $MediaGalleryPath = $this->params->def( 'MediaGalleryPath', ROOT_PATH .'/images/stories/' );
- $FilesGalleryPath = $this->params->def( 'FilesGalleryPath', ROOT_PATH .'/images/stories/' );
- $TemplateGalleryPath = $this->params->def( 'TemplateGalleryPath', ROOT_PATH .'/images/stories/' );
-
-
- $ImageGalleryPath = preg_replace('/(^\/|\/$)/','',$ImageGalleryPath);
- $FlashGalleryPath = preg_replace('/(^\/|\/$)/','',$FlashGalleryPath);
- $MediaGalleryPath = preg_replace('/(^\/|\/$)/','',$MediaGalleryPath);
- $FilesGalleryPath = preg_replace('/(^\/|\/$)/','',$FilesGalleryPath);
- $TemplateGalleryPath = preg_replace('/(^\/|\/$)/','',$TemplateGalleryPath);
-
- $editor->ImageGalleryPath = $this->HTMLPath($ImageGalleryPath);
- $editor->FlashGalleryPath = $this->HTMLPath($FlashGalleryPath);
- $editor->MediaGalleryPath = $this->HTMLPath($MediaGalleryPath);
- $editor->FilesGalleryPath = $this->HTMLPath($FilesGalleryPath);
- $editor->TemplateGalleryPath = $this->HTMLPath($TemplateGalleryPath);
- $editor->AbsoluteImageGalleryPath = ROOT_PATH ."/". $ImageGalleryPath;
- $editor->AbsoluteFlashGalleryPath = ROOT_PATH ."/". $FlashGalleryPath;
- $editor->AbsoluteMediaGalleryPath = ROOT_PATH ."/". $MediaGalleryPath;
- $editor->AbsoluteFilesGalleryPath = ROOT_PATH ."/". $FilesGalleryPath;
- $editor->AbsoluteTemplateGalleryPath = ROOT_PATH ."/". $TemplateGalleryPath;
- $editor->CustomCulture = $this->params->def( 'CustomCulture', 'en-US' );
- $editor->BreakElement = $this->params->def( 'BreakElement', 'Div' );
- $editor->AccessKey = $this->params->def( 'AccessKey', '' );
- $editor->AllowEditServerSideCode = $this->params->def( 'AllowEditServerSideCode', 0 );
- $editor->BackColor = $this->params->def( 'BackColor', '#ffffff' );
- $editor->BaseHref = $this->params->def( 'BaseHref', '' );
- $editor->BorderColor = $this->params->def( 'BorderColor', '#dddddd' );
- $editor->CodeViewTemplateItemList = $this->params->def( 'CodeViewTemplateItemList', 'Print,Cut,Copy,Paste,Find,ToFullPage,FromFullPage,SelectAll,SelectNone' );
- $editor->DisableItemList = $this->params->def( 'DisableItemList', '' );
- $editor->EditorBodyClass = $this->params->def( 'EditorBodyClass', '' );
- $editor->EditorBodyId = $this->params->def( 'EditorBodyId', '' );
- $editor->EditorBodyStyle = $this->params->def( 'EditorBodyStyle', '' );
- $editor->EditorOnPaste = $this->params->def( 'EditorOnPaste', 'ConfirmWord' );
- $editor->EnableAntiSpamEmailEncoder = $this->params->def( 'EnableAntiSpamEmailEncoder', 1 );
- $editor->EnableContextMenu = $this->params->def( 'EnableContextMenu', 1 );
- $editor->EnableObjectResizing = $this->params->def( 'EnableObjectResizing', 1 );
- $editor->EnableStripScriptTags = $this->params->def( 'EnableStripScriptTags', 1 );
- $editor->Focus = $this->params->def( 'Focus', 0 );
- $editor->FullPage = $this->params->def( 'FullPage', 0 );
- $editor->MaintainAspectRatioWhenDraggingImage = $this->params->def( 'MaintainAspectRatioWhenDraggingImage', 1 );
- $editor->RemoveTBODYTag = $this->params->def( 'RemoveTBODYTag', 1);
- $editor->ShowBottomBar = $this->params->def( 'ShowBottomBar', 1 );
- $editor->ShowHtmlMode = $this->params->def( 'ShowHtmlMode', 1 );
- $editor->ShowPreviewMode = $this->params->def( 'ShowPreviewMode', 1 );
- $editor->ShowTagSelector = $this->params->def( 'ShowTagSelector', 1 );
- $editor->TabSpaces = $this->params->def( 'TabSpaces', '3' );
- $editor->ToggleBorder = $this->params->def( 'ToggleBorder', 1 );
- $editor->URLType = $this->params->def( 'URLType', 'Default' );
- $editor->UseFontTags = $this->params->def( 'UseFontTags', 0 );
- $editor->UseHTMLEntities = $this->params->def( 'UseHTMLEntities', 1 );
- $editor->UsePhysicalFormattingTags = $this->params->def( 'UsePhysicalFormattingTags', 0 );
- $editor->UseSimpleAmpersand = $this->params->def( 'UseSimpleAmpersand', 0 );
- $editor->XHTMLOutput = $this->params->def( 'XHTMLOutput', 0 );
- $editor->CssClassStyleDropDownMenuNames = $this->params->def( 'CssClassStyleDropDownMenuNames', '' );
- $editor->CssClassStyleDropDownMenuList = $this->params->def( 'CssClassStyleDropDownMenuList', '' );
- $editor->HelpUrl = ROOT_PATH . "scripts/cuteeditor_files/Help/default.htm";
- $editor->Draw();
- return $this->_displayButtons($name, $buttons);
- }
-
- function HTMLPath($input_path)
- {
- if(substr($input_path, 0, 1)!="/")
- {
- $ThisFileName = basename($_SERVER['PHP_SELF']);
- $abspath = str_replace($ThisFileName,"",$_SERVER['PHP_SELF']);
- $input_path=$abspath.$input_path;
- $input_path = str_replace('/', '', $input_path);
- }
- return $input_path;
- }
-
- function onGetInsertMethod($name)
- {
-
- }
- }
Regards, Emile
|
|