| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: xstandard.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 6 * @license GNU/GPL, see LICENSE.php 7 * Joomla! is free software. This version may have been modified pursuant 8 * to the GNU General Public License, and as distributed it includes or 9 * is derivative of works licensed under the GNU General Public License or 10 * other free or open source software licenses. 11 * See COPYRIGHT.php for copyright notices and details. 12 */ 13 14 // Do not allow direct access 15 defined( '_JEXEC' ) or die( 'Restricted access' ); 16 17 jimport( 'joomla.plugin.plugin' ); 18 19 /** 20 * XStandard Lite for Joomla! WYSIWYG Editor Plugin 21 * 22 * @package Editors 23 * @since 1.5 24 */ 25 class plgEditorXstandard extends JPlugin 26 { 27 /** 28 * Constructor 29 * 30 * For php4 compatability we must not use the __constructor as a constructor for plugins 31 * because func_get_args ( void ) returns a copy of all passed arguments NOT references. 32 * This causes problems with cross-referencing necessary for the observer design pattern. 33 * 34 * @param object $subject The object to observe 35 * @param array $config An array that holds the plugin configuration 36 * @since 1.5 37 */ 38 function plgEditorXstandard(& $subject, $config) 39 { 40 parent::__construct($subject, $config); 41 } 42 43 /** 44 * Method to handle the onInitEditor event. 45 * - Initializes the XStandard Lite WYSIWYG Editor 46 * 47 * @access public 48 * @return string JavaScript Initialization string 49 * @since 1.5 50 */ 51 function onInit() 52 { 53 $html = ''; 54 ob_start(); 55 ?> 56 <script type="text/javascript" src="<?php echo JURI::root() ?>/plugins/editors/xstandard/xstandard.js"></script> 57 <?php 58 $html = ob_get_contents(); 59 ob_end_clean(); 60 61 return $html; 62 } 63 64 /** 65 * XStandard Lite WYSIWYG Editor - get the editor content 66 * 67 * @param string The name of the editor 68 */ 69 function onGetContent( $editor ) { 70 return "$('xstandard').value;"; 71 } 72 73 /** 74 * XStandard Lite WYSIWYG Editor - set the editor content 75 * 76 * @param string The name of the editor 77 */ 78 function onSetContent( $editor, $html ) { 79 return "$('xstandard').value =". $html .";"; 80 } 81 82 /** 83 * XStandard Lite WYSIWYG Editor - copy editor content to form field 84 * 85 * @param string The name of the editor 86 */ 87 function onSave( $editor ) { 88 89 $js = "var editor = $('xstandard');\n"; 90 $js .= "editor.EscapeUnicode = true;"; 91 $js .= "$('".$editor."').value = editor.value;"; 92 93 return $js; 94 } 95 96 /** 97 * XStandard Lite WYSIWYG Editor - display the editor 98 * 99 * @param string The name of the editor area 100 * @param string The content of the field 101 * @param string The name of the form field 102 * @param string The width of the editor area 103 * @param string The height of the editor area 104 * @param int The number of columns for the editor area 105 * @param int The number of rows for the editor area 106 * @param mixed Can be boolean or array. 107 */ 108 function onDisplay( $name, $content, $width, $height, $col, $row, $buttons = true ) 109 { 110 // Load modal popup behavior 111 JHTML::_('behavior.modal', 'a.modal-button'); 112 113 // Only add "px" to width and height if they are not given as a percentage 114 if (is_numeric( $width )) { 115 $width .= 'px'; 116 } 117 if (is_numeric( $height )) { 118 $height .= 'px'; 119 } 120 121 jimport('joomla.environment.browser'); 122 $instance =& JBrowser::getInstance(); 123 $language =& JFactory::getLanguage(); 124 $db =& JFactory::getDBO(); 125 126 $url = JURI::root(); 127 128 $lang = substr( $language->getTag(), 0, strpos( $language->getTag(), '-' ) ); 129 130 if ($language->isRTL()) { 131 $direction = 'rtl'; 132 } else { 133 $direction = 'ltr'; 134 } 135 136 /* 137 * Lets get the default template for the site application 138 */ 139 $query = 'SELECT template' 140 . ' FROM #__templates_menu' 141 . ' WHERE client_id = 0' 142 . ' AND menuid = 0' 143 ; 144 $db->setQuery( $query ); 145 $template = $db->loadResult(); 146 147 $file_path = JPATH_SITE .'/templates/'. $template .'/css/'; 148 if ( !file_exists( $file_path .DS. 'editor.css' ) ) { 149 $template = 'system'; 150 } 151 152 $css = JURI::root() .'/templates/'. $template . '/css/editor.css'; 153 154 $html = ''; 155 ob_start(); 156 ?> 157 158 <div style="border: 1px solid #D5D5D5"> 159 <object type="application/x-xstandard" id="xstandard" class="<?php echo $name ?>" width="<?php echo $width ?>" height="<?php echo $height ?>"> 160 <param name="Value" value="<?php echo $content ?>" /> 161 162 <param name="Lang" value="<?php echo $lang ?>" /> 163 <param name="Dir" value="<?php echo $direction ?>" /> 164 <param name="EditorCSS" value="<?php echo $css ?>" /> 165 <param name="EnablePasteMarkup" value="yes" /> 166 <param name="EnableTimestamp" value="no" /> 167 <param name="EscapeUnicode" value="no" /> 168 <param name="ToolbarWysiwyg" value="line, hyperlink, attachment, directory, undo, , wysiwyg, source, screen-reader, ,expand; strong, em, underline, strikethrough, , align-left, align-center, align-right, , blockquote, undo-blockquote, ,numbering, bullets, , undo, redo, ,layout-table, data-table, draw-layout-table, draw-data-table" /> 169 <param name="ToolbarSource" value="indent, whitespace, word-wrap, dim-tags, validate,, wysiwyg, source, screen-reader, , expand" /> 170 <param name="ToolbarPreview" value="wysiwyg, source, screen-reader, ,expand" /> 171 <param name="ToolbarScreenReader" value="wysiwyg, source, screen-reader, , expand" /> 172 <param name="BackgroundColor" value="#F9F9F9" /> 173 <param name="Mode" value="<?php echo $this->params->get('mode', 'wysiwyg'); ?>" /> 174 <param name="IndentOutput" value="yes" /> 175 <param name="Options" value="<?php echo $this->params->get('wrap', '0'); ?>" /> 176 <param name="BorderColor" value="#FFF" /> 177 <param name="Base" value="<?php echo $url ?>" /> 178 <param name="ExpandWidth" value="800" /> 179 <param name="ExpandHeight" value="600" /> 180 181 <param name="LatestVersion" value="2.0.0.0" /> 182 183 <param name="CMSCode" value="065126D6-357D-46FC-AF74-A1F5B2D5036E" /> 184 <param name="CMSImageLibraryURL" value="<?php echo $url ?>plugins/editors/xstandard/imagelibrary.php" /> 185 <param name="CMSAttachmentLibraryURL" value="<?php echo $url ?>plugins/editors/xstandard/attachmentlibrary.php" /> 186 <param name="CMSDirectoryURL" value="<?php echo $url ?>plugins/editors/xstandard/directory.php" /> 187 <param name="PreviewXSLT" value="<?php echo $url ?>plugins/editors/xstandard/preview.xsl" /> 188 189 <param name="CSS" value="<?php echo $this->_getTemplateCss(); ?>" /> 190 191 <textarea name="alternate1" id="alternate1" cols="60" rows="15"><?php echo $content ?></textarea> 192 </object> 193 <input type="hidden" id="<?php echo $name ?>" name="<?php echo $name ?>" value="" /> 194 </div> 195 <?php 196 $html = ob_get_contents(); 197 ob_end_clean(); 198 199 $html .= $this->_displayButtons($name, $buttons); 200 201 return $html; 202 } 203 204 function onGetInsertMethod($name) 205 { 206 $doc = & JFactory::getDocument(); 207 208 $js= "function jInsertEditorText( text ) { 209 var editor = document.getElementById('xstandard'); 210 editor.InsertXML(text); 211 }"; 212 $doc->addScriptDeclaration($js); 213 214 return true; 215 } 216 217 function _getTemplateCss() 218 { 219 $db =& JFactory::getDBO(); 220 221 /* 222 * Lets get the default template for the site application 223 */ 224 $query = 'SELECT template' 225 . ' FROM #__templates_menu' 226 . ' WHERE client_id = 0' 227 . ' AND menuid = 0' 228 ; 229 $db->setQuery( $query ); 230 $template = $db->loadResult(); 231 232 $content_css = JURI::root() .'/templates/'. $template .'/css/'; 233 234 $file_path = JPATH_SITE .'/templates/'. $template .'/css/'; 235 if ( file_exists( $file_path .DS. 'editor.css' ) ) { 236 $content_css = $content_css . 'editor.css' .'", '; 237 } else { 238 $content_css = $content_css . 'template_css.css", '; 239 } 240 241 return $content_css; 242 } 243 244 function _displayButtons($name, $buttons) 245 { 246 // Load modal popup behavior 247 JHTML::_('behavior.modal', 'a.modal-button'); 248 249 $args['name'] = $name; 250 $args['event'] = 'onGetInsertMethod'; 251 252 $return = ''; 253 $results[] = $this->update($args); 254 foreach ($results as $result) { 255 if (is_string($result) && trim($result)) { 256 $return .= $result; 257 } 258 } 259 260 if(!empty($buttons)) 261 { 262 $results = $this->_subject->getButtons($name, $buttons); 263 264 /* 265 * This will allow plugins to attach buttons or change the behavior on the fly using AJAX 266 */ 267 $return .= "\n<div id=\"editor-xtd-buttons\">\n"; 268 foreach ($results as $button) 269 { 270 /* 271 * Results should be an object 272 */ 273 if ( $button->get('name') ) 274 { 275 $modal = ($button->get('modal')) ? 'class="modal-button"' : null; 276 $href = ($button->get('link')) ? 'href="'.$button->get('link').'"' : null; 277 $onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : null; 278 $return .= "<div class=\"button2-left\"><div class=\"".$button->get('name')."\"><a ".$modal." title=\"".$button->get('text')."\" ".$href." ".$onclick." rel=\"".$button->get('options')."\">".$button->get('text')."</a></div></div>\n"; 279 } 280 } 281 $return .= "</div>\n"; 282 } 283 284 return $return; 285 } 286 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |