public static function addDocument(WikiDocument $document) { try { $tmp = self::getClient()->getDoc($document->getId()); } catch (Exception $e) { $tmp = new stdClass(); } $tmp->_id = $document->getId(); foreach ($document->getField() as $fieldName => $value) { $tmp->{$fieldName} = utf8_encode($value); } try { $response = self::getClient()->storeDoc($tmp); } catch (Exception $e) { echo "Error: " . $e->getMessage() . " (errcode=" . $e->getCode() . ")\n"; exit(1); } }
<?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">