<?php /** * Remove a pad * * Subpages are not deleted but are moved up a level in the tree * * @package ElggPad */ $guid = get_input('guid'); $page = new ElggPad($guid); if ($page) { if ($page->canEdit()) { $container = get_entity($page->container_guid); // Bring all child elements forward $parent = $page->parent_guid; $children = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $page->getGUID())); if ($children) { foreach ($children as $child) { $child->parent_guid = $parent; } } if ($page->delete()) { system_message(elgg_echo('etherpad:delete:success')); if ($parent) { if ($parent = get_entity($parent)) { forward($parent->getURL()); } } //Forward to pages only if pages integration enabled. Otherwise forward to pads. $handler = elgg_get_plugin_setting('integrate_in_pages', 'etherpad') == 'yes' ? 'pages' : 'etherpad';
/** * View for pad object * * @package ElggPad * * @uses $vars['entity'] The pad object * @uses $vars['full_view'] Whether to display the full view */ $full = elgg_extract('full_view', $vars, FALSE); $etherpad = elgg_extract('entity', $vars, FALSE); $timeslider = elgg_extract('timeslider', $vars, FALSE); if (!$etherpad || !elgg_instanceof($etherpad, 'object', 'etherpad') && !elgg_instanceof($etherpad, 'object', 'subpad')) { return TRUE; } $etherpad = new ElggPad($etherpad->guid); // pages used to use Public for write access if ($etherpad->write_access_id == ACCESS_PUBLIC) { // this works because this metadata is public $etherpad->write_access_id = ACCESS_LOGGED_IN; } $etherpad_icon = elgg_view('etherpad/icon', array('entity' => $etherpad, 'size' => 'small')); //link to owners pages only if pages integration is enabled. Else link to owners pads. $handler = elgg_get_plugin_setting('integrate_in_pages', 'etherpad') == 'yes' ? 'pages' : 'etherpad'; $editor = get_entity($etherpad->owner_guid); $editor_link = elgg_view('output/url', array('href' => "{$handler}/owner/{$editor->username}", 'text' => $editor->name, 'is_trusted' => true)); $date = elgg_view_friendly_time($etherpad->time_created); $editor_text = elgg_echo('pages:strapline', array($date, $editor_link)); $tags = elgg_view('output/tags', array('tags' => $etherpad->tags)); $categories = elgg_view('output/categories', $vars); $comments_count = $etherpad->countComments();
/** * Add timeslider to entity menu */ function etherpad_entity_menu($hook, $type, $return, $params) { $entity = $params['entity']; if (elgg_in_context('widgets')) { return $return; } if (!in_array($entity->getSubtype(), array('etherpad', 'subpad'))) { return $return; } // timeslider button, show only if pages integration is enabled. $handler = elgg_get_plugin_setting('integrate_in_pages', 'etherpad') == 'yes' ? 'pages' : 'etherpad'; if ($handler == 'pages') { $options = array('name' => 'etherpad-timeslider', 'text' => elgg_echo('etherpad:timeslider'), 'href' => elgg_get_site_url() . "{$handler}/history/" . $entity->guid, 'priority' => 200); } else { // fullscreen button $entity = new ElggPad($entity->guid); $options = array('name' => 'etherpadfs', 'text' => elgg_echo('etherpad:fullscreen'), 'href' => $entity->getPadPath(), 'priority' => 200); } $return[] = ElggMenuItem::factory($options); return $return; }
$container_guid = (int) get_input('container_guid'); $parent_guid = (int) get_input('parent_guid'); elgg_make_sticky_form('etherpad'); if (!$input['title']) { register_error(elgg_echo('pages:error:no_title')); forward(REFERER); } if ($page_guid) { $page = new ElggPad($page_guid); if (!$page || !$page->canEdit()) { register_error(elgg_echo('pages:error:no_save')); forward(REFERER); } $new_page = false; } else { $page = new ElggPad(); if ($parent_guid) { $page->subtype = 'subpad'; } $new_page = true; } if (sizeof($input) > 0) { foreach ($input as $name => $value) { $page->{$name} = $value; } } // need to add check to make sure user can write to container $page->container_guid = $container_guid; if ($parent_guid) { $page->parent_guid = $parent_guid; }