--- /home/duck/Download/wicked/lib/api.php	2008-01-02 12:14:12.000000000 +0100
+++ ../wicked/lib/api.php	2008-01-21 22:47:06.000000000 +0100
@@ -20,6 +20,18 @@
     'type' => 'array'
 );
 
+$_services['display'] = array(
+    'args' => array('pagename' => 'string'),
+    'type' => 'array'
+);
+
+$_services['edit'] = array(
+    'args' => array('pagename' => 'string',
+                    'text' => 'string',
+                    'changelog' => 'string',
+                    'minorchange' => 'boolean'),
+    'type' => 'array'
+);
 
 function _wicked_perms()
 {
@@ -58,3 +70,70 @@
     ksort($perms['tree']['wicked']['pages']);
     return $perms;
 }
+
+function _wicked_display($pagename)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    require_once 'Horde/MIME/Magic.php';
+    require_once 'Horde/MIME/Viewer.php';
+    if (is_callable(array('Horde', 'loadConfiguration'))) {
+        $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'horde');
+        extract($result);
+    } else {
+        require HORDE_BASE . '/config/mime_drivers.php';
+    }
+
+    $page = Page::getPage($pagename);
+    if (is_a($page, 'PEAR_Error')) {
+        return $page;
+    }
+
+    $GLOBALS['wicked']->logPageView($page->pageName());
+
+    if (!isset($_SESSION['wickedSession']['history'])) {
+        $_SESSION['wickedSession']['history'] = array();
+    }
+
+    $content = $page->displayContents(false);
+    if (is_a($content, 'PEAR_Error')) {
+        return $content;
+    }
+
+    return Horde::stylesheetLink('wicked') . $content;
+}
+
+function _wicked_edit($pagename, $text, $changelog = '', $minorchange = false)
+{
+    if (!Auth::isAdmin()) {
+        return PEAR::RaiseError(sprintf(_("You don't have permission to edit \"%s\"."), $pagename));
+    }
+
+    require_once dirname(__FILE__) . '/base.php';
+
+    $page = Page::getPage($pagename);
+    if (is_a($page, 'PEAR_Error')) {
+        return $page;
+    }
+
+    $content = $page->getText();
+    if (is_a($content, 'PEAR_Error')) {
+        // Maybe the page does not exists, if not create it
+        if ($GLOBALS['wicked']->pageExists($pagename)) {
+            return $content;
+        } else {
+            return $GLOBALS['wicked']->newPage($pagename, $text);
+        }
+    }
+
+    if (trim($text) == trim($page->getText())) {
+        return PEAR::RaiseError(_("No changes made"));
+    }
+
+    $result = $page->updateText($text, $changelog, $minorchange);
+    if (is_a($result, 'PEAR_Error')) {
+        return $result;
+    } else {
+        return true;
+    }
+}