Overview

Packages

  • None
  • Wicked

Classes

  • Text_Wiki_Parse_Heading2
  • Text_Wiki_Parse_Toc2
  • Text_Wiki_Render_Latex_Heading2
  • Text_Wiki_Render_Latex_Toc2
  • Text_Wiki_Render_Plain_Heading2
  • Text_Wiki_Render_Plain_Toc2
  • Text_Wiki_Render_Rst
  • Text_Wiki_Render_Rst_Blockquote
  • Text_Wiki_Render_Rst_Bold
  • Text_Wiki_Render_Rst_Code
  • Text_Wiki_Render_Rst_Deflist
  • Text_Wiki_Render_Rst_Emphasis
  • Text_Wiki_Render_Rst_Freelink
  • Text_Wiki_Render_Rst_Heading2
  • Text_Wiki_Render_Rst_Links
  • Text_Wiki_Render_Rst_List
  • Text_Wiki_Render_Rst_Newline
  • Text_Wiki_Render_Rst_Paragraph
  • Text_Wiki_Render_Rst_Raw
  • Text_Wiki_Render_Rst_Toc2
  • Text_Wiki_Render_Rst_Tt
  • Text_Wiki_Render_Rst_Url
  • Text_Wiki_Render_Xhtml_Attribute
  • Text_Wiki_Render_Xhtml_Code2
  • Text_Wiki_Render_Xhtml_Freelink2
  • Text_Wiki_Render_Xhtml_Heading2
  • Text_Wiki_Render_Xhtml_Image2
  • Text_Wiki_Render_Xhtml_Interwiki
  • Text_Wiki_Render_Xhtml_Registrylink
  • Text_Wiki_Render_Xhtml_Toc2
  • Text_Wiki_Render_Xhtml_Url
  • Text_Wiki_Render_Xhtml_Wickedblock
  • Text_Wiki_Render_Xhtml_Wikilink2
  • Wicked
  • Wicked_Api
  • Wicked_Driver
  • Wicked_Driver_Sql
  • Wicked_Exception
  • Wicked_Factory_Driver
  • Wicked_Page
  • Wicked_Page_AddPage
  • Wicked_Page_AllPages
  • Wicked_Page_AttachedFiles
  • Wicked_Page_BackLinks
  • Wicked_Page_DeletePage
  • Wicked_Page_EditPage
  • Wicked_Page_LeastPopular
  • Wicked_Page_LikePages
  • Wicked_Page_MergeOrRename
  • Wicked_Page_MostPopular
  • Wicked_Page_NewPage
  • Wicked_Page_RecentChanges
  • Wicked_Page_RevertPage
  • Wicked_Page_Search
  • Wicked_Page_StandardHistoryPage
  • Wicked_Page_StandardPage
  • Wicked_Page_SyncDiff
  • Wicked_Page_SyncPages
  • Wicked_Sync
  • Wicked_Sync_Wicked
  • Wicked_Test
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: 
  3: require_once 'Text/Wiki/Render/Xhtml/Wikilink.php';
  4: 
  5: /**
  6:  * @package Wicked
  7:  */
  8: class Text_Wiki_Render_Xhtml_Wikilink2 extends Text_Wiki_Render_Xhtml_Wikilink
  9: {
 10:     /**
 11:      * Renders a token into XHTML.
 12:      *
 13:      * @access public
 14:      *
 15:      * @param array $options The "options" portion of the token (second
 16:      * element).
 17:      *
 18:      * @return string The text rendered from the token options.
 19:      */
 20:     public function token($options)
 21:     {
 22:         // make nice variable names (page, anchor, text)
 23:         extract($options);
 24: 
 25:         // is there a "page existence" callback?
 26:         // we need to access it directly instead of through
 27:         // getConf() because we'll need a reference (for
 28:         // object instance method callbacks).
 29:         if (isset($this->conf['exists_callback'])) {
 30:             $callback =& $this->conf['exists_callback'];
 31:         } else {
 32:             $callback = false;
 33:         }
 34: 
 35:         if ($callback) {
 36:             // use the callback function
 37:             $exists = call_user_func($callback, $page);
 38:         } else {
 39:             // no callback, go to the naive page array.
 40:             $list = $this->getConf('pages');
 41:             if (is_array($list)) {
 42:                 // yes, check against the page list
 43:                 $exists = in_array($page, $list);
 44:             } else {
 45:                 // no, assume it exists
 46:                 $exists = true;
 47:             }
 48:         }
 49: 
 50:         $anchor = $this->urlEncode(substr($anchor, 1));
 51:         if (strlen($anchor)) {
 52:             $anchor = '#' . $anchor;
 53:         }
 54: 
 55:         // Does the page exist?
 56:         if ($exists) {
 57:             $href = sprintf(preg_replace('/%(?!s)/', '%%', $this->getConf('view_url')), $GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? htmlspecialchars($page) : $this->urlEncode($page)) . $anchor;
 58: 
 59:             // get the CSS class and generate output
 60:             $css = ' class="'.$this->textEncode($this->getConf('css')).'"';
 61: 
 62:             $start = '<a'.$css.' href="'.$this->textEncode($href).'">';
 63:             $end = '</a>';
 64:         } else {
 65:             $new_url = $this->getConf('new_url');
 66:             if (!$new_url) {
 67:                 return $this->textEncode($text);
 68:             }
 69: 
 70:             $href = sprintf(preg_replace('/%(?!s)/', '%%', $new_url), $GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? htmlspecialchars($page) : $this->urlEncode($page));
 71: 
 72:             // get the appropriate CSS class and new-link text
 73:             $css = ' class="'.$this->textEncode($this->getConf('css_new')).'"';
 74:             $new = $this->getConf('new_text');
 75: 
 76:             // what kind of linking are we doing?
 77:             $pos = $this->getConf('new_text_pos');
 78:             if (! $pos || ! $new) {
 79:                 // no position (or no new_text), use css only on the page name
 80: 
 81:                 $start = '<a'.$css.' href="'.$this->textEncode($href).'">';
 82:                 $end = '</a>';
 83:             } elseif ($pos == 'before') {
 84:                 // use the new_text BEFORE the page name
 85:                 $start = '<a'.$css.' href="'.$this->textEncode($href).'">'.$this->textEncode($new).'</a>';
 86:                 $end = '';
 87:             } else {
 88:                 // default, use the new_text link AFTER the page name
 89:                 $start = '';
 90:                 $end = '<a'.$css.' href="'.$this->textEncode($href).'">'.$this->textEncode($new).'</a>';
 91:             }
 92:         }
 93:         if (!strlen($text)) {
 94:             $start .= $this->textEncode($page);
 95:         }
 96:         if (isset($type)) {
 97:             switch ($type) {
 98:             case 'start':
 99:                 $output = $start;
100:                 break;
101:             case 'end':
102:                 $output = $end;
103:                 break;
104:             }
105:         } else {
106:             $output = $start.$this->textEncode($text).$end;
107:         }
108:         return $output;
109:     }
110: }
111: 
API documentation generated by ApiGen