Beispiel #1
0
 public function render($matches)
 {
     $text = '';
     list($variant, $data) = $matches;
     $text = self::render_chart(Codes::fix_tags($data), $variant);
     return $text;
 }
Beispiel #2
0
 public function render($matches)
 {
     $text = '';
     $mode = $matches[0];
     if ($mode == 'menu') {
         $variant = 'menu_1';
     } elseif ($mode = 'submenu') {
         $variant = 'menu_2';
     } else {
         $variant = $mode;
     }
     $url = isset($matches[2]) ? encode_link($matches[2]) : encode_link($matches[1]);
     $label = isset($matches[2]) ? Codes::fix_tags($matches[1]) : $matches[1];
     $text = Skin::build_link($url, $label, $variant);
     return $text;
 }
Beispiel #3
0
 public function render($matches)
 {
     $text = '';
     $mode = $matches[0];
     // detect horiz ruler
     if (preg_match('/(---|___)/', $mode)) {
         $mode = 'hrule';
     }
     switch ($mode) {
         case 'image':
         case 'img':
             if (count($matches) === 3) {
                 $alt = $matches[1];
                 $src = $matches[2];
             } else {
                 $alt = 'image';
                 $src = $matches[1];
             }
             $text = '<div class="external_image"><img src="' . encode_link($src) . '" alt="' . encode_link($alt) . '" /></div>' . "\n";
             break;
         case 'decorated':
             $text = Skin::build_block(Codes::fix_tags($matches[1]), 'decorated');
             break;
         case 'style':
             $text = Skin::build_block(Codes::fix_tags($matches[2]), $matches[1]);
             break;
         case 'abbr':
             $text = '<abbr title="' . $matches[1] . '">' . $matches[2] . '</abbr>';
             break;
         case 'color':
             $text = '<span style="color:' . $matches[1] . '">' . $matches[2] . '</span>';
             break;
         case 'tiny':
         case 'small':
         case 'big':
         case 'huge':
             $text = Skin::build_block(Codes::fix_tags($matches[1]), $mode);
             break;
         case 'sub':
         case 'sup':
         case 'ins':
         case 'del':
         case 'li':
             $text = '<' . $mode . '>' . $matches[1] . '</' . $mode . '>';
             break;
         case 'hrule':
             $text = HORIZONTAL_RULER;
             break;
         case '--':
             $text = '<del>' . $matches[1] . '</del>';
             break;
         case '++':
             $text = '<ins>' . $matches[1] . '</ins>';
             break;
         case '**':
         case 'b':
             $text = '<strong>' . $matches[1] . '</strong>';
             break;
         case '//':
         case 'i':
             $text = '<em>' . $matches[1] . '</em>';
             break;
         case '__':
         case 'u':
             $text = '<span style="text-decoration:underline;">' . $matches[1] . '</span>';
             break;
         case 'list':
             if (count($matches) === 3) {
                 $variant = $matches[1];
                 $content = $matches[2];
             } else {
                 $variant = '';
                 $content = $matches[1];
             }
             $text = self::render_list(Codes::fix_tags($content), $variant);
             break;
         case '*':
             $text = BR . BULLET_IMG . '&nbsp;';
             break;
         default:
             break;
     }
     return $text;
 }
Beispiel #4
0
 /**
  * build a box
  *
  * Accept following variants:
  * - 'extra' for a flashy box on page side
  * - 'floating' for a box floated to the left
  * - 'folded' for a folded box with content
  * - 'gadget' for additional content in the main part of the page
  * - 'header1' with a level 1 title
  * - 'header1 even'
  * - 'header1 odd'
  * - 'header2' with a level 2 title
  * - 'header3' with a level 3 title
  * - 'navigation' for additional navigational information on page side
  * - 'sidebar' for some extra information in the main part of the page
  * - 'sidecolumn' for some extra information in the main part of the page
  * - 'sliding' for sliding content
  * - 'toc' for a table of content
  * - 'toq' for a table of questions
  * - 'unfolded' for a folded box with content
  *
  * @param string the box title, if any
  * @param string the box content
  * @param string the box variant, if any
  * @param string a unique object id, if any
  * @param string a link to add to the title, if any
  * @param string the popup to display while hovering the link, if any
  * @return the HTML to display
  *
  */
 public static function &build_box($title, $content, $variant = 'header1', $id = '', $url = '', $popup = '')
 {
     global $context;
     $content = Codes::fix_tags($content);
     // accept line breaks in box titles
     $title = str_replace("\n", BR, $title);
     // append a link to the title, if any
     if ($url) {
         $title =& Skin::build_box_title($title, $url, $popup);
     }
     // depending on variant
     switch ($variant) {
         case 'extra':
             $output =& Skin::build_extra_box($title, $content, $id);
             break;
         case 'floating':
             $output =& Skin::build_floating_box($title, $content, $id);
             break;
         case 'folded':
         case 'folder':
             // obsoleted
             $output =& Skin::build_folded_box($title, $content, $id);
             break;
         case 'gadget':
             $output =& Skin::build_gadget_box($title, $content, $id);
             break;
         case 'header1':
         case 'header1 even':
         case 'header1 odd':
         case 'header2':
         case 'header3':
             $output =& Skin::build_header_box($title, $content, $id, $variant);
             break;
         case 'navigation':
             $output =& Skin::build_navigation_box($title, $content, $id);
             break;
         case 'section':
             // legacy
             $output =& Skin::build_header_box($title, $content, $id);
             break;
         case 'sidebar':
             $output =& Skin::build_sidebar_box($title, $content, $id);
             break;
         case 'sidecolumn':
             $output =& Skin::build_sidecolumn_box($title, $content, $id);
             break;
         case 'sliding':
             $output =& Skin::build_sliding_box($title, $content, $id);
             break;
         case 'toc':
             $output =& Skin::build_toc_box($title, $content, $id);
             break;
         case 'toq':
             $output =& Skin::build_toq_box($title, $content, $id);
             break;
         case 'unfolded':
             $output =& Skin::build_unfolded_box($title, $content, $id);
             break;
         default:
             // displayed in the navigation panel
             if (isset($context['skins_navigation_components']) && strpos($context['skins_navigation_components'], $variant) !== FALSE) {
                 $output =& Skin::build_navigation_box($title, $content, $id);
             } elseif (isset($context['skins_extra_components']) && strpos($context['skins_extra_components'], $variant) !== FALSE) {
                 $output =& Skin::build_extra_box($title, $content, $id);
             } else {
                 $output =& Skin::build_header_box($title, $content, $id, $variant);
             }
             break;
     }
     // job done
     return $output;
 }
Beispiel #5
0
 /**
  * render a link to Wikipedia
  *
  * @param string the id, with possible options or variant
  * @return string the rendered text
  **/
 public static function render_wikipedia($id)
 {
     global $context;
     $id = Codes::fix_tags($id);
     // maybe an alternate title has been provided
     $attributes = preg_split("/\\s*,\\s*/", $id, 2);
     $id = $attributes[0];
     // ensure we have a label for this link
     if (isset($attributes[1])) {
         $text = $attributes[1];
     } else {
         $text = '';
     }
     // select the language
     $language = $context['preferred_language'];
     // take the navigator language if possible
     if (isset($context['language']) && $context['without_language_detection'] == 'N') {
         $language = $context['language'];
     }
     // make a link to the target page
     $url = 'http://' . $language . '.wikipedia.org/wiki/Special:Search?search=' . preg_replace('[\\s]', '_', $id);
     // return a complete anchor
     $output = Skin::build_link($url, $text, 'wikipedia');
     return $output;
 }