xref: /plugin/nodetailsxhtml/renderer.php (revision f350675f54d86cb0d6fcc9d5c32cb594b11b7a5d)
1b07cf47aSGerry Weißbach<?php
2b07cf47aSGerry Weißbach/**
3b07cf47aSGerry Weißbach * Render Plugin for XHTML  without details link for internal images.
4b07cf47aSGerry Weißbach *
5b07cf47aSGerry Weißbach * @author i-net software <tools@inetsoftware.de>
6b07cf47aSGerry Weißbach */
7b07cf47aSGerry Weißbach
8b07cf47aSGerry Weißbachif(!defined('DOKU_INC')) die();
9b07cf47aSGerry Weißbachif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
10b07cf47aSGerry Weißbach
11b07cf47aSGerry Weißbachrequire_once DOKU_INC . 'inc/parser/xhtml.php';
12b07cf47aSGerry Weißbach
13b07cf47aSGerry Weißbach/**
14b07cf47aSGerry Weißbach * The Renderer
15b07cf47aSGerry Weißbach */
16b07cf47aSGerry Weißbachclass renderer_plugin_nodetailsxhtml extends Doku_Renderer_xhtml {
17b07cf47aSGerry Weißbach
18b07cf47aSGerry Weißbach    var $acronymsExchanged = null;
19b07cf47aSGerry Weißbach    var $hasSeenHeader = false;
20b07cf47aSGerry Weißbach    var $scriptmode = false;
21b07cf47aSGerry Weißbach
22b07cf47aSGerry Weißbach    var $startlevel = 0; // level to start with numbered headings (default = 2)
23b07cf47aSGerry Weißbach    var $levels = array( '======'=>1,
24b07cf47aSGerry Weißbach                         '====='=>2,
25b07cf47aSGerry Weißbach                         '===='=>3,
26b07cf47aSGerry Weißbach                         '==='=>4,
27b07cf47aSGerry Weißbach                         '=='=>5);
28b07cf47aSGerry Weißbach
29b07cf47aSGerry Weißbach    var $info = array(
30b07cf47aSGerry Weißbach        'cache'      => true, // may the rendered result cached?
31b07cf47aSGerry Weißbach        'toc'        => true, // render the TOC?
32b07cf47aSGerry Weißbach        'forceTOC'   => false, // shall I force the TOC?
33b07cf47aSGerry Weißbach        'scriptmode' => false, // In scriptmode, some tags will not be encoded => '<%', '%>'
34b07cf47aSGerry Weißbach    );
35b07cf47aSGerry Weißbach
36b07cf47aSGerry Weißbach    var $headingCount =
37b07cf47aSGerry Weißbach    array(  1=>0,
38b07cf47aSGerry Weißbach    2=>0,
39b07cf47aSGerry Weißbach    3=>0,
40b07cf47aSGerry Weißbach    4=>0,
41b07cf47aSGerry Weißbach    5=>0);
42b07cf47aSGerry Weißbach
43b07cf47aSGerry Weißbach    /**
44b07cf47aSGerry Weißbach     * return some info
45b07cf47aSGerry Weißbach     */
46b07cf47aSGerry Weißbach    function getInfo(){
47b07cf47aSGerry Weißbach        if ( method_exists(parent, 'getInfo')) {
48b07cf47aSGerry Weißbach            $info = parent::getInfo();
49b07cf47aSGerry Weißbach        }
50b07cf47aSGerry Weißbach	    return array_merge(is_array($info) ? $info : confToHash(dirname(__FILE__).'/../plugin.info.txt'), array(
51b07cf47aSGerry Weißbach
52b07cf47aSGerry Weißbach        ));
53b07cf47aSGerry Weißbach    }
54b07cf47aSGerry Weißbach
55b07cf47aSGerry Weißbach    function canRender($format) {
56b07cf47aSGerry Weißbach        return ($format=='xhtml');
57b07cf47aSGerry Weißbach    }
58b07cf47aSGerry Weißbach
59b07cf47aSGerry Weißbach    function document_start() {
60b07cf47aSGerry Weißbach        global $TOC, $ID, $INFO;
61b07cf47aSGerry Weißbach
62b07cf47aSGerry Weißbach        parent::document_start();
63b07cf47aSGerry Weißbach
64b07cf47aSGerry Weißbach        // Cheating in again
65b07cf47aSGerry Weißbach        $newMeta = p_get_metadata($ID, 'description tableofcontents', false); // 2010-10-23 This should be save to use
66b07cf47aSGerry Weißbach        if ( !empty( $newMeta ) && count($newMeta) > 1 ) {
67b07cf47aSGerry Weißbach            // $TOC = $this->toc = $newMeta; // 2010-08-23 doubled the TOC
68b07cf47aSGerry Weißbach            $TOC = $newMeta;
69b07cf47aSGerry Weißbach        }
70b07cf47aSGerry Weißbach    }
71b07cf47aSGerry Weißbach
72b07cf47aSGerry Weißbach    function document_end() {
73b07cf47aSGerry Weißbach
74b07cf47aSGerry Weißbach        parent::document_end();
75b07cf47aSGerry Weißbach
76b07cf47aSGerry Weißbach        // Prepare the TOC
77b07cf47aSGerry Weißbach        global $TOC, $ID;
78b07cf47aSGerry Weißbach        $meta = array();
79b07cf47aSGerry Weißbach
80b07cf47aSGerry Weißbach        // NOTOC, and no forceTOC
81b07cf47aSGerry Weißbach        if ( $this->info['toc'] === false && !($this->info['forceTOC'] || $this->meta['forceTOC']) ) {
82b07cf47aSGerry Weißbach            $TOC = $this->toc = array();
83b07cf47aSGerry Weißbach            $meta['internal']['toc'] = false;
84b07cf47aSGerry Weißbach            $meta['description']['tableofcontents'] = array();
85b07cf47aSGerry Weißbach            $meta['forceTOC'] = false;
86b07cf47aSGerry Weißbach
87b07cf47aSGerry Weißbach        } else if ( $this->info['forceTOC'] || $this->meta['forceTOC'] || (utf8_strlen(strip_tags($this->doc)) >= $this->getConf('documentlengthfortoc') && count($this->toc) > 1 ) ) {
88b07cf47aSGerry Weißbach            $TOC = $this->toc;
89b07cf47aSGerry Weißbach            // This is a little bit like cheating ... but this will force the TOC into the metadata
90b07cf47aSGerry Weißbach            $meta = array();
91b07cf47aSGerry Weißbach            $meta['internal']['toc'] = true;
92b07cf47aSGerry Weißbach            $meta['forceTOC'] = $this->info['forceTOC'] || $this->meta['forceTOC'];
93b07cf47aSGerry Weißbach            $meta['description']['tableofcontents'] = $TOC;
94b07cf47aSGerry Weißbach        }
95b07cf47aSGerry Weißbach
96b07cf47aSGerry Weißbach        // allways write new metadata
97b07cf47aSGerry Weißbach        p_set_metadata($ID, $meta);
98b07cf47aSGerry Weißbach
99b07cf47aSGerry Weißbach        // make sure there are no empty blocks
100b07cf47aSGerry Weißbach        $this->doc = preg_replace('#<div class="level\d">\s*</div>#','',$this->doc);
101b07cf47aSGerry Weißbach    }
102b07cf47aSGerry Weißbach
103b07cf47aSGerry Weißbach    function header($text, $level, $pos) {
104b07cf47aSGerry Weißbach        global $conf;
105b07cf47aSGerry Weißbach        global $ID;
106b07cf47aSGerry Weißbach        global $INFO;
107b07cf47aSGerry Weißbach
108b07cf47aSGerry Weißbach        if($text) {
109b07cf47aSGerry Weißbach            /* There should be no class for "sectioneditX" if there is no edit perm */
110b07cf47aSGerry Weißbach            $maxLevel = $conf['maxseclevel'];
111b07cf47aSGerry Weißbach            if ( $INFO['perm'] <= AUTH_READ )
112b07cf47aSGerry Weißbach            {
113b07cf47aSGerry Weißbach                $conf['maxseclevel'] = 0;
114b07cf47aSGerry Weißbach            }
115b07cf47aSGerry Weißbach
116b07cf47aSGerry Weißbach            $headingNumber = '';
117b07cf47aSGerry Weißbach            $useNumbered = p_get_metadata($ID, 'usenumberedheading', true); // 2011-02-07 This should be save to use
118b07cf47aSGerry Weißbach            if ( $this->getConf('usenumberedheading') || !empty($useNumbered) || !empty($INFO['meta']['usenumberedheading']) || isset($_REQUEST['usenumberedheading'])) {
119b07cf47aSGerry Weißbach
120b07cf47aSGerry Weißbach                // increment the number of the heading
121b07cf47aSGerry Weißbach                $this->headingCount[$level]++;
122b07cf47aSGerry Weißbach
123b07cf47aSGerry Weißbach                // build the actual number
124b07cf47aSGerry Weißbach                for ($i=1;$i<=5;$i++) {
125b07cf47aSGerry Weißbach
126b07cf47aSGerry Weißbach                    // reset the number of the subheadings
127b07cf47aSGerry Weißbach                    if ($i>$level) {
128b07cf47aSGerry Weißbach                        $this->headingCount[$i] = 0;
129b07cf47aSGerry Weißbach                    }
130b07cf47aSGerry Weißbach
131b07cf47aSGerry Weißbach                    // build the number of the heading
132b07cf47aSGerry Weißbach                    $headingNumber .= $this->headingCount[$i] . '.';
133b07cf47aSGerry Weißbach                }
134b07cf47aSGerry Weißbach
135b07cf47aSGerry Weißbach                $headingNumber = preg_replace("/(\.0)+\.?$/", '', $headingNumber) . ' ';
136b07cf47aSGerry Weißbach            }
137b07cf47aSGerry Weißbach
138*f350675fSGerry Weißbach            parent::header($headingNumber . $text, $level, $pos);
139*f350675fSGerry Weißbach            $conf['maxseclevel'] = $maxLevel;
140b07cf47aSGerry Weißbach
141b07cf47aSGerry Weißbach        } else if ( $INFO['perm'] > AUTH_READ ) {
142b07cf47aSGerry Weißbach
143b07cf47aSGerry Weißbach            if ( $hasSeenHeader ) $this->finishSectionEdit($pos);
144b07cf47aSGerry Weißbach
145b07cf47aSGerry Weißbach            // write the header
146b07cf47aSGerry Weißbach            $name = rand() . $level;
147b07cf47aSGerry Weißbach            $this->doc .= DOKU_LF.'<a name="'. $this->startSectionEdit($pos, 'section_empty', $name) .'" class="' . $this->startSectionEdit($pos, 'section_empty', $name) . '" ></a>'.DOKU_LF;
148b07cf47aSGerry Weißbach        }
149b07cf47aSGerry Weißbach
150b07cf47aSGerry Weißbach        $hasSeenHeader = true;
151b07cf47aSGerry Weißbach    }
152b07cf47aSGerry Weißbach
153b07cf47aSGerry Weißbach    public function finishSectionEdit($end = null) {
154b07cf47aSGerry Weißbach        global $INFO;
155b07cf47aSGerry Weißbach        if ( $INFO['perm'] > AUTH_READ )
156b07cf47aSGerry Weißbach        {
157b07cf47aSGerry Weißbach            return parent::finishSectionEdit($end);
158b07cf47aSGerry Weißbach        }
159b07cf47aSGerry Weißbach    }
160b07cf47aSGerry Weißbach
161b07cf47aSGerry Weißbach    public function startSectionEdit($start, $type, $title = null) {
162b07cf47aSGerry Weißbach        global $INFO;
163b07cf47aSGerry Weißbach        if ( $INFO['perm'] > AUTH_READ )
164b07cf47aSGerry Weißbach        {
165b07cf47aSGerry Weißbach            return parent::startSectionEdit($start, $type, $title);
166b07cf47aSGerry Weißbach        }
167b07cf47aSGerry Weißbach
168b07cf47aSGerry Weißbach        return "";
169b07cf47aSGerry Weißbach    }
170b07cf47aSGerry Weißbach
171b07cf47aSGerry Weißbach    function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL,
172b07cf47aSGerry Weißbach    $height=NULL, $cache=NULL, $linking=NULL) {
173b07cf47aSGerry Weißbach        global $ID;
174b07cf47aSGerry Weißbach        list($src,$hash) = explode('#',$src,2);
175b07cf47aSGerry Weißbach        resolve_mediaid(getNS($ID),$src, $exists);
176b07cf47aSGerry Weißbach
177b07cf47aSGerry Weißbach        $noLink = false;
178b07cf47aSGerry Weißbach        $render = ($linking == 'linkonly') ? false : true;
179b07cf47aSGerry Weißbach        $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
180b07cf47aSGerry Weißbach
181b07cf47aSGerry Weißbach        list($ext,$mime,$dl) = mimetype($src);
182b07cf47aSGerry Weißbach        if(substr($mime,0,5) == 'image' && $render){
183b07cf47aSGerry Weißbach            $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct'));
184b07cf47aSGerry Weißbach            if ( substr($mime,0,5) == 'image' && $linking='details' ) { $noLink = true;}
185b07cf47aSGerry Weißbach        }elseif($mime == 'application/x-shockwave-flash' && $render){
186b07cf47aSGerry Weißbach            // don't link flash movies
187b07cf47aSGerry Weißbach            $noLink = true;
188b07cf47aSGerry Weißbach        }else{
189b07cf47aSGerry Weißbach            // add file icons
190b07cf47aSGerry Weißbach            $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
191b07cf47aSGerry Weißbach            $link['class'] .= ' mediafile mf_'.$class;
192b07cf47aSGerry Weißbach            $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),true);
193b07cf47aSGerry Weißbach        }
194b07cf47aSGerry Weißbach
195b07cf47aSGerry Weißbach        if($hash) $link['url'] .= '#'.$hash;
196b07cf47aSGerry Weißbach
197b07cf47aSGerry Weißbach        //markup non existing files
198b07cf47aSGerry Weißbach        if (!$exists)
199b07cf47aSGerry Weißbach        $link['class'] .= ' wikilink2';
200b07cf47aSGerry Weißbach
201b07cf47aSGerry Weißbach        //output formatted
202b07cf47aSGerry Weißbach        if ($linking == 'nolink' || $noLink) $this->doc .= $link['name'];
203b07cf47aSGerry Weißbach        else $this->doc .= $this->_formatLink($link);
204b07cf47aSGerry Weißbach    }
205b07cf47aSGerry Weißbach
206b07cf47aSGerry Weißbach    /**
207b07cf47aSGerry Weißbach     * Render an internal Wiki Link
208b07cf47aSGerry Weißbach     *
209b07cf47aSGerry Weißbach     * $search,$returnonly & $linktype are not for the renderer but are used
210b07cf47aSGerry Weißbach     * elsewhere - no need to implement them in other renderers
211b07cf47aSGerry Weißbach     *
212b07cf47aSGerry Weißbach     * @author Andreas Gohr <andi@splitbrain.org>
213b07cf47aSGerry Weißbach     */
214b07cf47aSGerry Weißbach    function internallink($id, $name = null, $search=null,$returnonly=false,$linktype='content') {
215b07cf47aSGerry Weißbach        global $conf;
216b07cf47aSGerry Weißbach        global $ID;
217b07cf47aSGerry Weißbach        global $INFO;
218b07cf47aSGerry Weißbach
219b07cf47aSGerry Weißbach        $params = '';
220b07cf47aSGerry Weißbach        $parts = explode('?', $id, 2);
221b07cf47aSGerry Weißbach        if (count($parts) === 2) {
222b07cf47aSGerry Weißbach            $id = $parts[0];
223b07cf47aSGerry Weißbach            $params = $parts[1];
224b07cf47aSGerry Weißbach        }
225b07cf47aSGerry Weißbach
226b07cf47aSGerry Weißbach        // For empty $id we need to know the current $ID
227b07cf47aSGerry Weißbach        // We need this check because _simpleTitle needs
228b07cf47aSGerry Weißbach        // correct $id and resolve_pageid() use cleanID($id)
229b07cf47aSGerry Weißbach        // (some things could be lost)
230b07cf47aSGerry Weißbach        if ($id === '') {
231b07cf47aSGerry Weißbach            $id = $ID;
232b07cf47aSGerry Weißbach        }
233b07cf47aSGerry Weißbach
234b07cf47aSGerry Weißbach        // default name is based on $id as given
235b07cf47aSGerry Weißbach        $default = $this->_simpleTitle($id);
236b07cf47aSGerry Weißbach
237b07cf47aSGerry Weißbach        // now first resolve and clean up the $id
238b07cf47aSGerry Weißbach        resolve_pageid(getNS($ID),$id,$exists);
239b07cf47aSGerry Weißbach
240b07cf47aSGerry Weißbach        $name = $this->_getLinkTitle($name, $default, $isImage, $id, $linktype);
241b07cf47aSGerry Weißbach        if ( !$isImage ) {
242b07cf47aSGerry Weißbach            if ( $exists ) {
243b07cf47aSGerry Weißbach                $class='wikilink1';
244b07cf47aSGerry Weißbach            } else {
245b07cf47aSGerry Weißbach                $class='wikilink2';
246b07cf47aSGerry Weißbach                $link['rel']='nofollow';
247b07cf47aSGerry Weißbach            }
248b07cf47aSGerry Weißbach        } else {
249b07cf47aSGerry Weißbach            $class='media';
250b07cf47aSGerry Weißbach        }
251b07cf47aSGerry Weißbach
252b07cf47aSGerry Weißbach        //keep hash anchor
253b07cf47aSGerry Weißbach        list($id,$hash) = explode('#',$id,2);
254b07cf47aSGerry Weißbach        if(!empty($hash)) $hash = $this->_headerToLink($hash);
255b07cf47aSGerry Weißbach
256b07cf47aSGerry Weißbach        //prepare for formating
257b07cf47aSGerry Weißbach        $link['target'] = $conf['target']['wiki'];
258b07cf47aSGerry Weißbach        $link['style']  = '';
259b07cf47aSGerry Weißbach        $link['pre']    = '';
260b07cf47aSGerry Weißbach        $link['suf']    = '';
261b07cf47aSGerry Weißbach        // highlight link to current page
262b07cf47aSGerry Weißbach        if ($id == $INFO['id']) {
263b07cf47aSGerry Weißbach            $link['pre']    = '<span class="curid">';
264b07cf47aSGerry Weißbach            $link['suf']    = '</span>';
265b07cf47aSGerry Weißbach        }
266b07cf47aSGerry Weißbach        $link['more']   = '';
267b07cf47aSGerry Weißbach        $link['class']  = $class;
268b07cf47aSGerry Weißbach        $link['url']    = wl($id, $params);
269b07cf47aSGerry Weißbach        $link['name']   = $name;
270b07cf47aSGerry Weißbach        $link['title']  = $this->_getLinkTitle(null, $default, $isImage, $id, $linktype);
271b07cf47aSGerry Weißbach        //add search string
272b07cf47aSGerry Weißbach        if($search){
273b07cf47aSGerry Weißbach            ($conf['userewrite']) ? $link['url'].='?' : $link['url'].='&amp;';
274b07cf47aSGerry Weißbach            if(is_array($search)){
275b07cf47aSGerry Weißbach                $search = array_map('rawurlencode',$search);
276b07cf47aSGerry Weißbach                $link['url'] .= 's[]='.join('&amp;s[]=',$search);
277b07cf47aSGerry Weißbach            }else{
278b07cf47aSGerry Weißbach                $link['url'] .= 's='.rawurlencode($search);
279b07cf47aSGerry Weißbach            }
280b07cf47aSGerry Weißbach        }
281b07cf47aSGerry Weißbach
282b07cf47aSGerry Weißbach        //keep hash
283b07cf47aSGerry Weißbach        if($hash) $link['url'].='#'.$hash;
284b07cf47aSGerry Weißbach
285b07cf47aSGerry Weißbach        //output formatted
286b07cf47aSGerry Weißbach        if($returnonly){
287b07cf47aSGerry Weißbach            return $this->_formatLink($link);
288b07cf47aSGerry Weißbach        }else{
289b07cf47aSGerry Weißbach            $this->doc .= $this->_formatLink($link);
290b07cf47aSGerry Weißbach        }
291b07cf47aSGerry Weißbach    }
292b07cf47aSGerry Weißbach
293b07cf47aSGerry Weißbach	function locallink($hash, $name = null){
294b07cf47aSGerry Weißbach		global $ID;
295b07cf47aSGerry Weißbach		$name  = $this->_getLinkTitle($name, $hash, $isImage);
296b07cf47aSGerry Weißbach		$hash  = $this->_headerToLink($hash);
297b07cf47aSGerry Weißbach		$title = $name;
298b07cf47aSGerry Weißbach		$this->doc .= '<a href="#'.$hash.'" title="'.$title.'" class="wikilink1">';
299b07cf47aSGerry Weißbach		$this->doc .= $name;
300b07cf47aSGerry Weißbach		$this->doc .= '</a>';
301b07cf47aSGerry Weißbach	}
302b07cf47aSGerry Weißbach
303b07cf47aSGerry Weißbach    function acronym($acronym) {
304b07cf47aSGerry Weißbach
305b07cf47aSGerry Weißbach        if ( empty($this->acronymsExchanged) ) {
306b07cf47aSGerry Weißbach            $this->acronymsExchanged = $this->acronyms;
307b07cf47aSGerry Weißbach            $this->acronyms = array();
308b07cf47aSGerry Weißbach
309b07cf47aSGerry Weißbach            foreach( $this->acronymsExchanged as $key => $value ) {
310b07cf47aSGerry Weißbach                $this->acronyms[str_replace('_', ' ', $key)] = $value;
311b07cf47aSGerry Weißbach            }
312b07cf47aSGerry Weißbach        }
313b07cf47aSGerry Weißbach
314b07cf47aSGerry Weißbach        parent::acronym($acronym);
315b07cf47aSGerry Weißbach    }
316b07cf47aSGerry Weißbach
317b07cf47aSGerry Weißbach    function entity($entity) {
318b07cf47aSGerry Weißbach
319b07cf47aSGerry Weißbach        if ( array_key_exists($entity, $this->entities) ) {
320b07cf47aSGerry Weißbach            $entity = $this->entities[$entity];
321b07cf47aSGerry Weißbach        }
322b07cf47aSGerry Weißbach
323b07cf47aSGerry Weißbach        $this->doc .= $this->_xmlEntities($entity);
324b07cf47aSGerry Weißbach    }
325b07cf47aSGerry Weißbach
326b07cf47aSGerry Weißbach    function _xmlEntities($string) {
327b07cf47aSGerry Weißbach
328b07cf47aSGerry Weißbach        $string = parent::_xmlEntities($string);
329b07cf47aSGerry Weißbach        $string = htmlentities($string, 8, 'UTF-8');
330b07cf47aSGerry Weißbach        $string = $this->superentities($string);
331b07cf47aSGerry Weißbach
332b07cf47aSGerry Weißbach        if ( $this->info['scriptmode'] ) {
333b07cf47aSGerry Weißbach            $string = str_replace(	array( "&lt;%", "%&gt;", "&lt;?", "?&gt;"),
334b07cf47aSGerry Weißbach            array( "<%", "%>", "<?", "?>"),
335b07cf47aSGerry Weißbach            $string);
336b07cf47aSGerry Weißbach        }
337b07cf47aSGerry Weißbach
338b07cf47aSGerry Weißbach        return $string;
339b07cf47aSGerry Weißbach    }
340b07cf47aSGerry Weißbach
341b07cf47aSGerry Weißbach	// Unicode-proof htmlentities.
342b07cf47aSGerry Weißbach	// Returns 'normal' chars as chars and weirdos as numeric html entites.
343b07cf47aSGerry Weißbach	function superentities( $str ){
344b07cf47aSGerry Weißbach	    // get rid of existing entities else double-escape
345b07cf47aSGerry Weißbach	    $str = html_entity_decode(stripslashes($str),ENT_QUOTES,'UTF-8');
346b07cf47aSGerry Weißbach	    $ar = preg_split('/(?<!^)(?!$)(?!\n)/u', $str );  // return array of every multi-byte character
347b07cf47aSGerry Weißbach	    foreach ($ar as $c){
348b07cf47aSGerry Weißbach	        $o = ord($c);
349b07cf47aSGerry Weißbach	        if ( // (strlen($c) > 1) || /* multi-byte [unicode] */
350b07cf47aSGerry Weißbach	            ($o > 127) // || /* <- control / latin weirdos -> */
351b07cf47aSGerry Weißbach	            // ($o <32 || $o > 126) || /* <- control / latin weirdos -> */
352b07cf47aSGerry Weißbach	            // ($o >33 && $o < 40) ||/* quotes + ambersand */
353b07cf47aSGerry Weißbach	            // ($o >59 && $o < 63) /* html */
354b07cf47aSGerry Weißbach
355b07cf47aSGerry Weißbach	        ) {
356b07cf47aSGerry Weißbach	            // convert to numeric entity
357b07cf47aSGerry Weißbach	            $c = mb_encode_numericentity($c,array (0x0, 0xffff, 0, 0xffff), 'UTF-8');
358b07cf47aSGerry Weißbach	        }
359b07cf47aSGerry Weißbach	        $str2 .= $c;
360b07cf47aSGerry Weißbach	    }
361b07cf47aSGerry Weißbach	    return $str2;
362b07cf47aSGerry Weißbach	}
363b07cf47aSGerry Weißbach}
364b07cf47aSGerry Weißbach
365b07cf47aSGerry Weißbach//Setup VIM: ex: et ts=4 enc=utf-8 :
366