aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-06 19:16:23 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-06 19:16:23 +0000
commitc2d82db47ccdbd388658433d1f703c560d7fb84b (patch)
tree0bb352e9f7f9b6f676a5a7b608c18b2fe363b39b /mod
parent562900f1b36820843a28d7b68f2f0f3e55e04dbf (diff)
downloadelgg-c2d82db47ccdbd388658433d1f703c560d7fb84b.tar.gz
elgg-c2d82db47ccdbd388658433d1f703c560d7fb84b.tar.bz2
Fixes #2853 pages plugin uses the icon url plugin hook and fixes delete action
git-svn-id: http://code.elgg.org/elgg/trunk@8044 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r--mod/pages/actions/pages/delete.php41
-rw-r--r--mod/pages/start.php23
-rw-r--r--mod/pages/views/default/icon/object/page/medium.php8
-rw-r--r--mod/pages/views/default/icon/object/page/small.php8
-rw-r--r--mod/pages/views/default/icon/object/page_top/medium.php9
-rw-r--r--mod/pages/views/default/icon/object/page_top/small.php8
-rw-r--r--mod/pages/views/default/pages/icon.php12
7 files changed, 49 insertions, 60 deletions
diff --git a/mod/pages/actions/pages/delete.php b/mod/pages/actions/pages/delete.php
index 8bc20b821..aea383ef8 100644
--- a/mod/pages/actions/pages/delete.php
+++ b/mod/pages/actions/pages/delete.php
@@ -2,36 +2,39 @@
/**
* Remove a page
*
+ * Subpages are not deleted but are moved up a level in the tree
+ *
* @package ElggPages
*/
-$page = get_input('page');
-
-if ($page = get_entity($page)) {
-
+$guid = get_input('guid');
+$page = get_entity($guid);
+if ($page) {
if ($page->canEdit()) {
-
$container = get_entity($page->container_guid);
// Bring all child elements forward
- $parent = $page->parent_guid;
- if ($children = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $page->getGUID()))) {
- foreach($children as $child) {
- $child->parent_guid = $parent;
- }
+ $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('pages:delete:success'));
- if ($parent) {
- if ($parent = get_entity($parent)) {
- forward($parent->getURL());
- }
+ }
+
+ if ($page->delete()) {
+ system_message(elgg_echo('pages:delete:success'));
+ if ($parent) {
+ if ($parent = get_entity($parent)) {
+ forward($parent->getURL());
}
- forward("pg/pages/owned/$container->username/");
}
-
+ forward("pg/pages/owned/$container->username/");
+ }
}
-
}
register_error(elgg_echo('pages:delete:failure'));
diff --git a/mod/pages/start.php b/mod/pages/start.php
index efbf243d6..4a48368ec 100644
--- a/mod/pages/start.php
+++ b/mod/pages/start.php
@@ -68,6 +68,9 @@ function pages_init() {
elgg_register_plugin_hook_handler('permissions_check', 'object', 'pages_write_permission_check');
elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'pages_container_permission_check');
+ // icon url override
+ elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'pages_icon_url_override');
+
// register ecml views to parse
elgg_register_plugin_hook_handler('get_views', 'ecml', 'pages_ecml_views_hook');
}
@@ -173,6 +176,26 @@ function pages_revision_url($annotation) {
}
/**
+ * Override the default entity icon for pages
+ *
+ * @return string Relative URL
+ */
+function pages_icon_url_override($hook, $type, $returnvalue, $params) {
+ $entity = $params['entity'];
+ if (elgg_instanceof($entity, 'object', 'page_top') ||
+ elgg_instanceof($entity, 'object', 'page')) {
+ switch ($params['size']) {
+ case 'small':
+ return 'mod/pages/images/pages.gif';
+ break;
+ case 'medium':
+ return 'mod/pages/images/pages_lrg.gif';
+ break;
+ }
+ }
+}
+
+/**
* Add a menu item to the user ownerblock
*/
function pages_owner_block_menu($hook, $type, $return, $params) {
diff --git a/mod/pages/views/default/icon/object/page/medium.php b/mod/pages/views/default/icon/object/page/medium.php
deleted file mode 100644
index ebf028ef7..000000000
--- a/mod/pages/views/default/icon/object/page/medium.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Page icon override medium
- *
- * @package ElggPages
- */
-
-echo elgg_get_site_url() . "mod/pages/images/pages_lrg.gif";
diff --git a/mod/pages/views/default/icon/object/page/small.php b/mod/pages/views/default/icon/object/page/small.php
deleted file mode 100644
index 850c78a51..000000000
--- a/mod/pages/views/default/icon/object/page/small.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Page icon override small
- *
- * @package ElggPages
- */
-
-echo elgg_get_site_url() . "mod/pages/images/pages.gif"; \ No newline at end of file
diff --git a/mod/pages/views/default/icon/object/page_top/medium.php b/mod/pages/views/default/icon/object/page_top/medium.php
deleted file mode 100644
index d1200ad61..000000000
--- a/mod/pages/views/default/icon/object/page_top/medium.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * Top page icon override medium
- *
- * @package ElggPages
- */
-
-echo elgg_get_site_url() . "mod/pages/images/pages_lrg.gif";
-?>
diff --git a/mod/pages/views/default/icon/object/page_top/small.php b/mod/pages/views/default/icon/object/page_top/small.php
deleted file mode 100644
index bb9e0047a..000000000
--- a/mod/pages/views/default/icon/object/page_top/small.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/**
- * Top Page icon override small
- *
- * @package ElggPages
- */
-
-echo elgg_get_site_url() . "mod/pages/images/pages.gif";
diff --git a/mod/pages/views/default/pages/icon.php b/mod/pages/views/default/pages/icon.php
index ede0e49d1..d3b749eb8 100644
--- a/mod/pages/views/default/pages/icon.php
+++ b/mod/pages/views/default/pages/icon.php
@@ -2,6 +2,8 @@
/**
* Page icon
*
+ * Uses a separate icon view due to dependency on annotation
+ *
* @package ElggPages
*
* @uses $vars['entity']
@@ -12,18 +14,12 @@ $annotation = $vars['annotation'];
$entity = get_entity($annotation->entity_guid);
// Get size
-if (!in_array($vars['size'], array('small','medium','large','tiny','master','topbar'))) {
+if (!in_array($vars['size'], array('small', 'medium', 'large', 'tiny', 'master', 'topbar'))) {
$vars['size'] = "medium";
}
-if (!empty($vars['align'])) {
- $align = " align=\"{$vars['align']}\" ";
-} else {
- $align = "";
-}
-
?>
<a href="<?php echo $annotation->getURL(); ?>">
- <img src="<?php echo $entity->getIconURL($vars['size']); ?>" <?php echo $align; ?> />
+ <img src="<?php echo $entity->getIconURL($vars['size']); ?>" />
</a>