]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/CachedMarkup.php
* break overlong lines
[SourceForge/phpwiki.git] / lib / CachedMarkup.php
1 <?php 
2 rcs_id('$Id$');
3 /* Copyright (C) 2002 Geoffrey T. Dairiki <dairiki@dairiki.org>
4  * Copyright (C) 2004-2008 $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         // Gforge 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_gforge')) {
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 = pcre_fix_posix_classes("[.?!][\")]*\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 $item");
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, 'relation' => 0));
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::strong(array('class' => 'rawurl'),
537                                 HTML::u(array('class' => 'baduri'),
538                                         _("BAD semantic relation link")));
539         }
540         $this->_relation = urldecode($m[1]);
541         $is_attribute = ($m[2] == ':=');
542         if ($is_attribute) {
543             $this->_attribute = urldecode($m[3]);
544             // since this stored in the markup cache, we are extra sensible 
545             // not to store false empty stuff.
546             $units = new Units();
547             if (!DISABLE_UNITS and !$units->errcode) 
548             {
549                 $this->_attribute_base = $units->Definition($this->_attribute);
550                 $this->_unit = $units->baseunit($this->_attribute);
551             }
552         } else {
553             $this->_page = urldecode($m[3]);
554         }
555         return $m;
556     }
557
558     function _expand($url, $label = false) {
559         global $WikiTheme;
560         $m = $this->_expandurl($url);
561         $class = 'wiki';
562         // do not link to the attribute value, but to the attribute
563         $is_attribute = ($m[2] == ':=');
564         if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) {
565             if (isset($this->_page) and !in_array($this->_page, $WikiTheme->VALID_LINKS))
566                 return HTML($label ? $label : ($is_attribute ? $this->_relation : $this->_page));
567         }
568         if ($is_attribute)
569             $title = isset($this->_attribute_base)
570                 ? sprintf(_("Attribute %s, base value: %s"), $this->_relation, $this->_attribute_base)
571                 : sprintf(_("Attribute %s, value: %s"), $this->_relation, $this->_attribute);
572         if ($label) {
573             return HTML::span
574                 (
575                  HTML::a(array('href'  => WikiURL($is_attribute ? $this->_relation : $this->_page),
576                                'class' => "wiki ".($is_attribute ? "attribute" : "relation"),
577                                'title' => $is_attribute 
578                                ? $title 
579                                : sprintf(_("Relation %s to page %s"), $this->_relation, $this->_page)),
580                          $label)
581                  );
582         } elseif ($is_attribute) {
583             return HTML::span
584                 (
585                  HTML::a(array('href'  => WikiURL($this->_relation),
586                                'class' => "wiki attribute",
587                                'title' => $title),
588                          $url)
589                  );
590         } else {
591             return HTML::span
592                 (
593                  HTML::a(array('href'  => WikiURL($this->_relation),
594                                'class' => "wiki relation"),
595                          $this->_relation),
596                  HTML::span(array('class'=>'relation-symbol'), $m[2]),
597                  HTML::a(array('href'  => WikiURL($this->_page),
598                                'class' => "wiki"),
599                          $this->_page)
600                  );
601         }
602     }
603
604     function expand($basepage, &$markup) {
605         $label = isset($this->_label) ? $this->_label : false;
606         return $this->_expand($this->_url, $label);
607     }
608
609     function asXML() {
610         $label = isset($this->_label) ? $this->_label : false;
611         $link = $this->_expand($this->_url, $label);
612         return $link->asXML();
613     }
614
615     function asString() {
616         if (isset($this->_label))
617             return $this->_label;
618         return $this->_url;
619     }
620 }
621
622 /** 
623  * Highlight found search engine terms
624  */
625 class Cached_SearchHighlight extends Cached_DynamicContent
626 {
627     function Cached_SearchHighlight ($word, $engine) {
628         $this->_word = $word;
629         $this->engine = $engine;
630     }
631
632     function expand($basepage, &$markup) {
633         return HTML::span(array('class' => 'search-term',
634                                 'title' => _("Found by ") . $this->engine),
635                           $this->_word);
636     }
637 }    
638     
639 class Cached_ExternalLink extends Cached_Link {
640
641     function Cached_ExternalLink($url, $label=false) {
642         $this->_url = $url;
643         if ($label && $label != $url)
644             $this->_label = $label;
645     }
646
647     function _getType() {
648         return 'external';
649     }
650     
651     function _getName($basepage) {
652         $label = isset($this->_label) ? $this->_label : false;
653         return ($label and is_string($label)) ? $label : $this->_url;
654     }
655
656     function expand($basepage, &$markup) {
657         global $request;
658
659         $label = isset($this->_label) ? $this->_label : false;
660         $link = LinkURL($this->_url, $label);
661
662         if (GOOGLE_LINKS_NOFOLLOW) {
663             // Ignores nofollow when the user who saved the page was authenticated. 
664             $page = $request->getPage($basepage);
665             $current = $page->getCurrentRevision(false);
666             if (!$current->get('author_id'))
667                 $link->setAttr('rel', 'nofollow');
668         }
669         return $link;
670     }
671
672     function asString() {
673         if (isset($this->_label) and is_string($this->_label))
674             return $this->_label;
675         return $this->_url;
676     }
677 }
678
679 class Cached_InterwikiLink extends Cached_ExternalLink {
680     
681     function Cached_InterwikiLink($link, $label=false) {
682         $this->_link = $link;
683         if ($label)
684             $this->_label = $label;
685     }
686
687     function getPagename($basepage) {
688         list ($moniker, $page) = split (":", $this->_link, 2);
689         $page = new WikiPageName($page, $basepage);
690         if ($page->isValid()) return $page->name;
691         else return false;
692     }
693
694     function getWikiPageLinks($basepage) {
695         if ($basepage == '') return false;
696         /* ":DontStoreLink" */
697         if (substr($this->_link,0,1) == ':') return false;
698         /* store only links to valid pagenames */
699         if ($link = $this->getPagename($basepage)) 
700             return array(array('linkto' => $link, 'relation' => 0));
701         else return false; // dont store external links
702     }
703
704     function _getName($basepage) {
705         $label = isset($this->_label) ? $this->_label : false;
706         return ($label and is_string($label)) ? $label : $this->_link;
707     }
708     
709     /* there may be internal interwiki links also */
710     function _getType() {
711         return $this->getPagename(false) ? 'internal' : 'external';
712     }
713
714     function _getURL($basepage) {
715         $link = $this->expand($basepage, $this);
716         return $link->getAttr('href');
717     }
718
719     function expand($basepage, &$markup) {
720         global $WikiTheme;
721         $intermap = getInterwikiMap();
722         $label = isset($this->_label) ? $this->_label : false;
723         //FIXME: check Upload: inlined images
724         if ($WikiTheme->DUMP_MODE and !empty($WikiTheme->VALID_LINKS)) {
725             if (!in_array($this->_link, $WikiTheme->VALID_LINKS))
726                 return HTML($label ? $label : $this->_link);
727         }
728         return $intermap->link($this->_link, $label);
729     }
730
731     function asString() {
732         if (isset($this->_label))
733             return $this->_label;
734         return $this->_link;
735     }
736 }
737
738 // Needed to put UserPages to backlinks. Special method to markup userpages with icons
739 // Thanks to PhpWiki:DanFr for finding this bug. 
740 // Fixed since 1.3.8, prev. versions had no userpages in backlinks
741 class Cached_UserLink extends Cached_WikiLink {
742     function expand($basepage, &$markup) {
743         $label = isset($this->_label) ? $this->_label : false;
744         $anchor = isset($this->_anchor) ? (string)$this->_anchor : '';
745         $page = new WikiPageName($this->_page, $basepage, $anchor);
746         $link = WikiLink($page, 'auto', $label);
747         // $link = HTML::a(array('href' => $PageName));
748         $link->setContent(PossiblyGlueIconToText('wikiuser', $this->_page));
749         $link->setAttr('class', 'wikiuser');
750         return $link;
751     }
752 }
753
754 /**
755  * 1.3.13: Previously stored was only _pi. 
756  * A fresh generated cache has now ->name and ->args also.
757  * main::isActionPage only checks the raw content.
758  */
759 class Cached_PluginInvocation extends Cached_DynamicContent {
760
761     function Cached_PluginInvocation ($pi) {
762         $this->_pi = $pi;
763         $loader = $this->_getLoader();
764         if (is_array($plugin_cmdline = $loader->parsePI($pi)) and $plugin_cmdline[1]) {
765             $this->pi_name = $plugin_cmdline[0]; // plugin, plugin-form, plugin-list, plugin-link
766             $this->name = $plugin_cmdline[1]->getName();
767             $this->args = $plugin_cmdline[2];
768         }
769     }
770
771     function setTightness($top, $bottom) {
772     }
773     
774     function isInlineElement() {
775         return false;
776     }
777
778     function expand($basepage, &$markup) {
779         $loader = $this->_getLoader();
780         $xml = $loader->expandPI($this->_pi, $GLOBALS['request'], $markup, $basepage);
781         return $xml;
782     }
783
784     function asString() {
785         return $this->_pi;
786     }
787
788     function getWikiPageLinks($basepage) {
789         $loader = $this->_getLoader();
790
791         return $loader->getWikiPageLinks($this->_pi, $basepage);
792     }
793
794     function & _getLoader() {
795         static $loader = false;
796
797         if (!$loader) {
798             include_once('lib/WikiPlugin.php');
799             $loader = new WikiPluginLoader;
800         }
801         return $loader;
802     }
803 }
804
805 // (c-file-style: "gnu")
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 ?>