Ejemplo n.º 1
0
require_once 'includes/class_Wiki.inc.php';
try {
    //Used for editing, we already have an id
    $wikiDocument = Wiki::getDocument($_GET['page']);
} catch (Exception $e) {
    //Used for processing
    $wikiDocument = new WikiDocument($_POST['title']);
}
if (isset($_POST['process'])) {
    if (is_array($_POST['fieldTitle']) && is_array($_POST['fieldBody'])) {
        for ($i = 0; $i < sizeOf($_POST['fieldTitle']); $i++) {
            $body = trim($_POST['fieldBody'][$i]);
            $field = trim($_POST['fieldTitle'][$i]);
            if (strlen($body) > 0 && strlen($field) > 0 && $body != "Field Title" && $field != "Field Body") {
                $wikiDocument->addField($_POST['fieldTitle'][$i], $_POST['fieldBody'][$i]);
            }
        }
        $wikiDocument->addField(WikiDocument::FIELD_DATETIME, time());
        Wiki::addDocument($wikiDocument);
        header("Location: viewPage.php?page=" . $wikiDocument->getId());
        exit;
    }
}
require_once "header.php";
?>
<script type="text/javascript">
function addField() {
	var tmpNode = document.createElement("div");
	tmpNode.innerHTML = '<div class="formTitle"><input type="text" name="fieldTitle[]" onclick="if(this.value==\'Field Title\') this.value=\'\';" value="Field Title">:</div><textarea name="fieldBody[]" onclick="if(this.value==\'Field Body\') this.value=\'\';">Field Body</textarea>';
	document.getElementById('fields').appendChild(tmpNode);
Ejemplo n.º 2
0
    $data = $curl->getData();
    $regExp = "@";
    //Headline
    $regExp .= 'class="mw-headline" id="[^"]+">(?P<header>[^<]+)</span></h3>';
    //The Rest
    $regExp .= '(?P<content>.*?)(<h|<table class="navbox"|<div class="printfooter")';
    $regExp .= '@s';
    if (!preg_match_all($regExp, $data, $matches)) {
        $regExp = "@";
        //Headline
        $regExp .= 'class="mw-headline" id="[^"]+">(?P<header>[^<]+)</span></h2>';
        //The Rest
        $regExp .= '(?P<content>.*?)(<h|<table class="navbox"|<div class="printfooter")';
        $regExp .= '@s';
        preg_match_all($regExp, $data, $matches);
    }
    $wikiDocument = new WikiDocument(str_replace("_", " ", $site));
    $wikiDocument->addField(WikiDocument::FIELD_DATETIME, time());
    for ($i = 0; $i < sizeOf($matches['header']); $i++) {
        $header = $matches['header'][$i];
        $header = str_replace("_", " ", $header);
        $header = strip_tags($header);
        $header = html_entity_decode($header);
        $content = $matches['content'][$i];
        $content = strip_tags($content);
        $content = preg_replace("@\\[\\d+\\]@", "", $content);
        $content = html_entity_decode($content);
        $wikiDocument->addField($header, $content);
    }
    Wiki::addDocument($wikiDocument);
}
Ejemplo n.º 3
0
 /**
  * 
  * @param stdObject $stdObject
  * @return WikiDocument
  */
 private static function loadDocument($stdObject)
 {
     $wikiDocument = new WikiDocument($stdObject->{WikiDocument::FIELD_TITLE});
     foreach ($stdObject as $key => $value) {
         if ($key == "_id") {
             //DO NOTHING
         } elseif ($key == "_rev") {
             $wikiDocument->setRevision($value);
         } else {
             $wikiDocument->addField($key, utf8_decode($value));
         }
     }
     return $wikiDocument;
 }