} catch (Exception $e) { // the pad already exists or something else went wrong echo "\n\ngetRevisionsCount Failed with message " . $e->getMessage(); } /* Example: Get Pad Contents and echo to screen */ try { $padContents = $instance->getText('testPad'); echo "Pad text is: <br/><ul>{$padContents->text}\n\n</ul>"; echo "End of Pad Text\n\n<hr>"; } catch (Exception $e) { // the pad already exists or something else went wrong echo "\n\ngetText Failed with message " . $e->getMessage(); } /* Example: Delete Pad */ try { $instance->deletePad('testPad'); } catch (Exception $e) { // the pad doesn't exist? echo "\n\ndeletePad Failed with message " . $e->getMessage(); } echo "<h1>Groups</h1>"; /* Example: Create Group */ try { $createGroup = $instance->createGroup(); $groupID = $createGroup->groupID; echo "New GroupID is {$groupID}\n\n"; } catch (Exception $e) { // the pad already exists or something else went wrong echo "\n\ncreateGroup Failed with message " . $e->getMessage(); } /* Example: Create Group Pad */
try { $newPad = $instance->createGroupPad($groupID, $name, $contents); $padID = $newPad->padID; $newlocation = "{$HOST}/{$padID}"; // redirect to the new padID location header("Location: {$newlocation}"); } catch (Exception $e) { echo "\n\ncreateGroupPad Failed with message " . $e->getMessage(); } } if ($action == "deletePad") { $name = $_GET["name"]; try { // urldecode seems to be a historical problem $name = urldecode($name); $instance->deletePad($groupID . "\$" . $name); } catch (Exception $e) { // the pad doesn't exist? echo "\n\ndeletePad Failed with message " . $e->getMessage(); } } if ($action == "makePublic") { $name = $_GET["name"]; try { $instance->setPublicStatus($name, "true"); } catch (Exception $e) { // the pad doesn't exist? echo "\n\nMake Public Failed with message " . $e->getMessage(); } } if ($action == "makePrivate") {
$contents = $_GET["contents"]; try { $newPad = $instance->createGroupPad($groupID, $name, $contents); $padID = $newPad->padID; $newlocation = "{$host}/p/{$padID}"; // redirect to the new padID location header("Location: {$newlocation}"); } catch (Exception $e) { echo "\n\ncreateGroupPad Failed with message " . $e->getMessage(); } } if ($action == "deletePad") { $name = $_GET["name"]; try { $name = urldecode($name); $instance->deletePad($name); } catch (Exception $e) { // the pad doesn't exist? echo "\n\ndeletePad Failed with message " . $e->getMessage(); } } if ($action == "makePublic") { $name = $_GET["name"]; try { $instance->setPublicStatus($name, "true"); } catch (Exception $e) { // the pad doesn't exist? echo "\n\nMake Public Failed with message " . $e->getMessage(); } } if ($action == "makePrivate") {
function pad($control, $ID = false, $txt = '') { if ($control != 'print') { include '../img/lib/etherpad-lite/etherpad-lite-client.php'; $e = new EtherpadLiteClient(CLAVE_API_ETHERPAD, 'http://www.' . DOMAIN . ':9001/api'); } switch ($control) { case 'print': global $pol; return '<iframe src="http://www.virtualpol.com:9001/p/' . $ID . '?userName='******'nick'] . '" width="100%" height="500" frameborder="0" style="background:#FFF;margin:0 0 -9px -20px;"></iframe>'; break; case 'create': try { $e->createPad($ID, html_entity_decode(strip_tags(str_replace("<br />", "\n", $txt)), null, 'UTF-8')); return true; } catch (Exception $error) { return false; } break; case 'get': try { return $e->getHTML($ID)->html; } catch (Exception $error) { return false; } break; case 'delete': try { $e->deletePad($ID); return true; } catch (Exception $error) { return false; } break; } }