]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/CachedMarkup.php
Let us put some abstraction
[SourceForge/phpwiki.git] / lib / CachedMarkup.php
1 <?php
2
3 /* Copyright (C) 2002 Geoffrey T. Dairiki <dairiki@dairiki.org>
4  * Copyright (C) 2004-2010 $ThePhpWikiProgrammingTeam
5  * Copyright (C) 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
6  *
7  * This file is part of PhpWiki.
8  *
9  * PhpWiki is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * PhpWiki is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24 require_once 'lib/Units.php';
25
26 class CacheableMarkup extends XmlContent
27 {
28
29     function __construct($content, $basepage)
30     {
31         $this->_basepage = $basepage;
32         $this->_buf = '';
33         $this->_content = array();
34         $this->_append($content);
35         if ($this->_buf != '')
36             $this->_content[] = $this->_buf;
37         unset($this->_buf);
38     }
39
40     function pack()
41     {
42         // FusionForge hack
43         // This causes a strange bug when a comment containing
44         // a single quote is entered in the Summary box:
45         // - the history is wrong (user and comment missing)
46         // - the table of contents plugin no longer works
47         global $WikiTheme;
48         if (isa($WikiTheme, 'WikiTheme_fusionforge')) {
49             return serialize($this);
50         }
51
52         return gzcompress(serialize($this), 9);
53     }
54
55     function unpack($packed)
56     {
57         if (!$packed)
58             return false;
59
60         // ZLIB format has a five bit checksum in it's header.
61         // Lets check for sanity.
62         if (((ord($packed[0]) * 256 + ord($packed[1])) % 31 == 0)
63             and (substr($packed, 0, 2) == "\037\213")
64             or (substr($packed, 0, 2) == "x\332")
65         ) // 120, 218
66         {
67             // Looks like ZLIB.
68             $data = gzuncompress($packed);
69             return unserialize($data);
70         }
71         if (substr($packed, 0, 2) == "O:") {
72             // Looks like a serialized object
73             return unserialize($packed);
74         }
75         if (preg_match("/^\w+$/", $packed))
76             return $packed;
77         // happened with DebugBackendInfo problem also.
78         trigger_error("Can't unpack bad cached markup. Probably php_zlib extension not loaded.",
79             E_USER_WARNING);
80         return false;
81     }
82
83     /** Get names of wikipages linked to.
84      *
85      * @return array of hashes { linkto=>pagename, relation=>pagename }
86      */
87     function getWikiPageLinks()
88     {
89         $links = array();
90         foreach ($this->_content as $item) {
91             if (!isa($item, 'Cached_DynamicContent'))
92                 continue;
93             if (!($item_links = $item->getWikiPageLinks($this->_basepage)))
94                 continue;
95             $links = array_merge($links, $item_links);
96         }
97         // array_unique has a bug with hashes!
98         // set_links checks for duplicates, array_merge does not
99         //return array_unique($links);
100         return $links;
101     }
102
103     /** Get link info.
104      *
105      * This is here to support the XML-RPC listLinks() method.
106      *
107      * @return array
108      * Returns an array of hashes.
109      */
110     function getLinkInfo()
111     {
112         foreach ($this->_content as $link) {
113             if (!isa($link, 'Cached_Link'))
114                 continue;
115             $info = $link->getLinkInfo($this->_basepage);
116             $links[$info->href] = $info;
117         }
118         return array_values($links);
119     }
120
121     function _append($item)
122     {
123         if (is_array($item)) {
124             foreach ($item as $subitem)
125                 $this->_append($subitem);
126         } elseif (!is_object($item)) {
127             $this->_buf .= $this->_quote((string)$item);
128         } elseif (isa($item, 'Cached_DynamicContent')) {
129             if ($this->_buf) {
130                 $this->_content[] = $this->_buf;
131                 $this->_buf = '';
132             }
133             $this->_content[] = $item;
134         } elseif (isa($item, 'XmlElement')) {
135             if ($item->isEmpty()) {
136                 $this->_buf .= $item->emptyTag();
137             } else {
138                 $this->_buf .= $item->startTag();
139                 foreach ($item->getContent() as $subitem)
140                     $this->_append($subitem);
141                 $this->_buf .= "</$item->_tag>";
142
143                 if (!$this->getDescription() and $item->getTag() == 'p') {
144                     // performance: when is this really needed?
145                     $this->_glean_description($item->asString());
146                 }
147             }
148             if (!$item->isInlineElement())
149                 $this->_buf .= "\n";
150         } elseif (isa($item, 'XmlContent')) {
151             foreach ($item->getContent() as $item)
152                 $this->_append($item);
153         } elseif (method_exists($item, 'asXML')) {
154             $this->_buf .= $item->asXML();
155         } elseif (method_exists($item, 'asString')) {
156             $this->_buf .= $this->_quote($item->asString());
157         } else {
158             $this->_buf .= sprintf("==Object(%s)==", get_class($item));
159         }
160     }
161
162     function _glean_description($text)
163     {
164         static $two_sentences;
165         if (!$two_sentences) {
166             $two_sentences = "[.?!][\")]*\s+[\"(]*[[:upper:])]"
167                 . ".*"
168                 . "[.?!][\")]*\s*[\"(]*([[:upper:])]|$)";
169         }
170
171         if (!isset($this->_description) and preg_match("/$two_sentences/sx", $text))
172             $this->_description = preg_replace("/\s*\n\s*/", " ", trim($text));
173     }
174
175     /**
176      * Guess a short description of the page.
177      *
178      * Algorithm:
179      *
180      * This algorithm was suggested on MeatballWiki by
181      * Alex Schroeder <kensanata@yahoo.com>.
182      *
183      * Use the first paragraph in the page which contains at least two
184      * sentences.
185      *
186      * @see http://www.usemod.com/cgi-bin/mb.pl?MeatballWikiSuggestions
187      *
188      * @return string
189      */
190     function getDescription()
191     {
192         return isset($this->_description) ? $this->_description : '';
193     }
194
195     function asXML()
196     {
197         $xml = '';
198         $basepage = $this->_basepage;
199
200         foreach ($this->_content as $item) {
201             if (is_string($item)) {
202                 $xml .= $item;
203             } elseif (is_subclass_of($item, 'Cached_DynamicContent')
204             ) {
205                 $val = $item->expand($basepage, $this);
206                 $xml .= $val->asXML();
207             } else {
208                 $xml .= $item->asXML();
209             }
210         }
211         return $xml;
212     }
213
214     function printXML()
215     {
216         $basepage = $this->_basepage;
217         // _content might be changed from a plugin (CreateToc)
218         for ($i = 0; $i < count($this->_content); $i++) {
219             $item = $this->_content[$i];
220             if (is_string($item)) {
221                 print $item;
222             } elseif (is_subclass_of($item, 'Cached_DynamicContent')
223             ) { // give the content the chance to know about itself or even
224                 // to change itself
225                 $val = $item->expand($basepage, $this);
226                 if ($val) {
227                     $val->printXML();
228                 } else {
229                     if (DEBUG) {
230                         trigger_error('empty item ' . print_r($item, true));
231                     }
232                 }
233             } else {
234                 $item->printXML();
235             }
236         }
237     }
238 }
239
240 /**
241  * The base class for all dynamic content.
242  *
243  * Dynamic content is anything that can change even when the original
244  * wiki-text from which it was parsed is unchanged.
245  */
246 abstract class Cached_DynamicContent
247 {
248
249     function cache(&$cache)
250     {
251         $cache[] = $this;
252     }
253
254     abstract protected function expand($basepage, &$obj);
255
256     function getWikiPageLinks($basepage)
257     {
258         return false;
259     }
260 }
261
262 class XmlRpc_LinkInfo
263 {
264     function XmlRpc_LinkInfo($page, $type, $href, $relation = '')
265     {
266         $this->page = $page;
267         $this->type = $type;
268         $this->href = $href;
269         $this->relation = $relation;
270         //$this->pageref = str_replace("/RPC2.php", "/index.php", $href);
271     }
272 }
273
274 abstract class Cached_Link extends Cached_DynamicContent
275 {
276
277     function isInlineElement()
278     {
279         return true;
280     }
281
282     /** Get link info (for XML-RPC support)
283      *
284      * This is here to support the XML-RPC listLinks method.
285      * (See http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=WikiRPCInterface)
286      */
287     function getLinkInfo($basepage)
288     {
289         return new XmlRpc_LinkInfo($this->_getName($basepage),
290             $this->_getType(),
291             $this->_getURL($basepage),
292             $this->_getRelation($basepage));
293     }
294
295     function _getURL($basepage)
296     {
297         return $this->_url;
298     }
299
300     function __getRelation($basepage)
301     {
302         return $this->_relation;
303     }
304 }
305
306 /*
307  * Defer interwiki inline links. img src=upload:xx.png
308  * LinkImage($url, $alt = false)
309  */
310 class Cached_InlinedImage extends Cached_DynamicContent
311 {
312     function isInlineElement()
313     {
314         return true;
315     }
316
317     function _getURL($basepage)
318     {
319         return $this->_url;
320     }
321
322     // TODO: fix interwiki inline links in case of static dumps
323     function expand($basepage, &$markup)
324     {
325         global $WikiTheme;
326         $this->_basepage = $basepage;
327         $label = isset($this->_label) ? $this->_label : false;
328         if ($WikiTheme->DUMP_MODE) {
329             // In case of static dumps we need to check if we should
330             // inline the image or not: external: keep link, internal: copy locally
331             return LinkImage($label);
332         } else {
333             return LinkImage($label);
334         }
335     }
336 }
337
338 class Cached_WikiLink extends Cached_Link
339 {
340
341     function __construct($page, $label = false, $anchor = false)
342     {
343         $this->_page = $page;
344         /* ":DontStoreLink" */
345         if (substr($this->_page, 0, 1) == ':') {
346             $this->_page = substr($this->_page, 1);
347             $this->_nolink = true;
348         }
349         if ($anchor)
350             $this->_anchor = $anchor;
351         if ($label and $label != $page)
352             $this->_label = $label;
353         $this->_basepage = false;
354     }
355
356     function _getType()
357     {
358         return 'internal';
359     }
360
361     function getPagename($basepage)
362     {
363         $page = new WikiPageName($this->_page, $basepage);
364         if ($page->isValid()) return $page->name;
365         else return false;
366     }
367
368     function getWikiPageLinks($basepage)
369     {
370         if ($basepage == '') return false;
371         if (isset($this->_nolink)) return false;
372         if ($link = $this->getPagename($basepage))
373             return array(array('linkto' => $link));
374         else
375             return false;
376     }
377
378     function _getName($basepage)
379     {
380         return $this->getPagename($basepage);
381     }
382
383     function _getURL($basepage)
384     {
385         return WikiURL($this->getPagename($basepage));
386         //return WikiURL($this->getPagename($basepage), false, 'abs_url');
387     }
388
389     function expand($basepage, &$markup)
390     {
391         global $WikiTheme;
392         $this->_basepage = $basepage;
393         $label = isset($this->_label) ? $this->_label : false;
394         $anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
395         $page = new WikiPageName($this->_page, $basepage, $anchor);
396         if ($WikiTheme->DUMP_MODE and !empty($WikiTheme->VALID_LINKS)) {
397             if (!in_array($this->_page, $WikiTheme->VALID_LINKS))
398                 return HTML($label ? $label : $page->getName());
399         }
400         if ($page->isValid()) return WikiLink($page, 'auto', $label);
401         else return HTML($label);
402     }
403
404     function asXML()
405     {
406         global $WikiTheme;
407         $label = isset($this->_label) ? $this->_label : false;
408         $anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
409         //TODO: need basepage for subpages like /Remove (within CreateTOC)
410         $page = new WikiPageName($this->_page, $this->_basepage, $anchor);
411         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
412             if (!in_array($this->_page, $WikiTheme->VALID_LINKS))
413                 return $label ? $label : $page->getName();
414         }
415         $link = WikiLink($page, 'auto', $label);
416         return $link->asXML();
417     }
418
419     function asString()
420     {
421         if (isset($this->_label))
422             return $this->_label;
423         return $this->_page;
424     }
425 }
426
427 class Cached_WikiLinkIfKnown extends Cached_WikiLink
428 {
429     function __construct($moniker)
430     {
431         $this->_page = $moniker;
432     }
433
434     function expand($basepage, &$markup)
435     {
436         global $WikiTheme;
437         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
438             if (!in_array($this->_page, $WikiTheme->VALID_LINKS))
439                 return HTML($label ? $label : $page->getName());
440         }
441         return WikiLink($this->_page, 'if_known');
442     }
443 }
444
445 class Cached_SpellCheck extends Cached_WikiLink
446 {
447     function __construct($word, $suggs)
448     {
449         $this->_page = $word;
450         $this->suggestions = $suggs;
451     }
452
453     function expand($basepage, &$markup)
454     {
455         $link = HTML::a(array('class' => 'spell-wrong',
456                 'title' => 'SpellCheck: ' . join(', ', $this->suggestions),
457                 'name' => $this->_page),
458             $this->_page);
459         return $link;
460     }
461 }
462
463 class Cached_PhpwikiURL extends Cached_DynamicContent
464 {
465     function __construct($url, $label)
466     {
467         $this->_url = $url;
468         if ($label)
469             $this->_label = $label;
470     }
471
472     function isInlineElement()
473     {
474         return true;
475     }
476
477     function expand($basepage, &$markup)
478     {
479         global $WikiTheme;
480         $label = isset($this->_label) ? $this->_label : false;
481         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
482             if (!in_array($this->_page, $WikiTheme->VALID_LINKS))
483                 return HTML($label ? $label : $page->getName());
484         }
485         return LinkPhpwikiURL($this->_url, $label, $basepage);
486     }
487
488     function asXML()
489     {
490         $label = isset($this->_label) ? $this->_label : false;
491         $link = LinkPhpwikiURL($this->_url, $label);
492         return $link->asXML();
493     }
494
495     function asString()
496     {
497         if (isset($this->_label))
498             return $this->_label;
499         return $this->_url;
500     }
501 }
502
503 /*
504  * Relations (::) are named links to pages.
505  * Attributes (:=) are named metadata per page, "named links to numbers with units".
506  * We don't want to exhaust the linktable with numbers,
507  * since this would create empty pages per each value,
508  * so we don't store the attributes as full relationlink.
509  * But we do store the attribute name as relation with an empty pagename
510  * to denote that this is an attribute,
511  * and to enable a fast listRelations mode=attributes
512  */
513 class Cached_SemanticLink extends Cached_WikiLink
514 {
515
516     function __construct($url, $label = false)
517     {
518         $this->_url = $url;
519         if ($label && $label != $url)
520             $this->_label = $label;
521         $this->_expandurl($this->_url);
522     }
523
524     function isInlineElement()
525     {
526         return true;
527     }
528
529     function getPagename($basepage)
530     {
531         if (!isset($this->_page)) return false;
532         $page = new WikiPageName($this->_page, $basepage);
533         if ($page->isValid()) return $page->name;
534         else return false;
535     }
536
537     /* Add relation to the link table.
538      * attributes have the _relation, but not the _page set.
539      */
540     function getWikiPageLinks($basepage)
541     {
542         if ($basepage == '') return false;
543         if (!isset($this->_page) and isset($this->_attribute)) {
544             // An attribute: we store it in the basepage now, to fill the cache for page->save
545             // TODO: side-effect free query
546             $page = $GLOBALS['request']->getPage($basepage);
547             $page->setAttribute($this->_relation, $this->_attribute);
548             $this->_page = $basepage;
549             return array(array('linkto' => '', 'relation' => $this->_relation));
550         }
551         if ($link = $this->getPagename($basepage))
552             return array(array('linkto' => $link, 'relation' => $this->_relation));
553         else
554             return false;
555     }
556
557     function _expandurl($url)
558     {
559         $m = array();
560         if (!preg_match('/^ ([^:]+) (:[:=]) (.+) $/x', $url, $m)) {
561             return HTML::span(array('class' => 'error'), _("BAD semantic relation link"));
562         }
563         $this->_relation = urldecode($m[1]);
564         $is_attribute = ($m[2] == ':=');
565         if ($is_attribute) {
566             $this->_attribute = urldecode($m[3]);
567             // since this stored in the markup cache, we are extra sensible
568             // not to store false empty stuff.
569             $units = new Units();
570             if (!DISABLE_UNITS and !$units->errcode) {
571                 $this->_attribute_base = $units->Definition($this->_attribute);
572                 $this->_unit = $units->baseunit($this->_attribute);
573             }
574         } else {
575             $this->_page = urldecode($m[3]);
576         }
577         return $m;
578     }
579
580     function _expand($url, $label = false)
581     {
582         global $WikiTheme;
583         $m = $this->_expandurl($url);
584         $class = 'wiki';
585         // do not link to the attribute value, but to the attribute
586         $is_attribute = ($m[2] == ':=');
587         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
588             if (isset($this->_page) and !in_array($this->_page, $WikiTheme->VALID_LINKS))
589                 return HTML($label ? $label : ($is_attribute ? $this->_relation : $this->_page));
590         }
591         if ($is_attribute)
592             $title = isset($this->_attribute_base)
593                 ? sprintf(_("Attribute %s, base value: %s"), $this->_relation, $this->_attribute_base)
594                 : sprintf(_("Attribute %s, value: %s"), $this->_relation, $this->_attribute);
595         if ($label) {
596             return HTML::span(
597                 HTML::a(array('href' => WikiURL($is_attribute ? $this->_relation : $this->_page),
598                         'class' => "wiki " . ($is_attribute ? "attribute" : "relation"),
599                         'title' => $is_attribute
600                             ? $title
601                             : sprintf(_("Relation %s to page %s"), $this->_relation, $this->_page)),
602                     $label)
603             );
604         } elseif ($is_attribute) {
605             return HTML::span
606             (
607                 HTML::a(array('href' => WikiURL($this->_relation),
608                         'class' => "wiki attribute",
609                         'title' => $title),
610                     $url)
611             );
612         } else {
613             return HTML::span
614             (
615                 HTML::a(array('href' => WikiURL($this->_relation),
616                         'class' => "wiki relation"),
617                     $this->_relation),
618                 HTML::span(array('class' => 'relation-symbol'), $m[2]),
619                 HTML::a(array('href' => WikiURL($this->_page),
620                         'class' => "wiki"),
621                     $this->_page)
622             );
623         }
624     }
625
626     function expand($basepage, &$markup)
627     {
628         $label = isset($this->_label) ? $this->_label : false;
629         return $this->_expand($this->_url, $label);
630     }
631
632     function asXML()
633     {
634         $label = isset($this->_label) ? $this->_label : false;
635         $link = $this->_expand($this->_url, $label);
636         return $link->asXML();
637     }
638
639     function asString()
640     {
641         if (isset($this->_label))
642             return $this->_label;
643         return $this->_url;
644     }
645 }
646
647 /**
648  * Highlight found search engine terms
649  */
650 class Cached_SearchHighlight extends Cached_DynamicContent
651 {
652     function __construct($word, $engine)
653     {
654         $this->_word = $word;
655         $this->engine = $engine;
656     }
657
658     function expand($basepage, &$markup)
659     {
660         return HTML::span(array('class' => 'search-term',
661                 'title' => _("Found by ") . $this->engine),
662             $this->_word);
663     }
664 }
665
666 class Cached_ExternalLink extends Cached_Link
667 {
668
669     function __construct($url, $label = false)
670     {
671         $this->_url = $url;
672         if ($label && $label != $url)
673             $this->_label = $label;
674     }
675
676     function _getType()
677     {
678         return 'external';
679     }
680
681     function _getName($basepage)
682     {
683         $label = isset($this->_label) ? $this->_label : false;
684         return ($label and is_string($label)) ? $label : $this->_url;
685     }
686
687     function expand($basepage, &$markup)
688     {
689         global $request;
690
691         $label = isset($this->_label) ? $this->_label : false;
692         $link = LinkURL($this->_url, $label);
693
694         if (GOOGLE_LINKS_NOFOLLOW) {
695             // Ignores nofollow when the user who saved the page was authenticated.
696             $page = $request->getPage($basepage);
697             $current = $page->getCurrentRevision(false);
698             if (!$current->get('author_id'))
699                 $link->setAttr('rel', 'nofollow');
700         }
701         return $link;
702     }
703
704     function asString()
705     {
706         if (isset($this->_label) and is_string($this->_label))
707             return $this->_label;
708         return $this->_url;
709     }
710 }
711
712 class Cached_InterwikiLink extends Cached_ExternalLink
713 {
714
715     function __construct($link, $label = false)
716     {
717         $this->_link = $link;
718         if ($label)
719             $this->_label = $label;
720     }
721
722     function getPagename($basepage)
723     {
724         list ($moniker, $page) = explode(":", $this->_link, 2);
725         $page = new WikiPageName($page, $basepage);
726         if ($page->isValid()) return $page->name;
727         else return false;
728     }
729
730     function getWikiPageLinks($basepage)
731     {
732         if ($basepage == '') return false;
733         /* ":DontStoreLink" */
734         if (substr($this->_link, 0, 1) == ':') return false;
735         /* store only links to valid pagenames */
736         $dbi = $GLOBALS['request']->getDbh();
737         if ($link = $this->getPagename($basepage) and $dbi->isWikiPage($link)) {
738             return array(array('linkto' => $link));
739         } else {
740             return false; // dont store external links
741         }
742     }
743
744     function _getName($basepage)
745     {
746         $label = isset($this->_label) ? $this->_label : false;
747         return ($label and is_string($label)) ? $label : $this->_link;
748     }
749
750     /* there may be internal interwiki links also */
751     function _getType()
752     {
753         return $this->getPagename(false) ? 'internal' : 'external';
754     }
755
756     function _getURL($basepage)
757     {
758         $link = $this->expand($basepage, $this);
759         return $link->getAttr('href');
760     }
761
762     function expand($basepage, &$markup)
763     {
764         global $WikiTheme;
765         $intermap = getInterwikiMap();
766         $label = isset($this->_label) ? $this->_label : false;
767         //FIXME: check Upload: inlined images
768         if ($WikiTheme->DUMP_MODE and !empty($WikiTheme->VALID_LINKS)) {
769             if (!in_array($this->_link, $WikiTheme->VALID_LINKS))
770                 return HTML($label ? $label : $this->_link);
771         }
772         return $intermap->link($this->_link, $label);
773     }
774
775     function asString()
776     {
777         if (isset($this->_label))
778             return $this->_label;
779         return $this->_link;
780     }
781 }
782
783 // Needed to put UserPages to backlinks. Special method to markup userpages with icons
784 // Thanks to PhpWiki:DanFr for finding this bug.
785 // Fixed since 1.3.8, prev. versions had no userpages in backlinks
786 class Cached_UserLink extends Cached_WikiLink
787 {
788     function expand($basepage, &$markup)
789     {
790         $label = isset($this->_label) ? $this->_label : false;
791         $anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
792         $page = new WikiPageName($this->_page, $basepage, $anchor);
793         $link = WikiLink($page, 'auto', $label);
794         // $link = HTML::a(array('href' => $PageName));
795         $link->setContent(PossiblyGlueIconToText('wikiuser', $this->_page));
796         $link->setAttr('class', 'wikiuser');
797         return $link;
798     }
799 }
800
801 /**
802  * 1.3.13: Previously stored was only _pi.
803  * A fresh generated cache has now ->name and ->args also.
804  * main::isActionPage only checks the raw content.
805  */
806 class Cached_PluginInvocation extends Cached_DynamicContent
807 {
808
809     function __construct($pi)
810     {
811         $this->_pi = $pi;
812         $loader = $this->_getLoader();
813         if (is_array($plugin_cmdline = $loader->parsePI($pi)) and $plugin_cmdline[1]) {
814             $this->pi_name = $plugin_cmdline[0]; // plugin, plugin-form, plugin-list
815             $this->name = $plugin_cmdline[1]->getName();
816             $this->args = $plugin_cmdline[2];
817         }
818     }
819
820     function setTightness($top, $bottom)
821     {
822     }
823
824     function isInlineElement()
825     {
826         return false;
827     }
828
829     function expand($basepage, &$markup)
830     {
831         $loader = $this->_getLoader();
832         $xml = $loader->expandPI($this->_pi, $GLOBALS['request'], $markup, $basepage);
833         return $xml;
834     }
835
836     function asString()
837     {
838         return $this->_pi;
839     }
840
841     function getWikiPageLinks($basepage)
842     {
843         $loader = $this->_getLoader();
844
845         return $loader->getWikiPageLinks($this->_pi, $basepage);
846     }
847
848     function & _getLoader()
849     {
850         static $loader = false;
851
852         if (!$loader) {
853             include_once 'lib/WikiPlugin.php';
854             $loader = new WikiPluginLoader();
855         }
856         return $loader;
857     }
858 }
859
860 // Local Variables:
861 // mode: php
862 // tab-width: 8
863 // c-basic-offset: 4
864 // c-hanging-comment-ender-p: nil
865 // indent-tabs-mode: nil
866 // End: