예제 #1
0
 private function replace_callback($matches)
 {
     //Url is in index 4
     $url = $matches[4];
     $title = "";
     $namespace = "";
     if (array_key_exists(6, $matches) && $matches[6] !== "") {
         $title = $matches[6];
     } else {
         $title = $url;
         if (array_key_exists(7, $matches)) {
             $title .= $matches[7];
         }
     }
     $title = preg_replace('/\\(.*?\\)/', '', $title);
     $title = preg_replace('/^.*?\\:/', '', $title);
     if (array_key_exists(3, $matches)) {
         $namespace = $matches[3];
     }
     //TODO: Image Namspace Support
     $config = wikiParser::getConfigINI();
     if (strtoupper($namespace) === "FILE") {
         return "<img src=\"" . $matches[4] . "\" alt=\"" . $matches[5] . "\"/>";
     } else {
         $default_format = '?><a href="http://localhost/wiki/index.php?<?php if($namespace != ""){?>namespace=<?php echo $namespace;?>&<?php }?>document_id=<?php echo $url;?>" target="_blank"><?php echo $title;?></a>';
         if (array_key_exists('INTERNAL_LINKS', $config) && array_key_exists('FORMATTED_URL', $config['INTERNAL_LINKS'])) {
             $default_format = '?>' . $config['INTERNAL_LINKS']['FORMATTED_URL'];
         }
         ob_start();
         eval($default_format);
         $link_html = ob_get_contents();
         ob_end_clean();
         return $link_html;
     }
 }
 public function __construct()
 {
     $config = wikiParser::getConfigINI();
     if (array_key_exists('SIMPLE_VARIABLES', $config)) {
         foreach ($config['SIMPLE_VARIABLES'] as $variable_name => $php_code) {
             $this->variables[$variable_name] = $php_code;
         }
     }
 }
예제 #3
0
 private function replace_callback($matches)
 {
     //Url is in index 4
     $url = $matches[4];
     $title = "";
     $namespace = "main";
     if (array_key_exists(6, $matches)) {
         $title = $matches[6];
     } else {
         $title = $url;
         if (array_key_exists(7, $matches)) {
             $title .= $matches[7];
         }
     }
     $title = preg_replace('/\\(.*?\\)/', '', $title);
     $title = preg_replace('/^.*?\\:/', '', $title);
     if (array_key_exists(3, $matches) && $matches[3] != "") {
         $namespace = $matches[3];
     }
     //Link Type
     //PMWIKI Formats Internal And external Links the same.
     //If the $url starts with a valid protocal then we'll guess it's internal.
     $isInternalLink = true;
     if (preg_match(pmwiki_links::external_protocol_regular_expression, $matches[0])) {
         //External_link
         $isInternalLink = false;
     }
     $config = wikiParser::getConfigINI();
     $default_format = '?><a href="http://localhost/wiki/index.php?<?php if($namespace != ""){?>namespace=<?php echo $namespace;?>&<?php }?>document_id=<?php echo $url;?>" target="_blank"><?php echo $title;?></a>';
     if ($isInternalLink) {
         //PMWIKI Internal links automacically have the spaces removed.
         $url = str_replace(" ", "", $url);
         //Strip any markup (incase the formatting has markup inside)
         $url = strip_tags($url);
         if (array_key_exists('INTERNAL_LINKS', $config) && array_key_exists('FORMATTED_URL', $config['INTERNAL_LINKS'])) {
             $default_format = '?>' . $config['INTERNAL_LINKS']['FORMATTED_URL'];
         }
     } else {
         $url = $matches[2] . $url;
         if (array_key_exists('EXTERNAL_LINKS', $config) && array_key_exists('FORMATTED_URL', $config['EXTERNAL_LINKS'])) {
             $default_format = '?>' . $config['EXTERNAL_LINKS']['FORMATTED_URL'];
         }
     }
     ob_start();
     eval($default_format);
     $link_html = ob_get_contents();
     ob_end_clean();
     return $link_html;
 }
예제 #4
0
 private function replace_callback($matches)
 {
     $url = "";
     $title = "";
     if (array_key_exists(2, $matches)) {
         $url = $matches[2];
     }
     if (array_key_exists(3, $matches)) {
         $title = $matches[3];
     } else {
         $this->external_links[] = $url;
         $title = "[" . count($this->external_links) . "]";
     }
     $config = wikiParser::getConfigINI();
     $default_format = '?><a href="<?php echo $url;?>" target="_blank"><?php echo $title;?></a>';
     if (array_key_exists('EXTERNAL_LINKS', $config) && array_key_exists('FORMATTED_URL', $config['EXTERNAL_LINKS'])) {
         $default_format = '?>' . $config['EXTERNAL_LINKS']['FORMATTED_URL'];
     }
     ob_start();
     eval($default_format);
     $link_html = ob_get_contents();
     ob_end_clean();
     return $link_html;
 }
예제 #5
0
 private function parseSection($section_name, $wiki_text)
 {
     $parser_order_config = wikiParser::getConfigINI();
     $parser_order_int = array();
     foreach ($parser_order_config[$section_name] as $priority => $plugin_name) {
         $parser_order_int[(int) $priority] = $plugin_name;
     }
     ksort($parser_order_int);
     foreach ($parser_order_int as $priority => $plugin_name) {
         //Only Process those with a priority lower than 0
         if ($priority > 0) {
             break;
         }
         foreach ($this->parser_plugins as $plugin) {
             if ($plugin instanceof $section_name && $plugin instanceof $plugin_name) {
                 $wiki_text = $plugin->{$section_name}($wiki_text);
                 break;
             }
         }
     }
     //Process all the plugins we don't have a priority for (Equiv to them all having zero)
     $parsers = $this->parser_plugins;
     if (is_array($parser_order_config) && array_key_exists('ParsingDirection', $parser_order_config) && array_key_exists($section_name, $parser_order_config['ParsingDirection']) && strtolower($parser_order_config['ParsingDirection'][$section_name]) == 'reverse') {
         $parsers = array_reverse($this->parser_plugins);
     }
     foreach ($parsers as $plugin) {
         if (!in_array(get_class($plugin), $parser_order_int) && $plugin instanceof $section_name) {
             $wiki_text = $plugin->{$section_name}($wiki_text);
         }
     }
     foreach ($parser_order_int as $priority => $plugin_name) {
         //Only Process those with a priority higher than 0
         if ($priority <= 0) {
             continue;
         }
         foreach ($this->parser_plugins as $plugin) {
             if ($plugin instanceof $section_name && $plugin instanceof $plugin_name) {
                 $wiki_text = $plugin->{$section_name}($wiki_text);
                 break;
             }
         }
     }
     return $wiki_text;
 }