Ejemplo n.º 1
0
 private function showAddentum($tpl)
 {
     $parser = new wikiParser();
     $contentWiki = file_get_contents(DOCS_DIR . 'custom.wiki');
     $contentHtml = $parser->parse($contentWiki);
     $tpl->assign('content', $contentHtml);
     $tpl->display('controller_help.tpl');
 }
Ejemplo n.º 2
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;
         }
     }
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
    if (strtoupper($_GET['l']) == "GB") {
        $_GET['l'] = "en";
    }
    $dictURI = "http://" . strtolower($_GET['l']) . ".wiktionary.org/w/api.php?";
}
$uri = $dictURI . "action=query&titles=" . trim($vars['titles']) . "&rvlimit=1&prop=revisions&rvprop=content&format=json";
$opts = array('http' => array('method' => "GET", 'header' => "User-Agent: ATBar"));
$context = stream_context_create($opts);
$remData = file_get_contents($uri, false, $context);
$rawData = json_decode($remData, true);
require_once "inc/WP/wikiParser.class.php";
require_once "inc/wiky.inc.php";
// If there is data
if (!isset($rawData['query']['pages']['-1'])) {
    $wiky = new wiky();
    $parser = new wikiParser();
    foreach ($rawData['query']['pages'] as &$page) {
        // Remove pronounciation
        //var_dump($page['revisions'][0]["*"]);
        $page['revisions'][0]["*"] = preg_replace("/===Pronunciation===.*?===/is", "", $page['revisions'][0]["*"]);
        // Remove translations node
        $page['revisions'][0]["*"] = preg_replace("/===Translations===.*?===/is", "", $page['revisions'][0]["*"]);
        //$page['revisions'][0]["*"] = $wiky->parse( htmlspecialchars($page['revisions'][0]["*"]) );
        $page['revisions'][0]["*"] = $parser->parse(htmlspecialchars($page['revisions'][0]["*"]));
        // Strip out any curly brackets
        $page['revisions'][0]["*"] = preg_replace("/{{.*?}}/s", "", $page['revisions'][0]["*"]);
        // Remove extra li's
        $page['revisions'][0]["*"] = preg_replace("/<li>\\s+<\\/li>/", "", $page['revisions'][0]["*"]);
        // Remove trailing data
        $page['revisions'][0]["*"] = preg_replace("/<h3>Statistics<\\/h3>.*/s", "", $page['revisions'][0]["*"]);
        //echo $wiky->parse( htmlspecialchars($page['revisions'][0]["*"]) );
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
<?php

require_once dirname(__FILE__) . '/../wikiParser.class.php';
$test = new wikiParser();
echo $test->parse(file_get_contents(dirname(__FILE__) . '/example.wiki'));
Ejemplo n.º 9
0
<?php

$Output = file_get_contents('vala.wiki');
// Strip first line
$Output = substr($Output, strpos($Output, "\n") + 1);
$Previous = array('list_open' => ' * ', 'double_space' => '  ');
$Parse = array('list_open' => '*', 'double_space' => ' ');
foreach ($Parse as $Key => $Value) {
    $Output = str_replace($Previous[$Key], $Parse[$Key], $Output);
}
require_once __DIR__ . '/../_libs/WikiParser/wikiParser.class.php';
$New = new wikiParser();
echo $New->parse($Output);
Ejemplo n.º 10
0
<?php

require_once dirname(__FILE__) . '/../wikiParser.class.php';
$test = new wikiParser();
//echo ($test->parse(file_get_contents(dirname(__FILE__) . '/example.wiki')));
echo $test->parse(file_get_contents(dirname(__FILE__) . '/betty.mediawiki'));