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