|
iTx Technologies offre gratuitement
|
||
[Vue sommaire] [Imprimer] [Vue textuelle]
1 <?php 2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 3 /********************************************************************************* 4 * SugarCRM is a customer relationship management program developed by 5 * SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc. 6 * 7 * This program is free software; you can redistribute it and/or modify it under 8 * the terms of the GNU General Public License version 3 as published by the 9 * Free Software Foundation with the addition of the following permission added 10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK 11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY 12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. 13 * 14 * This program is distributed in the hope that it will be useful, but WITHOUT 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 * details. 18 * 19 * You should have received a copy of the GNU General Public License along with 20 * this program; if not, see http://www.gnu.org/licenses or write to the Free 21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22 * 02110-1301 USA. 23 * 24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, 25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. 26 * 27 * The interactive user interfaces in modified source and object code versions 28 * of this program must display Appropriate Legal Notices, as required under 29 * Section 5 of the GNU General Public License version 3. 30 * 31 * In accordance with Section 7(b) of the GNU General Public License version 3, 32 * these Appropriate Legal Notices must retain the display of the "Powered by 33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for 34 * technical reasons, the Appropriate Legal Notices must display the words 35 * "Powered by SugarCRM". 36 * *******************************************************************************/ 37 /********************************************************************************* 38 39 * Description: 40 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights 41 * Reserved. Contributor(s): ______________________________________.. 42 *********************************************************************************/ 43 44 45 /** 46 * PHP wrapper class for Javascript driven TinyMCE WYSIWYG HTML editor 47 */ 48 class SugarTinyMCE { 49 var $jsroot = "include/javascript/tiny_mce/"; 50 var $buttonConfig = "code,help,separator,bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright, 51 justifyfull,separator,forecolor,backcolor,separator,styleselect,formatselect,fontselect,fontsizeselect, 52 "; 53 var $buttonConfig2 = "cut,copy,paste,pastetext,pasteword,selectall,separator,search,replace,separator,bullist,numlist,separator, 54 outdent,indent,separator,ltr,rtl,separator,undo,redo,separator, 55 link,unlink,anchor,image,separator,sub,sup,separator,charmap,visualaid"; 56 var $buttonConfig3 = "tablecontrols,separator,advhr,hr,removeformat,separator,insertdate,inserttime,separator,preview"; 57 var $defaultConfig = array( 58 'convert_urls' => false, 59 'height' => 300, 60 'width' => '100%', 61 'theme' => 'advanced', 62 'theme_advanced_toolbar_align' => "left", 63 'theme_advanced_toolbar_location' => "top", 64 'theme_advanced_buttons1' => "", 65 'theme_advanced_buttons2' => "", 66 'theme_advanced_buttons3' => "", 67 'strict_loading_mode' => true, 68 'mode' => 'exact', 69 'language' => 'en', 70 'plugins' => 'advhr,insertdatetime,table,preview,paste,searchreplace,directionality', 71 'elements' => '', 72 'extended_valid_elements' => 'style,hr[class|width|size|noshade]', 73 ); 74 75 76 /** 77 * Sole constructor 78 */ 79 function SugarTinyMCE() { 80 81 } 82 83 /** 84 * Returns the Javascript necessary to initialize a TinyMCE instance for a given <textarea> or <div> 85 * @param string target Comma delimited list of DOM ID's, <textarea id='someTarget'> 86 * @return string 87 */ 88 function getInstance($targets = "") { 89 global $json; 90 91 if(empty($json)) { 92 $json = getJSONobj(); 93 } 94 95 $config = $this->defaultConfig; 96 $config['elements'] = $targets; 97 $config['theme_advanced_buttons1'] = $this->buttonConfig; 98 $config['theme_advanced_buttons2'] = $this->buttonConfig2; 99 $config['theme_advanced_buttons3'] = $this->buttonConfig3; 100 $jsConfig = $json->encode($config); 101 102 $instantiateCall = ''; 103 if (!empty($targets)) { 104 $exTargets = explode(",", $targets); 105 foreach($exTargets as $instance) { 106 //$instantiateCall .= "tinyMCE.execCommand('mceAddControl', false, document.getElementById('{$instance}'));\n"; 107 } 108 } 109 $path = getJSPath('include/javascript/tiny_mce/tiny_mce.js'); 110 $ret =<<<eoq 111 <script type="text/javascript" language="Javascript" src="$path"></script> 112 113 <script type="text/javascript" language="Javascript"> 114 tinyMCE.init({$jsConfig}); 115 {$instantiateCall} 116 </script> 117 118 eoq; 119 return $ret; 120 } 121 122 function getConfig() { 123 global $json; 124 125 if(empty($json)) { 126 $json = getJSONobj(); 127 } 128 129 $config = $this->defaultConfig; 130 //include tinymce lang file 131 $lang = substr($GLOBALS['current_language'], 0, 2); 132 if(file_exists('include/javascript/tiny_mce/langs/'.$lang.'.js')) 133 $config['language'] = $lang; 134 $config['theme_advanced_buttons1'] = $this->buttonConfig; 135 $config['theme_advanced_buttons2'] = $this->buttonConfig2; 136 $config['theme_advanced_buttons3'] = $this->buttonConfig3; 137 $jsConfig = $json->encode($config); 138 return "var tinyConfig = ".$jsConfig.";"; 139 140 } 141 142 /** 143 * This function takes in html code that has been produced (and somewhat mauled) by TinyMCE 144 * and returns a cleaned copy of it. 145 * 146 * @param $html 147 * @return $html with all the tinyMCE specific html removed 148 */ 149 function cleanEncodedMCEHtml($html) { 150 $html = str_replace("mce:script", "script", $html); 151 $html = str_replace("mce_src=", "src=", $html); 152 $html = str_replace("mce_href=", "href=", $html); 153 return $html; 154 } 155 } // end class def
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
|
|
|
|