From: cash Date: Sat, 20 Apr 2013 00:28:51 +0000 (-0400) Subject: Merge pull request #5325 into 1.8 branch X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=863d45bb76d5bce2dabe32acc6f7d1f5400d568d;p=lorea%2Felgg.git Merge pull request #5325 into 1.8 branch --- 863d45bb76d5bce2dabe32acc6f7d1f5400d568d diff --cc mod/pages/start.php index c1183c9bf,780d3d9a7..f9c34cd85 --- a/mod/pages/start.php +++ b/mod/pages/start.php @@@ -80,10 -81,11 +81,13 @@@ function pages_init() // entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'pages_entity_menu_setup'); - // register ecml views to parse - elgg_register_plugin_hook_handler('get_views', 'ecml', 'pages_ecml_views_hook'); - + // hook into annotation menu + elgg_register_plugin_hook_handler('register', 'menu:annotation', 'pages_annotation_menu_setup'); ++ + // register ecml views to parse + elgg_register_plugin_hook_handler('get_views', 'ecml', 'pages_ecml_views_hook'); + + elgg_register_event_handler('upgrade', 'system', 'pages_run_upgrades'); } /** @@@ -364,14 -366,72 +368,3 @@@ function pages_ecml_views_hook($hook, $ return $return_value; } -- --/** - * Process upgrades for the pages plugin - * Adds items to "page" annotations menu - * - * @param unknown_type $hook - * @param unknown_type $entity_type - * @param unknown_type $return_value - * @param unknown_type $params -- */ - function pages_run_upgrades() { - $path = elgg_get_plugins_path() . 'pages/upgrades/'; - $files = elgg_get_upgrade_files($path); - foreach ($files as $file) { - include "$path{$file}"; -function pages_annotation_menu_setup($hook, $type, $return, $params) { - $annotation = $params['annotation']; - /* @var ElggAnnotation $annotation */ - - $entity = get_entity($annotation->entity_guid); - - if ($annotation->name == 'page' && $entity->canEdit() && $annotation->canEdit()) { - // Get last revision - $revisions = elgg_get_annotations(array( - 'annotation_name' => 'page', - 'limit' => 1, - 'guid' => $annotation->entity_guid, - 'reverse_order_by' => true, - )); - - // Check if this annotation is the last revision - if ($revisions) { - $current_revision = $revisions[0]; - if ($current_revision == $annotation) { - // Don't allow any actions on last revision, just display 'current revision' - $options = array( - 'name' => 'current', - 'href' => false, - 'text' => elgg_echo('pages:current_revision'), - 'encode_text' => false - ); - $return[] = ElggMenuItem::factory($options); - return $return; - } - } - - // Revert - $options = array( - 'name' => 'revert', - 'href' => elgg_http_add_url_query_elements("pages/edit/{$annotation->entity_guid}", array( - 'annotation_id' => $annotation->id - )), - 'text' => elgg_echo('pages:revert'), - 'encode_text' => false - ); - $return[] = ElggMenuItem::factory($options); - - - // Delete - $url = elgg_http_add_url_query_elements('action/annotations/page/delete', array( - 'annotation_id' => $annotation->id, - )); - - $options = array( - 'name' => 'delete', - 'href' => $url, - 'text' => "", - 'confirm' => elgg_echo('deleteconfirm'), - 'encode_text' => false - ); - $return[] = ElggMenuItem::factory($options); -- } - - return $return; --}