Documentation TYPO3 par Ameos

class.tx_rtehtmlarea_acronym.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2005-2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is 
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license 
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00035 class tx_rtehtmlarea_acronym {
00036         var $content;
00037         var $modData;
00038         var $doc;
00039 
00043         function init() {
00044                 global $BE_USER,$LANG,$BACK_PATH;
00045                 
00046                 $this->editorNo = t3lib_div::_GP('editorNo');
00047                 
00048                 $this->doc = t3lib_div::makeInstance('template');
00049                 $this->doc->docType = 'xhtml_trans';
00050                 $this->doc->backPath = $BACK_PATH;
00051                 
00052                 if ($this->doc->styleSheetFile_post) {
00053                         $styleDir = dirname(dirname($this->doc->styleSheetFile_post));
00054                         $this->doc->styleSheetFile_post = $styleDir.'/rtehtmlarea/htmlarea.css';
00055                 } else {
00056                         $this->doc->styleSheetFile_post = $BACK_PATH . t3lib_extMgm::extRelPath('rtehtmlarea') . 'htmlarea/skins/default/htmlarea.css'; 
00057                 }
00058                 
00059                 $this->doc->JScode = '<script type="text/javascript" src="'. $BACK_PATH . t3lib_extMgm::extRelPath('rtehtmlarea') . 'htmlarea/popups/popup.js"></script>';
00060                 
00061                 $this->doc->bodyTagAdditions = 'class="popupwin" onload="init();"';
00062                 $this->doc->form = '<form action="" id="acronymForm" name="acronymForm" method="POST">';
00063                 $JScode='
00064                         var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
00065                         var HTMLArea = window.opener.HTMLArea;
00066                         var param = null;
00067                         var html = editor.getSelectedHTML();
00068                         var sel = editor._getSelection();
00069                         var range = editor._createRange(sel);
00070                         var abbr = editor._activeElement(sel);
00071                         var abbrType = null;
00072                         var acronyms = new Object();
00073                         var abbreviations = new Object();
00074                         if(!(abbr != null && (abbr.tagName.toLowerCase() == "acronym" || abbr.tagName.toLowerCase() == "abbr"))) { 
00075                                 abbr = editor._getFirstAncestor(sel, ["acronym", "abbr"]);
00076                                 if(abbr != null && (abbr.tagName.toLowerCase() == "acronym" || abbr.tagName.toLowerCase() == "abbr")) { 
00077                                         param = { title : abbr.title, text : abbr.innerHTML};
00078                                         abbrType = abbr.tagName.toLowerCase();
00079                                 } else {
00080                                         param = { title : "", text : html};
00081                                 }
00082                         }
00083                         
00084                         function setType() {
00085                                 if(document.acronymForm.acronym.checked) {
00086                                         abbrType = "acronym";
00087                                         document.getElementById("abbrType").innerHTML = "' . $LANG->getLL('Acronym') . '";
00088                                 } else {
00089                                         abbrType = "abbr";
00090                                         document.getElementById("abbrType").innerHTML = "' . $LANG->getLL('Abbreviation') . '";
00091                                 }
00092                                 document.getElementById("title").value = param["title"];
00093                                 fillSelect(param["text"]);
00094                                 __dlg_init(null, false);
00095                         }
00096                         
00097                         function init() {
00098                                 if(abbrType != null) document.getElementById("type").style.display = "none";
00099                                         else abbrType = "abbr";
00100                                 if(HTMLArea.is_ie) document.getElementById("type").style.display = "none";
00101                                 if(abbrType == "acronym") document.acronymForm.acronym.checked = true;
00102                                         else  document.acronymForm.abbreviation.checked = true;
00103                                 var acronymUrl = window.opener.RTEarea[editor._doc._editorNo]["acronymUrl"];
00104                                 var abbrData = HTMLArea._getScript(0, false, acronymUrl);
00105                                 if(abbrData) eval(abbrData);
00106                                 setType();
00107                                 HTMLArea._addEvents(document.acronymForm.title,["keypress", "keydown", "dragdrop", "drop", "paste", "change"],function(ev) { document.acronymForm.termSelector.selectedIndex=-1; document.acronymForm.acronymSelector.selectedIndex=-1; });
00108                                 document.body.onkeypress = __dlg_close_on_esc;
00109                                 document.getElementById("title").focus();
00110                         };
00111                         
00112                         function fillSelect(text) {
00113                                 var termSelector = document.getElementById("termSelector");
00114                                 var acronymSelector = document.getElementById("acronymSelector");
00115                                 while(termSelector.options.length>1) termSelector.options[termSelector.length-1] = null;
00116                                 while(acronymSelector.options.length>1) acronymSelector.options[acronymSelector.length-1] = null;
00117                                 if(abbrType == "acronym") var abbrObj = acronyms;
00118                                         else var abbrObj = abbreviations;
00119                                 if(abbrObj != "") {
00120                                         for(var i in abbrObj) {
00121                                                 same = (i==text);
00122                                                 termSelector.options[termSelector.options.length] = new Option(abbrObj[i], abbrObj[i], false, same);
00123                                                 acronymSelector.options[acronymSelector.options.length] = new Option(i, i, false, same);
00124                                                 if(same) document.acronymForm.title.value = abbrObj[i];
00125                                         }
00126                                 }
00127                                 if(acronymSelector.options.length == 1) {
00128                                         document.getElementById("selector").style.display = "none";
00129                                 } else {
00130                                         document.getElementById("selector").style.display = "block";
00131                                 }
00132                         };
00133                         
00134                         function processAcronym(title) {
00135                                 if (title == "" || title == null) {
00136                                         if (abbr) {
00137                                                 var child = abbr.innerHTML;
00138                                                 abbr.parentNode.removeChild(abbr);
00139                                                 editor.insertHTML(child);
00140                                         }
00141                                 } else {
00142                                         var doc = editor._doc;
00143                                         if (!abbr) {
00144                                                 abbr = doc.createElement(abbrType);
00145                                                 abbr.title = title;
00146                                                 if(document.acronymForm.acronymSelector.options.length != 1 && document.acronymForm.termSelector.selectedIndex > 0 && document.acronymForm.termSelector.options[document.acronymForm.termSelector.selectedIndex].value == title) html = document.acronymForm.acronymSelector.options[document.acronymForm.acronymSelector.selectedIndex].value;
00147                                                 abbr.innerHTML = html;
00148                                                 if (HTMLArea.is_ie) range.pasteHTML(abbr.outerHTML);
00149                                                         else editor.insertNodeAtSelection(abbr);
00150                                         } else {
00151                                                 abbr.title = title;
00152                                                 if(document.acronymForm.acronymSelector.options.length != 1 && document.acronymForm.termSelector.selectedIndex > 0 && document.acronymForm.termSelector.options[document.acronymForm.termSelector.selectedIndex].value == title) abbr.innerHTML = document.acronymForm.acronymSelector.options[document.acronymForm.acronymSelector.selectedIndex].value;
00153                                         }
00154                                 }
00155                         };
00156                         
00157                         function onOK() {
00158                                 processAcronym(document.getElementById("title").value);
00159                                 __dlg_close(null);
00160                                 return false;
00161                         };
00162                         
00163                         function onDelete() {
00164                                 processAcronym("");
00165                                 __dlg_close(null);
00166                                 return false;
00167                         };
00168                         function onCancel() {
00169                                 __dlg_close(null);
00170                                 return false;
00171                         };
00172                 ';
00173                 
00174                 $this->doc->JScode .= $this->doc->wrapScriptTags($JScode);
00175                 
00176                 $this->modData = $BE_USER->getModuleData('acronym.php','ses');
00177                 $BE_USER->pushModuleData('acronym.php',$this->modData);
00178         }
00179         
00185         function main() {
00186                 
00187                 $this->content='';
00188                 $this->content.=$this->main_acronym($this->modData['openKeys']);
00189         }
00190         
00196         function printContent() {
00197                 echo $this->content;
00198         }
00199         
00206         function main_acronym($openKeys)        {
00207                 global $LANG, $BE_USER;
00208 
00209                 $content.=$this->doc->startPage($LANG->getLL('Insert/Modify Acronym',1));
00210                 
00211                 $RTEtsConfigParts = explode(':',t3lib_div::_GP('RTEtsConfigParams'));
00212                 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00213                 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00214                 
00215                 $content.='
00216         <div class="title" id="abbrType">' . $LANG->getLL('Acronym',1) . '</div>
00217         <fieldset id="type">
00218                 <legend>' . $LANG->getLL('Type_of_abridged_form',1) . '</legend>
00219                 <label for="abbreviation" class="checkbox">' . $LANG->getLL('Abbreviation',1) . '</label><input type="radio" name="type" id="abbreviation" value="abbreviation" checked="checked" onclick="setType();" />
00220                 <label for="acronym" class="checkbox">' . $LANG->getLL('Acronym',1) . '</label><input type="radio" name="type" id="acronym" value="acronym" onclick="setType();" />
00221         </fieldset>
00222         <fieldset id="selector">
00223                 <legend>' . $LANG->getLL('Defined_term',1) . '</legend>
00224                 <label for="termSelector" class="fl" id="termSelectorLabel" title="' . $LANG->getLL('Select_a_term',1) . '">' . $LANG->getLL('Unabridged_term',1) . '</label>
00225                 <select id="termSelector" name="termSelector"  title="' . $LANG->getLL('Select_a_term',1) . '"
00226                         onChange="document.acronymForm.acronymSelector.selectedIndex=document.acronymForm.termSelector.selectedIndex; document.acronymForm.title.value=document.acronymForm.termSelector.options[document.acronymForm.termSelector.selectedIndex].value;">
00227                         <option value=""></option>
00228                 </select>
00229                 <label for="acronymSelector" id="acronymSelectorLabel" title="' . $LANG->getLL('Select_an_acronym',1) . '">' . $LANG->getLL('Abridged_term',1) . '</label>
00230                 <select id="acronymSelector" name="acronymSelector"  title="' . $LANG->getLL('Select_an_acronym',1) . '"
00231                         onChange="document.acronymForm.termSelector.selectedIndex=document.acronymForm.acronymSelector.selectedIndex; document.acronymForm.title.value=document.acronymForm.termSelector.options[document.acronymForm.termSelector.selectedIndex].value;">
00232                         <option value=""></option>
00233                 </select>
00234         </fieldset>
00235         <fieldset>
00236                 <legend>' . $LANG->getLL('Term_to_abridge',1) . '</legend>
00237                 <label for="title" class="fl" title="' . $LANG->getLL('Use_this_term_explain',1) . '">' . $LANG->getLL('Use_this_term',1) . '</label>
00238                 <input type="text" id="title" name="title" size="60" title="' . $LANG->getLL('Use_this_term_explain',1) . '" />
00239         </fieldset>
00240         <div class="buttons">
00241                 <button type="button" title="' . $LANG->getLL('OK',1) . '"onclick="return onOK();">' . $LANG->getLL('OK',1) . '</button>
00242                 <button type="button" title="' . $LANG->getLL('Delete',1) . '" onclick="return onDelete();">' . $LANG->getLL('Delete',1) . '</button>
00243                 <button type="button" title="' . $LANG->getLL('Cancel',1)  . '" onclick="return onCancel();">' . $LANG->getLL('Cancel',1) . '</button>
00244         </div>';
00245         
00246                 $content.= $this->doc->endPage();
00247                 return $content;
00248         }
00249 }
00250 
00251 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod2/class.tx_rtehtmlarea_acronym.php'])   {
00252         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod2/class.tx_rtehtmlarea_acronym.php']);
00253 }
00254 
00255 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6