"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/rtehtmlarea/mod2/acronym.php Source File", "datetime" => "Sat Dec 2 19:22:34 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

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 error_reporting (E_ALL ^ E_NOTICE);
00036 unset($MCONF);
00037 require ('conf.php');
00038 require ($BACK_PATH.'init.php');
00039 require ($BACK_PATH.'template.php');
00040 $LANG->includeLLFile('EXT:rtehtmlarea/mod2/locallang.xml');
00041 
00042 class tx_rtehtmlarea_acronym {
00043         var $content;
00044         var $modData;
00045         var $doc;
00046 
00050         function init() {
00051                 global $BE_USER,$LANG,$BACK_PATH;
00052 
00053                 $this->doc = t3lib_div::makeInstance("template");
00054                 $this->doc->backPath = $BACK_PATH;
00055                 $this->doc->bodyTagAdditions = 'class="popupwin" onload="init();"';
00056                 $this->doc->form = '<form action="" id="acronymForm" name="acronymForm" method="POST">';
00057                 $this->doc->JScode='
00058                 <script type="text/javascript">
00059                         /*<![CDATA[*/
00060                         var editor = parent.editor;
00061                         var HTMLArea = parent.HTMLArea;
00062                         var head = document.getElementsByTagName("head")[0];
00063                         var link = document.createElement("link");
00064                         link.rel = "stylesheet";
00065                         link.href = parent._editor_CSS;
00066                         head.appendChild(link);
00067                         document.documentElement.className = "popupwin";
00068                         var param = null;
00069                         var html = editor.getSelectedHTML();
00070                         var sel = editor._getSelection();
00071                         var range = editor._createRange(sel);
00072                         var abbr = editor._activeElement(sel);
00073                         var abbrType = null;
00074                         var acronyms = new Object();
00075                         var abbreviations = new Object();
00076                         if(!(abbr != null && (abbr.tagName.toLowerCase() == "acronym" || abbr.tagName.toLowerCase() == "abbr"))) { 
00077                                 abbr = editor._getFirstAncestor(sel, ["acronym", "abbr"]);
00078                                 if(abbr != null && (abbr.tagName.toLowerCase() == "acronym" || abbr.tagName.toLowerCase() == "abbr")) { 
00079                                         param = { title : abbr.title, text : abbr.innerHTML};
00080                                         abbrType = abbr.tagName.toLowerCase();
00081                                 } else {
00082                                         param = { title : "", text : html};
00083                                 }
00084                         }
00085 
00086                         function setType() {
00087                                 if(document.acronymForm.acronym.checked) {
00088                                         abbrType = "acronym";
00089                                         document.getElementById("abbrType").innerHTML = "' . $LANG->getLL("Acronym") . '";
00090                                 } else {
00091                                         abbrType = "abbr";
00092                                         document.getElementById("abbrType").innerHTML = "' . $LANG->getLL("Abbreviation") . '";
00093                                 }
00094                                 document.getElementById("title").value = param["title"];
00095                                 fillSelect(param["text"]);
00096                         }
00097 
00098                         function init() {
00099                                 if(abbrType != null) document.getElementById("type").style.display = "none";
00100                                         else abbrType = "abbr";
00101                                 if(HTMLArea.is_ie) document.getElementById("type").style.display = "none";
00102                                 if(abbrType == "acronym") document.acronymForm.acronym.checked = true;
00103                                         else  document.acronymForm.abbreviation.checked = true;
00104                                 var acronymUrl = parent.window.opener.RTEarea[editor._doc._editorNo]["acronymUrl"];
00105                                 var abbrData = HTMLArea._getScript(0, false, acronymUrl);
00106                                 if(abbrData) eval(abbrData);
00107                                 setType();
00108                                 HTMLArea._addEvents(document.acronymForm.title,["keypress", "keydown", "dragdrop", "drop", "paste", "change"],function(ev) { document.acronymForm.termSelector.selectedIndex=-1; document.acronymForm.acronymSelector.selectedIndex=-1; });
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                                 parent.__dlg_close(null);
00160                                 return false;
00161                         };
00162 
00163                         function onDelete() {
00164                                 processAcronym("");
00165                                 parent.__dlg_close(null);
00166                                 return false;
00167                         };
00168                         function onCancel() {
00169                                 parent.__dlg_close(null);
00170                                 return false;
00171                         };
00172                         /*]]>*/
00173                 </script>
00174                 ';
00175 
00176                 $this->modData = $BE_USER->getModuleData("acronym.php","ses");
00177                 if (t3lib_div::_GP("OC_key"))   {
00178                         $parts = explode("|",t3lib_div::_GP("OC_key"));
00179                         $this->modData["openKeys"][$parts[1]] = $parts[0]=="O" ? 1 : 0;
00180                         $BE_USER->pushModuleData("acronym.php",$this->modData);
00181                 }
00182         }
00183 
00189         function main() {
00190 
00191                 $this->content="";
00192                 $this->content.=$this->main_acronym($this->modData["openKeys"]);
00193         }
00194 
00200         function printContent() {
00201                 echo $this->content;
00202         }
00203         
00210         function main_acronym($openKeys)        {
00211                 global $LANG, $BE_USER;
00212 
00213                 $content.=$this->doc->startPage("RTE acronym");
00214                 $RTEtsConfigParts = explode(":",t3lib_div::_GP("RTEtsConfigParams"));
00215                 $RTEsetup = $BE_USER->getTSConfig("RTE",t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00216                 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup["properties"],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00217 
00218                 $content.='
00219         <div class="title" id="abbrType">' . $LANG->getLL("Acronym") . '</div>
00220         <fieldset id="type">
00221                 <legend>' . $LANG->getLL("Type_of_abridged_form") . '</legend>
00222                 <label for="abbreviation" class="checkbox">' . $LANG->getLL("Abbreviation") . '</label><input type="radio" name="type" id="abbreviation" value="abbreviation" checked="checked" onclick="setType();" />
00223                 <label for="acronym" class="checkbox">' . $LANG->getLL("Acronym") . '</label><input type="radio" name="type" id="acronym" value="acronym" onclick="setType();" />
00224         </fieldset>
00225         <fieldset id="selector">
00226                 <legend>' . $LANG->getLL("Defined_term") . '</legend>
00227                 <label for="termSelector" class="fl" id="termSelectorLabel" title="' . $LANG->getLL("Select_a_term") . '">' . $LANG->getLL("Unabridged_term") . '</label>
00228                 <select id="termSelector" name="termSelector"  title="' . $LANG->getLL("Select_a_term") . '"
00229                         onChange="document.acronymForm.acronymSelector.selectedIndex=document.acronymForm.termSelector.selectedIndex; document.acronymForm.title.value=document.acronymForm.termSelector.options[document.acronymForm.termSelector.selectedIndex].value;">
00230                         <option value=""></option>
00231                 </select>
00232                 <label for="acronymSelector" id="acronymSelectorLabel" title="' . $LANG->getLL("Select_an_acronym") . '">' . $LANG->getLL("Abridged_term") . '</label>
00233                 <select id="acronymSelector" name="acronymSelector"  title="' . $LANG->getLL("Select_an_acronym") . '"
00234                         onChange="document.acronymForm.termSelector.selectedIndex=document.acronymForm.acronymSelector.selectedIndex; document.acronymForm.title.value=document.acronymForm.termSelector.options[document.acronymForm.termSelector.selectedIndex].value;">
00235                         <option value=""></option>
00236                 </select>
00237         </fieldset>
00238         <fieldset>
00239                 <legend>' . $LANG->getLL("Term_to_abridge") . '</legend>
00240                 <label for="title" class="fl" title="' . $LANG->getLL('Use_this_term_explain') . '">' . $LANG->getLL('Use_this_term') . '</label>
00241                 <input type="text" id="title" name="title" size="60" title="' . $LANG->getLL('Use_this_term_explain') . '" />
00242         </fieldset>
00243         <div class="buttons">
00244                 <button type="button" title="' . $LANG->getLL("OK") . '"onclick="return onOK();">' . $LANG->getLL("OK") . '</button>
00245                 <button type="button" title="' . $LANG->getLL("Delete") . '" onclick="return onDelete();">' . $LANG->getLL("Delete") . '</button>
00246                 <button type="button" title="' . $LANG->getLL("Cancel")  . '" onclick="return onCancel();">' . $LANG->getLL("Cancel") . '</button>
00247         </div>';
00248         
00249                 $content.= $this->doc->endPage();
00250                 return $content;
00251         }
00252 }
00253 
00254 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod2/acronym.php'])        {
00255         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod2/acronym.php']);
00256 }
00257 
00258 
00259 
00260 // Make instance:
00261 $SOBE = t3lib_div::makeInstance('tx_rtehtmlarea_acronym');
00262 $SOBE->init();
00263 $SOBE->main();
00264 $SOBE->printContent();
00265 ?>