| [ Index ] |
PHP Cross Reference of Joomla 1.5.25 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: none.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 // no direct access 15 defined( '_JEXEC' ) or die( 'Restricted access' ); 16 17 jimport( 'joomla.plugin.plugin' ); 18 19 /** 20 * No WYSIWYG Editor Plugin 21 * 22 * @package Editors 23 * @since 1.5 24 */ 25 class plgEditorNone 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 plgEditorNone(& $subject, $config) 39 { 40 parent::__construct($subject, $config); 41 } 42 43 /** 44 * Method to handle the onInitEditor event. 45 * - Initializes the Editor 46 * 47 * @access public 48 * @return string JavaScript Initialization string 49 * @since 1.5 50 */ 51 function onInit() 52 { 53 $txt = "<script type=\"text/javascript\"> 54 function insertAtCursor(myField, myValue) { 55 if (document.selection) { 56 // IE support 57 myField.focus(); 58 sel = document.selection.createRange(); 59 sel.text = myValue; 60 } else if (myField.selectionStart || myField.selectionStart == '0') { 61 // MOZILLA/NETSCAPE support 62 var startPos = myField.selectionStart; 63 var endPos = myField.selectionEnd; 64 myField.value = myField.value.substring(0, startPos) 65 + myValue 66 + myField.value.substring(endPos, myField.value.length); 67 } else { 68 myField.value += myValue; 69 } 70 } 71 </script>"; 72 return $txt; 73 } 74 75 /** 76 * No WYSIWYG Editor - copy editor content to form field 77 * 78 * @param string The name of the editor 79 */ 80 function onSave( $editor ) { 81 return; 82 } 83 84 /** 85 * No WYSIWYG Editor - get the editor content 86 * 87 * @param string The name of the editor 88 */ 89 function onGetContent( $editor ) { 90 return "document.getElementById( '$editor' ).value;\n"; 91 } 92 93 /** 94 * No WYSIWYG Editor - set the editor content 95 * 96 * @param string The name of the editor 97 */ 98 function onSetContent( $editor, $html ) { 99 return "document.getElementById( '$editor' ).value = $html;\n"; 100 } 101 102 /** 103 * No WYSIWYG Editor - display the editor 104 * 105 * @param string The name of the editor area 106 * @param string The content of the field 107 * @param string The name of the form field 108 * @param string The width of the editor area 109 * @param string The height of the editor area 110 * @param int The number of columns for the editor area 111 * @param int The number of rows for the editor area 112 */ 113 function onDisplay( $name, $content, $width, $height, $col, $row, $buttons = true ) 114 { 115 // Only add "px" to width and height if they are not given as a percentage 116 if (is_numeric( $width )) { 117 $width .= 'px'; 118 } 119 if (is_numeric( $height )) { 120 $height .= 'px'; 121 } 122 123 $buttons = $this->_displayButtons($name, $buttons); 124 $editor = "<textarea name=\"$name\" id=\"$name\" cols=\"$col\" rows=\"$row\" style=\"width: $width; height: $height;\">$content</textarea>" . $buttons; 125 126 return $editor; 127 } 128 129 function onGetInsertMethod($name) 130 { 131 $doc = & JFactory::getDocument(); 132 133 $js= "\tfunction jInsertEditorText( text, editor ) { 134 insertAtCursor( document.getElementById(editor), text ); 135 }"; 136 $doc->addScriptDeclaration($js); 137 138 return true; 139 } 140 141 function _displayButtons($name, $buttons) 142 { 143 // Load modal popup behavior 144 JHTML::_('behavior.modal', 'a.modal-button'); 145 146 $args['name'] = $name; 147 $args['event'] = 'onGetInsertMethod'; 148 149 $return = ''; 150 $results[] = $this->update($args); 151 foreach ($results as $result) { 152 if (is_string($result) && trim($result)) { 153 $return .= $result; 154 } 155 } 156 157 if(!empty($buttons)) 158 { 159 $results = $this->_subject->getButtons($name, $buttons); 160 161 /* 162 * This will allow plugins to attach buttons or change the behavior on the fly using AJAX 163 */ 164 $return .= "\n<div id=\"editor-xtd-buttons\">\n"; 165 foreach ($results as $button) 166 { 167 /* 168 * Results should be an object 169 */ 170 if ( $button->get('name') ) 171 { 172 $modal = ($button->get('modal')) ? 'class="modal-button"' : null; 173 $href = ($button->get('link')) ? 'href="'.$button->get('link').'"' : null; 174 $onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : null; 175 $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"; 176 } 177 } 178 $return .= "</div>\n"; 179 } 180 181 return $return; 182 } 183 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Nov 14 16:47:20 2011 | Cross-referenced by PHPXref 0.7.1 |