1<?php
2
3/**
4 * Plugin anewssystem: provides an easy to handle, page based news system
5 *
6 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author     Taggic <taggic@t-online.de>
8 */
9
10if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
11if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
12if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
14if(!defined('DOKU_DATA')) define('DOKU_DATA',DOKU_INC.'data/pages/');
15require_once(DOKU_PLUGIN.'syntax.php');
16require_once(DOKU_INC.'inc/parser/xhtml.php');
17require_once(DOKU_INC.'inc/auth.php');
18
19/**
20 * All DokuWiki plugins to extend the parser/rendering mechanism
21 * need to inherit from this class
22 */
23class syntax_plugin_anewssystem extends DokuWiki_Syntax_Plugin {
24
25/******************************************************************************/
26/* return some info
27*/
28    function getInfo(){
29        return confToHash(dirname(__FILE__).'/plugin.info.txt');
30    }
31
32    function getType(){ return 'substition';}
33    function getPType(){ return 'block';}
34    function getSort(){ return 167;}
35
36/******************************************************************************/
37/* Connect pattern to lexer
38*/
39    function connectTo($mode){
40        $this->Lexer->addSpecialPattern('\{\{anss>[^}]*\}\}',$mode,'plugin_anewssystem');
41    }
42
43/******************************************************************************/
44/* handle the match
45*/
46    function handle($match, $state, $pos,Doku_Handler &$handler) {
47        global $ID, $conf;
48        $match = substr($match,strlen('{{anss>'),-2); //strip markup from start and end
49
50        //handle params
51        $data = array();
52    /******************************************************************************/
53    /*      parameter 1 can be one of the following: xs-author, flash
54    /******************************************************************************/
55
56        $params = $match;  // if you will have more parameters and choose ',' to delim them
57
58        //Default Value
59        $ans_conf                 = array();
60        $ans_conf['newsroot']     = 'news';
61        $ans_conf['newspage']     = 'newsdata';
62        $ans_conf['newstemplate'] = DOKU_PLUGIN.'anewssystem/tpl/newstemplate_'.$conf['lang'].'.txt';
63        $ans_conf['param']        = $params;
64
65        if (!$params) {
66          msg('Syntax of anewssystem detected but unknown parameter was attached.', -1);
67        }
68        else { return $ans_conf;}
69     }
70/******************************************************************************/
71/* render output
72* @author Taggic <taggic@t-online.de>
73*/
74    function render($mode,Doku_Renderer &$renderer, $ans_conf) {
75        global $ID, $conf;
76        $xhtml_renderer = new Doku_Renderer_xhtml();
77        $records      = file(DOKU_PLUGIN.'anewssystem/tpl/newstemplate_'.$conf['lang'].'.txt');
78        unset($records[0]);
79        $target       = $this->getConf('news_datafile');
80        $targetpage   = htmlspecialchars(trim($target));
81        $prefix       = 'anss';
82        $del          = 'anss_del';
83        $cut_prefx    = 'news_input_';
84        $allnewsdata1 = $this->getConf('news_output');
85        $allnewsdata  = wl( (isset($allnewsdata1) ? $allnewsdata1 : 'news:newsdata') );
86        $i            = strripos($allnewsdata, ":");
87        $news_root    = substr($allnewsdata, 0, $i);
88        // check if user has write permission on that ID
89        $current_usr = pageinfo();
90        // necessary for the back link of a show one article per page (SOAPP)
91        if(stripos($_GET['archive'],'archive')!== false) $ans_conf['param'] = $_GET['archive'];
92        $_GET['archive']="";
93
94        // 1. read template (plugins/anewssystem/template.php)
95        $template   = file_get_contents(DOKU_PLUGIN.'anewssystem/tpl/newstemplate.txt');
96      /*------- add news action part -----------------------------------------*/
97            $post_prefix   = $_POST["xs-".$prefix];
98            $delete_record = $_POST["anss_del_record"];
99            $delete_anchor = $_POST["anss_del_anchor"];
100//            msg($delete_record." = |".$delete_anchor.'|',0);
101
102            if(!isset($delete_anchor)) $delete_anchor = $delete_record; // if anchor field was deleted on input
103
104
105            if( (strlen($post_prefix)>2) && (auth_quickaclcheck($targetpage) >= AUTH_EDIT) ) {
106                // this will be called to store the news article to the others
107                $id_count = 1;
108                foreach( $_POST as $postkey => $postvalue ) {
109                    if( strpos($postkey, "news_input_") === 0 ) {
110                      $key = substr($postkey, strlen($cut_prefx));
111                      $key = trim($key);
112                      if( strpos(trim($postvalue), "\n") !== false ) {
113                        // this is a multilined value, so we need to prepend a linebreak
114                        // to achieve a multilined value for the template plugin
115                        $postvalue = "\n" . $postvalue;
116                        $postvalue = str_replace(chr(13),"",$postvalue);
117                      }
118//                      if( strpos(trim($postvalue), "\n\n") !== false ) $postvalue = str_replace('\n\n','\n',$postvalue);
119                      if(strpos('anchor',$key)>0) {
120                        $postvalue ='<a href="'.$postvalue.'">'.$postvalue.'</a>';
121                      }
122                      $newrecord .= "  * " . $key . ": " . $postvalue . "\n";
123                    }
124                }
125
126                $newrecord = '====== '.$_POST['news_input_head'].' ======'.chr(10).chr(10).$newrecord.chr(10);
127                $oldrecord = rawWiki($targetpage);
128
129                saveWikiText($targetpage, $newrecord.$oldrecord, "New entry", true);
130                $_POST["xs-".$prefix] = '';
131                msg($this->getLang('news_added'),1);
132            }
133            elseif( (strlen($post_prefix)>2) && (auth_quickaclcheck($targetpage) < AUTH_EDIT) ) {
134                msg($this->getLang('no_permission'),-1);
135            }
136      /*------- delete a news record -----------------------------------------*/
137            elseif( (strlen($delete_record)>2) && (auth_quickaclcheck($targetpage) >= AUTH_EDIT) ) {
138                $raw_records = rawWiki($targetpage);
139                $news_record = explode("====== ",$raw_records);
140                foreach($news_record as $record) {
141
142                  if((stripos($record, $delete_record)!==false) && (stripos($record, $delete_anchor)!==false))  {
143                    // inform user
144//                    msg("Delete: $record = ".$delete_record,0);
145//                    msg("Anchor: $record = ".$delete_anchor,0);
146                    msg('News Article deleted.',1);
147                  }
148                  else { if(strlen($record)>1) $news_records.= "====== ".$record;}
149                }
150                // write file
151                saveWikiText($targetpage, $news_records, "New entry", true);
152            }
153      /*------- show user form -----------------------------------------------*/
154            // this will provide the user form to add further news
155            // 2. create input form based on template
156        if ($ans_conf['param']==='author') {
157
158            if($this->getConf('wysiwyg')==true) { $myFunc = 'onsubmit="myFunction()"'; }
159            $output .= '<div class="news_form_div">
160                       <form class="news_input_form" id="'.$prefix.'" name="'.$prefix.'" method="POST" '.$myFunc.'>'.NL;
161
162            $output .= '<input type="hidden" name="xs-'.$prefix.'" value="check" />'.NL;
163
164
165
166            foreach ($records as $record) {
167                $fields = explode('|',$record);
168                if (trim($fields[1]) == "textarea") {
169                        $output .= '<p>'.trim($fields[4]);
170                        $output .= '<label class="nws_charcount"
171                                             id="nws_charcount"
172                                             name="nws_charcount">'.$this->getLang('wordcount2').$this->getConf('prev_length').' )</label><br />';
173                        if($this->getConf('wysiwyg')==false) {
174                              $output .= $this->news_edit_toolbar('news_input_'.trim($fields[0]));
175                              $imgBASE = DOKU_BASE."lib/plugins/anewssystem/images/toolbar/";
176                                        $output .= '<textarea class="news_input_textarea"'.
177                                                            ' id="news_input_'.trim($fields[0]).'"'.
178                                                            ' name="news_input_'.trim($fields[0]).'"'.
179                                                            ' title="'.trim($this->getLang(trim($fields[5]))).'" '.trim($fields[2]).'"'.
180                                                            ' onkeyup="count_chars(this,'.$this->getConf('prev_length').')" >'.
181                                                      '</textarea>
182                                                      <span class="reply_close_link">
183                                                      <a href="javascript:resizeBoxId(\'news_input_'.trim($fields[0]).'\', -20)"><img src="'.$imgBASE.'reduce.png" title="reduce textarea" style="float:right;" /></a>
184                                                      <a href="javascript:resizeBoxId(\'news_input_'.trim($fields[0]).'\', +20)"><img src="'.$imgBASE.'enlarge.png" title="enlarge textarea" style="float:right;" /></a>
185                                                      </span></p>'.NL;
186                        }
187                        else {
188                              $ansTBox_ID ='anss_textBox_'.trim($fields[0]);
189                              $template    = file_get_contents(DOKU_PLUGIN.'anewssystem/tpl/newstemplate.txt');
190                              $FontRecords = file(DOKU_PLUGIN.'anewssystem/tpl/fonts.txt');
191                              foreach ($FontRecords as $FontDef) {
192                                // $Font = font-family
193                                $Font = explode(',', $FontDef);
194                                $Font[0] = trim($Font[0]);      // font-family
195                                $Font[1] = trim($Font[1]);      // font
196                                $fontOptions .= '<option style="font-family:'.$Font[0].';" value="'.$Font[1].'" title="'.$Font[1].'" onclick="formatDoc(\'fontName\',\''.$Font[1].'\')">'.$Font[1].'</option>'.NL;
197                              }
198
199                              $output .= '<input type="hidden" name="news_input_wysiwyg" value="1" />'.NL;
200                              $output .= '<input type="hidden" id="news_input_text" name="news_input_text">
201
202                              <div style="border: 1px dotted grey;padding-left:10px;border-radius:3px 3px 0px 0px;padding-top:4px;padding-bottom:2px;">
203
204                                  <div id="toolBar2" style="margin-top:3px;">
205                                      <img class="anss_intLink" title="'.$this->getLang("Undo").'" onclick="formatDoc(\'undo\');" src="data:image/gif;base64,R0lGODlhFgAWAOMKADljwliE33mOrpGjuYKl8aezxqPD+7/I19DV3NHa7P///////////////////////yH5BAEKAA8ALAAAAAAWABYAAARR8MlJq7046807TkaYeJJBnES4EeUJvIGapWYAC0CsocQ7SDlWJkAkCA6ToMYWIARGQF3mRQVIEjkkSVLIbSfEwhdRIH4fh/DZMICe3/C4nBQBADs=" />
206                                      <img class="anss_intLink" title="'.$this->getLang("Redo").'" onclick="formatDoc(\'redo\');" src="data:image/gif;base64,R0lGODlhFgAWAMIHAB1ChDljwl9vj1iE34Kl8aPD+7/I1////yH5BAEKAAcALAAAAAAWABYAAANKeLrc/jDKSesyphi7SiEgsVXZEATDICqBVJjpqWZt9NaEDNbQK1wCQsxlYnxMAImhyDoFAElJasRRvAZVRqqQXUy7Cgx4TC6bswkAOw==" />
207                                      <img class="anss_intLink" title="'.$this->getLang("Clean").'" onclick="oDoc.innerHTML=sDefTxt;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAjxJREFUSEu1k9tvEkEYxfv/mhgTEx9MGrVa9cE0plotEEIUxeCDFJuaiijXLpQ7hJBFIIRwk9tyJxgvx/mWYJmdTXkQH37Z7NlzTna+mdkC8F/QFTeBrriOfjiFwu4zFO4dQAklmSR6BGEdVPSVFf46PcfvjxHIO0/QkxLsE+/jXtahsAIq+nkiofv6A7pvTtXy3K3H6AZjzHLh5YKXQX8l39nHj+Mg2i+P0Xl1wpVnbj5C2x9h1oVfKNCj1WohmUzi+5EPLcsRWi/ec+XFB4dQDG+RuPGQ2RcZoUQLlcbjccznc0ynU3wzv+PK82zehfvP0Tu0I3J9l0UWOaFolWaziWg0itlshtFo9JdleY6NRr77FO0DG86v7aDpCbHYIiuULWk0GgiHw5hMJuj3+wKZ7T1k2aY1960IXb2N+heJxS7yXNmSer0OSZIwHo/R7XYFEokEUqkUqnsWnF3ZRu3zGYvxHdwLUavVEAgEMBwOQfPVEolEEIvFUCwW4XA4UP0UYDG+gxAEn8+HwWAAGoUWWgWNR5Zl2O125HI5FuHzSwTB7XarxdVqlcPv9yMYDCKbzcJqtapPbXYVQSiVSnA6nWp5pVJR8Xg88Hq9SKfTsFgsyGQyzMrntOiKtESbzYZyuaxu1BKTyaRumtavhyAoioJ8Pg+XywWz2ayWGY1GGAwG9c9pBTRvOh20wXTGtR2EIJCRQnTkqIAuCZ2GTqeDXq+njoguCd1CbXYVXXET6IqbQFfcBLriv4OtP5w57lyaBByNAAAAAElFTkSuQmCC" />
208                                      <img class="anss_intLink" title="'.$this->getLang("Remove_formatting").'" onclick="formatDoc(\'removeFormat\')" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB9oECQMCKPI8CIIAAAAIdEVYdENvbW1lbnQA9syWvwAAAuhJREFUOMtjYBgFxAB501ZWBvVaL2nHnlmk6mXCJbF69zU+Hz/9fB5O1lx+bg45qhl8/fYr5it3XrP/YWTUvvvk3VeqGXz70TvbJy8+Wv39+2/Hz19/mGwjZzuTYjALuoBv9jImaXHeyD3H7kU8fPj2ICML8z92dlbtMzdeiG3fco7J08foH1kurkm3E9iw54YvKwuTuom+LPt/BgbWf3//sf37/1/c02cCG1lB8f//f95DZx74MTMzshhoSm6szrQ/a6Ir/Z2RkfEjBxuLYFpDiDi6Af///2ckaHBp7+7wmavP5n76+P2ClrLIYl8H9W36auJCbCxM4szMTJac7Kza////R3H1w2cfWAgafPbqs5g7D95++/P1B4+ECK8tAwMDw/1H7159+/7r7ZcvPz4fOHbzEwMDwx8GBgaGnNatfHZx8zqrJ+4VJBh5CQEGOySEua/v3n7hXmqI8WUGBgYGL3vVG7fuPK3i5GD9/fja7ZsMDAzMG/Ze52mZeSj4yu1XEq/ff7W5dvfVAS1lsXc4Db7z8C3r8p7Qjf///2dnZGxlqJuyr3rPqQd/Hhyu7oSpYWScylDQsd3kzvnH738wMDzj5GBN1VIWW4c3KDon7VOvm7S3paB9u5qsU5/x5KUnlY+eexQbkLNsErK61+++VnAJcfkyMTIwffj0QwZbJDKjcETs1Y8evyd48toz8y/ffzv//vPP4veffxpX77z6l5JewHPu8MqTDAwMDLzyrjb/mZm0JcT5Lj+89+Ybm6zz95oMh7s4XbygN3Sluq4Mj5K8iKMgP4f0////fv77//8nLy+7MCcXmyYDAwODS9jM9tcvPypd35pne3ljdjvj26+H2dhYpuENikgfvQeXNmSl3tqepxXsqhXPyc666s+fv1fMdKR3TK72zpix8nTc7bdfhfkEeVbC9KhbK/9iYWHiErbu6MWbY/7//8/4//9/pgOnH6jGVazvFDRtq2VgiBIZrUTIBgCk+ivHvuEKwAAAAABJRU5ErkJggg==" />
209
210                                      <img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAFVJREFUSEvtzDEKAEEIQ9G5/8UUwcITuamsfrFTTGfxCCSQ092/uLuCN4IlMTMFbwRL8uw4IhS8ESzJHo89Hns89nhkpoI3giWpKgVvBEuyx+PuuM8HbRKvOi5p1GMAAAAASUVORK5CYII=" />
211                                      <img class="anss_intLink" title="'.$this->getLang("Bold").'" onclick="formatDoc(\'bold\');" src="data:image/gif;base64,R0lGODlhFgAWAID/AMDAwAAAACH5BAEAAAAALAAAAAAWABYAQAInhI+pa+H9mJy0LhdgtrxzDG5WGFVk6aXqyk6Y9kXvKKNuLbb6zgMFADs=" />
212                                      <img class="anss_intLink" title="'.$this->getLang("Italic").'" onclick="formatDoc(\'italic\');" src="data:image/gif;base64,R0lGODlhFgAWAKEDAAAAAF9vj5WIbf///yH5BAEAAAMALAAAAAAWABYAAAIjnI+py+0Po5x0gXvruEKHrF2BB1YiCWgbMFIYpsbyTNd2UwAAOw==" />
213                                      <img class="anss_intLink" title="'.$this->getLang("Underline").'" onclick="formatDoc(\'underline\');" src="data:image/gif;base64,R0lGODlhFgAWAKECAAAAAF9vj////////yH5BAEAAAIALAAAAAAWABYAAAIrlI+py+0Po5zUgAsEzvEeL4Ea15EiJJ5PSqJmuwKBEKgxVuXWtun+DwxCCgA7" />
214
215                                      <img title="'.$this->getLang("Font_color").'" id="hoveritem1" onMouseOver="ShowPopup(\'hoveritem1\', \'hoverpopup1\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAlxJREFUSEu1kktIVFEchyWwiKSnUQgZgT0WURJlBGELy0WEQRFhi0gJctNCCxIjrMmIgh4DGfYyiBRSkkIaIwNfleAjjagUk0lzNF/Z4MxEZvfrf+fOXO/N06pp8Z3Hd37nf8493Cjgv6CUkUAp/0qHdDqqtT9QymlM9sPQPuiKhu4FaL4K0YqchWmifaCR0vZCqrsqGA0MiRI/6YHB/VJ0EbiXSeHHhhe03o9w7xaU3pXD5QIhbys6OO7hmCudpOux7C3ZRE13pWhjbcJbxa/eXLRhJ9pPOSjkNedZWLEUEuKgvNj0ZlGdfm8PmQ9TWeOMJqU4AVfnA9FT635fwDYP4jgO82YZ3LlqrttDQoPbheN5FiVtTr4FRkQRNeaFgkJIOwKnrsDwqK5Dez67wXECLuaDp9v0tqJhvN+/EpjwydCYN72B5dsgJhGWbIHql/qSZc+4nOwftzlzMDjqZ2RM8anChZuwOAnSs2HGarngNbGKnJVgU9viIS2nmowz9bS8D/0JFlIOgo6rFuKTIfUQfOrTY/aclWCTf6OVmVvvE7ezjNuPOkRNBZ41GM+Qd0n+OHnyzFyj+JMaPWYvZiXYVNa5id9VxuaMSmqag1cxA9nnIFae4XwRNLbBycswZx2cduoxezEr5qDu3Rcau3rw/RiWqeE+vPWTtEdj/gZYuR1W7TD6mPWQfAD6BvSovWAYpQxTXtDM3ESNw3lQ3wSvXsOLFtidBQs3QlWdpBT7dJQyTE56J7PXajytl5nFF5UahY867N6KUkYCpYwEShkJlDISKGUkUMp/h6jfdMOr6dXAlTYAAAAASUVORK5CYII=" />
216                                      <div id="hoverpopup1" style="visibility:hidden; position:absolute;" >
217                                      <table>
218                                      <tr><td>
219                                      <img usemap="#fcolor_pallete" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAABLCAYAAACx+i/GAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKKSURBVHhe7drBitNQGMXxZOgriGVWZXwGBVcJunEvUt/ApR1059rdQOty3sAi7gVRblaCPoNDV1LxFcrEfuUiHtP75UI2wfn/IJBLwpkGDtPm8pXL5Yu2AKJDIRaLi7jETbZavSxO4jlwQCEgKATE0d8QTdPEszxVVcUz9b/mmDFmDc2x3xCFFeJfIYR41s+7167t/07W0Zezvynr6M1p9/dlHF6Osevl/r6cIyfryKMcPbysw7XiY9ZxLMe6wFcGBIWAoBAQFAKCQkBQCAgKAUEhICgEBFvXjlSOGWPW0BzbumYeAn8wD4EOCgFBISAoBASFgOC105HKMWPMGpqTfO204NlsFle+zWbjfsD1eh1Xvvl87uZUPx7Ela85/eznVFdx5Wuas2SOsayT+3n/YK+/XPdmlXfS1//WfrdncJ7v6lZc+ZqzX50cXjvRQSEgKAQEhYCgEBAUAoJCQFAICAoBwda1I5Vjxpg1NIeJKQi2rtFBISAoBASFgKAQELx2OlI5ZoxZQ3PciamyLOPK17at+wFtoiqHTWh5OdWHzImpRz0TU7fruPI1P0Myx1hWHfKyQt2f9ezTJK58lw937vPt6q9x5ZuEe50cXjvRQSEgKAQEhYCgEBAUAoJCQFAICAoBwda1I5Vjxpg1NIeJKQi2rtFBISAoBASFgKAQELx2OlI5ZoxZQ3PciantdhtXvul06n7AySRvEmi38yeBQp03nVSH9HSS5Xx7/TiufHdfvU/mGMt6vlzGle/N+XlvVl2/jStfCE/d53tXr+LK9yQsOjm8dqKDQkBQCAgKAUEhICgEBIWAoBAQFAKCrWtHKseMMWtoDhNTEGxdo4NCQBy+MuI5bryi+A1GxhVi/hSIzAAAAABJRU5ErkJggg==" />
220                                      </td></tr></table></div>
221
222                                      <img title="'.$this->getLang("Background_color").'" id="hoveritem2" onMouseOver="ShowPopup(\'hoveritem2\', \'hoverpopup2\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAihJREFUSEu1lE9Ik3EYx0eXLh2iW5fAQ6cOHio6F0EdokNihARRStCgXTosLPvDIoIaSB6yDq4FJTIrsz9rasNqIgUrXqdr6XSbbXOzOTdL59zYp5/vsvm217+tw+d5n+f7fL/P7fdqgP+CqlgKVMW14veFxUepKYb1MDmZofutm2AwKsaCrjCtB8k1hXd4VrRKXTGslR5HFMn1g5S46w9A78c+Ied3RebV0u9O0/thTLQQi0O3PYrZbJsf5X1RYDX0uzN02WOihfQcOJ0ZzA+c6PW35yXZUxRaiVAQmkxfsb6OEpsC1yA8fOSjrtZC9QmDsOR9RcGV6Hlvx3jDiPFmB033vTSaA1wyvEJ39g6NDZ3CkvcVBZcj8M3A0Eg57U+2ce3qMbQn71FVZeH85RaaLVZhKXgVweXwjb9kOrdBHrOC9uebOH6khurKF7S1eUkkZ8Su4FeEl+JnOskQBxXy574yOh8/w+MS4+LFb/40w3TRwlHesQOu7GFaWwH7GqDChnShgxF2C9tG2T6R2kw41CZ65bHFyCWAAyuneSqCHpuGXGUZ38v1pLa0MrhVon5niHrHXZrdtZgkLV/CFhFTP7iAXD5hopVDDEjbSd/aRfx6DZHDA0ztjfJmP1w8ALpTc5w7k0FXBx7xyhYOLIVcUiRIEmB2ZojcxCjZeJRsMAPip5UWJCIwPpolMgxBv0j8dUQNVbEUqIqlQFUsBapiKVAV/x00vwAP3byEksuehwAAAABJRU5ErkJggg==" />
223                                      <div id="hoverpopup2" style="visibility:hidden; position:absolute;" >
224                                      <table>
225                                      <tr><td>
226                                      <img usemap="#bgcolor_pallete" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAABLCAYAAACx+i/GAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKKSURBVHhe7drBitNQGMXxZOgriGVWZXwGBVcJunEvUt/ApR1059rdQOty3sAi7gVRblaCPoNDV1LxFcrEfuUiHtP75UI2wfn/IJBLwpkGDtPm8pXL5Yu2AKJDIRaLi7jETbZavSxO4jlwQCEgKATE0d8QTdPEszxVVcUz9b/mmDFmDc2x3xCFFeJfIYR41s+7167t/07W0Zezvynr6M1p9/dlHF6Osevl/r6cIyfryKMcPbysw7XiY9ZxLMe6wFcGBIWAoBAQFAKCQkBQCAgKAUEhICgEBFvXjlSOGWPW0BzbumYeAn8wD4EOCgFBISAoBASFgOC105HKMWPMGpqTfO204NlsFle+zWbjfsD1eh1Xvvl87uZUPx7Ela85/eznVFdx5Wuas2SOsayT+3n/YK+/XPdmlXfS1//WfrdncJ7v6lZc+ZqzX50cXjvRQSEgKAQEhYCgEBAUAoJCQFAICAoBwda1I5Vjxpg1NIeJKQi2rtFBISAoBASFgKAQELx2OlI5ZoxZQ3PciamyLOPK17at+wFtoiqHTWh5OdWHzImpRz0TU7fruPI1P0Myx1hWHfKyQt2f9ezTJK58lw937vPt6q9x5ZuEe50cXjvRQSEgKAQEhYCgEBAUAoJCQFAICAoBwda1I5Vjxpg1NIeJKQi2rtFBISAoBASFgKAQELx2OlI5ZoxZQ3PciantdhtXvul06n7AySRvEmi38yeBQp03nVSH9HSS5Xx7/TiufHdfvU/mGMt6vlzGle/N+XlvVl2/jStfCE/d53tXr+LK9yQsOjm8dqKDQkBQCAgKAUEhICgEBIWAoBAQFAKCrWtHKseMMWtoDhNTEGxdo4NCQBy+MuI5bryi+A1GxhVi/hSIzAAAAABJRU5ErkJggg==" />
227                                      </td></tr></table></div>
228
229                                      <img class="anss_intLink" title="'.$this->getLang("Strikethrough").'" onclick="formatDoc(\'strikethrough\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAABGdBTUEAAK/INwWK6QAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAA30lEQVQ4T2P4//8/Ay0xTQ0HOXxwWBAbGysYGBg409HRMU1PT69cXl5+Jicn525igpYoH3h5eb2zs7MrhxnIxsZWzgD2POH4I2iBu7t7mqGh4X8NDY0OZAOBFlDHByYmJi7AIPnPz88PjDGGmUBsDI48BgYXqvgAZAgovEFBgoTPUGRBWlpaKRD/R8fS0tLIlqCzS7D5iGAcAF0qiBb2aUCxu1DfnCEUTMRYADIQnoJgBkItuEstC0DBge6Td9gsRreQWB+ADANFLCj9g30ExCjJFpdPCFpAKAgIyQ99CwDEVf+A3LSrWQAAAABJRU5ErkJggg==">
230                                      <img class="anss_intLink" title="'.$this->getLang("Superscript").'" onclick="formatDoc(\'superscript\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAABGdBTUEAAK/INwWK6QAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAA9UlEQVQ4T7WTLQ7CQBCFV6ARtfUIBA5LQCA4QxEILBK7Z8BwgZ4FgW44AYoj1G3fbGbIiG67y9ImL/1J+72ZeVPjnDNTKgu+Nc8CekEOuvYVmmtwBPgGlWSSZGCMqSEHtdCcPsaxVs8WAgR8DzWpBiXDiXxmgwcb+HsSwEuohXZJBgw8MfCDc8XXtYLTaIJwzxjaIABnkFRNnbyhQhlYDphCTstAIABeuHIyuKeu9FgHkkOjTHpnHTIeM5BNOsDAsgmNyW9VjIIvAbJhIFVPWeitsjHwYMgMlLFUKg/pgvJYxZhEtRkD+imDHPC3639ABv+lqQ06XCTTcqILhPIAAAAASUVORK5CYII=">
231                                      <img class="anss_intLink" title="'.$this->getLang("Subscript").'" onclick="formatDoc(\'subscript\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAA9UlEQVQ4T8WTIQ7CQBBFR6AR2HoEAoclQSA4QxEILBLbcAQMF+hZOEHDCVAcoW75s/kLK9rubEKD+Gm7bf6b+TMV55yMqVHNtfD/AUSkhlCCtNDUVyOyis7mlmh7O4BRQXN1PhJwJ8A/WzT4EcwONHzhWvK+thiHb1KACUxD1drJE5r9DMBYTqxcAbcc8+QWRXNoIsgmB5KKKGzSDoCKEI3Jb9UFcUEPyEHnLvDQFq1pqNXrLOKtqgjYw/gKFQoxA2gYYik/G/HtQuexDOcw30KNGZCTMYwXUAt1zsb0s/QBGU2veXKLUp0AUHHAOmT7DFLGOe/fRwDI0vXm3AMAAAAASUVORK5CYII=">
232
233                                      <img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAFVJREFUSEvtzDEKAEEIQ9G5/8UUwcITuamsfrFTTGfxCCSQ092/uLuCN4IlMTMFbwRL8uw4IhS8ESzJHo89Hns89nhkpoI3giWpKgVvBEuyx+PuuM8HbRKvOi5p1GMAAAAASUVORK5CYII=" />
234
235                                      <img class="anss_intLink" title="'.$this->getLang("Left_align").'" onclick="formatDoc(\'justifyleft\');" src="data:image/gif;base64,R0lGODlhFgAWAID/AMDAwAAAACH5BAEAAAAALAAAAAAWABYAQAIghI+py+0Po5y02ouz3jL4D4JMGELkGYxo+qzl4nKyXAAAOw==" />
236                                      <img class="anss_intLink" title="'.$this->getLang("Center_align").'" onclick="formatDoc(\'justifycenter\');" src="data:image/gif;base64,R0lGODlhFgAWAID/AMDAwAAAACH5BAEAAAAALAAAAAAWABYAQAIfhI+py+0Po5y02ouz3jL4D4JOGI7kaZ5Bqn4sycVbAQA7" />
237                                      <img class="anss_intLink" title="'.$this->getLang("Right_align").'" onclick="formatDoc(\'justifyright\');" src="data:image/gif;base64,R0lGODlhFgAWAID/AMDAwAAAACH5BAEAAAAALAAAAAAWABYAQAIghI+py+0Po5y02ouz3jL4D4JQGDLkGYxouqzl43JyVgAAOw==" />
238                                      <img class="anss_intLink" title="'.$this->getLang("Full_align").'" onclick="formatDoc(\'justifyfull\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAFlJREFUOE+1ziEOADEQQtHe/9LTxU0Aw4aKZ74gnJl5ysYmG5t8/PIfvAMS2nxcrxK8AxLafFyvErwDEtp8XK8SvAMS2nxcrxK8AxLafFyvErwDEtps7JlzAcY81FZTtdiRAAAAAElFTkSuQmCC">
239
240                                      <br />
241
242                                      <img class="anss_intLink" title="'.$this->getLang("Add_indentation").'" onclick="formatDoc(\'indent\');" src="data:image/gif;base64,R0lGODlhFgAWAOMIAAAAADljwl9vj1iE35GjuaezxtDV3NHa7P///////////////////////////////yH5BAEAAAgALAAAAAAWABYAAAQ7EMlJq704650B/x8gemMpgugwHJNZXodKsO5oqUOgo5KhBwWESyMQsCRDHu9VOyk5TM9zSpFSr9gsJwIAOw==" />
243                                      <img class="anss_intLink" title="'.$this->getLang("Delete_indentation").'" onclick="formatDoc(\'outdent\');" src="data:image/gif;base64,R0lGODlhFgAWAMIHAAAAADljwliE35GjuaezxtDV3NHa7P///yH5BAEAAAcALAAAAAAWABYAAAM2eLrc/jDKCQG9F2i7u8agQgyK1z2EIBil+TWqEMxhMczsYVJ3e4ahk+sFnAgtxSQDqWw6n5cEADs=" />
244                                      <img class="anss_intLink" title="'.$this->getLang("Numbered_list").'" onclick="formatDoc(\'insertorderedlist\');" src="data:image/gif;base64,R0lGODlhFgAWAMIGAAAAADljwliE35GjuaezxtHa7P///////yH5BAEAAAcALAAAAAAWABYAAAM2eLrc/jDKSespwjoRFvggCBUBoTFBeq6QIAysQnRHaEOzyaZ07Lu9lUBnC0UGQU1K52s6n5oEADs=" />
245                                      <img class="anss_intLink" title="'.$this->getLang("Dotted_list").'" onclick="formatDoc(\'insertunorderedlist\');" src="data:image/gif;base64,R0lGODlhFgAWAMIGAAAAAB1ChF9vj1iE33mOrqezxv///////yH5BAEAAAcALAAAAAAWABYAAAMyeLrc/jDKSesppNhGRlBAKIZRERBbqm6YtnbfMY7lud64UwiuKnigGQliQuWOyKQykgAAOw==" />
246
247                                      <img class="anss_intLink" title="'.$this->getLang("H-Ruler").'" onclick="formatDoc(\'inserthorizontalrule\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAPNJREFUOE9j+P//PwMtMU0NBzkcpwXl5eX/YbikpOR/Xl7e/7S0tP8xMTH/g4KC/ru7u/+3sbH5b2Bg8F9VVRVoFvaQGDgfEONqaWnp/4KCgv85OTkHoQ9whTXU1X+Arj5KTOobmDho2/By76LD7/5jw/MPvP0/e9/r/9N2v/o/cdur/z2bn/9vXf/8f+Sku3ux+QirD0AG77j4CY63nf/4f/PZD//Xn37/f/Xx9/+XH337f9Ght//n7X/9f9be1/+n73r1v3jxY6wRjdMCXC5tWP30f/XKp//Llz4GG4qMifYBMZFHrJqBiWRiXUeMuqHvAwA6MV3j7jeEEwAAAABJRU5ErkJggg==">
248                                      <img class="anss_intLink" title="'.$this->getLang("Quote").'" onclick="makeCite();" src="data:image/gif;base64,R0lGODlhFgAWAIQXAC1NqjFRjkBgmT9nqUJnsk9xrFJ7u2R9qmKBt1iGzHmOrm6Sz4OXw3Odz4Cl2ZSnw6KxyqO306K63bG70bTB0rDI3bvI4P///////////////////////////////////yH5BAEKAB8ALAAAAAAWABYAAAVP4CeOZGmeaKqubEs2CekkErvEI1zZuOgYFlakECEZFi0GgTGKEBATFmJAVXweVOoKEQgABB9IQDCmrLpjETrQQlhHjINrTq/b7/i8fp8PAQA7" />
249                                      <img class="anss_intLink" title="'.$this->getLang("Code").'" onclick="makeCode();" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAARBJREFUSEu1kqGRhTAQhpFIJGVQAoICKAFBAUgcJSAogEIQCCQCgUAgkEgEBezt5s3eS16WmTdze+IL8P3JboAEAPAviFIDUWogSg1EqYEoNRAls20bXny/ritefG8jymVZIM9zTAM4jgOVm5dlCXEcQ9u2XsY4D3bBMAyBCtg5M00TJEli5j01MAPtigtGUQR1XcN5nhi5kz8ZhgGyLPtt0HUd6ldmBhIU0i6+KfhJ3/dmPcHFTbDvO6RpagLacdM0XzUYx9F5U1rHmTeRG9A3rqoK9Ttn5nn2NnJdF0bvOc4Cxm4gnYqiKB4LMp6wob9/3zfeup5Oz1NBRpQaiFIDUWogSg1EqYEoNRDl34HgB96MckGYHkIZAAAAAElFTkSuQmCC" />
250                                      <img class="anss_intLink" title="'.$this->getLang("Hyperlink").'" onclick="var sLnk=prompt(\'Write the URL here\',\'http:\/\/\');if(sLnk&&sLnk!=\'\'&&sLnk!=\'http://\'){formatDoc(\'createlink\',sLnk)}" src="data:image/gif;base64,R0lGODlhFgAWAOMKAB1ChDRLY19vj3mOrpGjuaezxrCztb/I19Ha7Pv8/f///////////////////////yH5BAEKAA8ALAAAAAAWABYAAARY8MlJq7046827/2BYIQVhHg9pEgVGIklyDEUBy/RlE4FQF4dCj2AQXAiJQDCWQCAEBwIioEMQBgSAFhDAGghGi9XgHAhMNoSZgJkJei33UESv2+/4vD4TAQA7" />
251                                      <img class="anss_intLink" title="'.$this->getLang("Unlink").'" onclick="formatDoc(\'unlink\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAk5JREFUSEu1k19IU1EcxwUfEyF80JJoFGShLLWpID5Ioi+xh+wlX+ohYg2EwEDRCGdF0sOcKRTYQ1rRfHDD0qnVw15sxITUp0p8Cv/QSCdTCqrx6Z5zd7ddPQuk9fC5597v+Z3v73fO+d0c4L+gFLOBUswGSjEbKMWM7Oxog0JXkHxZXPqGdyLEg2evkwTff9Sm9Lkx7wyB1pu8vHGbh4/HZayxVhKNwvw8xGJSN5mK8dfvuESYdvb5pS5YGntDvLmZeEMDHx49pdPtw/vqnTQhGISuLmhpgamplLFhKqq0nbvC5euepKFAJPG9mOHJcStfCg4Rtl8k4B3F4ewFjwfq66GsDBobYXo6ZSwMRZXCVJgIM6NygUi6+CnC/fPXiJ4+w/qxE6zc6qXvZDVYrVBVBR0dyMq3t1PG6RWL7YvxyNm7JkRS173nhC5cIlZczFZBISsHC6GiAtxu2NiQhgbyYZiOTwT06jREAnEkQhfI5FrVn31vWT1s4WduLj8O5EF7O2xtmUwFyRfjsoRZ+jmnz7VevcPo0VN8zS/ge14+FBXpl5bohHRMH39lcxN6eqC0FJqaoK0NKivBZoOBAXb3uHlxJsRWu7v1my8vh5ERffv9/frF1dXB8LAWmlpjNsiE369XVlsLg4OalNCNhKIzamqQcYk5s4GK1VVwOKCkBFyuvee5tgZOJ1gsYLdDOCznzSYq5uZA++PkuYZ2/cYGCwt6TLXW10ND8rz3BqmYnU1WkpHlZZichEhE+9xPV+wTpZgNlGI2UIr/Djl/AJ5goKk+yVctAAAAAElFTkSuQmCC" />
252
253                                      <select style="margin: 0 12pt 0 12pt;" size="1">
254                                          '.$fontOptions.'
255                                      </select>
256                                      <img class="anss_intLink" title="'.$this->getLang("Smaller").'" onclick="addTags(\'small\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAD0SURBVDhPpdChbgJBEMbxeYAKQggC1WeorgCFQWGLpK6iD1DXJ8CAQCBxICsQCPoCeBIkSRG0qqLi+p9lLzc3LAmESX7J7sx9u3cnWZbdJNm0Yg2xgzbUD5Zh7gNerDY+kR+wwVOY+4AXq4oBvvCNGeph7gOeqS6WWONZG2HuA56pBt6g/+NeG2GeCDxigte4t/WA1nF5/oAp/vCLO22cq5MDKA1ocKRz9Ow8pbwhgPzmLeZ2nlLeiCzyEPUO/ZSafcYrFjwYAwfo7XvooG8DXrEQeYmBDpqRHrKwAa9YiHxgVRqKjKFvVbF9K9m8RrJ5uUz+AVQNGdVN6ktGAAAAAElFTkSuQmCC" />
257                                      <img class="anss_intLink" title="'.$this->getLang("Bigger").'"  onclick="addTags(\'big\');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAEJSURBVDhPldI7TsNAEIBhlxQ0SIgCpcgRnCOkojUtcpkDUFC6ywGiFDmBSxTlAEi4CH2UOki0CBpQCgqKzT/2LjseVoKs9FmzOw87jjPn3J/MGmHchaxUg2bWJSosMJSDZJNm1jUescVEDlINJ5DpAzPgDHO84QNLXKQG1JBAlGrIFZ4Qcs+4sc1y9z1C0YMaIL/7FSH3icYOKHxyhi9841zXWP1Nlt1DghwrH98iuXoDWKeQu+78voQE61CTEoPYMPX7MFA2w1BnxSA+8jtePHkHclbpJq27xLuJRtlACja2Megu8fHrXpJ/AOEpcp37qWkv8e0Xvwr4FnzuzubafOrwGMnD/3PZAXT02e5rxY58AAAAAElFTkSuQmCC" />
258                                    </div>
259                                  </div>
260                                  <div  id="anss_textBox_'.trim($fields[0]).'"
261                                        class="anss_textBox"
262                                        contenteditable="true"
263                                        name="anss_textBox_'.trim($fields[0]).'"
264                                        title="'.trim($this->getLang(trim($fields[5]))).'" '.trim($fields[2]).'"
265                                        onkeyup="count_chars(this,'.$this->getConf("prev_length").')"
266                                        onMouseOver="HidePopup(\'hoverpopup1\', \'hoverpopup2\', \'hoverpopup3\')" ></div>
267
268                                        <map name="fcolor_pallete" id="fcolor_pallete">
269                                          <area shape="rect" coords=" 5, 5,16,16"   href="#FFFFFF" onclick="getfColor(this);" />
270                                          <area shape="rect" coords=" 5,23,16,34"   href="#E0E0E0" onclick="getfColor(this);" />
271                                          <area shape="rect" coords=" 5,41,16,52"   href="#C1C1C1" onclick="getfColor(this);" />
272                                          <area shape="rect" coords=" 5,59,16,70"   href="#A8A8A8" onclick="getfColor(this);" />
273
274                                          <area shape="rect" coords="23, 5,34,16"   href="#000000" onclick="getfColor(this);" />
275                                          <area shape="rect" coords="23,23,34,34"   href="#696969" onclick="getfColor(this);" />
276                                          <area shape="rect" coords="23,41,34,52"   href="#A0A0A0" onclick="getfColor(this);" />
277                                          <area shape="rect" coords="23,59,34,70"   href="#C4C4C4" onclick="getfColor(this);" />
278
279                                          <area shape="rect" coords="41, 5,52,16"   href="#FF0000" onclick="getfColor(this);" />
280                                          <area shape="rect" coords="41,23,52,34"   href="#FFA600" onclick="getfColor(this);" />
281                                          <area shape="rect" coords="41,41,52,52"   href="#FF7800" onclick="getfColor(this);" />
282                                          <area shape="rect" coords="41,59,52,70"   href="#800000" onclick="getfColor(this);" />
283
284                                          <area shape="rect" coords="59, 5,70,16"   href="#FFFF00" onclick="getfColor(this);" />
285                                          <area shape="rect" coords="59,23,70,34"   href="#FFFF9E" onclick="getfColor(this);" />
286                                          <area shape="rect" coords="59,41,70,52"   href="#FFD700" onclick="getfColor(this);" />
287                                          <area shape="rect" coords="59,59,70,70"   href="#8B4513" onclick="getfColor(this);" />
288
289                                          <area shape="rect" coords="78, 5,89,16"   href="#00FF00" onclick="getfColor(this);" />
290                                          <area shape="rect" coords="78,23,89,34"   href="#C2F9C2" onclick="getfColor(this);" />
291                                          <area shape="rect" coords="78,41,89,52"   href="#008000" onclick="getfColor(this);" />
292                                          <area shape="rect" coords="78,59,89,70"   href="#2F4F4F" onclick="getfColor(this);" />
293
294                                          <area shape="rect" coords="97, 5,108,16"   href="#0000FF" onclick="getfColor(this);" />
295                                          <area shape="rect" coords="97,23,108,34"   href="#C1E3FF" onclick="getfColor(this);" />
296                                          <area shape="rect" coords="97,41,108,52"   href="#277DC4" onclick="getfColor(this);" />
297                                          <area shape="rect" coords="97,59,108,70"   href="#000068" onclick="getfColor(this);" />
298
299                                          <area shape="rect" coords="115, 5,126,16"   href="#FF00BB" onclick="getfColor(this);" />
300                                          <area shape="rect" coords="115,23,126,34"   href="#FF9ED5" onclick="getfColor(this);" />
301                                          <area shape="rect" coords="115,41,126,52"   href="#BC008A" onclick="getfColor(this);" />
302                                          <area shape="rect" coords="115,59,126,70"   href="#6B0050" onclick="getfColor(this);" />
303                                        </map>
304
305                                        <map name="bgcolor_pallete" id="bgcolor_pallete">
306                                          <area shape="rect" coords=" 5, 5,16,16"   href="#FFFFFF" onclick="getbColor(this);" />
307                                          <area shape="rect" coords=" 5,23,16,34"   href="#E0E0E0" onclick="getbColor(this);" />
308                                          <area shape="rect" coords=" 5,41,16,52"   href="#C1C1C1" onclick="getbColor(this);" />
309                                          <area shape="rect" coords=" 5,59,16,70"   href="#A8A8A8" onclick="getbColor(this);" />
310
311                                          <area shape="rect" coords="23, 5,34,16"   href="#000000" onclick="getbColor(this);" />
312                                          <area shape="rect" coords="23,23,34,34"   href="#696969" onclick="getbColor(this);" />
313                                          <area shape="rect" coords="23,41,34,52"   href="#A0A0A0" onclick="getbColor(this);" />
314                                          <area shape="rect" coords="23,59,34,70"   href="#C4C4C4" onclick="getbColor(this);" />
315
316                                          <area shape="rect" coords="41, 5,52,16"   href="#FF0000" onclick="getbColor(this);" />
317                                          <area shape="rect" coords="41,23,52,34"   href="#FFA600" onclick="getbColor(this);" />
318                                          <area shape="rect" coords="41,41,52,52"   href="#FF7800" onclick="getbColor(this);" />
319                                          <area shape="rect" coords="41,59,52,70"   href="#800000" onclick="getbColor(this);" />
320
321                                          <area shape="rect" coords="59, 5,70,16"   href="#FFFF00" onclick="getbColor(this);" />
322                                          <area shape="rect" coords="59,23,70,34"   href="#FFFF9E" onclick="getbColor(this);" />
323                                          <area shape="rect" coords="59,41,70,52"   href="#FFD700" onclick="getbColor(this);" />
324                                          <area shape="rect" coords="59,59,70,70"   href="#8B4513" onclick="getbColor(this);" />
325
326                                          <area shape="rect" coords="78, 5,89,16"   href="#00FF00" onclick="getbColor(this);" />
327                                          <area shape="rect" coords="78,23,89,34"   href="#C2F9C2" onclick="getbColor(this);" />
328                                          <area shape="rect" coords="78,41,89,52"   href="#008000" onclick="getbColor(this);" />
329                                          <area shape="rect" coords="78,59,89,70"   href="#2F4F4F" onclick="getbColor(this);" />
330
331                                          <area shape="rect" coords="97, 5,108,16"   href="#0000FF" onclick="getbColor(this);" />
332                                          <area shape="rect" coords="97,23,108,34"   href="#C1E3FF" onclick="getbColor(this);" />
333                                          <area shape="rect" coords="97,41,108,52"   href="#277DC4" onclick="getbColor(this);" />
334                                          <area shape="rect" coords="97,59,108,70"   href="#000068" onclick="getbColor(this);" />
335
336                                          <area shape="rect" coords="115, 5,126,16"   href="#FF00BB" onclick="getbColor(this);" />
337                                          <area shape="rect" coords="115,23,126,34"   href="#FF9ED5" onclick="getbColor(this);" />
338                                          <area shape="rect" coords="115,41,126,52"   href="#BC008A" onclick="getbColor(this);" />
339                                          <area shape="rect" coords="115,59,126,70"   href="#6B0050" onclick="getbColor(this);" />
340                                        </map>
341
342                              <p id="editMode"><input type="hidden" name="switchMode" id="switchBox" onchange="setDocMode(this.checked);" /> </p>
343
344                          <br /> '.NL; }
345
346
347
348                }
349                else if (trim($fields[0]) == "anchor") {
350
351                        $default_anker = date("YmdHis");
352                        if($this->getConf('soapp')>0) $link_anker = $this->getConf('act_delim').'anchor='.$default_anker; // to show only one article only on a page
353                        else $link_anker = '#'.$default_anker;  // to show all news at one page but scroll to the anchor position
354                        $default_anker = '#'.$default_anker;
355
356                        if((stripos($fields[1],'hidden') === false) && ($this->getConf('hide_anchorID')< 1)) {
357                            $output .= '<p>'.trim($fields[4]).'
358                                          <input class="news_input_'.trim($fields[0]).
359                                              '" id="news_input_'.trim($fields[0]).
360                                              '" name="news_input_'.trim($fields[0]).
361                                              '" type="'.trim($fields[1]).
362                                              '" '.trim($fields[2]).
363                                                 'value="'.$default_anker.'" title="'.trim($this->getLang(trim($fields[5]))).
364                                          '" /></p>'.NL;
365                        }
366                        else {
367                            $output .= '<input class="news_input_'.trim($fields[0]).
368                                              '" id="news_input_'.trim($fields[0]).
369                                              '" name="news_input_'.trim($fields[0]).
370                                              '" type="hidden'.
371                                              '" '.trim($fields[2]).
372                                                 'value="'.$default_anker.'" title="'.trim($this->getLang(trim($fields[5]))).
373                                          '" />'.NL;
374                        }
375                }
376                else if (trim($fields[1]) == "date") {
377                        $default_value = date("Y-m-d", strtotime($fields[3]));
378                        $output .= '<p>'.trim($fields[4]).'
379                                      <input class="news_input_'.trim($fields[0]).
380                                          '" id="news_input_'.trim($fields[0]).
381                                          '" name="news_input_'.trim($fields[0]).
382                                          '" type="'.trim($fields[1]).
383                                          '" '.trim($fields[2]).
384                                             'value="'.$default_value.'" title="'.trim($this->getLang(trim($fields[5]))).
385                                      '" /></p>'.NL;
386                }
387                else if (trim($fields[0]) == "author") {
388                        global $ID;
389                        global $conf;
390                        $current_usr = pageinfo();  //to get current user as author
391                        // real name: $current_usr['userinfo']['name']
392                        // login:     $current_usr['client']
393                        if($conf['showuseras'] == 'loginname') {
394                          $default_value = $current_usr['client'];
395                        }
396                        elseif($conf['showuseras'] == 'username') {
397                          // real name
398                          $default_value = $current_usr['userinfo']['name'];
399                        }
400                        elseif($conf['showuseras'] == 'email') {
401                          // ofuscated mail address according mailguard settings
402                          $default_value = $current_usr['userinfo']['name'];
403                        }
404                        elseif($conf['showuseras'] == 'email_link') {
405                          $default_value = $current_usr['userinfo']['name'];
406                        }
407                        else $default_value = "";
408
409                        $output .= '<p>'.trim($fields[4]).'
410                                      <input class="news_input_'.trim($fields[0]).
411                                          '" id="news_input_'.trim($fields[0]).
412                                          '" name="news_input_'.trim($fields[0]).
413                                          '" type="'.trim($fields[1]).
414                                          '" '.trim($fields[2]).
415                                           ' value="'.$default_value.'" title="'.trim($this->getLang(trim($fields[5]))).
416                                      '" /></p>'.NL;
417                }
418                else if (trim($fields[1]) == "link") {
419                        $default_value = wl($allnewsdata1).$link_anker;
420                        $output .= '<p>'.trim($fields[4]).'
421                                      <input class="news_input_'.trim($fields[0]).
422                                          '" id="news_input_'.trim($fields[0]).
423                                          '" name="news_input_'.trim($fields[0]).
424                                          '" type="'.trim($fields[1]).
425                                          '" '.trim($fields[2]).
426                                             'value="'.$default_value.'" title="'.trim($this->getLang(trim($fields[5]))).
427                                      '" /></p>'.NL;
428                }
429                else {
430                        $output .= '<p>'.trim($fields[4]).'
431                                      <input class="news_input_'.trim($fields[0]).
432                                          '" id="news_input_'.trim($fields[0]).
433                                          '" name="news_input_'.trim($fields[0]).
434                                          '" type="'.trim($fields[1]).
435                                          '" '.trim($fields[2]).
436                                             'value="'.trim($fields[3]).'" title="'.trim($this->getLang(trim($fields[5]))).
437                                      '" /></p>'.NL;
438                }
439                $id_count = $id_count + 1;
440            }
441
442            $output .= '<input class="anss_input_btn_save"
443                               type="submit"
444                               name="submit"
445                               id ="submit"
446                               value="'.$this->getLang('anss_input_btn_save').'"
447                               title="'.$this->getLang('anss_input_btn_save_descr').'" />'.NL;
448
449            if($this->getConf('wysiwyg')==true) {
450                  $output .= '<script type="text/javascript">
451                              var oDoc, sDefTxt;
452
453                              function validateMode() {
454                                oDoc = document.getElementById("'.$ansTBox_ID.'");
455                                if (document.'.$prefix.'.switchMode.checked !== true) { return true ; }
456                                alert("Uncheck \"Show HTML\".");
457                                oDoc.focus();
458                                return false;
459                              }
460
461                              function formatDoc(sCmd, sValue) {
462
463                                oDoc = document.getElementById("'.$ansTBox_ID.'");
464                                sDefTxt = oDoc.innerHTML;
465                                if (validateMode()) { document.execCommand(sCmd, false, sValue); oDoc.focus(); }
466                              }
467
468                              function makeCite()
469                              {
470                                  var html = "";
471                                  var sel, range;
472                                oDoc = document.getElementById("'.$ansTBox_ID.'");
473                                sDefTxt = oDoc.innerHTML;
474                                  if (typeof window.getSelection != "undefined") {
475                                      var sel = window.getSelection();
476                                      if (sel.rangeCount) {
477                                          var container = document.createElement("blockquote");
478                                          container.setAttribute("class", "ans_cite");
479                                          for (var i = 0, len = sel.rangeCount; i < len; ++i) {
480                                              container.appendChild(sel.getRangeAt(i).cloneContents());
481                                          }
482                                          html = container.innerHTML;
483
484                                      }
485                                  } else if (typeof document.selection != "undefined") {
486                                      if (document.selection.type == "Text") {
487                                          html = document.selection.createRange().htmlText;
488                                      }
489                                  }
490                                  range = sel.getRangeAt(0);
491                                  range.deleteContents();
492                                  var post_p = document.createElement("p")
493                                  range.insertNode(post_p);
494                                  var post_br = document.createElement("br")
495                                  range.insertNode(post_br);
496                                  range.insertNode(container);
497
498                              }
499
500                              function addTags(sCmd)
501                              { var html = "";
502                                var sel, range;
503                                oDoc = document.getElementById("'.$ansTBox_ID.'");
504                                sDefTxt = oDoc.innerHTML;
505                                  if (typeof window.getSelection != "undefined") {
506                                      var sel = window.getSelection();
507                                      if (sel.rangeCount) {
508                                          var container = document.createElement(sCmd);
509                                          for (var i = 0, len = sel.rangeCount; i < len; ++i) {
510                                              container.appendChild(sel.getRangeAt(i).cloneContents());
511                                          }
512                                          html = container.innerHTML;
513                                      }
514                                  } else if (typeof document.selection != "undefined") {
515                                      if (document.selection.type == "Text") {
516                                          html = document.selection.createRange().htmlText;
517                                      }
518                                  }
519                                  range = sel.getRangeAt(0);
520                                  range.deleteContents();
521                                  var post_p = document.createElement("p")
522                                  range.insertNode(post_p);
523                                  var post_br = document.createElement("br")
524                                  range.insertNode(post_br);
525                                  var p_container = document.createElement("p");
526                                  p_container.appendChild(container);
527                                  range.insertNode(p_container);
528                              }
529
530                              function makeCode()
531                              { var html = "";
532                                var sel, range;
533                                oDoc = document.getElementById("'.$ansTBox_ID.'");
534                                sDefTxt = oDoc.innerHTML;
535                                  if (typeof window.getSelection != "undefined") {
536                                      var sel = window.getSelection();
537                                      if (sel.rangeCount) {
538                                          var container = document.createElement("code");
539                                          for (var i = 0, len = sel.rangeCount; i < len; ++i) {
540                                              container.appendChild(sel.getRangeAt(i).cloneContents());
541                                          }
542                                          html = "<p>"+container.innerHTML+"</p>";
543                                      }
544                                  } else if (typeof document.selection != "undefined") {
545                                      if (document.selection.type == "Text") {
546                                          html = document.selection.createRange().htmlText;
547                                      }
548                                  }
549                                  range = sel.getRangeAt(0);
550                                  range.deleteContents();
551                                  var post_p = document.createElement("p")
552                                  range.insertNode(post_p);
553                                  var post_br = document.createElement("br")
554                                  range.insertNode(post_br);
555                                  var p_container = document.createElement("p");
556                                  p_container.appendChild(container);
557                                  range.insertNode(p_container);
558                              }
559
560                              function setDocMode(bToSource) {
561                                var oContent;
562                                oDoc = document.getElementById("'.$ansTBox_ID.'");
563                                sDefTxt = oDoc.innerHTML;
564                                if (bToSource) {
565                                  oContent = document.createTextNode(oDoc.innerHTML);
566                                  oDoc.innerHTML = "";
567                                  var oPre = document.createElement("pre");
568                                  oDoc.contentEditable = false;
569                                  oPre.id = "sourceText";
570                                  oPre.contentEditable = true;
571                                  oPre.appendChild(oContent);
572                                  oDoc.appendChild(oPre);
573                                } else {
574                                  if (document.all) {
575                                    oDoc.innerHTML = oDoc.innerText;
576                                  } else {
577                                    oContent = document.createRange();
578                                    oContent.selectNodeContents(oDoc.firstChild);
579                                    oDoc.innerHTML = oContent.toString();
580                                  }
581                                  oDoc.contentEditable = true;
582                                }
583                                oDoc.focus();
584                              }
585
586                              function getfColor(block)
587                              {
588                              	hp = document.getElementById("hoverpopup1");
589                              	hp.style.visibility = "Hidden";
590                                var s_url=block.href;
591                                var pColor=s_url.substr(s_url.indexOf("#"));
592                                document.execCommand(\'forecolor\',         false, pColor);
593                              }
594
595                              function getbColor(block)
596                              {
597                              	hp = document.getElementById("hoverpopup2");
598                              	hp.style.visibility = "Hidden";
599                                var s_url=block.href;
600                                var pColor=s_url.substr(s_url.indexOf("#"));
601                                document.execCommand(\'backcolor\',         false, pColor);
602
603                              }
604
605                              function ShowPopup(hoveritem, hoverpopup)
606                              {
607                                HidePopup("hoverpopup1", "hoverpopup2");
608                                hp = document.getElementById(hoverpopup);
609                              	// Set position of hover popup
610                              	hp.style.top = (document.getElementById(hoveritem).offsetTop+15) + \'px\';
611                              	hp.style.left = (document.getElementById(hoveritem).offsetLeft ) + \'px\';
612                              	// Set popup to visible
613                              	hp.style.visibility = "Visible";
614                              }
615
616                              function HidePopup(hoverpopup1, hoverpopup2)
617                              {
618                                document.getElementById("hoverpopup1").style.visibility = "Hidden";
619                                document.getElementById("hoverpopup2").style.visibility = "Hidden";
620                              }
621                              function count_chars(obj, max) {
622                                    var data = obj.innerHTML;
623                                    var extract = data.split(" ");
624                                    var bextract = data.split("\n");
625                                    var cextract = extract.length + bextract.length -1;
626                                    if(cextract>max) output = \'<span style="color:red;">\' + cextract + \'</span>\';
627                                    else output = cextract;
628                                    document.getElementById("nws_charcount").innerHTML =  "'.$this->getLang('wordcount').'"
629                                }
630
631                                function resizeBoxId(obj,size) {
632                                    var arows = document.getElementById(obj).rows;
633                                    document.getElementById(obj).rows = arows + size;
634                                }
635
636                                function myFunction() {
637                                  document.getElementById("news_input_text").value = document.getElementById("anss_textBox_text").innerHTML;
638                                }
639
640                             </script>'.NL;
641            }
642            $output .= '</form></div>';
643            // 3. check if path/file exist on save click
644            // 4. add the new post before the existing (e.g. news:newsdata.txt)
645            $renderer->doc .= $output;
646        }
647
648      /*------- show perview -------------------------------------------------*/
649        elseif (strpos($ans_conf['param'], 'flash')!== false) {
650          $info        = array();
651          $tmp         = substr($ans_conf['param'],strlen('flash')); //strip parameter to get set of add parameter
652          $prefs       = explode(',',$tmp);
653          // $prefs[0] = preview length
654          // $prefs[1] = box width
655          // $prefs[2] = float option
656          // $prefs[3] = max items
657          // $prefs[4] = tags separated by pipe
658          if(!isset($prefs[4])) $tag_flag = true;
659
660          if($prefs[0]<10) $prefs[0] = $this->getConf('prev_length');
661          $preview_length = $prefs[0];
662
663          if(! isset($prefs[1])) {
664            $prefs[1]='';
665            $item_width = '';}
666          else {
667            $a=0.5;
668            $item_width = 'style="margin-right: 10px !important;"';
669            $prefs[2] = "float: ".$prefs[2].";";
670            $prefs[1] = 'style="width: '.$prefs[1].'; '.$prefs[2].'"';}
671
672          if($prefs[3]==0) $prefs[3]=5;
673
674          $newsitems = array();
675          // this will be called to display a preview
676          $output  = '<div class="news_box" '.$prefs[1].'>';
677          if($this->getConf('newsflash_link') == false) {
678              $output .= '<div  class="news_header">'.$this->getLang('newsflash_title').'</div>'.NL;
679          }
680          else {
681              $output .= '<div  class="news_header"><a class="news_header_link" href="'. $allnewsdata .'">'.$this->getLang('newsflash_title').'</a></div>'.NL;
682          }
683          $output .= '<div class="news_list" '.$item_width.'">'.NL;
684
685          // 1. read news file (e.g. news:newsdata.txt)
686          $oldrecord = rawWiki($targetpage);
687//          $entries = explode("\n----\n\n",$oldrecord);
688          $entries = explode("======",$oldrecord);
689          foreach($entries as $entry) {
690             // split news block into line items
691             $temp_array = explode("\n  * ",$entry);
692             unset($temp_array[0]);
693             $wysiwyg = false;
694
695             // 2. create preview output
696             // split line items into key and data
697             $aFlag = false;
698             $bFlag = false;
699             foreach ($temp_array as $item) {
700                    list($key, $value) = split(":",trim($item),2);
701                    $tag_flag = false;
702
703                    if($key=='anchor') {
704                            $anchor = trim($value);
705                        }
706                    elseif(($key=='start') && strtotime(trim($value)) < time()) {
707                        $aFlag = true;
708                        $value = date($this->getConf('d_format'), strtotime($value));
709                        $news_date = '<span class="news_date"> ('. $value ;
710                    }
711                    elseif(($key=='stop') && strtotime(trim($value)) > time()) {
712                        $bFlag = true;
713                    }
714                    elseif($key=='wysiwyg'){
715                      $wysiwyg = 1;
716                    }
717                    elseif($key=='text'){
718                        if($bFlag !== true) break;
719                        // replace media links
720                        $linkx = array();
721                        $pattern = '/\{\{.*?\}\}/i';
722                        $linkx = $this->replace_links($pattern, $value, 'medi');
723
724                        // replace hyperlinks
725                        $links = array();
726                        $pattern = '/\[\[.*?\]\]/i';
727                        $links = $this->replace_links($pattern, $value, 'url');
728
729                        // shrink the output according settings
730                        //$prvw_string = substr( preg_replace ('/\<.*?\>/', ' ', $value ) , 0, $preview_length );
731                        $check = explode(' ', $value);
732                        $i=0;
733                        $prvw_string ='';
734                        foreach($check as $a) {
735                            $prvw_string .= $a.' ';
736                            $i++;
737                            if($i>$preview_length) {break;}
738                        }
739                        if(count($check)-1>$preview_length) $prvw_string .= ' ...';
740
741                        // replace placeholder
742                        $links = $this->replace_placeholder($links, $prvw_string, 'url');
743                        $linkx = $this->replace_placeholder($linkx, $prvw_string, 'medi');
744
745                        if ($wysiwyg==false) $prvw_string = p_render('xhtml',p_get_instructions($prvw_string),$info);
746                        $preview_string = '<span class="news_preview">' . $prvw_string .'</span>'. NL;
747                    }
748                    // head has to be before the link in the template !
749                    elseif($key=='head'){
750                        $news_head = $value;
751                             // add edit button to section edit the article if edit
752                             // permission is given to that current user for this ID
753                             if($current_usr["perm"]>1) {
754                                 // detect start and stop of section
755                                 $news_rawcontent = rawWiki($targetpage);
756                                 $start= stripos($news_rawcontent,$value)-5;
757                                 $tmp = explode("====== ",$news_rawcontent);
758                                 foreach($tmp as $temps) {
759                                    if(stripos($temps,$value)!==false) {
760                                        $stop = strlen($temps)+$start+6;
761                                        break;
762                                    }
763                                 }
764                                 // assemble the pieces for the button and form.
765                                 $url = wl($this->getConf('news_datafile'),'',true);
766
767                                 $ank = '<div><form class="btn_secedit"
768                                              method="post"
769                                              action="'.$url.'">
770                                                <input type="hidden" name="do" value="edit" />
771                                                <input type="hidden" name="summary" value="['.$value.'] " />
772                                                <input type="hidden" name="target" value="section" />
773                                                <input type="hidden" name="range" value="'.$start.'-'.$stop.'" />
774                                                <input class="anss_edit_img" type="image" src="'.DOKU_BASE.'lib/plugins/anewssystem/images/dot2.gif" alt="'.$this->getLang('anss_edit_imgttl').'" title="'.$this->getLang('anss_edit_imgttl').'" value="Edit" />
775                                          </form>
776                                          <span style="width:3em;">&nbsp;</span>';
777                                 // add a delete button and $POST
778                                 $ank .= '<form class="anss_delete"
779                                              method="post" >
780                                              <input type="hidden" name="anss_del_anchor" value="'.$anchor.'"/>
781                                              <input type="hidden" name="anss_del_record" value="'.$news_head.'"/>
782                                              <input class="anss_del_img" type="image" src="'.DOKU_BASE.'lib/plugins/anewssystem/images/dot.gif" alt="Del" title="'.$this->getLang('del_title').'" />
783                                          </form>
784                                          </div>';
785                             }
786                             else $ank='';
787                    }
788                    elseif($key=='link'){
789                        $prev_id++;
790                        $news_head   = '<a class="news_link" href="'.$value.'"  id="news_link'.$prev_id.'" rel="subcontent'.$prev_id.'">'. $news_head .'</a>'.NL;
791                        // generate an overlap div with Thumbshot picture if link is provided by conf
792                        if($this->getConf('convert')) {
793                            if(is_string($response)) {
794    	      		               msg($response,-1);
795    	      	              }
796                            else {
797                              list($link,$image) = $response;
798                              $anID = explode("id=",$value);
799                              if($anID[1]) $theLink = DOKU_URL.'doku.php?id='.$anID[1];
800                              else $theLink = $value;
801                              $theLink = sprintf($this->getConf('convert'), $theLink);
802                              $news_head  .= '
803                              <DIV id="subcontent'.$prev_id.'" class="news_subcontent">
804                                  <a class="news_link" href="'.$value.'" target="_blank">
805                                    <img class="news_subcontent_pic" alt="News" src="'.$theLink.'" a="">
806                                  </a><br />
807                              </DIV>'.NL;                            // anchorid,             pos,        glidetime, revealbehavior
808                              $news_head  .= '<script type="text/javascript">'.
809                                             '   dropdowncontent.init("news_link'.$prev_id.'", "left", 500, "mouseover")'.
810                                             '</script>'.NL;
811                            }
812                        }
813                    }
814                    elseif($key=='author'){
815                        $news_date .= ', '. $value;
816                    }
817                    elseif(($key=='tags') && (isset($prefs[4]) !== false)) {
818                        $tags = explode(',',$value);
819                        foreach($tags as $tag) {
820                            if(($tag!==false) && (stripos($prefs[4],trim($tag))!==false)){
821                                $tag_flag = true;
822                                break;
823                            }
824                        }
825                    }
826             }
827             if(isset($prefs[4]) == false) $tag_flag = true;
828             $news_date  .=  ')</span><br />'.NL;
829             if(($aFlag === true) && ($bFlag === true) && ($tag_flag === true)) {
830                 $output .= '<div class="prev_newsitem">'.$news_head.$news_date.$preview_string.$ank.'</div>'.NL;
831                 $item_counter = $item_counter + 1;
832                 // stop if max number of items is reached
833                 if (isset($prefs[3]) && ($item_counter == $prefs[3])) {
834                    break; }
835             }
836          }
837          if($item_counter==0)
838          {
839              $output .= '<div class="prev_newsitem">'.$this->getLang('noNews').'</div>'.NL;
840          }
841          $output        .= '</div></div>'.NL.NL;
842          $output         = '<script type="text/javascript" src="'.DOKU_URL.'lib/plugins/anewssystem/dropdowncontent.js"></script>'.$output;
843          $renderer->doc .= $output;
844        }
845        /* --- Display a cloud of News Tags --------------------------------*/
846        elseif (strpos($ans_conf['param'], 'cloud')!== false) {
847          $tmp         = substr($ans_conf['param'],strlen('cloud')); //strip parameter to get set of add parameter
848          $oldrecord   = rawWiki($targetpage);
849          $entries     = explode("======",$oldrecord);
850          // loop through configured all news page
851          foreach($entries as $entry) {
852              // split news block into line items
853              $temp_array = explode("\n  * ",$entry);
854              unset($temp_array[0]);
855              $aFlag    = false;
856              $bFlag    = false;
857              $tag_flag = false;
858
859              // if perishing date is not exceeded then collect the tags
860              foreach ($temp_array as $item) {
861                  list($key, $value) = split(":",trim($item),2);
862                  if(($key=='start') && strtotime(trim($value)) < time()) {
863                      $aFlag = true;
864                      $value = date($this->getConf('d_format'), strtotime($value));
865                      $news_date = '<span class="news_date"> ('. $value ;
866                  }
867                  elseif(($key=='stop') && strtotime(trim($value)) > time()) {
868                      $bFlag = true;
869                  }
870                  if($key=='tags') {
871                      if(($aFlag !== true) || ($bFlag !== true)) break;
872                      $aFlag = false;
873                      $bFlag = false;
874                      $tags  = explode(',',$value);
875                      if(count($tags) >0 ) {
876                          foreach($tags as $tag) {
877                              $tags_result[$tag]++;
878                          }
879                          break;
880                      }
881                  }
882              }
883          }
884
885          // evaluate the styling parameters
886          $tokens = preg_split('/\s+/', $tmp,-1, PREG_SPLIT_NO_EMPTY);
887          $div_class = 'newsclouddiv';
888          foreach ($tokens as $token) {
889
890              if (preg_match('/^\d*\.?\d+(%|px|em|ex|pt|cm|mm|pi|in)$/', $token)) {
891                $styles .= ' width: '.$token.';';
892                continue;
893              }
894              if (preg_match('/^(
895                  (\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}))|        #color value
896                  (rgb\(([0-9]{1,3}%?,){2}[0-9]{1,3}%?\))     #rgb triplet
897                  )$/x', $token)) {
898                $styles .= ' background-color: '.$token.';';
899                continue;
900              }
901              if((stripos($token,'tleft')    !== false) ||
902                 (stripos($token,'tright')   !== false) ||
903                 (stripos($token,'tcenter')  !== false) ||
904                 (stripos($token,'tjustify') !== false) ||
905                 (stripos($token,'tinherit') !== false)) {
906                $styles .= ' text-align: '.substr(trim($token),1).';';
907                //style the tabs properly
908                if(stripos($token,'tright')!== false) {
909                  $tab_right = "";
910                  $tab_left = DOKU_TAB;
911                }
912                else {
913                  $tab_right = "";
914                  $tab_left = DOKU_TAB;
915                }
916                continue;
917              }
918              if((stripos($token,'fleft')    !== false) ||
919                 (stripos($token,'fright')   !== false) ||
920                 (stripos($token,'fnone')    !== false) ||
921                 (stripos($token,'finherit') !== false)) {
922                $styles .= ' float: '.substr(trim($token),1).';';
923                continue;
924              }
925              if((stripos($token,'uppercase')  !== false) ||
926                 (stripos($token,'capitalize') !== false) ||
927                 (stripos($token,'lowercase')  !== false)) {
928                $styles .= ' text-transform: '.$token.';';
929                continue;
930              }
931              if(stripos($token,'newsclouddiv')    !== false) {
932                $div_class = $token;
933                continue;
934              }
935          }
936          // output the tags as links
937          $output  = '<div class="'.$div_class.'" style="'.$styles.'">'.NL;
938          // loop through the tags array and evaluate the size per tag
939          $min = 1000;
940          $max = 1;
941
942          if(count($tags_result)<1) $output.='<span>no tags found</span>';
943          else {
944              foreach($tags_result as $tag => $val) {
945                  $min = min($val,$min);
946                  $max = max($val,$max);
947              }
948              $delta = ($max-$min)/16;
949              foreach($tags_result as $tag => $val) {
950                  if ($val < $min+round($delta)) $class = 'newscloud1';
951                  elseif ($val < $min+round(2*$delta)) $class = 'newscloud2';
952                  elseif ($val < $min+round(4*$delta)) $class = 'newscloud3';
953                  elseif ($val < $min+round(8*$delta)) $class = 'newscloud4';
954                  else $class = 'newscloud5';
955                  $output .= $tab_left.'<a href="'.DOKU_URL.'doku.php?id='.$this->getConf('news_output').$this->getConf('act_delim').'tag='.trim($tag).'" class="' . $class .'"title="'.$val.'">'.$tag.'</a>'.$tab_right.NL;
956              }
957          }
958          $output .= '</div>'.NL;
959          $renderer->doc .= $output;
960        }
961        /* --- Show all news -------------------------------------------------*/
962        elseif ((strpos($ans_conf['param'], 'allnews')!== false)) {
963          // check if page ID was called with tag filter
964          $tmp         = ','.$_GET['tag'];    // this will overrule the page syntax setting
965          $info        = array();
966          if(strlen($tmp)<2) {
967              // strip parameter to get set of add parameter
968              // there exist either 'tag' or 'anchor', never both at the same time
969              $tmp     = substr($ans_conf['param'],strlen('allnews'));
970          }
971          $prefs           = explode(',',$tmp); // one or multiple tag filters: $prefs[1] ... [n]
972          // $prefs[0] = preview length
973          // $prefs[1] = not used but comme must be existing to delim further params
974          // $prefs[2] = not used but comme must be existing to delim further params
975          // $prefs[3] = max items
976          // $prefs[4] = tags separated by pipe
977          if($prefs[0]<10) $prefs[0] = $this->getConf('prev_length');
978          $preview_length = $prefs[0];
979
980          $prefs['anchor'] = $_GET['anchor'];   // this will overrule the page syntax setting to
981                                                // show just the one article instead all of them
982
983          // necessary for the back link of a show one article per page (SOAPP)
984//          if($_GET['archive']=='archive') $ans_conf['param'] = 'archive';
985
986          $newsitems   = array();
987          // this will be called to display all news articles
988          $page = wl( (isset($targetpage) ? $targetpage : 'news:newsdata') );
989          $output = '<div class="allnews_box">'.NL;
990          // 1. read news file (e.g. news:newsdata.txt)
991          $oldrecord = rawWiki($targetpage);
992          $entries = explode("======",$oldrecord);
993          $info = array();
994          $yh_level = $this->getConf('yh_level');
995          $mh_level = $this->getConf('mh_level');
996          $h_level = $this->getConf('h_level');
997
998          foreach($entries as $entry) {
999             // split news block into line items
1000             $temp_array = explode("\n  * ",$entry);
1001             unset($temp_array[0]);
1002             $wysiwyg = false;
1003
1004             // 2. create output
1005             // split line items into key and data
1006             $aFlag = false;
1007             $bFlag = false;
1008
1009                 foreach ($temp_array as $item) {
1010                        list($key, $value) = split(":",trim($item),2);
1011                        $tag_flag = false;
1012                        if($key=='anchor') {
1013                            $anchor = trim($value);
1014                        }
1015                        elseif(($key=='start') && strtotime(trim($value)) < time()) {
1016                            $aFlag = true;
1017                            $value = date($this->getConf('d_format'), strtotime($value));
1018/*                            if (strpos($ans_conf['param'], 'archive')!== false) {
1019                                 $news_date = '<span class="news_date_a"> ('. $value;
1020                            }
1021                            else */$news_date = '<span class="news_date"> ('. $value ;
1022                        }
1023                        elseif(($key=='stop') && strtotime(trim($value)) > time()) {
1024                            $bFlag = true;
1025                        }
1026                        elseif($key=='wysiwyg'){
1027                          $wysiwyg = 1;
1028                        }
1029                        elseif($key=='text'){
1030                            // replace media links
1031                            $linkx = array();
1032                            $pattern = '/\{\{.*?\}\}/i';
1033                            $linkx = $this->replace_links($pattern, $value, 'medi');
1034
1035                            // replace hyperlinks
1036                            $links = array();
1037                            $pattern = '/\[\[.*?\]\]/i';
1038                            $links = $this->replace_links($pattern, $value, 'url');
1039
1040                            if(isset($prefs['anchor'])!==true) {
1041                                // shrink the output according settings
1042                                //$prvw_string = substr( preg_replace ('/\<.*?\>/', ' ', $value ) , 0, $preview_length );
1043                                $check = explode(' ', $value);
1044                                $i=0;
1045                                $prvw_string ='';
1046                                foreach($check as $a) {
1047                                    $prvw_string .= $a.' ';
1048                                    $i++;
1049                                    if($i>$preview_length) {break;}
1050                                }
1051                                if(count($check)-1>$preview_length) $prvw_string .= ' ...';
1052                            }
1053                            else {
1054                              $prvw_string = $value;
1055                            }
1056                            // replace placeholder
1057                            $links = $this->replace_placeholder($links, $prvw_string, 'url');
1058                            $linkx = $this->replace_placeholder($linkx, $prvw_string, 'medi');
1059
1060                            if ($wysiwyg==false) $prvw_string = p_render('xhtml',p_get_instructions($prvw_string),$info);
1061                            $preview_string = '<span class="news_preview">' . $prvw_string .'</span>'. NL;
1062                        }
1063                        // head has to be before the link in the template !
1064                        elseif($key=='head'){
1065                             $news_head = trim($value);
1066                             // add edit button to section edit the article if edit
1067                             // permission is given to that current user for this ID
1068                             if($current_usr["perm"]>1) {
1069                                 // detect start and stop of section
1070                                 $news_rawcontent = rawWiki($targetpage);
1071                                 $start= stripos($news_rawcontent,$value)-5;
1072                                 $tmp = explode("====== ",$news_rawcontent);
1073                                 foreach($tmp as $temps) {
1074                                    if(stripos($temps,$value)!==false) {
1075                                        $stop = strlen($temps)+$start+6;
1076                                        break;
1077                                    }
1078                                 }
1079                                 // assemble the pieces for the button and form.
1080                                 $url = wl($this->getConf('news_datafile'),'',true);
1081                                 $ank = '<div><form class="btn_secedit"
1082                                              method="post"
1083                                              action="'.$url.'">
1084                                                <input type="hidden" name="do" value="edit" />
1085                                                <input type="hidden" name="summary" value="['.$value.'] " />
1086                                                <input type="hidden" name="target" value="section" />
1087                                                <input type="hidden" name="range" value="'.$start.'-'.$stop.'" />
1088                                                <input class="anss_edit_img" type="image" src="'.DOKU_BASE.'lib/plugins/anewssystem/images/dot2.gif" alt="'.$this->getLang('anss_edit_imgttl').'" title="'.$this->getLang('anss_edit_imgttl').'" value="Edit" />
1089                                          </form>
1090                                          <span style="width:3em;">&nbsp;</span>';
1091                                 // add a delete button and $POST
1092                                 $ank .= '<form class="anss_delete"
1093                                              method="post" >
1094                                              <input type="hidden" name="anss_del_anchor" value="'.$anchor.'"/>
1095                                              <input type="hidden" name="anss_del_record" value="'.$news_head.'"/>
1096                                              <input class="anss_del_img" type="image" src="'.DOKU_BASE.'lib/plugins/anewssystem/images/dot.gif" alt="Del" title="'.$this->getLang('del_title').'" />
1097                                          </form>
1098                                          </div>';
1099                             }
1100                             else $ank='';
1101                        }
1102                        elseif($key=='subtitle'){
1103                             $news_subtitle = '<br /><span class="news_subtitle">'.trim($value).'</span>'.NL;
1104                        }
1105                        elseif($key=='link'){
1106                            $news_head = '<a href="'.$value.'" id="'.$value.'" name="'.$value.'">'. $news_head .'</a>'.NL;
1107                        }
1108
1109                        elseif($key=='author'){
1110                            $news_date .= ', '. $value;
1111                        }
1112                        elseif(($key=='tags') && (isset($prefs[1]) !== false)) {
1113                            $tags = explode(',',$value);
1114                            foreach($tags as $tag) {
1115                                if(($tag!==false) && (stripos($prefs[1],trim($tag))!==false)){
1116                                    $tag_flag = true;
1117                                    break;
1118                                }
1119                            }
1120                        }
1121                 }
1122
1123                 $news_date .=  ')</span>'.NL;
1124
1125                 // prevent output of date and author of ho parameter is given as off
1126                 if ((strpos($ans_conf['param'], 'ho=off')!== false)) { $news_date =''; }
1127
1128                 if((isset($prefs[1]) === false) || (strlen($prefs[1]) <2)) $tag_flag = true;
1129
1130                 if(($aFlag === true) && ($bFlag === true) && ($tag_flag === true)) {
1131                     $output .= '<div>'.NL.'<h'.$h_level.'>'.$news_head.$news_date.$news_subtitle.'</h'.$h_level.'>'.NL.$preview_string.NL.$ank.NL.'</div>'.NL;
1132                     $item_counter++;
1133                 }
1134                 elseif(isset($prefs['anchor'])===true) {
1135                      // show the single article independently if it is current or outdated
1136                      $output .= '<div>'.NL.'<h'.$h_level.'>'.$news_head.$news_date.$news_subtitle.'</h'.$h_level.'>'.NL.$preview_string.NL.$ank.NL.'</div>'.NL;
1137                 }
1138                 $news_subtitle='';
1139                // --- just ouput only the linked article on the page ----------
1140                $archive_lnkTitle = $this->getConf('lnk_newsarchive');
1141                if($archive_lnkTitle=='') $archive_lnkTitle = "News Archive";
1142                if((strlen($anchor)>2) && (isset($prefs['anchor'])!==false)) {
1143                  if(stripos($anchor,$prefs['anchor']) !== false) {
1144        $backlink = '<a href="javascript:history.back(-1)">'.$this->getLang('lnk_back').'</a>';
1145        $backlink .= '<span class="anss_sep"> &nbsp;|&nbsp;</span>
1146                      <a href="'.DOKU_URL.'doku.php?id='.$this->getConf('news_output').'">'.$this->getLang('allnews').'</a>';
1147                      $output = '<div style="font-size:.85em;">'.$backlink.NL.
1148                                '<span class="anss_sep">&nbsp;|&nbsp;</span><a class"wikilink" href="'.wl($ID).$this->getConf('act_delim').'archive=archive">'.$archive_lnkTitle.'</a></div><br />'.NL.
1149                                '<div class="archive_section" id="news_archive_head"  style="'.$archive_options['style'].'">'.
1150                                  $output.
1151                                '<div style="font-size:.85em;">'.$backlink.NL.
1152                                '<span class="anss_sep">&nbsp;|&nbsp;</span><a class"wikilink" href="'.wl($ID).$this->getConf('act_delim').'archive=archive">'.$archive_lnkTitle.'</a></div><br />'.NL;
1153                      break;  // due to the single linked article is loaded into $output
1154                  }
1155                }
1156                if(isset($prefs['anchor']) === true) {
1157                   $output = '';  // to strip away all other articles
1158                }
1159          }
1160
1161          if($item_counter==0)
1162          {
1163              $output .= '<span>'.$this->getLang('noNews').'</span>'.NL;
1164          }
1165          $output .= '</div><div style="clear: both;"></div>'.NL.NL;
1166          $renderer->doc .= $output;
1167        }
1168/* --- Show archive ----------------------------------------------------------*/
1169        elseif ((strpos($ans_conf['param'], 'archive')!== false)) {
1170          // date    ... consider all news of a defined month of a year (mm.yyyy, empty per default)
1171          // qty     ... limits the number of news headlines starting with most recent (either integer or all, default:all)
1172          // tag     ... consider all news where news article owns the given tag string (empty per default) tag delimiter is "|"
1173          // style   ... css style string as used in HTML (except quotation marks) for the outer element div
1174          // class   ... css style for usecase toc, page or box
1175          // ho      ... headlinesonly will list the news headlines without timestamp and author (on/off, default: off)
1176          // p_signs ... number of previewed signs of the article
1177          // cws     ... define if less simple styling to be kept (or none if the parameter is missing)
1178
1179          // check if page ID was called with tag filter
1180//          $tmp         .= ','.$_GET['tag'];    // this will overrule the page syntax setting
1181          if(strlen($tmp)<2) {
1182              // strip parameter to get set of add parameter
1183              $tmp     = substr($ans_conf['param'],strlen('allnews'));
1184          }
1185          $split_array = explode(',',$tmp); // one or multiple tag filters: $prefs[1] ... [n]
1186          $archive_options = array();
1187
1188          // split parameter into array with key and data
1189          foreach ($split_array as $item) {
1190            list($key, $value) = split("=",trim($item),2);
1191            $archive_options = $archive_options + array($key => $value);
1192          }
1193//          echo $archive_options['tag'].'<br />';
1194          if(($archive_options['qty']=='') || ($archive_options['qty']<1)) $archive_options['qty']   = 'all';
1195          if(array_key_exists('class',$archive_options) === false)         $archive_options['class'] = 'page';
1196          if(array_key_exists('ho',$archive_options) === false)            $archive_options['ho']    = 'off';
1197          $page        = wl( (isset($targetpage) ? $targetpage : 'news:newsdata') );
1198
1199          // load raw news file (e.g. news:newsdata.txt)
1200          $oldrecord = rawWiki($targetpage);
1201
1202          // split the news articles
1203          $newsitems = explode("======",$oldrecord);
1204          $info = array();
1205
1206          // get the headline level from config
1207          $yh_level = $this->getConf('yh_level');
1208          $mh_level = $this->getConf('mh_level');
1209          $h_level = $this->getConf('h_level');
1210
1211          // 1. read news file (e.g. news:newsdata.txt)
1212          foreach($newsitems as $article) {
1213             // split news block into line items
1214             $article_array = explode("\n  * ",$article);
1215             unset($article_array[0]);
1216
1217             // 2. create output
1218             // split line items into key and data
1219             $aFlag = false;   // flag: start date value exists and start is not in future
1220
1221                 foreach ($article_array as $item) {
1222                        list($key, $value) = split(":",trim($item),2);
1223                        $tag_flag = false;
1224                        if($key=='anchor') {
1225                            $anchor = trim($value);
1226                        }
1227                        elseif(($key=='start') && strtotime(trim($value)) < time()) {
1228                            $value = date($this->getConf('d_format'), strtotime($value));
1229                            $news_date = '<span class="news_date_a"> ('. $value;
1230                            // get month and year to compare with $archive_options['date']
1231                            if(isset($archive_options['date']) && ($archive_options['date'] !== date('m.Y',strtotime($value)))) break;
1232                            $aFlag = true;
1233                        }
1234                        // head has to be before the link in the template !
1235                        elseif($key=='head'){
1236                             $news_head = trim($value);
1237                        }
1238                        elseif($key=='subtitle'){
1239                             $news_subtitle = '<br /><span class="news_subtitle">'.trim($value).'</span>'.NL;
1240                        }
1241                        elseif($key=='link'){
1242                            $news_head = '<a href="'.$value.'" id="'.$value.'" name="'.$value.'">'. trim($news_head) .'</a>'.NL;
1243                        }
1244                        elseif($key=='wysiwyg'){
1245                            $news_wysiwyg = $value;
1246                        }
1247                        elseif($key=='text'){
1248                            $news_content = $value;
1249                        }
1250                        elseif($key=='author'){
1251                            $news_date .= ', '. $value;
1252                        }
1253                        elseif(($key=='tags') && (isset($archive_options['tag']) !== false)) {
1254                            $tags = explode(',',$value);
1255                            foreach($tags as $tag) {
1256                                if(($tag!==false) && (stripos($archive_options['tag'],trim($tag))!==false)){
1257                                    $tag_flag = true;
1258                                    break;
1259                                }
1260                            }
1261                        }
1262                 }
1263
1264                 $news_date .=  ')</span>'.NL;
1265
1266                 if((isset($archive_options['tag']) === false) || (strlen($archive_options['tag']) <2)) $tag_flag = true;
1267
1268                 if (($aFlag === true) && ($tag_flag === true)) {
1269                    //stop adding older news articles if quantity is reached
1270                    $qty++;
1271                    if(($qty > intval($archive_options['qty'])) && ($archive_options['qty']!=='all')) break;
1272
1273                    // list all news stories as headline linked to the story itself
1274                    $elt = explode(",",$news_date);
1275                    $elt[0] = trim(strip_tags(str_replace('(','',$elt[0])));
1276                    $elt[0] = date('F,Y',strtotime($elt[0]));
1277                    list($new_month,$new_year) = explode(',',$elt[0]);
1278
1279                    // idea is that all stories are created one after the other
1280                    // and the order within newsdata is according the start date
1281                    // manipulation of Start/Perishing date possible but not expected
1282                    // !!! There is no sort algorithm for year and month implemented !!!
1283                    // to do such would lead into re-development of the plugin
1284                    if(($old_year  !== $new_year) && (($archive_options['class']==='page') || ($archive_options['ho']==='off')))  {
1285                      if(trim($old_year) !== '') $close_ytag = "</li></ul>".NL;
1286                      $output .= $close_ytag.'<ul><li class="level1"><div class="li">'.$new_year.'</div><ul class="n_box">';
1287                      $old_year  = $new_year;
1288                    }
1289
1290                    if(($old_month  !== $new_month) && (($archive_options['class']==='page') || ($archive_options['ho']==='off'))) {
1291                      if(trim($old_month) !== '') $close_mtag = "</li></ul>".NL;
1292                      $output .= $close_mtag.'<ul><li class="level2"><div class="li">'.$new_month.'</div>';
1293                      $old_month = $new_month;
1294                    }
1295
1296                    if($archive_options['ho']==='on') $news_date='';
1297                    else $news_date .= '<br />';
1298
1299                    if (($archive_options['p_signs'] !== false) && ((int)$archive_options['p_signs'] >2)) {
1300                        if ((int)$news_wysiwyg==false) $news_content = p_render('xhtml',p_get_instructions($news_content),$info);
1301                        // cws   ...   content with style syntax parameter
1302                        // strip all HTML-tags except a few selected
1303                        if ($archive_options['cws'] == false) $news_content = strip_tags($news_content, '<br>');
1304                        elseif ((int)$archive_options['cws'] <2 && ($archive_options['cws'] !== false)) $news_content = strip_tags($news_content, '<br><font><strong><a><u><ul><b><i>');
1305
1306                        $news_content = "<br>".'<span class="news_preview">' . trim(substr($news_content,0,(int)$archive_options['p_signs'])).' ...</span>'.NL;
1307                    }
1308                    else $news_content="";
1309
1310                    if(($archive_options['tag']!==false) && ($archive_options['tag']!=='off') && ($archive_options['class']=='page')) $output .= '<div class="archive_item">'.trim($news_date).$news_head.$news_subtitle.$news_content.'</div>'.NL;
1311                    else $output .= '<ul><li class="level3"><div class="li">'.trim($news_date).$news_head.$news_content.'</div></li></ul>'.NL;
1312
1313                    $close_ytag    = "";
1314                    $close_mtag    = "";
1315                    $anchor        = "";
1316                    $news_date     = "";
1317                    $news_head     = "";
1318                    $news_subtitle = "";
1319                    $news_wysiwyg  = false;
1320                    $news_content  = "";
1321                    $tags          = "";
1322                }
1323          }
1324          $blink_id = "news_items";
1325          $img_ID   = "img_archive__toc";
1326
1327          if($archive_options['class']=='toc') {
1328              $output = '<script type="text/javascript">
1329                             function archive__toc_open(toggle_id, img_ID)
1330                              {   if (document.getElementById(toggle_id).style.display == "none")
1331                                  {   document.getElementById(toggle_id).style.display = "block";
1332                                      document.getElementById(img_ID).style.backgroundPosition = "0px 0px";
1333                                  }
1334                                  else
1335                                  {   document.getElementById(toggle_id).style.display = "none";
1336                                      document.getElementById(img_ID).style.backgroundPosition = "0px -5px";
1337                                  }
1338                              }
1339                         </script>
1340                         <div class="archive_box" id="archive__toc"  style="'.$archive_options['style'].'">
1341                            <h3 class="toggle open" style="cursor: pointer;" onClick="archive__toc_open(\''.$blink_id.'\',\''.$img_ID.'\')">
1342                              <strong id="img_archive__toc"></strong>
1343                              NEWS
1344                            </h3>
1345                             <div id="news_items">
1346                                 <div style="text-align:left;">
1347                                 <ul class="n_box">'.$output.'</ul>
1348                                 </div
1349                                 <hr />
1350                                 <div style="text-align:right;font-size:.85em; border-top: 1px dotted #828282;">
1351                                    <a href="'.$news_root.':allnewsdata'.$this->getConf('act_delim').'do=shownewsarchive">&raquo; News Archive</a>
1352                                 </div>
1353                             </div>
1354                          </div>'.NL.NL;
1355          }
1356          elseif($archive_options['class']=='box') {
1357
1358              $output  = '<div class="archive_box" id="archive__box" style="'.$archive_options['style'].'">
1359                            <div id="news_items">
1360                                <ul class="n_box">'.$output.'</ul>
1361                             </div>
1362                         </div>'.NL;
1363          }
1364          $renderer->doc .= $output;
1365        }
1366
1367// --- faulty syntax ----------------------------------------------------------
1368        else {
1369          $renderer->doc .= msg('Syntax of anewssystem plugin detected but unknown parameter  ['.$ans_conf['param'].'] was provided.', -1);
1370        }
1371    }
1372//---------------------------------------------------------------------------------------
1373    // flatten the hierarchical arry to store path + file at first "column"
1374    function array_flat($array) {
1375        $out=array();
1376        foreach($array as $k=>$v){
1377            if(is_array($array[$k]))  { $out=array_merge($out,$this->array_flat($array[$k])); }
1378            else  { $out[]=$v; }
1379        }
1380        return $out;
1381    }
1382//---------------------------------------------------------------------------------------
1383    function replace_links($pattern, &$value, $r_string) {
1384        // check for links and replace them by placeholder
1385        preg_match_all($pattern, $value, $links);
1386        $in=0;
1387        foreach($links[0] as $link) {
1388            $in++;
1389            $value = str_replace($link,$r_string.$in,$value);
1390        }
1391        return $links;
1392
1393    }
1394//---------------------------------------------------------------------------------------
1395    function replace_placeholder($links, &$prvw_string, $r_string) {
1396        $in=0;
1397        foreach($links[0] as $link) {
1398            $in++;
1399            $prvw_string = str_replace($r_string.$in,$link,$prvw_string);
1400        }
1401        return $links;
1402    }
1403
1404/******************************************************************************/
1405/* return html-code for news edit toolbar                                     */
1406    function news_edit_toolbar($type) {
1407        $imgBASE = DOKU_BASE."lib/plugins/anewssystem/images/toolbar/";
1408        $news_edit_tb .= '<script type="text/javascript">
1409          function doHLine(tag1,obj)
1410          { textarea = document.getElementById(obj);
1411          	if (document.selection)
1412          	{     // Code for IE
1413          				textarea.focus();
1414          				var sel = document.selection.createRange();
1415          				sel.text = "\n" + tag1 + "\n" + "\n" + sel.text;
1416          	}
1417            else
1418            {   // Code for Mozilla Firefox
1419             		var len = textarea.value.length;
1420             	  var start = textarea.selectionStart;
1421             		var end = textarea.selectionEnd;
1422
1423             		var scrollTop = textarea.scrollTop;
1424             		var scrollLeft = textarea.scrollLeft;
1425
1426                var sel = textarea.value.substring(start, end);
1427         		    var rep = tag1 + sel;
1428                textarea.value =  textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
1429
1430             		textarea.scrollTop = scrollTop;
1431             		textarea.scrollLeft = scrollLeft;
1432          	}
1433          }'.
1434
1435         'function doAddTags(tag1,tag2,obj)
1436          { textarea = document.getElementById(obj);
1437          	// Code for IE
1438          	if (document.selection)
1439          			{ textarea.focus();
1440          				var sel = document.selection.createRange();
1441                  if (sel.text == "") sel.text = " ";
1442          				sel.text = tag1 + sel.text + tag2;
1443          			}
1444             else
1445              {  // Code for Mozilla Firefox
1446          		  var len = textarea.value.length;
1447          	    var start = textarea.selectionStart;
1448          		  var end = textarea.selectionEnd;
1449
1450          		  var scrollTop = textarea.scrollTop;
1451          		  var scrollLeft = textarea.scrollLeft;
1452
1453                var sel = textarea.value.substring(start, end);
1454          		  if (start == end) { sel = " "; }
1455                var rep = tag1 + sel + tag2;
1456                textarea.value =  textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
1457
1458          		  textarea.scrollTop = scrollTop;
1459          		  textarea.scrollLeft = scrollLeft;
1460          	}
1461          }'.
1462
1463         'function doTT(obj)
1464          { textarea = document.getElementById(obj);
1465          	// Code for IE
1466          	if (document.selection)
1467          			{ textarea.focus();
1468          				var sel = document.selection.createRange();
1469                  if (sel.text == "") sel.text = " ";
1470          				sel.text = "\'\'" + sel.text + "\'\'";
1471          			}
1472             else
1473              {  // Code for Mozilla Firefox
1474          		  var len = textarea.value.length;
1475          	    var start = textarea.selectionStart;
1476          		  var end = textarea.selectionEnd;
1477
1478          		  var scrollTop = textarea.scrollTop;
1479          		  var scrollLeft = textarea.scrollLeft;
1480
1481                var sel = textarea.value.substring(start, end);
1482                if (start == end) { sel = " "; }
1483          		  var rep = "\'\'" + sel + "\'\'";
1484                textarea.value =  textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
1485
1486          		  textarea.scrollTop = scrollTop;
1487          		  textarea.scrollLeft = scrollLeft;
1488          	}
1489          }'.
1490
1491          'function doList(tag1,obj)
1492          {
1493              textarea = document.getElementById(obj);
1494
1495          		if (document.selection)
1496          			{ // Code for IE
1497          				textarea.focus();
1498          				var sel = document.selection.createRange();
1499          				var list = sel.text.split("\n");
1500
1501          				for(i=0;i<list.length;i++)
1502          				{ list[i] = tag1 + list[i]; }
1503          				sel.text = "\n" + list.join("\n") + "\n";
1504          			}
1505              else
1506          			{ // Code for Firefox
1507          		    var len = textarea.value.length;
1508          	      var start = textarea.selectionStart;
1509          		    var end = textarea.selectionEnd;
1510          		    var i;
1511
1512          		    var scrollTop = textarea.scrollTop;
1513          		    var scrollLeft = textarea.scrollLeft;
1514
1515                  var sel = textarea.value.substring(start, end);
1516          		    var list = sel.split("\n");
1517
1518              		for(i=0;i<list.length;i++)
1519          				{ list[i] = tag1 + list[i]; }
1520
1521              		var rep = "\n" + list.join("\n") + "\n";
1522              		textarea.value =  textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
1523
1524              		textarea.scrollTop = scrollTop;
1525              		textarea.scrollLeft = scrollLeft;
1526              }
1527          }
1528
1529          function count_chars(obj, max) {
1530                var data = obj.innerHTML;
1531                var extract = data.split(" ");
1532                var bextract = data.split("\n");
1533                var cextract = extract.length + bextract.length -1;
1534                if(cextract>max) output = \'<span style="color:red;">\' + cextract + \'</span>\';
1535                else output = cextract;
1536                document.getElementById("nws_charcount").innerHTML =  "'.$this->getLang('wordcount').'"
1537            }
1538
1539         </script>';
1540        $news_edit_tb .= '<div class="news_edittoolbar">'.NL;
1541      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."bold.png\"      name=\"btnBold\"          title=\"Bold [b]\"             accesskey=\"b\" onClick=\"doAddTags('**','**','$type')\">".NL;
1542        $news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."italic.png\"    name=\"btnItalic\"        title=\"Italic [i]\"           accesskey=\"i\" onClick=\"doAddTags('//','//','$type')\">".NL;
1543      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."underline.png\" name=\"btnUnderline\"     title=\"Underline [u]\"        accesskey=\"u\" onClick=\"doAddTags('__','__','$type')\">".NL;
1544      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."mono.png\"      name=\"btnMono\"          title=\"mono-spaced font [m]\" accesskey=\"m\" onClick=\"doTT('$type')\">".NL;
1545      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."strike.png\"    name=\"btnStrike\"        title=\"Strike through [d]\"   accesskey=\"d\" onClick=\"doAddTags('<del>','</del>','$type')\">".NL;
1546      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."subscript.png\" name=\"btnSubscript\"     title=\"Subscript\"                            onClick=\"doAddTags('<sub>','</sub>','$type')\">".NL;
1547      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."superscript.png\" name=\"btnSuperscript\" title=\"Superscript\"                          onClick=\"doAddTags('<sup>','</sup>','$type')\">".NL;
1548      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."linkextern.png\" name=\"btnLink_extern\"  title=\"external Link [l]\"    accesskey=\"l\" onClick=\"doAddTags('[[',']]','$type')\">".NL;
1549      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."hr.png\"        name=\"btnLine\"          title=\"Horizontal ruler [r]\" accesskey=\"r\" onClick=\"doHLine('----','$type')\">".NL;
1550      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."ol.png\"        name=\"btn_o_List\"       title=\"Ordered List [-]\"     accesskey=\"-\" onClick=\"doList('  - ','$type')\">".NL;
1551      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."ul.png\"        name=\"btn_u_List\"       title=\"Unordered List [*]\"   accesskey=\"*\" onClick=\"doList('  * ','$type')\">".NL;
1552//      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."h1.png\"        name=\"btn_u_List\"       title=\"Headline Level 1 (Page Title) [1]\" accesskey=\"1\" onClick=\"doAddTags('======','======','$type')\">".NL;
1553      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."h2.png\"        name=\"btn_u_List\"       title=\"Headline Level 2 [2]\" accesskey=\"2\" onClick=\"doAddTags('=====','=====','$type')\">".NL;
1554      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."h3.png\"        name=\"btn_u_List\"       title=\"Headline Level 3 [3]\" accesskey=\"3\" onClick=\"doAddTags('====','====','$type')\">".NL;
1555      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."h4.png\"        name=\"btn_u_List\"       title=\"Headline Level 4 [4]\" accesskey=\"4\" onClick=\"doAddTags('===','===','$type')\">".NL;
1556      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."h5.png\"        name=\"btn_u_List\"       title=\"Headline Level 5 [5]\" accesskey=\"5\" onClick=\"doAddTags('==','==','$type')\">".NL;
1557      	$news_edit_tb .= "<img class=\"newsedit_button\" src=\"".$imgBASE."code.png\"      name=\"btnCode\"          title=\"Code block [c]\"       accesskey=\"c\" onClick=\"doAddTags('<code>','</code>','$type')\">".NL;
1558        $news_edit_tb .= "<br></div>".NL;
1559        return $news_edit_tb;
1560    }
1561}
1562?>