function handler_ajax_update($page) { $json = json_decode(Env::v('json')); $wiki = new Wiki($json->wid); $page->jsonAssign('success', true); try { $wiki->select(Wiki::SELECT_VERSION); $content = trim($json->content); if ($content != $wiki->content()) { $wiki->update($content); $wiki->select(Wiki::SELECT_VERSION); } $page->jsonAssign('html', $wiki->html()); } catch (Exception $e) { $page->jsonAssign('success', false); } return PL_JSON; }