File: CachedMarkup.php

package info (click to toggle)
phpwiki 1.3.14-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 15,716 kB
  • ctags: 23,548
  • sloc: php: 88,295; sql: 1,476; sh: 1,378; perl: 765; makefile: 602; awk: 28
file content (806 lines) | stat: -rwxr-xr-x 24,931 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
<?php 
rcs_id('$Id: CachedMarkup.php,v 1.57 2007/05/28 20:13:46 rurban Exp $');
/* Copyright (C) 2002 Geoffrey T. Dairiki <dairiki@dairiki.org>
 * Copyright (C) 2004,2005,2006,2007 $ThePhpWikiProgrammingTeam
 *
 * This file is part of PhpWiki.
 * 
 * PhpWiki is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * PhpWiki is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with PhpWiki; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

include_once("lib/Units.php");

class CacheableMarkup extends XmlContent {

    function CacheableMarkup($content, $basepage) {
        $this->_basepage = $basepage;
	$this->_buf = '';
	$this->_content = array();
	$this->_append($content);
	if ($this->_buf != '')
	    $this->_content[] = $this->_buf;
	unset($this->_buf);
    }

    function pack() {
        if (function_exists('gzcompress'))
            return gzcompress(serialize($this), 9);
        return serialize($this);

        // FIXME: probably should implement some sort of "compression"
        //   when no gzcompress is available.
    }

    function unpack($packed) {
        if (!$packed)
            return false;

        // ZLIB format has a five bit checksum in it's header.
        // Lets check for sanity.
        if (((ord($packed[0]) * 256 + ord($packed[1])) % 31 == 0)
             and (substr($packed,0,2) == "\037\213") 
                  or (substr($packed,0,2) == "x\332"))   // 120, 218
        {
            if (function_exists('gzuncompress')) {
                // Looks like ZLIB.
                $data = gzuncompress($packed);
                return unserialize($data);
            } else {
                // user our php lib. TESTME
                include_once("ziplib.php");
                $zip = new ZipReader($packed);
                list(,$data,$attrib) = $zip->readFile();
                return unserialize($data);
            }
        }
        if (substr($packed,0,2) == "O:") {
            // Looks like a serialized object
            return unserialize($packed);
        }
        if (preg_match("/^\w+$/", $packed))
            return $packed;
        // happened with _BackendInfo problem also.
        trigger_error("Can't unpack bad cached markup. Probably php_zlib extension not loaded.", 
                      E_USER_WARNING);
        return false;
    }
    
    /** Get names of wikipages linked to.
     *
     * @return array of hashes { linkto=>pagename, relation=>pagename }
     */
    function getWikiPageLinks() {
	$links = array();
	foreach ($this->_content as $item) {
	    if (!isa($item, 'Cached_DynamicContent'))
                continue;
            if (!($item_links = $item->getWikiPageLinks($this->_basepage)))
                continue;
            $links = array_merge($links, $item_links);
        }
        // array_unique has a bug with hashes! 
        // set_links checks for duplicates, array_merge does not
	//return array_unique($links);
	return $links;
    }

    /** Get link info.
     *
     * This is here to support the XML-RPC listLinks() method.
     *
     * @return array
     * Returns an array of hashes.
     */
    function getLinkInfo() {
	$link = array();
	foreach ($this->_content as $link) {
	    if (! isa($link, 'Cached_Link'))
		continue;
	    $info = $link->getLinkInfo($this->_basepage);
	    $links[$info->href] = $info;
	}
	return array_values($links);
    }

    function _append($item) {
	if (is_array($item)) {
	    foreach ($item as $subitem)
		$this->_append($subitem);
	}
	elseif (!is_object($item)) {
	    $this->_buf .= $this->_quote((string) $item);
	}
	elseif (isa($item, 'Cached_DynamicContent')) {
	    if ($this->_buf) {
		$this->_content[] = $this->_buf;
		$this->_buf = '';
	    }
	    $this->_content[] = $item;
	}
	elseif (isa($item, 'XmlElement')) {
	    if ($item->isEmpty()) {
		$this->_buf .= $item->emptyTag();
	    }
	    else {
		$this->_buf .= $item->startTag();
		foreach ($item->getContent() as $subitem)
		    $this->_append($subitem);
		$this->_buf .= "</$item->_tag>";

                if (!isset($this->_description) and $item->getTag() == 'p')
                    $this->_glean_description($item->asString());
	    }
	    if (!$item->isInlineElement())
		$this->_buf .= "\n";
	}
	elseif (isa($item, 'XmlContent')) {
	    foreach ($item->getContent() as $item)
		$this->_append($item);
	}
	elseif (method_exists($item, 'asXML')) {
	    $this->_buf .= $item->asXML();
	}
	elseif (method_exists($item, 'asString')) {
	    $this->_buf .= $this->_quote($item->asString());
	}
	else {
	    $this->_buf .= sprintf("==Object(%s)==", get_class($item));
	}
    }

    function _glean_description($text) {
        static $two_sentences;
        if (!$two_sentences) {
            $two_sentences = pcre_fix_posix_classes("[.?!][\")]*\s+[\"(]*[[:upper:])]"
                                                    . ".*"
                                                    . "[.?!][\")]*\s*[\"(]*([[:upper:])]|$)");
        }
        
        if (!isset($this->_description) and preg_match("/$two_sentences/sx", $text))
            $this->_description = preg_replace("/\s*\n\s*/", " ", trim($text));
    }

    /**
     * Guess a short description of the page.
     *
     * Algorithm:
     *
     * This algorithm was suggested on MeatballWiki by
     * Alex Schroeder <kensanata@yahoo.com>.
     *
     * Use the first paragraph in the page which contains at least two
     * sentences.
     *
     * @see http://www.usemod.com/cgi-bin/mb.pl?MeatballWikiSuggestions
     *
     * @return string
     */
    function getDescription () {
        return isset($this->_description) ? $this->_description : '';
    }
    
    function asXML () {
	$xml = '';
        $basepage = $this->_basepage;
        
	foreach ($this->_content as $item) {
            if (is_string($item)) {
                $xml .= $item;
            }
            elseif (is_subclass_of($item, 
                                   check_php_version(5) 
                                     ? 'Cached_DynamicContent' 
                                     : 'cached_dynamiccontent'))
            {
                $val = $item->expand($basepage, $this);
                $xml .= $val->asXML();
            }
            else {
                $xml .= $item->asXML();
            }
	}
	return $xml;
    }

    function printXML () {
        $basepage = $this->_basepage;
        // _content might be changed from a plugin (CreateToc)
	for ($i=0; $i < count($this->_content); $i++) {
	    $item = $this->_content[$i];
            if (is_string($item)) {
                print $item;
            }
            elseif (is_subclass_of($item, 
                                   check_php_version(5) 
                                     ? 'Cached_DynamicContent' 
                                     : 'cached_dynamiccontent')) 
            {  	// give the content the chance to know about itself or even 
            	// to change itself
                $val = $item->expand($basepage, $this);
                $val->printXML();
            }
            else {
                $item->printXML();
            }
	}
    }
}	

/**
 * The base class for all dynamic content.
 *
 * Dynamic content is anything that can change even when the original
 * wiki-text from which it was parsed is unchanged.
 */
class Cached_DynamicContent {

    function cache(&$cache) {
	$cache[] = $this;
    }

    function expand($basepage, &$obj) {
        trigger_error("Pure virtual", E_USER_ERROR);
    }

    function getWikiPageLinks($basepage) {
        return false;
    }
}

class XmlRpc_LinkInfo {
    function XmlRpc_LinkInfo($page, $type, $href, $relation = '') {
	$this->page = $page;
	$this->type = $type;
	$this->href = $href;
	$this->relation = $relation;
	//$this->pageref = str_replace("/RPC2.php", "/index.php", $href);
    }
}

class Cached_Link extends Cached_DynamicContent {

    function isInlineElement() {
	return true;
    }

    /** Get link info (for XML-RPC support)
     *
     * This is here to support the XML-RPC listLinks method.
     * (See http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=WikiRPCInterface)
     */
    function getLinkInfo($basepage) {
	return new XmlRpc_LinkInfo($this->_getName($basepage),
                                   $this->_getType(),
                                   $this->_getURL($basepage),
                                   $this->_getRelation($basepage));
    }
    
    function _getURL($basepage) {
	return $this->_url;
    }
    function __getRelation($basepage) {
	return $this->_relation;
    }
}

class Cached_WikiLink extends Cached_Link {

    function Cached_WikiLink ($page, $label = false, $anchor = false) {
	$this->_page = $page;
	/* ":DontStoreLink" */
	if (substr($this->_page,0,1) == ':') {
	    $this->_page = substr($this->_page,1);
	    $this->_nolink = true;
        }    
        if ($anchor)
            $this->_anchor = $anchor;
        if ($label and $label != $page)
            $this->_label = $label;
        $this->_basepage = false;    
    }

    function _getType() {
        return 'internal';
    }
    
    function getPagename($basepage) {
        $page = new WikiPageName($this->_page, $basepage);
	if ($page->isValid()) return $page->name;
	else return false;
    }

    function getWikiPageLinks($basepage) {
        if ($basepage == '') return false;
	if (isset($this->_nolink)) return false;
        if ($link = $this->getPagename($basepage)) 
            return array(array('linkto' => $link, 'relation' => 0));
        else 
            return false;
    }

    function _getName($basepage) {
	return $this->getPagename($basepage);
    }

    function _getURL($basepage) {
	return WikiURL($this->getPagename($basepage));
	//return WikiURL($this->getPagename($basepage), false, 'abs_url');
    }

    function expand($basepage, &$markup) {
    	$this->_basepage = $basepage;
	$label = isset($this->_label) ? $this->_label : false;
	$anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
        $page = new WikiPageName($this->_page, $basepage, $anchor);
        if ($page->isValid()) return WikiLink($page, 'auto', $label);
	else return HTML($label);
    }

    function asXML() {
	$label = isset($this->_label) ? $this->_label : false;
	$anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
	//TODO: need basepage for subpages like /Remove (within CreateTOC)
        $page = new WikiPageName($this->_page, $this->_basepage, $anchor);
	$link = WikiLink($page, 'auto', $label);
        return $link->asXML();
    }

    function asString() {
        if (isset($this->_label))
            return $this->_label;
        return $this->_page;
    }
}

class Cached_WikiLinkIfKnown extends Cached_WikiLink
{
    function Cached_WikiLinkIfKnown ($moniker) {
	$this->_page = $moniker;
    }

    function expand($basepage, &$markup) {
        return WikiLink($this->_page, 'if_known');
    }
}    

class Cached_SpellCheck extends Cached_WikiLink
{
    function Cached_SpellCheck ($word, $suggs) {
	$this->_page = $word;
	$this->suggestions = $suggs;
    }

    function expand($basepage, &$markup) {
        $link = HTML::a(array('class' => 'spell-wrong', 
			      'title' => 'SpellCheck: '.join(', ', $this->suggestions),
			      'name' => $this->_page), 
			$this->_page);
        return $link;
    }
}    
    
class Cached_PhpwikiURL extends Cached_DynamicContent
{
    function Cached_PhpwikiURL ($url, $label) {
	$this->_url = $url;
        if ($label)
            $this->_label = $label;
    }

    function isInlineElement() {
	return true;
    }

    function expand($basepage, &$markup) {
        $label = isset($this->_label) ? $this->_label : false;
        return LinkPhpwikiURL($this->_url, $label, $basepage);
    }

    function asXML() {
        $label = isset($this->_label) ? $this->_label : false;
        $link = LinkPhpwikiURL($this->_url, $label);
        return $link->asXML();
    }

    function asString() {
        if (isset($this->_label))
            return $this->_label;
        return $this->_url;
    }
}    

/*
 * Relations (::) are named links to pages.
 * Attributes (:=) are named metadata per page, "named links to numbers with units". 
 * We don't want to exhaust the linktable with numbers,
 * since this would create empty pages per each value, 
 * so we don't store the attributes as full relationlink. 
 * But we do store the attribute name as relation with an empty pagename 
 * to denote that this is an attribute, 
 * and to enable a fast listRelations mode=attributes
 */
class Cached_SemanticLink extends Cached_WikiLink {

    function Cached_SemanticLink ($url, $label=false) {
	$this->_url = $url;
        if ($label && $label != $url)
            $this->_label = $label;
        $this->_expandurl($this->_url);
    }

    function isInlineElement() {
	return true;
    }

    function getPagename($basepage) {
	if (!isset($this->_page)) return false;
	$page = new WikiPageName($this->_page, $basepage);
	if ($page->isValid()) return $page->name;
	else return false;
    }

    /* Add relation to the link table.
     * attributes have the _relation, but not the _page set.
     */
    function getWikiPageLinks($basepage) {
        if ($basepage == '') return false;
	if (!isset($this->_page) and isset($this->_attribute)) {
            // An attribute: we store it in the basepage now, to fill the cache for page->save
            // TODO: side-effect free query
            $page = $GLOBALS['request']->getPage($basepage); 
            $page->setAttribute($this->_relation, $this->_attribute);
            $this->_page = $basepage;
            return array(array('linkto' => '', 'relation' => $this->_relation));
	}
        if ($link = $this->getPagename($basepage)) 
            return array(array('linkto' => $link, 'relation' => $this->_relation));
        else
            return false;
    }

    function _expandurl($url) {
        $m = array();
        if (!preg_match('/^ ([^:]+) (:[:=]) (.+) $/x', $url, $m)) {
            return HTML::strong(array('class' => 'rawurl'),
                                HTML::u(array('class' => 'baduri'),
                                        _("BAD semantic relation link")));
        }
	$this->_relation = urldecode($m[1]);
        $is_attribute = ($m[2] == ':=');
        if ($is_attribute) {
            $this->_attribute = urldecode($m[3]);
	    // since this stored in the markup cache, we are extra sensible 
	    // not to store false empty stuff.
	    $units = new Units();
            if (!DISABLE_UNITS and !$units->errcode) 
	    {
		$this->_attribute_base = $units->Definition($this->_attribute);
		$this->_unit = $units->baseunit($this->_attribute);
	    }
        } else {
	    $this->_page = urldecode($m[3]);
        }
	return $m;
    }

    function _expand($url, $label = false) {
	$m = $this->_expandurl($url);
        $class = 'wiki';
        // do not link to the attribute value, but to the attribute
        $is_attribute = ($m[2] == ':=');
	if ($is_attribute)
	    $title = isset($this->_attribute_base)
		? sprintf(_("Attribute %s, base value: %s"), $this->_relation, $this->_attribute_base)
		: sprintf(_("Attribute %s, value: %s"), $this->_relation, $this->_attribute);
        if ($label) {
            return HTML::span
		(
		 HTML::a(array('href'  => WikiURL($is_attribute ? $this->_relation : $this->_page),
			       'class' => "wiki ".($is_attribute ? "attribute" : "relation"),
			       'title' => $is_attribute 
			       ? $title 
			       : sprintf(_("Relation %s to page %s"), $this->_relation, $this->_page)),
			 $label)
		 );
        } elseif ($is_attribute) {
            return HTML::span
		(
		 HTML::a(array('href'  => WikiURL($this->_relation),
			       'class' => "wiki attribute",
			       'title' => $title),
			 $url)
		 );
        } else {
            return HTML::span
		(
		 HTML::a(array('href'  => WikiURL($this->_relation),
			       'class' => "wiki relation"),
			 $this->_relation),
		 HTML::span(array('class'=>'relation-symbol'), $m[2]),
		 HTML::a(array('href'  => WikiURL($this->_page),
			       'class' => "wiki"),
			 $this->_page)
		 );
        }
    }

    function expand($basepage, &$markup) {
        $label = isset($this->_label) ? $this->_label : false;
        return $this->_expand($this->_url, $label);
    }

    function asXML() {
        $label = isset($this->_label) ? $this->_label : false;
        $link = $this->_expand($this->_url, $label);
        return $link->asXML();
    }

    function asString() {
        if (isset($this->_label))
            return $this->_label;
        return $this->_url;
    }
}

/** 
 * Highlight found search engine terms
 */
class Cached_SearchHighlight extends Cached_DynamicContent
{
    function Cached_SearchHighlight ($word, $engine) {
	$this->_word = $word;
	$this->engine = $engine;
    }

    function expand($basepage, &$markup) {
        return HTML::span(array('class' => 'search-term',
                                'title' => _("Found by ") . $this->engine),
                          $this->_word);
    }
}    
    
class Cached_ExternalLink extends Cached_Link {

    function Cached_ExternalLink($url, $label=false) {
	$this->_url = $url;
        if ($label && $label != $url)
            $this->_label = $label;
    }

    function _getType() {
        return 'external';
    }
    
    function _getName($basepage) {
	$label = isset($this->_label) ? $this->_label : false;
	return ($label and is_string($label)) ? $label : $this->_url;
    }

    function expand($basepage, &$markup) {
        global $request;

	$label = isset($this->_label) ? $this->_label : false;
	$link = LinkURL($this->_url, $label);

        if (GOOGLE_LINKS_NOFOLLOW) {
            // Ignores nofollow when the user who saved the page was authenticated. 
            $page = $request->getPage($basepage);
            $current = $page->getCurrentRevision(false);
            if (!$current->get('author_id'))
                $link->setAttr('rel', 'nofollow');
        }
        return $link;
    }

    function asString() {
        if (isset($this->_label))
            return $this->_label;
        return $this->_url;
    }
}

class Cached_InterwikiLink extends Cached_ExternalLink {
    
    function Cached_InterwikiLink($link, $label=false) {
	$this->_link = $link;
        if ($label)
            $this->_label = $label;
    }

    function getPagename($basepage) {
        list ($moniker, $page) = split (":", $this->_link, 2);
	$page = new WikiPageName($page, $basepage);
	if ($page->isValid()) return $page->name;
	else return false;
    }

    function getWikiPageLinks($basepage) {
        if ($basepage == '') return false;
	/* ":DontStoreLink" */
	if (substr($this->_link,0,1) == ':') return false;
	/* store only links to valid pagenames */
        if ($link = $this->getPagename($basepage)) 
            return array(array('linkto' => $link, 'relation' => 0));
        else return false; // dont store external links
    }

    function _getName($basepage) {
	$label = isset($this->_label) ? $this->_label : false;
	return ($label and is_string($label)) ? $label : $this->_link;
    }
    
    /* there may be internal interwiki links also */
    function _getType() {
        return $this->getPagename(false) ? 'internal' : 'external';
    }

    function _getURL($basepage) {
	$link = $this->expand($basepage, $this);
	return $link->getAttr('href');
    }

    function expand($basepage, &$markup) {
	$intermap = getInterwikiMap();
	$label = isset($this->_label) ? $this->_label : false;
	return $intermap->link($this->_link, $label);
    }

    function asString() {
        if (isset($this->_label))
            return $this->_label;
        return $this->_link;
    }
}

// Needed to put UserPages to backlinks. Special method to markup userpages with icons
// Thanks to PhpWiki:DanFr for finding this bug. 
// Fixed since 1.3.8, prev. versions had no userpages in backlinks
class Cached_UserLink extends Cached_WikiLink {
    function expand($basepage, &$markup) {
        $label = isset($this->_label) ? $this->_label : false;
	$anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
        $page = new WikiPageName($this->_page, $basepage, $anchor);
	$link = WikiLink($page, 'auto', $label);
        // $link = HTML::a(array('href' => $PageName));
        $link->setContent(PossiblyGlueIconToText('wikiuser', $this->_page));
        $link->setAttr('class', 'wikiuser');
        return $link;
    }
}

/**
 * 1.3.13: Previously stored was only _pi. 
 * A fresh generated cache has now ->name and ->args also.
 * main::isActionPage only checks the raw content.
 */
class Cached_PluginInvocation extends Cached_DynamicContent {

    function Cached_PluginInvocation ($pi) {
	$this->_pi = $pi;
	$loader = $this->_getLoader();
        if (is_array($plugin_cmdline = $loader->parsePI($pi)) and $plugin_cmdline[1]) {
            $this->pi_name = $plugin_cmdline[0]; // plugin, plugin-form, plugin-list, plugin-link
            $this->name = $plugin_cmdline[1]->getName();
            $this->args = $plugin_cmdline[2];
        }
    }

    function setTightness($top, $bottom) {
        $this->_tightenable = 0;
        if ($top) $this->_tightenable |= 1;
        if ($bottom) $this->_tightenable |= 2;
    }
    
    function isInlineElement() {
	return false;
    }

    function expand($basepage, &$markup) {
        $loader = $this->_getLoader();

        $xml = $loader->expandPI($this->_pi, $GLOBALS['request'], $markup, $basepage);
        $div = HTML::div(array('class' => 'plugin'));
        if (isset($this->name))
            $id = GenerateId($this->name . 'Plugin');
   
	if (isset($this->_tightenable)) {
	    if ($this->_tightenable == 3) {
                $span = HTML::span(array('class' => 'plugin'), $xml);
                if (!empty($id))
                    $span->setAttr('id', $id);
	        return $span;
            }
	    $div->setInClass('tightenable');
	    $div->setInClass('top', ($this->_tightenable & 1) != 0);
	    $div->setInClass('bottom', ($this->_tightenable & 2) != 0);
	}
        if (!empty($id))
            $div->setAttr('id', $id);
	$div->pushContent($xml);
	return $div;
    }

    function asString() {
        return $this->_pi;
    }


    function getWikiPageLinks($basepage) {
        $loader = $this->_getLoader();

        return $loader->getWikiPageLinks($this->_pi, $basepage);
    }

    function & _getLoader() {
        static $loader = false;

	if (!$loader) {
            include_once('lib/WikiPlugin.php');
	    $loader = new WikiPluginLoader;
        }
        return $loader;
    }
}

// $Log: CachedMarkup.php,v $
// Revision 1.57  2007/05/28 20:13:46  rurban
// Overwrite all attributes at once at page->save to delete dangling meta
//
// Revision 1.56  2007/04/08 16:39:40  rurban
// fix when DISABLE_UNITS = true (thanks to Walter Rafelsberger)
// simplify title calculation
//
// Revision 1.55  2007/03/18 17:35:14  rurban
// Fix :DontStoreLink
//
// Revision 1.54  2007/01/25 07:41:41  rurban
// Print attribute in title. Use CSS formatting for ::=
//
// Revision 1.53  2007/01/21 23:26:52  rurban
// Translate Found by
//
// Revision 1.52  2007/01/20 15:53:51  rurban
// Rewrite of SearchHighlight: through ActionPage and InlineParser
//
// Revision 1.51  2007/01/20 11:24:53  rurban
// add SpellCheck support
//
// Revision 1.50  2007/01/07 18:41:51  rurban
// Fix fallback ZipReader syntax error. Use label=false. Add parsed plugin names to the stored tree.
//
// Revision 1.49  2007/01/04 16:40:35  rurban
// Remove units object from CachedMarkup links, Store parsed linkinfo only: basevalue, baseunit.
//
// Revision 1.48  2007/01/03 21:22:08  rurban
// Use Units for attributes. Store the unified base value as Cached_SemanticLink->_attribute_base in the wikimarkup and display it as title.
//
// Revision 1.47  2007/01/02 13:17:57  rurban
// fix semantic page links and attributes, esp. attributes. they get stored as link to empty page also. tighten semantic url expander regex, omit want_content if not necessary
//
// Revision 1.46  2006/12/22 00:11:38  rurban
// add seperate expandurl method, to simplify pagename parsing
//
// Revision 1.45  2006/10/12 06:33:50  rurban
// decide later with which class to render this link (fixes interwiki link layout)

// (c-file-style: "gnu")
// Local Variables:
// mode: php
// tab-width: 8
// c-basic-offset: 4
// c-hanging-comment-ender-p: nil
// indent-tabs-mode: nil
// End:   
?>