]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/CachedMarkup.php
gzcompress, gzuncompress, gzinflate and gzopen exist
[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 class Cached_DynamicContent
247 {
248
249     function cache(&$cache)
250     {
251         $cache[] = $this;
252     }
253
254     function expand($basepage, &$obj)
255     {
256         trigger_error("Pure virtual", E_USER_ERROR);
257     }
258
259     function getWikiPageLinks($basepage)
260     {
261         return false;
262     }
263 }
264
265 class XmlRpc_LinkInfo
266 {
267     function XmlRpc_LinkInfo($page, $type, $href, $relation = '')
268     {
269         $this->page = $page;
270         $this->type = $type;
271         $this->href = $href;
272         $this->relation = $relation;
273         //$this->pageref = str_replace("/RPC2.php", "/index.php", $href);
274     }
275 }
276
277 class Cached_Link extends Cached_DynamicContent
278 {
279
280     function isInlineElement()
281     {
282         return true;
283     }
284
285     /** Get link info (for XML-RPC support)
286      *
287      * This is here to support the XML-RPC listLinks method.
288      * (See http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=WikiRPCInterface)
289      */
290     function getLinkInfo($basepage)
291     {
292         return new XmlRpc_LinkInfo($this->_getName($basepage),
293             $this->_getType(),
294             $this->_getURL($basepage),
295             $this->_getRelation($basepage));
296     }
297
298     function _getURL($basepage)
299     {
300         return $this->_url;
301     }
302
303     function __getRelation($basepage)
304     {
305         return $this->_relation;
306     }
307 }
308
309 /*
310  * Defer interwiki inline links. img src=upload:xx.png
311  * LinkImage($url, $alt = false)
312  */
313 class Cached_InlinedImage extends Cached_DynamicContent
314 {
315     function isInlineElement()
316     {
317         return true;
318     }
319
320     function _getURL($basepage)
321     {
322         return $this->_url;
323     }
324
325     // TODO: fix interwiki inline links in case of static dumps
326     function expand($basepage, &$markup)
327     {
328         global $WikiTheme;
329         $this->_basepage = $basepage;
330         $label = isset($this->_label) ? $this->_label : false;
331         if ($WikiTheme->DUMP_MODE) {
332             // In case of static dumps we need to check if we should
333             // inline the image or not: external: keep link, internal: copy locally
334             return LinkImage($label);
335         } else {
336             return LinkImage($label);
337         }
338     }
339 }
340
341 class Cached_WikiLink extends Cached_Link
342 {
343
344     function __construct($page, $label = false, $anchor = false)
345     {
346         $this->_page = $page;
347         /* ":DontStoreLink" */
348         if (substr($this->_page, 0, 1) == ':') {
349             $this->_page = substr($this->_page, 1);
350             $this->_nolink = true;
351         }
352         if ($anchor)
353             $this->_anchor = $anchor;
354         if ($label and $label != $page)
355             $this->_label = $label;
356         $this->_basepage = false;
357     }
358
359     function _getType()
360     {
361         return 'internal';
362     }
363
364     function getPagename($basepage)
365     {
366         $page = new WikiPageName($this->_page, $basepage);
367         if ($page->isValid()) return $page->name;
368         else return false;
369     }
370
371     function getWikiPageLinks($basepage)
372     {
373         if ($basepage == '') return false;
374         if (isset($this->_nolink)) return false;
375         if ($link = $this->getPagename($basepage))
376             return array(array('linkto' => $link));
377         else
378             return false;
379     }
380
381     function _getName($basepage)
382     {
383         return $this->getPagename($basepage);
384     }
385
386     function _getURL($basepage)
387     {
388         return WikiURL($this->getPagename($basepage));
389         //return WikiURL($this->getPagename($basepage), false, 'abs_url');
390     }
391
392     function expand($basepage, &$markup)
393     {
394         global $WikiTheme;
395         $this->_basepage = $basepage;
396         $label = isset($this->_label) ? $this->_label : false;
397         $anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
398         $page = new WikiPageName($this->_page, $basepage, $anchor);
399         if ($WikiTheme->DUMP_MODE and !empty($WikiTheme->VALID_LINKS)) {
400             if (!in_array($this->_page, $WikiTheme->VALID_LINKS))
401                 return HTML($label ? $label : $page->getName());
402         }
403         if ($page->isValid()) return WikiLink($page, 'auto', $label);
404         else return HTML($label);
405     }
406
407     function asXML()
408     {
409         global $WikiTheme;
410         $label = isset($this->_label) ? $this->_label : false;
411         $anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
412         //TODO: need basepage for subpages like /Remove (within CreateTOC)
413         $page = new WikiPageName($this->_page, $this->_basepage, $anchor);
414         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
415             if (!in_array($this->_page, $WikiTheme->VALID_LINKS))
416                 return $label ? $label : $page->getName();
417         }
418         $link = WikiLink($page, 'auto', $label);
419         return $link->asXML();
420     }
421
422     function asString()
423     {
424         if (isset($this->_label))
425             return $this->_label;
426         return $this->_page;
427     }
428 }
429
430 class Cached_WikiLinkIfKnown extends Cached_WikiLink
431 {
432     function __construct($moniker)
433     {
434         $this->_page = $moniker;
435     }
436
437     function expand($basepage, &$markup)
438     {
439         global $WikiTheme;
440         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
441             if (!in_array($this->_page, $WikiTheme->VALID_LINKS))
442                 return HTML($label ? $label : $page->getName());
443         }
444         return WikiLink($this->_page, 'if_known');
445     }
446 }
447
448 class Cached_SpellCheck extends Cached_WikiLink
449 {
450     function __construct($word, $suggs)
451     {
452         $this->_page = $word;
453         $this->suggestions = $suggs;
454     }
455
456     function expand($basepage, &$markup)
457     {
458         $link = HTML::a(array('class' => 'spell-wrong',
459                 'title' => 'SpellCheck: ' . join(', ', $this->suggestions),
460                 'name' => $this->_page),
461             $this->_page);
462         return $link;
463     }
464 }
465
466 class Cached_PhpwikiURL extends Cached_DynamicContent
467 {
468     function __construct($url, $label)
469     {
470         $this->_url = $url;
471         if ($label)
472             $this->_label = $label;
473     }
474
475     function isInlineElement()
476     {
477         return true;
478     }
479
480     function expand($basepage, &$markup)
481     {
482         global $WikiTheme;
483         $label = isset($this->_label) ? $this->_label : false;
484         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
485             if (!in_array($this->_page, $WikiTheme->VALID_LINKS))
486                 return HTML($label ? $label : $page->getName());
487         }
488         return LinkPhpwikiURL($this->_url, $label, $basepage);
489     }
490
491     function asXML()
492     {
493         $label = isset($this->_label) ? $this->_label : false;
494         $link = LinkPhpwikiURL($this->_url, $label);
495         return $link->asXML();
496     }
497
498     function asString()
499     {
500         if (isset($this->_label))
501             return $this->_label;
502         return $this->_url;
503     }
504 }
505
506 /*
507  * Relations (::) are named links to pages.
508  * Attributes (:=) are named metadata per page, "named links to numbers with units".
509  * We don't want to exhaust the linktable with numbers,
510  * since this would create empty pages per each value,
511  * so we don't store the attributes as full relationlink.
512  * But we do store the attribute name as relation with an empty pagename
513  * to denote that this is an attribute,
514  * and to enable a fast listRelations mode=attributes
515  */
516 class Cached_SemanticLink extends Cached_WikiLink
517 {
518
519     function __construct($url, $label = false)
520     {
521         $this->_url = $url;
522         if ($label && $label != $url)
523             $this->_label = $label;
524         $this->_expandurl($this->_url);
525     }
526
527     function isInlineElement()
528     {
529         return true;
530     }
531
532     function getPagename($basepage)
533     {
534         if (!isset($this->_page)) return false;
535         $page = new WikiPageName($this->_page, $basepage);
536         if ($page->isValid()) return $page->name;
537         else return false;
538     }
539
540     /* Add relation to the link table.
541      * attributes have the _relation, but not the _page set.
542      */
543     function getWikiPageLinks($basepage)
544     {
545         if ($basepage == '') return false;
546         if (!isset($this->_page) and isset($this->_attribute)) {
547             // An attribute: we store it in the basepage now, to fill the cache for page->save
548             // TODO: side-effect free query
549             $page = $GLOBALS['request']->getPage($basepage);
550             $page->setAttribute($this->_relation, $this->_attribute);
551             $this->_page = $basepage;
552             return array(array('linkto' => '', 'relation' => $this->_relation));
553         }
554         if ($link = $this->getPagename($basepage))
555             return array(array('linkto' => $link, 'relation' => $this->_relation));
556         else
557             return false;
558     }
559
560     function _expandurl($url)
561     {
562         $m = array();
563         if (!preg_match('/^ ([^:]+) (:[:=]) (.+) $/x', $url, $m)) {
564             return HTML::span(array('class' => 'error'), _("BAD semantic relation link"));
565         }
566         $this->_relation = urldecode($m[1]);
567         $is_attribute = ($m[2] == ':=');
568         if ($is_attribute) {
569             $this->_attribute = urldecode($m[3]);
570             // since this stored in the markup cache, we are extra sensible
571             // not to store false empty stuff.
572             $units = new Units();
573             if (!DISABLE_UNITS and !$units->errcode) {
574                 $this->_attribute_base = $units->Definition($this->_attribute);
575                 $this->_unit = $units->baseunit($this->_attribute);
576             }
577         } else {
578             $this->_page = urldecode($m[3]);
579         }
580         return $m;
581     }
582
583     function _expand($url, $label = false)
584     {
585         global $WikiTheme;
586         $m = $this->_expandurl($url);
587         $class = 'wiki';
588         // do not link to the attribute value, but to the attribute
589         $is_attribute = ($m[2] == ':=');
590         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
591             if (isset($this->_page) and !in_array($this->_page, $WikiTheme->VALID_LINKS))
592                 return HTML($label ? $label : ($is_attribute ? $this->_relation : $this->_page));
593         }
594         if ($is_attribute)
595             $title = isset($this->_attribute_base)
596                 ? sprintf(_("Attribute %s, base value: %s"), $this->_relation, $this->_attribute_base)
597                 : sprintf(_("Attribute %s, value: %s"), $this->_relation, $this->_attribute);
598         if ($label) {
599             return HTML::span(
600                 HTML::a(array('href' => WikiURL($is_attribute ? $this->_relation : $this->_page),
601                         'class' => "wiki " . ($is_attribute ? "attribute" : "relation"),
602                         'title' => $is_attribute
603                             ? $title
604                             : sprintf(_("Relation %s to page %s"), $this->_relation, $this->_page)),
605                     $label)
606             );
607         } elseif ($is_attribute) {
608             return HTML::span
609             (
610                 HTML::a(array('href' => WikiURL($this->_relation),
611                         'class' => "wiki attribute",
612                         'title' => $title),
613                     $url)
614             );
615         } else {
616             return HTML::span
617             (
618                 HTML::a(array('href' => WikiURL($this->_relation),
619                         'class' => "wiki relation"),
620                     $this->_relation),
621                 HTML::span(array('class' => 'relation-symbol'), $m[2]),
622                 HTML::a(array('href' => WikiURL($this->_page),
623                         'class' => "wiki"),
624                     $this->_page)
625             );
626         }
627     }
628
629     function expand($basepage, &$markup)
630     {
631         $label = isset($this->_label) ? $this->_label : false;
632         return $this->_expand($this->_url, $label);
633     }
634
635     function asXML()
636     {
637         $label = isset($this->_label) ? $this->_label : false;
638         $link = $this->_expand($this->_url, $label);
639         return $link->asXML();
640     }
641
642     function asString()
643     {
644         if (isset($this->_label))
645             return $this->_label;
646         return $this->_url;
647     }
648 }
649
650 /**
651  * Highlight found search engine terms
652  */
653 class Cached_SearchHighlight extends Cached_DynamicContent
654 {
655     function __construct($word, $engine)
656     {
657         $this->_word = $word;
658         $this->engine = $engine;
659     }
660
661     function expand($basepage, &$markup)
662     {
663         return HTML::span(array('class' => 'search-term',
664                 'title' => _("Found by ") . $this->engine),
665             $this->_word);
666     }
667 }
668
669 class Cached_ExternalLink extends Cached_Link
670 {
671
672     function __construct($url, $label = false)
673     {
674         $this->_url = $url;
675         if ($label && $label != $url)
676             $this->_label = $label;
677     }
678
679     function _getType()
680     {
681         return 'external';
682     }
683
684     function _getName($basepage)
685     {
686         $label = isset($this->_label) ? $this->_label : false;
687         return ($label and is_string($label)) ? $label : $this->_url;
688     }
689
690     function expand($basepage, &$markup)
691     {
692         global $request;
693
694         $label = isset($this->_label) ? $this->_label : false;
695         $link = LinkURL($this->_url, $label);
696
697         if (GOOGLE_LINKS_NOFOLLOW) {
698             // Ignores nofollow when the user who saved the page was authenticated.
699             $page = $request->getPage($basepage);
700             $current = $page->getCurrentRevision(false);
701             if (!$current->get('author_id'))
702                 $link->setAttr('rel', 'nofollow');
703         }
704         return $link;
705     }
706
707     function asString()
708     {
709         if (isset($this->_label) and is_string($this->_label))
710             return $this->_label;
711         return $this->_url;
712     }
713 }
714
715 class Cached_InterwikiLink extends Cached_ExternalLink
716 {
717
718     function __construct($link, $label = false)
719     {
720         $this->_link = $link;
721         if ($label)
722             $this->_label = $label;
723     }
724
725     function getPagename($basepage)
726     {
727         list ($moniker, $page) = explode(":", $this->_link, 2);
728         $page = new WikiPageName($page, $basepage);
729         if ($page->isValid()) return $page->name;
730         else return false;
731     }
732
733     function getWikiPageLinks($basepage)
734     {
735         if ($basepage == '') return false;
736         /* ":DontStoreLink" */
737         if (substr($this->_link, 0, 1) == ':') return false;
738         /* store only links to valid pagenames */
739         $dbi = $GLOBALS['request']->getDbh();
740         if ($link = $this->getPagename($basepage) and $dbi->isWikiPage($link)) {
741             return array(array('linkto' => $link));
742         } else {
743             return false; // dont store external links
744         }
745     }
746
747     function _getName($basepage)
748     {
749         $label = isset($this->_label) ? $this->_label : false;
750         return ($label and is_string($label)) ? $label : $this->_link;
751     }
752
753     /* there may be internal interwiki links also */
754     function _getType()
755     {
756         return $this->getPagename(false) ? 'internal' : 'external';
757     }
758
759     function _getURL($basepage)
760     {
761         $link = $this->expand($basepage, $this);
762         return $link->getAttr('href');
763     }
764
765     function expand($basepage, &$markup)
766     {
767         global $WikiTheme;
768         $intermap = getInterwikiMap();
769         $label = isset($this->_label) ? $this->_label : false;
770         //FIXME: check Upload: inlined images
771         if ($WikiTheme->DUMP_MODE and !empty($WikiTheme->VALID_LINKS)) {
772             if (!in_array($this->_link, $WikiTheme->VALID_LINKS))
773                 return HTML($label ? $label : $this->_link);
774         }
775         return $intermap->link($this->_link, $label);
776     }
777
778     function asString()
779     {
780         if (isset($this->_label))
781             return $this->_label;
782         return $this->_link;
783     }
784 }
785
786 // Needed to put UserPages to backlinks. Special method to markup userpages with icons
787 // Thanks to PhpWiki:DanFr for finding this bug.
788 // Fixed since 1.3.8, prev. versions had no userpages in backlinks
789 class Cached_UserLink extends Cached_WikiLink
790 {
791     function expand($basepage, &$markup)
792     {
793         $label = isset($this->_label) ? $this->_label : false;
794         $anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
795         $page = new WikiPageName($this->_page, $basepage, $anchor);
796         $link = WikiLink($page, 'auto', $label);
797         // $link = HTML::a(array('href' => $PageName));
798         $link->setContent(PossiblyGlueIconToText('wikiuser', $this->_page));
799         $link->setAttr('class', 'wikiuser');
800         return $link;
801     }
802 }
803
804 /**
805  * 1.3.13: Previously stored was only _pi.
806  * A fresh generated cache has now ->name and ->args also.
807  * main::isActionPage only checks the raw content.
808  */
809 class Cached_PluginInvocation extends Cached_DynamicContent
810 {
811
812     function __construct($pi)
813     {
814         $this->_pi = $pi;
815         $loader = $this->_getLoader();
816         if (is_array($plugin_cmdline = $loader->parsePI($pi)) and $plugin_cmdline[1]) {
817             $this->pi_name = $plugin_cmdline[0]; // plugin, plugin-form, plugin-list
818             $this->name = $plugin_cmdline[1]->getName();
819             $this->args = $plugin_cmdline[2];
820         }
821     }
822
823     function setTightness($top, $bottom)
824     {
825     }
826
827     function isInlineElement()
828     {
829         return false;
830     }
831
832     function expand($basepage, &$markup)
833     {
834         $loader = $this->_getLoader();
835         $xml = $loader->expandPI($this->_pi, $GLOBALS['request'], $markup, $basepage);
836         return $xml;
837     }
838
839     function asString()
840     {
841         return $this->_pi;
842     }
843
844     function getWikiPageLinks($basepage)
845     {
846         $loader = $this->_getLoader();
847
848         return $loader->getWikiPageLinks($this->_pi, $basepage);
849     }
850
851     function & _getLoader()
852     {
853         static $loader = false;
854
855         if (!$loader) {
856             include_once 'lib/WikiPlugin.php';
857             $loader = new WikiPluginLoader();
858         }
859         return $loader;
860     }
861 }
862
863 // Local Variables:
864 // mode: php
865 // tab-width: 8
866 // c-basic-offset: 4
867 // c-hanging-comment-ender-p: nil
868 // indent-tabs-mode: nil
869 // End: