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; } }
echo "The AuthorID is now {$authorID}\n\n"; } catch (Exception $e) { // the pad already exists or something else went wrong echo "\n\ncreateAuthor Failed with message " . $e->getMessage(); } /* Example: get Mapped Author ID based on a value from your web application such as the userID */ try { $authormap = $instance->createAuthorIfNotExistsFor('John McLear', 'Cake'); // This would show my local UserID mapping John McLear as Cake on Etherpad } catch (Exception $e) { echo "\n\ncreateAuthorIfNotExistsFor Failed with message " . $e->getMessage(); } //cake /* Example: Create a new Pad */ try { $instance->createPad('testPad', 'Hello world'); } catch (Exception $e) { echo "\n\ncreatePad Failed with message " . $e->getMessage(); } /* Example: Set Text into a Pad */ try { $instance->setText('testPad', 'Hello world'); } catch (Exception $e) { echo "\n\nsetText Failed with message " . $e->getMessage(); } /* Example: Create a new Pad */ try { $instance->createPad('testPad', 'Hello world'); } catch (Exception $e) { // the pad already exists or something else went wrong echo "Failed with message " . $e->getMessage();
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } include dirname(__FILE__) . '/write_missionpost_js/base.php'; require_once MODPATH . 'core/views/_base/admin/js/write_missionpost_js.php'; try { require_once dirname(__FILE__) . '/etherpad/etherpad_lite_client.php'; $etherpad_url = $this->config->item('collaborative_writing_etherpad_url') ?: 'http://0.0.0.0:9001'; $etherpad_api_url = $etherpad_url . '/api'; $etherpad_api_key = $this->config->item('collaborative_writing_etherpad_api_key') ?: ''; $etherpad_client = new EtherpadLiteClient($etherpad_api_key, $etherpad_api_url); if ($this->uri->segment(3)) { $post = $this->posts->get_post($this->uri->segment(3)); $pad_id = $this->posts->get_post_pad_id($this->uri->segment(3)); } if (!isset($pad_id)) { $pad_id = str_replace('.', '', uniqid('', true)); $etherpad_client->createPad($pad_id, ''); } else { $etherpad_client->checkToken(); } $user_main_character_name = str_replace('\'', '\\\'', $this->char->get_character_name($this->user->get_user($this->session->userdata('userid'))->main_char)); include dirname(__FILE__) . '/write_missionpost_js/disable_locking.php'; include dirname(__FILE__) . '/write_missionpost_js/etherpad.php'; } catch (Exception $e) { // If this fails, do nothing, which will fall back to the default behavior // of just using the textarea and the old style. }