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