xref: /dokuwiki/lib/exe/css.php (revision dbfd2a2c7bb8cab263b1e64c75a85ea93d6e0b60)
1<?php
2/**
3 * DokuWiki StyleSheet creator
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Andreas Gohr <andi@splitbrain.org>
7 */
8
9if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
10if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching)
11if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT',1); // we gzip ourself here
12if(!defined('NL')) define('NL',"\n");
13require_once(DOKU_INC.'inc/init.php');
14
15// Main (don't run when UNIT test)
16if(!defined('SIMPLE_TEST')){
17    header('Content-Type: text/css; charset=utf-8');
18    css_out();
19}
20
21
22// ---------------------- functions ------------------------------
23
24/**
25 * Output all needed Styles
26 *
27 * @author Andreas Gohr <andi@splitbrain.org>
28 */
29function css_out(){
30    global $conf;
31    global $lang;
32    global $config_cascade;
33    global $INPUT;
34
35    if ($INPUT->str('s') == 'feed') {
36        $mediatypes = array('feed');
37        $type = 'feed';
38    } else {
39        $mediatypes = array('screen', 'all', 'print');
40        $type = '';
41    }
42
43    // decide from where to get the template
44    $tpl = trim(preg_replace('/[^\w-]+/','',$INPUT->str('t')));
45    if(!$tpl) $tpl = $conf['template'];
46
47    // The generated script depends on some dynamic options
48    $cache = new cache('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].$INPUT->int('preview').DOKU_BASE.$tpl.$type,'.css');
49
50    // load styl.ini
51    $styleini = css_styleini($tpl, $INPUT->bool('preview'));
52
53    // if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility
54    if (isset($config_cascade['userstyle']['default'])) {
55        $config_cascade['userstyle']['screen'] = array($config_cascade['userstyle']['default']);
56    }
57
58    // cache influencers
59    $tplinc = tpl_incdir($tpl);
60    $cache_files = getConfigFiles('main');
61    $cache_files[] = $tplinc.'style.ini';
62    $cache_files[] = $tplinc.'style.local.ini'; // @deprecated
63    $cache_files[] = DOKU_CONF."tpl/$tpl/style.ini";
64    $cache_files[] = __FILE__;
65    if($INPUT->bool('preview')) $cache_files[] = $conf['cachedir'].'/preview.ini';
66
67    // Array of needed files and their web locations, the latter ones
68    // are needed to fix relative paths in the stylesheets
69    $files = array();
70    foreach($mediatypes as $mediatype) {
71        $files[$mediatype] = array();
72        // load core styles
73        $files[$mediatype][DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/';
74
75        // load jQuery-UI theme
76        if ($mediatype == 'screen') {
77            $files[$mediatype][DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/scripts/jquery/jquery-ui-theme/';
78        }
79        // load plugin styles
80        $files[$mediatype] = array_merge($files[$mediatype], css_pluginstyles($mediatype));
81        // load template styles
82        if (isset($styleini['stylesheets'][$mediatype])) {
83            $files[$mediatype] = array_merge($files[$mediatype], $styleini['stylesheets'][$mediatype]);
84        }
85        // load user styles
86        if(!empty($config_cascade['userstyle'][$mediatype])) {
87            foreach($config_cascade['userstyle'][$mediatype] as $userstyle) {
88                $files[$mediatype][$userstyle] = DOKU_BASE;
89            }
90        }
91
92        $cache_files = array_merge($cache_files, array_keys($files[$mediatype]));
93    }
94
95    // check cache age & handle conditional request
96    // This may exit if a cache can be used
97    http_cached($cache->cache,
98                $cache->useCache(array('files' => $cache_files)));
99
100    // start output buffering
101    ob_start();
102
103    // build the stylesheet
104    foreach ($mediatypes as $mediatype) {
105
106        // print the default classes for interwiki links and file downloads
107        if ($mediatype == 'screen') {
108            print '@media screen {';
109            css_interwiki();
110            css_filetypes();
111            print '}';
112        }
113
114        // load files
115        $css_content = '';
116        foreach($files[$mediatype] as $file => $location){
117            $display = str_replace(fullpath(DOKU_INC), '', fullpath($file));
118            $css_content .= "\n/* XXXXXXXXX $display XXXXXXXXX */\n";
119            $css_content .= css_loadfile($file, $location);
120        }
121        switch ($mediatype) {
122            case 'screen':
123                print NL.'@media screen { /* START screen styles */'.NL.$css_content.NL.'} /* /@media END screen styles */'.NL;
124                break;
125            case 'print':
126                print NL.'@media print { /* START print styles */'.NL.$css_content.NL.'} /* /@media END print styles */'.NL;
127                break;
128            case 'all':
129            case 'feed':
130            default:
131                print NL.'/* START rest styles */ '.NL.$css_content.NL.'/* END rest styles */'.NL;
132                break;
133        }
134    }
135    // end output buffering and get contents
136    $css = ob_get_contents();
137    ob_end_clean();
138
139    // strip any source maps
140    stripsourcemaps($css);
141
142    // apply style replacements
143    $css = css_applystyle($css, $styleini['replacements']);
144
145    // parse less
146    $css = css_parseless($css);
147
148    // compress whitespace and comments
149    if($conf['compress']){
150        $css = css_compress($css);
151    }
152
153    // embed small images right into the stylesheet
154    if($conf['cssdatauri']){
155        $base = preg_quote(DOKU_BASE,'#');
156        $css = preg_replace_callback('#(url\([ \'"]*)('.$base.')(.*?(?:\.(png|gif)))#i','css_datauri',$css);
157    }
158
159    http_cached_finish($cache->cache, $css);
160}
161
162/**
163 * Uses phpless to parse LESS in our CSS
164 *
165 * most of this function is error handling to show a nice useful error when
166 * LESS compilation fails
167 *
168 * @param string $css
169 * @return string
170 */
171function css_parseless($css) {
172    global $conf;
173
174    $less = new lessc();
175    $less->importDir[] = DOKU_INC;
176    $less->setPreserveComments(!$conf['compress']);
177
178    if (defined('DOKU_UNITTEST')){
179        $less->importDir[] = TMP_DIR;
180    }
181
182    try {
183        return $less->compile($css);
184    } catch(Exception $e) {
185        // get exception message
186        $msg = str_replace(array("\n", "\r", "'"), array(), $e->getMessage());
187
188        // try to use line number to find affected file
189        if(preg_match('/line: (\d+)$/', $msg, $m)){
190            $msg = substr($msg, 0, -1* strlen($m[0])); //remove useless linenumber
191            $lno = $m[1];
192
193            // walk upwards to last include
194            $lines = explode("\n", $css);
195            for($i=$lno-1; $i>=0; $i--){
196                if(preg_match('/\/(\* XXXXXXXXX )(.*?)( XXXXXXXXX \*)\//', $lines[$i], $m)){
197                    // we found it, add info to message
198                    $msg .= ' in '.$m[2].' at line '.($lno-$i);
199                    break;
200                }
201            }
202        }
203
204        // something went wrong
205        $error = 'A fatal error occured during compilation of the CSS files. '.
206            'If you recently installed a new plugin or template it '.
207            'might be broken and you should try disabling it again. ['.$msg.']';
208
209        echo ".dokuwiki:before {
210            content: '$error';
211            background-color: red;
212            display: block;
213            background-color: #fcc;
214            border-color: #ebb;
215            color: #000;
216            padding: 0.5em;
217        }";
218
219        exit;
220    }
221}
222
223/**
224 * Does placeholder replacements in the style according to
225 * the ones defined in a templates style.ini file
226 *
227 * This also adds the ini defined placeholders as less variables
228 * (sans the surrounding __ and with a ini_ prefix)
229 *
230 * @author Andreas Gohr <andi@splitbrain.org>
231 *
232 * @param string $css
233 * @param array $replacements  array(placeholder => value)
234 * @return string
235 */
236function css_applystyle($css, $replacements) {
237    // we convert ini replacements to LESS variable names
238    // and build a list of variable: value; pairs
239    $less = '';
240    foreach((array) $replacements as $key => $value) {
241        $lkey = trim($key, '_');
242        $lkey = '@ini_'.$lkey;
243        $less .= "$lkey: $value;\n";
244
245        $replacements[$key] = $lkey;
246    }
247
248    // we now replace all old ini replacements with LESS variables
249    $css = strtr($css, $replacements);
250
251    // now prepend the list of LESS variables as the very first thing
252    $css = $less.$css;
253    return $css;
254}
255
256/**
257 * Load style ini contents
258 *
259 * Loads and merges style.ini files from template and config and prepares
260 * the stylesheet modes
261 *
262 * @author Andreas Gohr <andi@splitbrain.org>
263 *
264 * @param string $tpl the used template
265 * @param bool   $preview load preview replacements
266 * @return array with keys 'stylesheets' and 'replacements'
267 */
268function css_styleini($tpl, $preview=false) {
269    global $conf;
270
271    $stylesheets = array(); // mode, file => base
272    $replacements = array(); // placeholder => value
273
274    // load template's style.ini
275    $incbase = tpl_incdir($tpl);
276    $webbase = tpl_basedir($tpl);
277    $ini = $incbase.'style.ini';
278    if(file_exists($ini)){
279        $data = parse_ini_file($ini, true);
280
281        // stylesheets
282        if(is_array($data['stylesheets'])) foreach($data['stylesheets'] as $file => $mode){
283            $stylesheets[$mode][$incbase.$file] = $webbase;
284        }
285
286        // replacements
287        if(is_array($data['replacements'])){
288            $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'],$webbase));
289        }
290    }
291
292    // load template's style.local.ini
293    // @deprecated 2013-08-03
294    $ini = $incbase.'style.local.ini';
295    if(file_exists($ini)){
296        $data = parse_ini_file($ini, true);
297
298        // stylesheets
299        if(is_array($data['stylesheets'])) foreach($data['stylesheets'] as $file => $mode){
300            $stylesheets[$mode][$incbase.$file] = $webbase;
301        }
302
303        // replacements
304        if(is_array($data['replacements'])){
305            $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'],$webbase));
306        }
307    }
308
309    // load configs's style.ini
310    $webbase = DOKU_BASE;
311    $ini = DOKU_CONF."tpl/$tpl/style.ini";
312    $incbase = dirname($ini).'/';
313    if(file_exists($ini)){
314        $data = parse_ini_file($ini, true);
315
316        // stylesheets
317        if(is_array($data['stylesheets'])) foreach($data['stylesheets'] as $file => $mode){
318            $stylesheets[$mode][$incbase.$file] = $webbase;
319        }
320
321        // replacements
322        if(is_array($data['replacements'])){
323            $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'],$webbase));
324        }
325    }
326
327    // allow replacement overwrites in preview mode
328    if($preview) {
329        $webbase = DOKU_BASE;
330        $ini     = $conf['cachedir'].'/preview.ini';
331        if(file_exists($ini)) {
332            $data = parse_ini_file($ini, true);
333            // replacements
334            if(is_array($data['replacements'])) {
335                $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'], $webbase));
336            }
337        }
338    }
339
340    return array(
341        'stylesheets' => $stylesheets,
342        'replacements' => $replacements
343    );
344}
345
346/**
347 * Amend paths used in replacement relative urls, refer FS#2879
348 *
349 * @author Chris Smith <chris@jalakai.co.uk>
350 *
351 * @param array $replacements with key-value pairs
352 * @param string $location
353 * @return array
354 */
355function css_fixreplacementurls($replacements, $location) {
356    foreach($replacements as $key => $value) {
357        $replacements[$key] = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$value);
358    }
359    return $replacements;
360}
361
362/**
363 * Prints classes for interwikilinks
364 *
365 * Interwiki links have two classes: 'interwiki' and 'iw_$name>' where
366 * $name is the identifier given in the config. All Interwiki links get
367 * an default style with a default icon. If a special icon is available
368 * for an interwiki URL it is set in it's own class. Both classes can be
369 * overwritten in the template or userstyles.
370 *
371 * @author Andreas Gohr <andi@splitbrain.org>
372 */
373function css_interwiki(){
374
375    // default style
376    echo 'a.interwiki {';
377    echo ' background: transparent url('.DOKU_BASE.'lib/images/interwiki.png) 0px 1px no-repeat;';
378    echo ' padding: 1px 0px 1px 16px;';
379    echo '}';
380
381    // additional styles when icon available
382    $iwlinks = getInterwiki();
383    foreach(array_keys($iwlinks) as $iw){
384        $class = preg_replace('/[^_\-a-z0-9]+/i','_',$iw);
385        if(file_exists(DOKU_INC.'lib/images/interwiki/'.$iw.'.png')){
386            echo "a.iw_$class {";
387            echo '  background-image: url('.DOKU_BASE.'lib/images/interwiki/'.$iw.'.png)';
388            echo '}';
389        }elseif(file_exists(DOKU_INC.'lib/images/interwiki/'.$iw.'.gif')){
390            echo "a.iw_$class {";
391            echo '  background-image: url('.DOKU_BASE.'lib/images/interwiki/'.$iw.'.gif)';
392            echo '}';
393        }
394    }
395}
396
397/**
398 * Prints classes for file download links
399 *
400 * @author Andreas Gohr <andi@splitbrain.org>
401 */
402function css_filetypes(){
403
404    // default style
405    echo '.mediafile {';
406    echo ' background: transparent url('.DOKU_BASE.'lib/images/fileicons/file.png) 0px 1px no-repeat;';
407    echo ' padding-left: 18px;';
408    echo ' padding-bottom: 1px;';
409    echo '}';
410
411    // additional styles when icon available
412    // scan directory for all icons
413    $exts = array();
414    if($dh = opendir(DOKU_INC.'lib/images/fileicons')){
415        while(false !== ($file = readdir($dh))){
416            if(preg_match('/([_\-a-z0-9]+(?:\.[_\-a-z0-9]+)*?)\.(png|gif)/i',$file,$match)){
417                $ext = strtolower($match[1]);
418                $type = '.'.strtolower($match[2]);
419                if($ext!='file' && (!isset($exts[$ext]) || $type=='.png')){
420                    $exts[$ext] = $type;
421                }
422            }
423        }
424        closedir($dh);
425    }
426    foreach($exts as $ext=>$type){
427        $class = preg_replace('/[^_\-a-z0-9]+/','_',$ext);
428        echo ".mf_$class {";
429        echo '  background-image: url('.DOKU_BASE.'lib/images/fileicons/'.$ext.$type.')';
430        echo '}';
431    }
432}
433
434/**
435 * Loads a given file and fixes relative URLs with the
436 * given location prefix
437 *
438 * @param string $file file system path
439 * @param string $location
440 * @return string
441 */
442function css_loadfile($file,$location=''){
443    $css_file = new DokuCssFile($file);
444    return $css_file->load($location);
445}
446
447/**
448 *  Helper class to abstract loading of css/less files
449 *
450 *  @author Chris Smith <chris@jalakai.co.uk>
451 */
452class DokuCssFile {
453
454    protected $filepath;             // file system path to the CSS/Less file
455    protected $location;             // base url location of the CSS/Less file
456    protected $relative_path = null;
457
458    public function __construct($file) {
459        $this->filepath = $file;
460    }
461
462    /**
463     * Load the contents of the css/less file and adjust any relative paths/urls (relative to this file) to be
464     * relative to the dokuwiki root: the web root (DOKU_BASE) for most files; the file system root (DOKU_INC)
465     * for less files.
466     *
467     * @param   string   $location   base url for this file
468     * @return  string               the CSS/Less contents of the file
469     */
470    public function load($location='') {
471        if (!file_exists($this->filepath)) return '';
472
473        $css = io_readFile($this->filepath);
474        if (!$location) return $css;
475
476        $this->location = $location;
477
478        $css = preg_replace_callback('#(url\( *)([\'"]?)(.*?)(\2)( *\))#',array($this,'replacements'),$css);
479        $css = preg_replace_callback('#(@import\s+)([\'"])(.*?)(\2)#',array($this,'replacements'),$css);
480
481        return $css;
482    }
483
484    /**
485     * Get the relative file system path of this file, relative to dokuwiki's root folder, DOKU_INC
486     *
487     * @return string   relative file system path
488     */
489    protected function getRelativePath(){
490
491        if (is_null($this->relative_path)) {
492            $basedir = array(DOKU_INC);
493
494            // during testing, files may be found relative to a second base dir, TMP_DIR
495            if (defined('DOKU_UNITTEST')) {
496                $basedir[] = realpath(TMP_DIR);
497            }
498
499            $basedir = array_map('preg_quote_cb', $basedir);
500            $regex = '/^('.join('|',$basedir).')/';
501            $this->relative_path = preg_replace($regex, '', dirname($this->filepath));
502        }
503
504        return $this->relative_path;
505    }
506
507    /**
508     * preg_replace callback to adjust relative urls from relative to this file to relative
509     * to the appropriate dokuwiki root location as described in the code
510     *
511     * @param  array    see http://php.net/preg_replace_callback
512     * @return string   see http://php.net/preg_replace_callback
513     */
514    public function replacements($match) {
515
516        // not a relative url? - no adjustment required
517        if (preg_match('#^(/|data:|https?://)#',$match[3])) {
518            return $match[0];
519        }
520        // a less file import? - requires a file system location
521        else if (substr($match[3],-5) == '.less') {
522            if ($match[3]{0} != '/') {
523                $match[3] = $this->getRelativePath() . '/' . $match[3];
524            }
525        }
526        // everything else requires a url adjustment
527        else {
528            $match[3] = $this->location . $match[3];
529        }
530
531        return join('',array_slice($match,1));
532    }
533}
534
535/**
536 * Convert local image URLs to data URLs if the filesize is small
537 *
538 * Callback for preg_replace_callback
539 *
540 * @param array $match
541 * @return string
542 */
543function css_datauri($match){
544    global $conf;
545
546    $pre   = unslash($match[1]);
547    $base  = unslash($match[2]);
548    $url   = unslash($match[3]);
549    $ext   = unslash($match[4]);
550
551    $local = DOKU_INC.$url;
552    $size  = @filesize($local);
553    if($size && $size < $conf['cssdatauri']){
554        $data = base64_encode(file_get_contents($local));
555    }
556    if($data){
557        $url = 'data:image/'.$ext.';base64,'.$data;
558    }else{
559        $url = $base.$url;
560    }
561    return $pre.$url;
562}
563
564
565/**
566 * Returns a list of possible Plugin Styles (no existance check here)
567 *
568 * @author Andreas Gohr <andi@splitbrain.org>
569 *
570 * @param string $mediatype
571 * @return array
572 */
573function css_pluginstyles($mediatype='screen'){
574    $list = array();
575    $plugins = plugin_list();
576    foreach ($plugins as $p){
577        $list[DOKU_PLUGIN."$p/$mediatype.css"]  = DOKU_BASE."lib/plugins/$p/";
578        $list[DOKU_PLUGIN."$p/$mediatype.less"]  = DOKU_BASE."lib/plugins/$p/";
579        // alternative for screen.css
580        if ($mediatype=='screen') {
581            $list[DOKU_PLUGIN."$p/style.css"]  = DOKU_BASE."lib/plugins/$p/";
582            $list[DOKU_PLUGIN."$p/style.less"]  = DOKU_BASE."lib/plugins/$p/";
583        }
584    }
585    return $list;
586}
587
588/**
589 * Very simple CSS optimizer
590 *
591 * @author Andreas Gohr <andi@splitbrain.org>
592 *
593 * @param string $css
594 * @return string
595 */
596function css_compress($css){
597    //strip comments through a callback
598    $css = preg_replace_callback('#(/\*)(.*?)(\*/)#s','css_comment_cb',$css);
599
600    //strip (incorrect but common) one line comments
601    $css = preg_replace_callback('/^.*\/\/.*$/m','css_onelinecomment_cb',$css);
602
603    // strip whitespaces
604    $css = preg_replace('![\r\n\t ]+!',' ',$css);
605    $css = preg_replace('/ ?([;,{}\/]) ?/','\\1',$css);
606    $css = preg_replace('/ ?: /',':',$css);
607
608    // number compression
609    $css = preg_replace('/([: ])0+(\.\d+?)0*((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2$3', $css); // "0.1em" to ".1em", "1.10em" to "1.1em"
610    $css = preg_replace('/([: ])\.(0)+((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2', $css); // ".0em" to "0"
611    $css = preg_replace('/([: ]0)0*(\.0*)?((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1', $css); // "0.0em" to "0"
612    $css = preg_replace('/([: ]\d+)(\.0*)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$3', $css); // "1.0em" to "1em"
613    $css = preg_replace('/([: ])0+(\d+|\d*\.\d+)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$2$3', $css); // "001em" to "1em"
614
615    // shorten attributes (1em 1em 1em 1em -> 1em)
616    $css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width|radius)):)([\w\.]+)( \2)+(?=[;\}]| !)/', '$1$2', $css); // "1em 1em 1em 1em" to "1em"
617    $css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width)):)([\w\.]+) ([\w\.]+) \2 \3(?=[;\}]| !)/', '$1$2 $3', $css); // "1em 2em 1em 2em" to "1em 2em"
618
619    // shorten colors
620    $css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3(?=[^\{]*[;\}])/", "#\\1\\2\\3", $css);
621
622    return $css;
623}
624
625/**
626 * Callback for css_compress()
627 *
628 * Keeps short comments (< 5 chars) to maintain typical browser hacks
629 *
630 * @author Andreas Gohr <andi@splitbrain.org>
631 *
632 * @param array $matches
633 * @return string
634 */
635function css_comment_cb($matches){
636    if(strlen($matches[2]) > 4) return '';
637    return $matches[0];
638}
639
640/**
641 * Callback for css_compress()
642 *
643 * Strips one line comments but makes sure it will not destroy url() constructs with slashes
644 *
645 * @param array $matches
646 * @return string
647 */
648function css_onelinecomment_cb($matches) {
649    $line = $matches[0];
650
651    $i = 0;
652    $len = strlen($line);
653
654    while ($i< $len){
655        $nextcom = strpos($line, '//', $i);
656        $nexturl = stripos($line, 'url(', $i);
657
658        if($nextcom === false) {
659            // no more comments, we're done
660            $i = $len;
661            break;
662        }
663
664        // keep any quoted string that starts before a comment
665        $nextsqt = strpos($line, "'", $i);
666        $nextdqt = strpos($line, '"', $i);
667        if(min($nextsqt, $nextdqt) < $nextcom) {
668            $skipto = false;
669            if($nextsqt !== false && ($nextdqt === false || $nextsqt < $nextdqt)) {
670                $skipto = strpos($line, "'", $nextsqt+1) +1;
671            } else if ($nextdqt !== false) {
672                $skipto = strpos($line, '"', $nextdqt+1) +1;
673            }
674
675            if($skipto !== false) {
676                $i = $skipto;
677                continue;
678            }
679        }
680
681        if($nexturl === false || $nextcom < $nexturl) {
682            // no url anymore, strip comment and be done
683            $i = $nextcom;
684            break;
685        }
686
687        // we have an upcoming url
688        $i = strpos($line, ')', $nexturl);
689    }
690
691    return substr($line, 0, $i);
692}
693
694//Setup VIM: ex: et ts=4 :
695