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