$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); }
/** * * @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; }
<?php 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>';
<?php require_once 'includes/class_Wiki.inc.php'; try { Wiki::test(); } catch (Exception $e) { echo "Please Move wiki.couch to the following directory couchdb install folder:"; echo Wiki::getDatabaseDirectory(); echo "<br>\n"; exit; } if (!is_object($wikiDocument)) { $wikiDocument = new WikiDocument(); } else { if (!defined("TITLE")) { define("TITLE", $wikiDocument->getField(WikiDocument::FIELD_TITLE)); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="style.css" rel="stylesheet" type="text/css" /> <title><?php echo TITLE; ?> | Wiki Dogs</title> </head> <body> <div id="container">