From 1fd8bd6e296e2b1fc960fde1dd204b6c4e3e8aec Mon Sep 17 00:00:00 2001
From: Evan Winslow
Date: Wed, 8 Jun 2011 02:31:30 -0700
Subject: River revamp for 1.8
---
engine/lib/views.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'engine/lib')
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 45b2c35f8..4911171c8 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1203,7 +1203,7 @@ function elgg_view_river_item($item, array $vars = array()) {
$vars['item'] = $item;
- return elgg_view('river/item', $vars);
+ return elgg_view($item->getView(), $vars);
}
/**
--
cgit v1.2.3
From 6e05a5d7486ede1c8408144b823b895c6282f270 Mon Sep 17 00:00:00 2001
From: cash
Date: Sun, 19 Jun 2011 15:03:30 -0400
Subject: added another way for an action to be detected as an Ajax action: set
the request variable X-Requested-With = XMLHttpRequest. This is because files
cannot be uploaded with XMLHttpRequest
---
engine/lib/actions.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'engine/lib')
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index ff598916f..017653aa8 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -384,7 +384,8 @@ function actions_init() {
*/
function elgg_is_xhr() {
return isset($_SERVER['HTTP_X_REQUESTED_WITH'])
- && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
+ && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ||
+ get_input('X-Requested-With') === 'XMLHttpRequest';
}
/**
@@ -448,6 +449,9 @@ function ajax_forward_hook($hook, $type, $reason, $params) {
header("Content-type: application/json");
echo json_encode($params);
exit;
+ } else {
+ echo json_encode('not ajax');
+ exit;
}
}
--
cgit v1.2.3
From 5240a01d98d7c8b99c9d9c3f820de9c598ec5849 Mon Sep 17 00:00:00 2001
From: cash
Date: Mon, 20 Jun 2011 21:09:10 -0400
Subject: removed debug code
---
engine/lib/actions.php | 3 ---
1 file changed, 3 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index 017653aa8..4ccffd267 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -449,9 +449,6 @@ function ajax_forward_hook($hook, $type, $reason, $params) {
header("Content-type: application/json");
echo json_encode($params);
exit;
- } else {
- echo json_encode('not ajax');
- exit;
}
}
--
cgit v1.2.3
From e29500440b1848f192bc56a1bad89eac69408e7b Mon Sep 17 00:00:00 2001
From: benbro
Date: Mon, 20 Jun 2011 08:43:09 +0300
Subject: added find_active_users hook
---
engine/lib/statistics.php | 2 +-
engine/lib/users.php | 34 ++++++++++++++++++++--------------
2 files changed, 21 insertions(+), 15 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/statistics.php b/engine/lib/statistics.php
index cd2b7a6a1..1232c6128 100644
--- a/engine/lib/statistics.php
+++ b/engine/lib/statistics.php
@@ -96,7 +96,7 @@ function get_number_users($show_deactivated = false) {
*/
function get_online_users() {
$offset = get_input('offset', 0);
- $count = count(find_active_users(600, 9999));
+ $count = find_active_users(600, 10, $offset, true);
$objects = find_active_users(600, 10, $offset);
if ($objects) {
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 59bfa1259..e7e1a57f0 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -625,31 +625,37 @@ function get_user_by_email($email) {
/**
* A function that returns a maximum of $limit users who have done something within the last
- * $seconds seconds.
+ * $seconds seconds or the total count of active users.
*
* @param int $seconds Number of seconds (default 600 = 10min)
* @param int $limit Limit, default 10.
- * @param int $offset Offset, defualt 0.
+ * @param int $offset Offset, default 0.
+ * @param bool $count Count, default false.
*
* @return mixed
*/
-function find_active_users($seconds = 600, $limit = 10, $offset = 0) {
- global $CONFIG;
-
+function find_active_users($seconds = 600, $limit = 10, $offset = 0, $count = false) {
$seconds = (int)$seconds;
$limit = (int)$limit;
$offset = (int)$offset;
+ $params = array('seconds' => $seconds, 'limit' => $limit, 'offset' => $offset, 'count' => $count);
+ $data = elgg_trigger_plugin_hook('find_active_users', 'system', $params, NULL);
+ if (!$data) {
+ global $CONFIG;
- $time = time() - $seconds;
-
- $access = get_access_sql_suffix("e");
-
- $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e
- join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid
- where u.last_action >= {$time} and $access
- order by u.last_action desc limit {$offset}, {$limit}";
+ $time = time() - $seconds;
- return get_data($query, "entity_row_to_elggstar");
+ $data = elgg_get_entities(array(
+ 'type' => 'user',
+ 'limit' => $limit,
+ 'offset' => $offset,
+ 'count' => $count,
+ 'joins' => array("join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid"),
+ 'wheres' => array("u.last_action >= {$time}"),
+ 'order_by' => "u.last_action desc"
+ ));
+ }
+ return $data;
}
/**
--
cgit v1.2.3
From 43e2672f65d12a36d75ad9257a936dc93a2108f3 Mon Sep 17 00:00:00 2001
From: cash
Date: Fri, 24 Jun 2011 19:55:58 -0400
Subject: cleaned up the list/gallery css classes to use standard class naming
- minor modifications only
---
engine/lib/views.php | 4 ++--
mod/search/views/default/search/list.php | 4 ++--
views/default/css/admin.php | 2 +-
views/default/css/elements/components.php | 4 ++--
views/default/object/elements/summary.php | 2 +-
views/default/page/components/gallery.php | 31 ++++++++++++++++++++++++++++---
views/default/page/components/list.php | 6 +++---
7 files changed, 39 insertions(+), 14 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 4911171c8..df69593f9 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -969,7 +969,7 @@ $list_type_toggle = true, $pagination = true) {
// new function
$defaults = array(
'items' => $entities,
- 'list_class' => 'elgg-entity-list',
+ 'list_class' => 'elgg-list-entity',
'full_view' => true,
'pagination' => true,
'gallery' => false,
@@ -992,7 +992,7 @@ $list_type_toggle = true, $pagination = true) {
'pagination' => $pagination,
'gallery' => false,
'list_type_toggle' => $list_type_toggle,
- 'list_class' => 'elgg-entity-list',
+ 'list_class' => 'elgg-list-entity',
);
}
diff --git a/mod/search/views/default/search/list.php b/mod/search/views/default/search/list.php
index c5afaaa86..11860c094 100644
--- a/mod/search/views/default/search/list.php
+++ b/mod/search/views/default/search/list.php
@@ -82,7 +82,7 @@ $more = ($more_check > 0) ? $more_check : 0;
if ($more) {
$title_key = ($more == 1) ? 'comment' : 'comments';
$more_str = elgg_echo('search:more', array($count, $type_str));
- $more_link = "$more_str ";
+ $more_link = "$more_str ";
} else {
$more_link = '';
}
@@ -98,7 +98,7 @@ if ($view) {
$body .= '';
foreach ($entities as $entity) {
$id = "elgg-{$entity->getType()}-{$entity->getGUID()}";
- $body .= "";
+ $body .= " ";
$body .= elgg_view($view, array(
'entity' => $entity,
'params' => $vars['params'],
diff --git a/views/default/css/admin.php b/views/default/css/admin.php
index a56c7b214..d7c154438 100644
--- a/views/default/css/admin.php
+++ b/views/default/css/admin.php
@@ -383,7 +383,7 @@ table.mceLayout {
margin-left: 5px;
}
-.elgg-list-item {
+.elgg-item {
margin: 3px;
}
.elgg-menu-metadata {
diff --git a/views/default/css/elements/components.php b/views/default/css/elements/components.php
index 203f6d257..594694e60 100644
--- a/views/default/css/elements/components.php
+++ b/views/default/css/elements/components.php
@@ -47,10 +47,10 @@
border-bottom: 1px dotted #CCCCCC;
}
-.elgg-list-item .elgg-subtext {
+.elgg-item .elgg-subtext {
margin-bottom: 5px;
}
-.elgg-list-content {
+.elgg-item .elgg-content {
margin: 10px 5px;
}
diff --git a/views/default/object/elements/summary.php b/views/default/object/elements/summary.php
index d3a6ea862..9206ada66 100644
--- a/views/default/object/elements/summary.php
+++ b/views/default/object/elements/summary.php
@@ -49,5 +49,5 @@ echo "$title_link ";
echo "$subtitle
";
echo $tags;
if ($content) {
- echo "$content
";
+ echo "$content
";
}
diff --git a/views/default/page/components/gallery.php b/views/default/page/components/gallery.php
index e86b9f885..f03eb1109 100644
--- a/views/default/page/components/gallery.php
+++ b/views/default/page/components/gallery.php
@@ -2,7 +2,17 @@
/**
* Gallery view
*
- * @uses $vars['items']
+ * Implemented as an unorder list
+ *
+ * @uses $vars['items'] Array of ElggEntity or ElggAnnotation objects
+ * @uses $vars['offset'] Index of the first list item in complete list
+ * @uses $vars['limit'] Number of items per page
+ * @uses $vars['count'] Number of items in the complete list
+ * @uses $vars['pagination'] Show pagination? (default: true)
+ * @uses $vars['position'] Position of the pagination: before, after, or both
+ * @uses $vars['full_view'] Show the full view of the items (default: false)
+ * @uses $vars['gallery_class'] Additional CSS class for the element
+ * @uses $vars['item_class'] Additional CSS class for the elements
*/
$items = $vars['items'];
@@ -19,6 +29,16 @@ $pagination = elgg_extract('pagination', $vars, true);
$offset_key = elgg_extract('offset_key', $vars, 'offset');
$position = elgg_extract('position', $vars, 'after');
+$gallery_class = 'elgg-gallery';
+if (isset($vars['gallery_class'])) {
+ $gallery_class = "$gallery_class {$vars['gallery_class']}";
+}
+
+$item_class = 'elgg-item';
+if (isset($vars['item_class'])) {
+ $item_class = "$item_class {$vars['item_class']}";
+}
+
if ($pagination && $count) {
$nav .= elgg_view('navigation/pagination', array(
'offset' => $offset,
@@ -33,10 +53,15 @@ if ($position == 'before' || $position == 'both') {
}
?>
-
+
';
+ if (elgg_instanceof($item)) {
+ $id = "elgg-{$item->getType()}-{$item->getGUID()}";
+ } else {
+ $id = "item-{$item->getType()}-{$item->id}";
+ }
+ echo "";
echo elgg_view_list_item($item, $vars);
echo " ";
}
diff --git a/views/default/page/components/list.php b/views/default/page/components/list.php
index ae951c89f..c83fa0966 100644
--- a/views/default/page/components/list.php
+++ b/views/default/page/components/list.php
@@ -27,12 +27,12 @@ $position = elgg_extract('position', $vars, 'after');
$list_class = 'elgg-list';
if (isset($vars['list_class'])) {
- $list_class = "{$vars['list_class']} $list_class";
+ $list_class = "$list_class {$vars['list_class']}";
}
-$item_class = 'elgg-list-item';
+$item_class = 'elgg-item';
if (isset($vars['item_class'])) {
- $item_class = "{$vars['item_class']} $item_class";
+ $item_class = "$item_class {$vars['item_class']}";
}
$html = "";
--
cgit v1.2.3
From efff3471e09a864948feadb989d2ac9f5f2e0fc5 Mon Sep 17 00:00:00 2001
From: cash
Date: Fri, 24 Jun 2011 20:25:34 -0400
Subject: Refs #1253 using 'list_type' string instead of boolean 'gallery' for
entity listing
---
engine/lib/entities.php | 9 ++++-----
engine/lib/views.php | 23 ++++++++++++----------
mod/custom_index/index.php | 2 +-
mod/file/views/default/file/typecloud.php | 2 +-
.../views/default/groups/sidebar/members.php | 2 +-
views/default/widgets/friends/content.php | 2 +-
6 files changed, 21 insertions(+), 19 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index cb197b569..10313fc8c 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1190,10 +1190,10 @@ $time_created_lower = NULL, $time_updated_upper = NULL, $time_updated_lower = NU
* @internal This also provides the views for elgg_view_annotation().
*
* @param array $options Any options from $getter options plus:
- * full_view => BOOL Display full view entities
- * list_type_toggle => BOOL Display gallery / list switch
- * pagination => BOOL Display pagination links
- * gallery => BOOL display in gallery view
+ * full_view => BOOL Display full view entities
+ * list_type => STR 'list' or 'gallery'
+ * list_type_toggle => BOOL Display gallery / list switch
+ * pagination => BOOL Display pagination links
*
* @param mixed $getter The entity getter function to use to fetch the entities
* @param mixed $viewer The function to use to view the entity list.
@@ -1216,7 +1216,6 @@ function elgg_list_entities(array $options = array(), $getter = 'elgg_get_entiti
'full_view' => TRUE,
'list_type_toggle' => FALSE,
'pagination' => TRUE,
- 'gallery' => FALSE,
);
$options = array_merge($defaults, $options);
diff --git a/engine/lib/views.php b/engine/lib/views.php
index df69593f9..7358fc0ba 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -950,9 +950,10 @@ function elgg_view_annotation(ElggAnnotation $annotation, array $vars = array(),
* 'offset' The current indexing offset
* 'limit' The number of entities to display per page
* 'full_view' Display the full view of the entities?
- * 'list_class' CSS Class applied to the list
+ * 'list_class' CSS class applied to the list
+ * 'item_class' CSS class applied to the list items
* 'pagination' Display pagination?
- * 'gallery' Display as gallery?
+ * 'list_type' List type: 'list' (default), 'gallery'
* 'list_type_toggle' Display the list type toggle?
*
* @return string The rendered list of entities
@@ -965,6 +966,13 @@ $list_type_toggle = true, $pagination = true) {
$offset = (int)get_input('offset', 0);
}
+ // list type can be passed as request parameter
+ $list_type = get_input('list_type', 'list');
+ if (get_input('listtype')) {
+ elgg_deprecated_notice("'listtype' has been deprecated by 'list_type' for lists", 1.8);
+ $list_type = get_input('listtype');
+ }
+
if (is_array($vars)) {
// new function
$defaults = array(
@@ -972,7 +980,7 @@ $list_type_toggle = true, $pagination = true) {
'list_class' => 'elgg-list-entity',
'full_view' => true,
'pagination' => true,
- 'gallery' => false,
+ 'list_type' => $list_type,
'list_type_toggle' => false,
'offset' => $offset,
);
@@ -990,18 +998,13 @@ $list_type_toggle = true, $pagination = true) {
'limit' => (int) $limit,
'full_view' => $full_view,
'pagination' => $pagination,
- 'gallery' => false,
+ 'list_type' => $list_type,
'list_type_toggle' => $list_type_toggle,
'list_class' => 'elgg-list-entity',
);
}
- $listtype = get_input('listtype', 'list');
- if ($listtype != 'list') {
- $vars['gallery'] = true;
- }
-
- if ($vars['gallery']) {
+ if ($vars['list_type'] != 'list') {
return elgg_view('page/components/gallery', $vars);
} else {
return elgg_view('page/components/list', $vars);
diff --git a/mod/custom_index/index.php b/mod/custom_index/index.php
index e39e6ef29..831114127 100644
--- a/mod/custom_index/index.php
+++ b/mod/custom_index/index.php
@@ -35,7 +35,7 @@ $newest_members = elgg_list_entities_from_metadata(array(
'limit' => 10,
'full_view' => false,
'pagination' => false,
- 'gallery' => true,
+ 'list_type' => 'gallery',
'size' => 'small',
));
diff --git a/mod/file/views/default/file/typecloud.php b/mod/file/views/default/file/typecloud.php
index ce4d6c127..4253bf674 100644
--- a/mod/file/views/default/file/typecloud.php
+++ b/mod/file/views/default/file/typecloud.php
@@ -15,7 +15,7 @@ function file_type_cloud_get_url($type, $friends) {
}
if ($type->tag == "image") {
- $url .= "&listtype=gallery";
+ $url .= "&list_type=gallery";
}
if (elgg_get_page_owner_guid()) {
diff --git a/mod/groups/views/default/groups/sidebar/members.php b/mod/groups/views/default/groups/sidebar/members.php
index 28111554f..3026c05f2 100644
--- a/mod/groups/views/default/groups/sidebar/members.php
+++ b/mod/groups/views/default/groups/sidebar/members.php
@@ -21,7 +21,7 @@ $body = elgg_list_entities_from_relationship(array(
'inverse_relationship' => true,
'types' => 'user',
'limit' => $limit,
- 'gallery' => true,
+ 'list_type' => 'gallery',
));
$body .= "$all_link
";
diff --git a/views/default/widgets/friends/content.php b/views/default/widgets/friends/content.php
index ec842a252..bb5bd7a8d 100644
--- a/views/default/widgets/friends/content.php
+++ b/views/default/widgets/friends/content.php
@@ -16,7 +16,7 @@ $size = $vars['entity']->icon_size;
if (elgg_instanceof($owner, 'user')) {
$html = $owner->listFriends('', $num, array(
'size' => $size,
- 'gallery' => true,
+ 'list_type' => 'gallery',
));
if ($html) {
echo $html;
--
cgit v1.2.3
From fe1003bbbbcd577c5059b5d8822ffe710e195e0b Mon Sep 17 00:00:00 2001
From: cash
Date: Sat, 25 Jun 2011 16:14:55 -0400
Subject: fixed spacing in elgg_admin_add_plugin_settings_menu()
---
engine/lib/admin.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'engine/lib')
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 3bfb69102..c16da9295 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -348,7 +348,7 @@ function elgg_admin_add_plugin_settings_menu() {
'parent_name' => 'settings',
'context' => 'admin',
'section' => 'configure',
- ));
+ ));
}
}
}
--
cgit v1.2.3
From 5f4db01d382159858a1d37c5fd1708d9165b1911 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Sat, 25 Jun 2011 12:36:53 -0400
Subject: datalist_get() was incorrectly setting escaped values in the cache.
---
engine/lib/configuration.php | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php
index cbc083bd0..b756d2e70 100644
--- a/engine/lib/configuration.php
+++ b/engine/lib/configuration.php
@@ -282,8 +282,8 @@ function datalist_set($name, $value) {
return false;
}
- $name = sanitise_string($name);
- $value = sanitise_string($value);
+ $sanitised_name = sanitise_string($name);
+ $sanitised_value = sanitise_string($value);
// If memcache is available then invalidate the cached copy
static $datalist_memcache;
@@ -295,13 +295,16 @@ function datalist_set($name, $value) {
$datalist_memcache->delete($name);
}
- insert_data("INSERT into {$CONFIG->dbprefix}datalists"
- . " set name = '{$name}', value = '{$value}'"
- . " ON DUPLICATE KEY UPDATE value='{$value}'");
-
- $DATALIST_CACHE[$name] = $value;
+ $success = insert_data("INSERT into {$CONFIG->dbprefix}datalists"
+ . " set name = '{$sanitised_name}', value = '{$sanitised_value}'"
+ . " ON DUPLICATE KEY UPDATE value='{$sanitised_value}'");
- return true;
+ if ($success) {
+ $DATALIST_CACHE[$name] = $value;
+ return true;
+ } else {
+ return false;
+ }
}
/**
--
cgit v1.2.3
From 6e8662a4d6bae1ba433664555df3b5fa05049172 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Sat, 25 Jun 2011 20:48:13 -0400
Subject: Fixes #3554. Pulled 1.7->1.8 upgrade bootstrapping into a separate
function. Made the plugin upgrade that forwards (2011010101) set itself in
the processed upgrades.
---
engine/lib/upgrade.php | 104 +++++++++++++++++++++++++++----------
engine/lib/upgrades/2011010101.php | 5 +-
2 files changed, 81 insertions(+), 28 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/upgrade.php b/engine/lib/upgrade.php
index 85810956b..dc3911062 100644
--- a/engine/lib/upgrade.php
+++ b/engine/lib/upgrade.php
@@ -20,15 +20,15 @@ function upgrade_code($version, $quiet = FALSE) {
$version = (int) $version;
$upgrade_path = elgg_get_config('path') . 'engine/lib/upgrades/';
- $processed_upgrades = unserialize(datalist_get('processed_upgrades'));
- // the day we started the new upgrade names
- $upgrade_epoch = 2011021700;
+ $processed_upgrades = elgg_get_processed_upgrades();
+ // upgrading from 1.7 to 1.8. Need to bootstrap.
if (!$processed_upgrades) {
- $processed_upgrades = array();
- }
+ elgg_upgrade_bootstrap_17_to_18();
- $upgrades = array();
+ // grab accurate processed upgrades
+ $processed_upgrades = elgg_get_processed_upgrades();
+ }
$upgrade_files = elgg_get_upgrade_files($upgrade_path);
@@ -36,23 +36,7 @@ function upgrade_code($version, $quiet = FALSE) {
return false;
}
- // if before the new upgrade system, run through all upgrades and check
- // version number. After the upgrade epoch, pull run upgrades from db
- if ($version < $upgrade_epoch) {
- foreach ($upgrade_files as $upgrade_file) {
- $upgrade_version = elgg_get_upgrade_file_version($upgrade_file);
-
- if ($version < $upgrade_version) {
- $upgrades[] = $upgrade_file;
- } else {
- // set this upgrade as processed so that we don't run it again
- $processed_upgrades[] = $upgrade_file;
- }
- }
- } else {
- // add any upgrades that haven't been run to the upgrades list
- $upgrades = elgg_get_unprocessed_upgrades($upgrade_files, $processed_upgrades);
- }
+ $upgrades = elgg_get_unprocessed_upgrades($upgrade_files, $processed_upgrades);
// Sort and execute
sort($upgrades);
@@ -67,7 +51,7 @@ function upgrade_code($version, $quiet = FALSE) {
try {
if (!@include("$upgrade_path/$upgrade")) {
$success = false;
- error_log($e->getmessage());
+ error_log("Could not include $upgrade_path/$upgrade");
}
} catch (Exception $e) {
$success = false;
@@ -76,6 +60,7 @@ function upgrade_code($version, $quiet = FALSE) {
} else {
if (!include("$upgrade_path/$upgrade")) {
$success = false;
+ error_log("Could not include $upgrade_path/$upgrade");
}
}
@@ -84,13 +69,12 @@ function upgrade_code($version, $quiet = FALSE) {
$processed_upgrades[] = $upgrade;
// don't set the version to a lower number in instances where an upgrade
- // has been merged from a lower version
+ // has been merged from a lower version of Elgg
if ($upgrade_version > $version) {
datalist_set('version', $upgrade_version);
}
- $processed_upgrades = array_unique($processed_upgrades);
- datalist_set('processed_upgrades', serialize($processed_upgrades));
+ elgg_set_processed_upgrades($processed_upgrades);
} else {
return false;
}
@@ -99,6 +83,29 @@ function upgrade_code($version, $quiet = FALSE) {
return true;
}
+/**
+ * Saves the processed upgrades to a dataset.
+ *
+ * @param array $processed_upgrades An array of processed upgrade filenames
+ * (not the path, just the file)
+ * @return bool
+ */
+function elgg_set_processed_upgrades(array $processed_upgrades) {
+ $processed_upgrades = array_unique($processed_upgrades);
+ return datalist_set('processed_upgrades', serialize($processed_upgrades));
+}
+
+/**
+ * Gets a list of processes upgrades
+ *
+ * @return mixed Array of processed upgrade filenames or false
+ */
+function elgg_get_processed_upgrades() {
+ $upgrades = datalist_get('processed_upgrades');
+ $unserialized = unserialize($upgrades);
+ return $unserialized;
+}
+
/**
* Returns the version of the upgrade filename.
*
@@ -248,3 +255,46 @@ function version_upgrade() {
return false;
}
+
+/**
+ * Boot straps into 1.8 upgrade system from 1.7
+ *
+ * This runs all the 1.7 upgrades, then sets the processed_upgrades to all existing 1.7 upgrades.
+ * Control is then passed back to the main upgrade function which detects and runs the
+ * 1.8 upgrades, regardless of filename convention.
+ *
+ * @return bool
+ */
+function elgg_upgrade_bootstrap_17_to_18() {
+ $db_version = (int) datalist_get('version');
+
+ // the 1.8 upgrades before the upgrade system change that are interspersed with 1.7 upgrades.
+ $upgrades_18 = array(
+ '2010111501.php',
+ '2010121601.php',
+ '2010121602.php',
+ '2010121701.php',
+ '2010123101.php',
+ '2011010101.php',
+ );
+
+ $upgrades_17 = array();
+ $upgrade_files = elgg_get_upgrade_files();
+ $processed_upgrades = array();
+
+ foreach ($upgrade_files as $upgrade_file) {
+ // ignore if not in 1.7 format or if it's a 1.8 upgrade
+ if (in_array($upgrade_file, $upgrades_18) || !preg_match("/[0-9]{10}\.php/", $upgrade_file)) {
+ continue;
+ }
+
+ $upgrade_version = elgg_get_upgrade_file_version($upgrade_file);
+
+ // this has already been run in a previous 1.7.X -> 1.7.X upgrade
+ if ($upgrade_version < $db_version) {
+ $processed_upgrades[] = $upgrade_file;
+ }
+ }
+
+ return elgg_set_processed_upgrades($processed_upgrades);
+}
diff --git a/engine/lib/upgrades/2011010101.php b/engine/lib/upgrades/2011010101.php
index 9dbaff1e4..b063c249b 100644
--- a/engine/lib/upgrades/2011010101.php
+++ b/engine/lib/upgrades/2011010101.php
@@ -87,7 +87,10 @@ if ($upgrade_version > $version) {
datalist_set('version', $upgrade_version);
}
+// add ourselves to the processed_upgrades.
+$processed_upgrades[] = '2011010101.php';
+
$processed_upgrades = array_unique($processed_upgrades);
-datalist_set('processed_upgrades', serialize($processed_upgrades));
+elgg_set_processed_upgrades($processed_upgrades);
forward('upgrade.php');
--
cgit v1.2.3
From 6008aea060c27be0b4e0bf81e4f111d0f6d47db3 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Sat, 25 Jun 2011 20:53:13 -0400
Subject: Don't say the db was upgradeded when it wasn't.
---
engine/lib/deprecated-1.8.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php
index d92257a09..ff4fa0756 100644
--- a/engine/lib/deprecated-1.8.php
+++ b/engine/lib/deprecated-1.8.php
@@ -20,7 +20,7 @@
* @param string $fromdir Optional directory to load upgrades from. default: engine/schema/upgrades/
* @param bool $quiet If true, suppress all error messages. Only use for the upgrade from <=1.6.
*
- * @return bool
+ * @return int The number of upgrades run.
* @see upgrade.php
* @see version.php
* @deprecated 1.8 Use PHP upgrades for sql changes.
@@ -35,6 +35,8 @@ function db_upgrade($version, $fromdir = "", $quiet = FALSE) {
if (!$fromdir) {
$fromdir = $CONFIG->path . 'engine/schema/upgrades/';
}
+
+ $i = 0;
if ($handle = opendir($fromdir)) {
$sqlupgrades = array();
@@ -65,11 +67,12 @@ function db_upgrade($version, $fromdir = "", $quiet = FALSE) {
} else {
run_sql_script($fromdir . $sqlfile);
}
+ $i++;
}
}
}
- return TRUE;
+ return $i;
}
/**
--
cgit v1.2.3
From 32387e6db0c56935e93314217b52eab4d9dca016 Mon Sep 17 00:00:00 2001
From: Cash Costello
Date: Sun, 26 Jun 2011 08:16:19 -0400
Subject: Fixes #3470 using rel=toggle now
---
engine/classes/ElggMenuItem.php | 4 ++++
engine/lib/navigation.php | 2 +-
js/lib/ui.js | 6 +++---
mod/groups/start.php | 4 ++--
mod/logbrowser/views/default/logbrowser/form.php | 8 ++++----
mod/profile/views/default/profile/owner_block.php | 2 +-
mod/reportedcontent/views/default/object/reported_content.php | 2 +-
views/default/object/plugin/advanced.php | 2 +-
views/default/object/plugin/invalid.php | 2 +-
views/default/object/widget/elements/controls.php | 6 ++++--
views/default/page/layouts/widgets/add_button.php | 11 ++++++++---
11 files changed, 30 insertions(+), 19 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index cd6267ad6..1181583f2 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -504,6 +504,10 @@ class ElggMenuItem {
$vars['class'] = $this->getLinkClass();
}
+ if ($this->link_rel) {
+ $vars['rel'] = $this->link_rel;
+ }
+
if ($this->rel) {
$vars['rel'] = $this->rel;
}
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index b51c63b49..4b2c998a2 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -276,7 +276,7 @@ function elgg_river_menu_setup($hook, $type, $return, $params) {
'href' => "#comments-add-$object->guid",
'text' => elgg_view_icon('speech-bubble'),
'title' => elgg_echo('comment:this'),
- 'link_class' => "elgg-toggler",
+ 'link_rel' => 'toggle',
'priority' => 50,
);
$return[] = ElggMenuItem::factory($options);
diff --git a/js/lib/ui.js b/js/lib/ui.js
index 89a996122..fd20acbd1 100644
--- a/js/lib/ui.js
+++ b/js/lib/ui.js
@@ -11,7 +11,7 @@ elgg.ui.init = function () {
$('.elgg-system-messages li').animate({opacity: 0.9}, 6000);
$('.elgg-system-messages li').fadeOut('slow');
- $('.elgg-toggler').live('click', elgg.ui.toggles);
+ $('[rel=toggle]').live('click', elgg.ui.toggles);
$('[rel=popup]').live('click', elgg.ui.popsUp);
@@ -27,8 +27,8 @@ elgg.ui.init = function () {
/**
* Toggles an element based on clicking a separate element
*
- * Use .elgg-toggler on the toggler element
- * Set the href to target the item you want to toggle ()
+ * Use rel="toggle" on the toggler element
+ * Set the href to target the item you want to toggle ( )
*
* @param {Object} event
* @return void
diff --git a/mod/groups/start.php b/mod/groups/start.php
index f35c058b6..57c40af5d 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -764,7 +764,7 @@ function discussion_owner_block_menu($hook, $type, $return, $params) {
* Add the reply button for the river
*/
function discussion_add_to_river_menu($hook, $type, $return, $params) {
- if (elgg_is_logged_in() && !elgg_get_context('widgets')) {
+ if (elgg_is_logged_in() && !elgg_in_context('widgets')) {
$item = $params['item'];
$object = $item->getObjectEntity();
if (elgg_instanceof($object, 'object', 'groupforumtopic')) {
@@ -776,7 +776,7 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) {
'href' => "#groups-reply-$object->guid",
'text' => elgg_view_icon('speech-bubble'),
'title' => elgg_echo('reply:this'),
- 'link_class' => "elgg-toggler",
+ 'link_rel' => 'toggle',
'priority' => 50,
);
$return[] = ElggMenuItem::factory($options);
diff --git a/mod/logbrowser/views/default/logbrowser/form.php b/mod/logbrowser/views/default/logbrowser/form.php
index d2476afac..d5cf9f6b8 100644
--- a/mod/logbrowser/views/default/logbrowser/form.php
+++ b/mod/logbrowser/views/default/logbrowser/form.php
@@ -59,9 +59,12 @@
$toggle_link = elgg_view('output/url', array(
'href' => '#log-browser-search-form',
'text' => elgg_echo('logbrowser:search'),
- 'class' => 'elgg-toggler',
+ 'rel' => 'toggle',
));
?>
+
+
+
-
-
-
\ No newline at end of file
diff --git a/mod/profile/views/default/profile/owner_block.php b/mod/profile/views/default/profile/owner_block.php
index 48d7ff24f..5a65a3a26 100644
--- a/mod/profile/views/default/profile/owner_block.php
+++ b/mod/profile/views/default/profile/owner_block.php
@@ -35,7 +35,7 @@ if (elgg_is_admin_logged_in() && elgg_get_logged_in_user_guid() != elgg_get_page
$text = elgg_echo('admin:options');
$admin_links = '
diff --git a/views/default/object/plugin/advanced.php b/views/default/object/plugin/advanced.php
index 51fb69d17..84fc0439b 100644
--- a/views/default/object/plugin/advanced.php
+++ b/views/default/object/plugin/advanced.php
@@ -242,7 +242,7 @@ if (elgg_view_exists($settings_view_old) || elgg_view_exists($settings_view_new)
echo elgg_view('output/url', array(
'href' => "#elgg-plugin-manifest-{$plugin->getID()}",
'text' => elgg_echo("admin:plugins:label:moreinfo"),
- 'class' => 'elgg-toggler',
+ 'rel' => 'toggle',
));
?>
diff --git a/views/default/object/plugin/invalid.php b/views/default/object/plugin/invalid.php
index 9e239b7ca..f29ee8d12 100644
--- a/views/default/object/plugin/invalid.php
+++ b/views/default/object/plugin/invalid.php
@@ -29,7 +29,7 @@ $error = $plugin->getError();
echo elgg_view('output/url', array(
'href' => "#elgg-plugin-manifest-{$plugin->getID()}",
'text' => elgg_echo("admin:plugins:label:moreinfo"),
- 'class' => 'elgg-toggler',
+ 'rel' => 'toggle',
));
?>
diff --git a/views/default/object/widget/elements/controls.php b/views/default/object/widget/elements/controls.php
index 83a2f5767..abf2154fc 100644
--- a/views/default/object/widget/elements/controls.php
+++ b/views/default/object/widget/elements/controls.php
@@ -12,7 +12,8 @@ $show_edit = elgg_extract('show_edit', $vars, true);
$params = array(
'text' => ' ',
'href' => "#elgg-widget-content-$widget->guid",
- 'class' => 'elgg-widget-collapse-button elgg-toggler',
+ 'class' => 'elgg-widget-collapse-button',
+ 'rel' => 'toggle',
);
$collapse_link = elgg_view('output/url', $params);
@@ -33,7 +34,8 @@ if ($widget->canEdit()) {
'text' => elgg_view_icon('settings-alt'),
'title' => elgg_echo('widget:edit'),
'href' => "#widget-edit-$widget->guid",
- 'class' => "elgg-toggler elgg-widget-edit-button",
+ 'class' => "elgg-widget-edit-button",
+ 'rel' => 'toggle',
);
$edit_link = elgg_view('output/url', $params);
}
diff --git a/views/default/page/layouts/widgets/add_button.php b/views/default/page/layouts/widgets/add_button.php
index a8670146b..89e83b096 100644
--- a/views/default/page/layouts/widgets/add_button.php
+++ b/views/default/page/layouts/widgets/add_button.php
@@ -4,7 +4,12 @@
*/
?>
--
cgit v1.2.3
From f3240e1da73d4a89e379c0c34f8ce86f460e18dc Mon Sep 17 00:00:00 2001
From: Cash Costello
Date: Sun, 26 Jun 2011 08:38:28 -0400
Subject: Fixes #3585 do not need to check parameters because was registered
for only one event
---
engine/lib/relationships.php | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index 5224efaf1..9d5fd39b6 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -593,38 +593,31 @@ function export_relationship_plugin_hook($hook, $entity_type, $returnvalue, $par
}
/**
- * An event listener which will notify users based on certain events.
+ * Notify user that someone has friended them
*
- * @param string $event Event name
- * @param string $object_type Object type
- * @param mixed $object Object
+ * @param string $event Event name
+ * @param string $type Object type
+ * @param mixed $object Object
*
* @return bool
*/
-function relationship_notification_hook($event, $object_type, $object) {
- global $CONFIG;
+function relationship_notification_hook($event, $type, $object) {
- if (
- ($object instanceof ElggRelationship) &&
- ($event == 'create') &&
- ($object_type == 'friend')
- ) {
- $user_one = get_entity($object->guid_one);
- $user_two = get_entity($object->guid_two);
+ $user_one = get_entity($object->guid_one);
+ $user_two = get_entity($object->guid_two);
- // Notify target user
- return notify_user($object->guid_two, $object->guid_one,
+ return notify_user($object->guid_two,
+ $object->guid_one,
elgg_echo('friend:newfriend:subject', array($user_one->name)),
elgg_echo("friend:newfriend:body", array($user_one->name, $user_one->getURL()))
- );
- }
+ );
}
-/** Register the import hook */
+// Register the import hook
elgg_register_plugin_hook_handler("import", "all", "import_relationship_plugin_hook", 3);
-/** Register the hook, ensuring entities are serialised first */
+// Register the hook, ensuring entities are serialised first
elgg_register_plugin_hook_handler("export", "all", "export_relationship_plugin_hook", 3);
-/** Register event to listen to some events **/
+// Register event to listen to some events
elgg_register_event_handler('create', 'friend', 'relationship_notification_hook');
--
cgit v1.2.3
From e43d4443e6e9718433496b739f0af6630aad9e95 Mon Sep 17 00:00:00 2001
From: cash
Date: Sun, 26 Jun 2011 14:02:36 -0400
Subject: added a data array to ElggMenuItem. Now by default options end up
being passed to output/url.
---
engine/classes/ElggMenuItem.php | 273 ++++++++++++++++++++++------------------
engine/lib/navigation.php | 2 +-
mod/groups/start.php | 2 +-
3 files changed, 152 insertions(+), 125 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index 1181583f2..36c21b8b4 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -10,75 +10,62 @@
* @since 1.8.0
*/
class ElggMenuItem {
- /**
- * @var string Identifier of the menu
- */
- protected $name;
/**
- * @var string The menu display string
+ * @var array Non-rendered data about the menu item
*/
- protected $text;
+ protected $data = array(
+ // string Identifier of the menu
+ 'name' => '',
- /**
- * @var string The menu url
- */
- protected $href = null;
+ // array Page contexts this menu item should appear on
+ 'contexts' => array('all'),
- /**
- * @var string The string to display if link is clicked
- */
- protected $confirm = '';
+ // string Menu section identifier
+ 'section' => 'default',
- /**
- * @var array Classes to apply to the anchor tag.
- */
- protected $linkClass = array();
+ // int Smaller priorities float to the top
+ 'priority' => 100,
- /**
- * @var array Classes to apply to the li tag.
- */
- protected $itemClass = array();
+ // bool Is this the currently selected menu item
+ 'selected' => false,
- /**
- * @var array Page context array
- */
- protected $contexts = array('all');
+ // string Identifier of this item's parent
+ 'parent_name' => '',
- /**
- * @var string Menu section identifier
- */
- protected $section = 'default';
+ // ElggMenuItem The parent object or null
+ 'parent' => null,
- /**
- * @var string Tooltip
- */
- protected $title = '';
+ // array Array of children objects or empty array
+ 'children' => array(),
- /**
- * @var int Menu priority - smaller prioritys float to the top
- */
- protected $priority = 100;
+ // array Classes to apply to the li tag
+ 'itemClass' => array(),
+
+ // array Classes to apply to the anchor tag
+ 'linkClass' => array(),
+ );
/**
- * @var bool Is this the currently selected menu item
+ * @var string The menu display string
*/
- protected $selected = false;
+ protected $text;
/**
- * @var string Identifier of this item's parent
+ * @var string The menu url
*/
- protected $parent_name = '';
+ protected $href = null;
/**
- * @var ElggMenuItem The parent object or null
+ * @var string Tooltip
*/
- protected $parent = null;
+ protected $title = '';
/**
- * @var array Array of children objects or empty array
+ * @var string The string to display if link is clicked
*/
- protected $children = array();
+ protected $confirm = '';
+
/**
* ElggMenuItem constructor
@@ -88,13 +75,15 @@ class ElggMenuItem {
* @param string $href URL of the menu item (false if not a link)
*/
public function __construct($name, $text, $href) {
- $this->name = $name;
+ //$this->name = $name;
$this->text = $text;
if ($href) {
$this->href = elgg_normalize_url($href);
} else {
$this->href = $href;
}
+
+ $this->data['name'] = $name;
}
/**
@@ -122,6 +111,12 @@ class ElggMenuItem {
$options['contexts'] = $options['context'];
unset($options['context']);
}
+
+ // make sure contexts is set correctly
+ if (isset($options['contexts'])) {
+ $item->setContext($options['contexts']);
+ unset($options['contexts']);
+ }
if (isset($options['link_class'])) {
$item->setLinkClass($options['link_class']);
@@ -133,16 +128,62 @@ class ElggMenuItem {
unset($options['item_class']);
}
+ if (isset($options['data']) && is_array($options['data'])) {
+ $item->setData($options['data']);
+ unset($options['data']);
+ }
+
foreach ($options as $key => $value) {
- $item->$key = $value;
+ if (isset($item->data[$key])) {
+ $item->data[$key] = $value;
+ } else {
+ $item->$key = $value;
+ }
}
- // make sure contexts is set correctly
- if (isset($options['contexts'])) {
- $item->setContext($options['contexts']);
+ return $item;
+ }
+
+ /**
+ * Set a data key/value pair or a set of key/value pairs
+ *
+ * This method allows storage of arbitrary data with this menu item. The
+ * data can be used for sorting, custom rendering, or any other use.
+ *
+ * @param mixed $key String key or an associative array of key/value pairs
+ * @param mixed $value The value if $key is a string
+ * @return void
+ */
+ public function setData($key, $value = null) {
+ if (is_array($key)) {
+ $this->data += $key;
+ } else {
+ $this->data[$key] = $value;
}
+ }
- return $item;
+ /**
+ * Get stored data
+ *
+ * @param string $key The key for the requested key/value pair
+ * @return mixed
+ */
+ public function getData($key) {
+ if (isset($this->data[$key])) {
+ return $this->data[$key];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Set the identifier of the menu item
+ *
+ * @param string Unique identifier
+ * @return void
+ */
+ public function setName($name) {
+ $this->data['name'] = $name;
}
/**
@@ -151,14 +192,13 @@ class ElggMenuItem {
* @return string
*/
public function getName() {
- return $this->name;
+ return $this->data['name'];
}
-
+
/**
* Set the display text of the menu item
*
* @param string $text The display text
- *
* @return void
*/
public function setText($text) {
@@ -177,6 +217,7 @@ class ElggMenuItem {
/**
* Set the URL of the menu item
*
+ * @param string $href URL or false if not a link
* @return void
*/
public function setHref($href) {
@@ -196,14 +237,13 @@ class ElggMenuItem {
* Set the contexts that this menu item is available for
*
* @param array $contexts An array of context strings
- *
* @return void
*/
public function setContext($contexts) {
if (is_string($contexts)) {
$contexts = array($contexts);
}
- $this->contexts = $contexts;
+ $this->data['contexts'] = $contexts;
}
/**
@@ -212,27 +252,26 @@ class ElggMenuItem {
* @return array
*/
public function getContext() {
- return $this->contexts;
+ return $this->data['contexts'];
}
/**
* Should this menu item be used given the current context
*
* @param string $context A context string (default is empty string for
- * current context stack.
- *
+ * current context stack).
* @return bool
*/
public function inContext($context = '') {
if ($context) {
- return in_array($context, $this->contexts);
+ return in_array($context, $this->data['contexts']);
}
- if (in_array('all', $this->contexts)) {
+ if (in_array('all', $this->data['contexts'])) {
return true;
}
- foreach ($this->contexts as $context) {
+ foreach ($this->data['contexts'] as $context) {
if (elgg_in_context($context)) {
return true;
}
@@ -244,11 +283,10 @@ class ElggMenuItem {
* Set the selected flag
*
* @param bool $state Selected state (default is true)
- *
* @return void
*/
public function setSelected($state = true) {
- $this->selected = $state;
+ $this->data['selected'] = $state;
}
/**
@@ -257,14 +295,13 @@ class ElggMenuItem {
* @return bool
*/
public function getSelected() {
- return $this->selected;
+ return $this->data['selected'];
}
/**
* Set the tool tip text
*
* @param string $text The text of the tool tip
- *
* @return void
*/
public function setTooltip($text) {
@@ -284,7 +321,6 @@ class ElggMenuItem {
* Set the confirm text shown when link is clicked
*
* @param string $text The text to show
- *
* @return void
*/
public function setConfirmText($text) {
@@ -304,14 +340,13 @@ class ElggMenuItem {
* Set the anchor class
*
* @param mixed $class An array of class names, or a single string class name.
- *
* @return void
*/
public function setLinkClass($class) {
if (!is_array($class)) {
- $this->linkClass[] = $class;
+ $this->data['linkClass'] = array($class);
} else {
- $this->linkClass = $class;
+ $this->data['linkClass'] = $class;
}
}
@@ -321,21 +356,34 @@ class ElggMenuItem {
* @return string
*/
public function getLinkClass() {
- return implode(' ', $this->linkClass);
+ return implode(' ', $this->data['linkClass']);
}
/**
- * Set the li classes
+ * Add a link class
*
* @param mixed $class An array of class names, or a single string class name.
+ * @return void
+ */
+ public function addLinkClass($class) {
+ if (!is_array($class)) {
+ $this->data['linkClass'][] = $class;
+ } else {
+ $this->data['linkClass'] += $class;
+ }
+ }
+
+ /**
+ * Set the li classes
*
+ * @param mixed $class An array of class names, or a single string class name.
* @return void
*/
public function setItemClass($class) {
if (!is_array($class)) {
- $this->itemClass[] = $class;
+ $this->data['itemClass'] = array($class);
} else {
- $this->itemClass = $class;
+ $this->data['itemClass'] = $class;
}
}
@@ -345,11 +393,11 @@ class ElggMenuItem {
* @return string
*/
public function getItemClass() {
- //allow people to specify name with underscores and colons
+ // allow people to specify name with underscores and colons
$name = str_replace('_', '-', $this->getName());
$name = str_replace(':', '-', $name);
- $class = implode(' ', $this->itemClass);
+ $class = implode(' ', $this->data['itemClass']);
if ($class) {
return "elgg-menu-item-$name $class";
} else {
@@ -361,11 +409,10 @@ class ElggMenuItem {
* Set the priority of the menu item
*
* @param int $priority The smaller numbers mean higher priority (1 before 100)
- *
* @return void
*/
public function setWeight($priority) {
- $this->priority = $priority;
+ $this->data['priority'] = $priority;
}
/**
@@ -374,18 +421,17 @@ class ElggMenuItem {
* @return int
*/
public function getWeight() {
- return $this->priority;
+ return $this->data['priority'];
}
/**
* Set the section identifier
*
* @param string $section The identifier of the section
- *
* @return void
*/
public function setSection($section) {
- $this->section = $section;
+ $this->data['section'] = $section;
}
/**
@@ -394,18 +440,17 @@ class ElggMenuItem {
* @return string
*/
public function getSection() {
- return $this->section;
+ return $this->data['section'];
}
/**
* Set the parent identifier
*
- * @param string $parent_name The identifier of the parent ElggMenuItem
- *
+ * @param string $name The identifier of the parent ElggMenuItem
* @return void
*/
- public function setParentName($parent_name) {
- $this->parent_name = $parent_name;
+ public function setParentName($name) {
+ $this->data['parent_name'] = $name;
}
/**
@@ -414,18 +459,17 @@ class ElggMenuItem {
* @return string
*/
public function getParentName() {
- return $this->parent_name;
+ return $this->data['parent_name'];
}
/**
* Set the parent menu item
*
* @param ElggMenuItem $parent
- *
* @return void
*/
public function setParent($parent) {
- $this->parent = $parent;
+ $this->data['parent'] = $parent;
}
/**
@@ -434,29 +478,27 @@ class ElggMenuItem {
* @return ElggMenuItem or null
*/
public function getParent() {
- return $this->parent;
+ return $this->data['parent'];
}
/**
* Add a child menu item
*
* @param ElggMenuItem $item
- *
* @return void
*/
public function addChild($item) {
- $this->children[] = $item;
+ $this->data['children'][] = $item;
}
/**
* Set the menu item's children
*
* @param array $children Array of ElggMenuItems
- *
* @return void
*/
public function setChildren($children) {
- $this->children = $children;
+ $this->data['children'] = $children;
}
/**
@@ -465,25 +507,23 @@ class ElggMenuItem {
* @return array
*/
public function getChildren() {
- return $this->children;
+ return $this->data['children'];
}
/**
* Sort the children
*
- * @param string $sort_function
- *
+ * @param string $sortFunction A function that is passed to usort()
* @return void
*/
- public function sortChildren($sort_function) {
- usort($this->children, $sort_function);
+ public function sortChildren($sortFunction) {
+ usort($this->data['children'], $sortFunction);
}
/**
* Get the menu item content (usually a link)
*
* @params array $vars Options to pass to output/url if a link
- *
* @return string
*
* @todo View code in a model. How do we feel about that?
@@ -494,30 +534,17 @@ class ElggMenuItem {
return $this->text;
}
- $vars['text'] = $this->text;
+ $defaults = get_object_vars($this);
+ unset($defaults['data']);
- if ($this->href) {
- $vars['href'] = $this->href;
- }
+ $vars += $defaults;
- if ($this->linkClass) {
- $vars['class'] = $this->getLinkClass();
- }
-
- if ($this->link_rel) {
- $vars['rel'] = $this->link_rel;
- }
-
- if ($this->rel) {
- $vars['rel'] = $this->rel;
- }
-
- if ($this->title) {
- $vars['title'] = $this->title;
- }
-
- if ($this->is_action) {
- $vars['is_action'] = $this->is_action;
+ if ($this->data['linkClass']) {
+ if (isset($vars['class'])) {
+ $vars['class'] += $this->getLinkClass();
+ } else {
+ $vars['class'] = $this->getLinkClass();
+ }
}
if ($this->confirm) {
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 4b2c998a2..48a3659f6 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -276,7 +276,7 @@ function elgg_river_menu_setup($hook, $type, $return, $params) {
'href' => "#comments-add-$object->guid",
'text' => elgg_view_icon('speech-bubble'),
'title' => elgg_echo('comment:this'),
- 'link_rel' => 'toggle',
+ 'rel' => 'toggle',
'priority' => 50,
);
$return[] = ElggMenuItem::factory($options);
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 57c40af5d..83353bae5 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -776,7 +776,7 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) {
'href' => "#groups-reply-$object->guid",
'text' => elgg_view_icon('speech-bubble'),
'title' => elgg_echo('reply:this'),
- 'link_rel' => 'toggle',
+ 'rel' => 'toggle',
'priority' => 50,
);
$return[] = ElggMenuItem::factory($options);
--
cgit v1.2.3
From 3c34ddf59804767e6a7deea3e3ee6c81d4a09601 Mon Sep 17 00:00:00 2001
From: cash
Date: Sun, 26 Jun 2011 15:13:50 -0400
Subject: removed buttons logic from content header view, created convenience
function rather than copying and pasting, and updated the blog plugin
---
engine/lib/navigation.php | 35 +++++++++++++++++++++++++++
mod/blog/lib/blog.php | 6 +++--
views/default/page/layouts/content.php | 1 -
views/default/page/layouts/content/header.php | 30 ++++++++---------------
4 files changed, 49 insertions(+), 23 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 4b2c998a2..1cb289654 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -153,6 +153,41 @@ function elgg_is_menu_item_registered($menu_name, $item_name) {
return false;
}
+/**
+ * Convenience function for registering an add content button to title menu
+ *
+ * The add URL must be $handler/add/$guid where $guid is the guid of the page owner.
+ * The label of the button is "$handler:add" so that must be defined in a
+ * language file.
+ *
+ * @param string $handler The handler to use or null to autodetect from context
+ * @return void
+ * @since 1.8.0
+ */
+function elgg_register_add_button($handler = null) {
+ if (elgg_is_logged_in()) {
+
+ if (!$handler) {
+ $handler = elgg_get_context();
+ }
+
+ $owner = elgg_get_page_owner_entity();
+ if (!$owner) {
+ // no owns the page so this is probably an all site list page
+ $owner = elgg_get_logged_in_user_entity();
+ }
+ if ($owner && $owner->canWriteToContainer()) {
+ $guid = $owner->getGUID();
+ elgg_register_menu_item('title', array(
+ 'name' => 'add',
+ 'href' => "$handler/add/$guid",
+ 'text' => elgg_echo("$handler:add"),
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+ }
+ }
+}
+
/**
* Adds a breadcrumb to the breadcrumbs stack.
*
diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php
index 4d1edd50e..d13b2244e 100644
--- a/mod/blog/lib/blog.php
+++ b/mod/blog/lib/blog.php
@@ -92,6 +92,8 @@ function blog_get_page_content_list($container_guid = NULL) {
elgg_push_breadcrumb(elgg_echo('blog:blogs'));
}
+ elgg_register_add_button();
+
// show all posts for admin or users looking at their own blogs
// show only published posts for other users.
if (!(elgg_is_admin_logged_in() || (elgg_is_logged_in() && $container_guid == $loggedin_userid))) {
@@ -129,6 +131,8 @@ function blog_get_page_content_friends($user_guid) {
elgg_push_breadcrumb($crumbs_title, "blog/owner/{$user->username}");
elgg_push_breadcrumb(elgg_echo('friends'));
+ elgg_register_add_button();
+
if (!$friends = get_user_friends($user_guid, ELGG_ENTITIES_ANY_VALUE, 0)) {
$return['content'] .= elgg_echo('friends:none:you');
return $return;
@@ -235,7 +239,6 @@ function blog_get_page_content_archive($owner_guid, $lower = 0, $upper = 0) {
return array(
'content' => $content,
'title' => $title,
- 'buttons' => '',
'filter' => '',
);
}
@@ -253,7 +256,6 @@ function blog_get_page_content_edit($page, $guid = 0, $revision = NULL) {
elgg_load_js('elgg.blog');
$return = array(
- 'buttons' => '',
'filter' => '',
);
diff --git a/views/default/page/layouts/content.php b/views/default/page/layouts/content.php
index 35d695f0a..c406c9faf 100644
--- a/views/default/page/layouts/content.php
+++ b/views/default/page/layouts/content.php
@@ -10,7 +10,6 @@
* @uses $vars['filter'] HTML of the content area filter (override)
* @uses $vars['title'] Title text (override)
* @uses $vars['context'] Page context (override)
- * @uses $vars['buttons'] Content header buttons (override)
* @uses $vars['filter_context'] Filter context: everyone, friends, mine
* @uses $vars['class'] Additional class to apply to layout
*/
diff --git a/views/default/page/layouts/content/header.php b/views/default/page/layouts/content/header.php
index 403da8a0a..345163bdd 100644
--- a/views/default/page/layouts/content/header.php
+++ b/views/default/page/layouts/content/header.php
@@ -7,9 +7,13 @@
* @uses $vars['header_override'] HTML for overriding the default header (override)
* @uses $vars['title'] Title text (override)
* @uses $vars['context'] Page context (override)
- * @uses $vars['buttons'] Content header buttons (override)
*/
+if (isset($vars['buttons'])) {
+ // it was a bad idea to implement buttons with a pass through
+ elgg_deprecated_notice("Use elgg_register_menu_item() to register for the title menu", 1.0);
+}
+
if (isset($vars['header_override'])) {
echo $vars['header_override'];
return true;
@@ -22,27 +26,13 @@ if ($context) {
$title = elgg_echo($context);
}
- if (isset($vars['buttons'])) {
+ if (isset($vars['buttons']) && $vars['buttons']) {
$buttons = $vars['buttons'];
} else {
- if (elgg_is_logged_in() && $context) {
- $owner = elgg_get_page_owner_entity();
- if (!$owner) {
- // this is probably an all page
- $owner = elgg_get_logged_in_user_entity();
- }
- if ($owner && $owner->canWriteToContainer()) {
- $guid = $owner->getGUID();
- elgg_register_menu_item('title', array(
- 'name' => 'add',
- 'href' => elgg_extract('new_link', $vars, "$context/add/$guid"),
- 'text' => elgg_echo("$context:add"),
- 'link_class' => 'elgg-button elgg-button-action',
- ));
- }
- }
-
- $buttons = elgg_view_menu('title', array('sort_by' => 'priority', 'class' => 'elgg-menu-hz'));
+ $buttons = elgg_view_menu('title', array(
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+ ));
}
echo <<
--
cgit v1.2.3
From eb43980ad428e9c64406579de0677da7a4fcd081 Mon Sep 17 00:00:00 2001
From: Cash Costello
Date: Tue, 28 Jun 2011 07:30:22 -0400
Subject: using elgg_view_title() in content layout header
---
engine/lib/views.php | 15 +++++++-----
views/default/page/layouts/content/header.php | 35 ++++++++++++++-------------
2 files changed, 27 insertions(+), 23 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 7358fc0ba..aff0dbd0d 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1076,21 +1076,24 @@ function elgg_view_entity_annotations(ElggEntity $entity, $full_view = true) {
}
/**
- * Returns a rendered title.
+ * Renders a title.
*
* This is a shortcut for {@elgg_view page/elements/title}.
*
- * @param string $title The page title
- * @param string $submenu Should a submenu be displayed? (deprecated)
+ * @param string $title The page title
+ * @param string $vars View variables (was submenu be displayed? (deprecated))
*
* @return string The HTML (etc)
*/
-function elgg_view_title($title, $submenu = false) {
- if ($submenu !== false) {
+function elgg_view_title($title, $vars = array()) {
+ if (!is_array($vars)) {
elgg_deprecated_notice('setting $submenu in elgg_view_title() is deprecated', 1.8);
+ $vars = array('submenu' => $vars);
}
- return elgg_view('page/elements/title', array('title' => $title, 'submenu' => $submenu));
+ $vars['title'] = $title;
+
+ return elgg_view('page/elements/title', $vars);
}
/**
diff --git a/views/default/page/layouts/content/header.php b/views/default/page/layouts/content/header.php
index 345163bdd..1e66e52db 100644
--- a/views/default/page/layouts/content/header.php
+++ b/views/default/page/layouts/content/header.php
@@ -2,7 +2,7 @@
/**
* Main content header
*
- * This includes a title and a new content button by default
+ * Title and title menu
*
* @uses $vars['header_override'] HTML for overriding the default header (override)
* @uses $vars['title'] Title text (override)
@@ -20,23 +20,24 @@ if (isset($vars['header_override'])) {
}
$context = elgg_extract('context', $vars, elgg_get_context());
-if ($context) {
- $title = elgg_extract('title', $vars, '');
- if (!$title) {
- $title = elgg_echo($context);
- }
- if (isset($vars['buttons']) && $vars['buttons']) {
- $buttons = $vars['buttons'];
- } else {
- $buttons = elgg_view_menu('title', array(
- 'sort_by' => 'priority',
- 'class' => 'elgg-menu-hz',
- ));
- }
- echo << 'elgg-heading-main'));
+
+if (isset($vars['buttons']) && $vars['buttons']) {
+ $buttons = $vars['buttons'];
+} else {
+ $buttons = elgg_view_menu('title', array(
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+ ));
+}
+
+echo <<
- $title $buttons
+ $title$buttons
HTML;
-}
--
cgit v1.2.3
From 1bcdb6a23d907668c5965f908f53483be3af074f Mon Sep 17 00:00:00 2001
From: cash
Date: Wed, 29 Jun 2011 20:16:04 -0400
Subject: added @since dates on two functions in group library
---
engine/lib/group.php | 2 ++
1 file changed, 2 insertions(+)
(limited to 'engine/lib')
diff --git a/engine/lib/group.php b/engine/lib/group.php
index 755482b00..e7b70fd10 100644
--- a/engine/lib/group.php
+++ b/engine/lib/group.php
@@ -294,6 +294,7 @@ function group_gatekeeper($forward = true) {
* @param bool $default_on True if this option should be active by default
*
* @return void
+ * @since 1.5.0
*/
function add_group_tool_option($name, $label, $default_on = true) {
global $CONFIG;
@@ -319,6 +320,7 @@ function add_group_tool_option($name, $label, $default_on = true) {
* @param string $name Name of the group tool option
*
* @return void
+ * @since 1.7.5
*/
function remove_group_tool_option($name) {
global $CONFIG;
--
cgit v1.2.3
From 0750728e977c04a4a358bac0496b9d31c958238f Mon Sep 17 00:00:00 2001
From: cash
Date: Wed, 29 Jun 2011 20:34:55 -0400
Subject: added backward compatibility for the view
page_elements/content_wrapper
---
engine/lib/views.php | 14 ++++++++++++++
views/default/page/elements/wrapper.php | 22 ++++++++++++++++++++++
2 files changed, 36 insertions(+)
create mode 100644 views/default/page/elements/wrapper.php
(limited to 'engine/lib')
diff --git a/engine/lib/views.php b/engine/lib/views.php
index aff0dbd0d..8745d3117 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1514,6 +1514,19 @@ function elgg_views_add_rss_link() {
}
}
+/**
+ * Registers deprecated views to avoid making some pages from older plugins
+ * completely empty.
+ *
+ * @private
+ */
+function elgg_views_handle_deprecated_views() {
+ $location = elgg_get_view_location('page_elements/contentwrapper');
+ if ($location === "/var/www/views/") {
+ elgg_extend_view('page_elements/contentwrapper', 'page/elements/wrapper');
+ }
+}
+
/**
* Initialize viewtypes on system boot event
* This ensures simplecache is cleared during upgrades. See #2252
@@ -1560,3 +1573,4 @@ function elgg_views_boot() {
}
elgg_register_event_handler('boot', 'system', 'elgg_views_boot', 1000);
+elgg_register_event_handler('init', 'system', 'elgg_views_handle_deprecated_views');
diff --git a/views/default/page/elements/wrapper.php b/views/default/page/elements/wrapper.php
new file mode 100644
index 000000000..61828832d
--- /dev/null
+++ b/views/default/page/elements/wrapper.php
@@ -0,0 +1,22 @@
+
+
+
+
+
--
cgit v1.2.3
From a7b5ea1ee0ed37bae6091ba8fd98d529ba04707b Mon Sep 17 00:00:00 2001
From: Cash Costello
Date: Thu, 30 Jun 2011 06:54:45 -0400
Subject: Refs #3015 updated jquery and jquery-ui to their latest releases
---
engine/lib/views.php | 4 +-
vendors/jquery/jquery-1.5.min.js | 16 -
vendors/jquery/jquery-1.6.1.min.js | 18 +
vendors/jquery/jquery-ui-1.8.14.min.js | 789 +++++++++++++++++++++++++++++++++
vendors/jquery/jquery-ui-1.8.9.min.js | 781 --------------------------------
5 files changed, 809 insertions(+), 799 deletions(-)
delete mode 100644 vendors/jquery/jquery-1.5.min.js
create mode 100644 vendors/jquery/jquery-1.6.1.min.js
create mode 100644 vendors/jquery/jquery-ui-1.8.14.min.js
delete mode 100644 vendors/jquery/jquery-ui-1.8.9.min.js
(limited to 'engine/lib')
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 8745d3117..dde298c2b 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1543,8 +1543,8 @@ function elgg_views_boot() {
elgg_register_simplecache_view('css/ie6');
elgg_register_simplecache_view('js/elgg');
- elgg_register_js('jquery', '/vendors/jquery/jquery-1.5.min.js', 'head', 1);
- elgg_register_js('jquery-ui', '/vendors/jquery/jquery-ui-1.8.9.min.js', 'head', 2);
+ elgg_register_js('jquery', '/vendors/jquery/jquery-1.6.1.min.js', 'head', 1);
+ elgg_register_js('jquery-ui', '/vendors/jquery/jquery-ui-1.8.14.min.js', 'head', 2);
elgg_register_js('jquery.form', '/vendors/jquery/jquery.form.js');
elgg_load_js('jquery');
elgg_load_js('jquery-ui');
diff --git a/vendors/jquery/jquery-1.5.min.js b/vendors/jquery/jquery-1.5.min.js
deleted file mode 100644
index 9144b8ae9..000000000
--- a/vendors/jquery/jquery-1.5.min.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.5
- * http://jquery.com/
- *
- * Copyright 2011, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Mon Jan 31 08:31:29 2011 -0500
- */
-(function(a,b){function b$(a){return d.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function bX(a){if(!bR[a]){var b=d("<"+a+">").appendTo("body"),c=b.css("display");b.remove();if(c==="none"||c==="")c="block";bR[a]=c}return bR[a]}function bW(a,b){var c={};d.each(bV.concat.apply([],bV.slice(0,b)),function(){c[this]=a});return c}function bJ(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var e=a.dataTypes,f=a.converters,g,h=e.length,i,j=e[0],k,l,m,n,o;for(g=1;g=0===c})}function N(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function F(a,b){return(a&&a!=="*"?a+".":"")+b.replace(q,"`").replace(r,"&")}function E(a){var b,c,e,f,g,h,i,j,k,l,m,n,p,q=[],r=[],s=d._data(this,u);typeof s==="function"&&(s=s.events);if(a.liveFired!==this&&s&&s.live&&!a.target.disabled&&(!a.button||a.type!=="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var t=s.live.slice(0);for(i=0;ic)break;a.currentTarget=f.elem,a.data=f.handleObj.data,a.handleObj=f.handleObj,p=f.handleObj.origHandler.apply(f.elem,arguments);if(p===!1||a.isPropagationStopped()){c=f.level,p===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function C(a,b,c){c[0].type=a;return d.event.handle.apply(b,c)}function w(){return!0}function v(){return!1}function f(a,c,f){if(f===b&&a.nodeType===1){f=a.getAttribute("data-"+c);if(typeof f==="string"){try{f=f==="true"?!0:f==="false"?!1:f==="null"?null:d.isNaN(f)?e.test(f)?d.parseJSON(f):f:parseFloat(f)}catch(g){}d.data(a,c,f)}else f=b}return f}var c=a.document,d=function(){function I(){if(!d.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(I,1);return}d.ready()}}var d=function(a,b){return new d.fn.init(a,b,g)},e=a.jQuery,f=a.$,g,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,i=/\S/,j=/^\s+/,k=/\s+$/,l=/\d/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=navigator.userAgent,w,x=!1,y,z="then done fail isResolved isRejected promise".split(" "),A,B=Object.prototype.toString,C=Object.prototype.hasOwnProperty,D=Array.prototype.push,E=Array.prototype.slice,F=String.prototype.trim,G=Array.prototype.indexOf,H={};d.fn=d.prototype={constructor:d,init:function(a,e,f){var g,i,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!e&&c.body){this.context=c,this[0]=c.body,this.selector="body",this.length=1;return this}if(typeof a==="string"){g=h.exec(a);if(!g||!g[1]&&e)return!e||e.jquery?(e||f).find(a):this.constructor(e).find(a);if(g[1]){e=e instanceof d?e[0]:e,k=e?e.ownerDocument||e:c,j=m.exec(a),j?d.isPlainObject(e)?(a=[c.createElement(j[1])],d.fn.attr.call(a,e,!0)):a=[k.createElement(j[1])]:(j=d.buildFragment([g[1]],[k]),a=(j.cacheable?d.clone(j.fragment):j.fragment).childNodes);return d.merge(this,a)}i=c.getElementById(g[2]);if(i&&i.parentNode){if(i.id!==g[2])return f.find(a);this.length=1,this[0]=i}this.context=c,this.selector=a;return this}if(d.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return d.makeArray(a,this)},selector:"",jquery:"1.5",length:0,size:function(){return this.length},toArray:function(){return E.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var e=this.constructor();d.isArray(a)?D.apply(e,a):d.merge(e,a),e.prevObject=this,e.context=this.context,b==="find"?e.selector=this.selector+(this.selector?" ":"")+c:b&&(e.selector=this.selector+"."+b+"("+c+")");return e},each:function(a,b){return d.each(this,a,b)},ready:function(a){d.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(E.apply(this,arguments),"slice",E.call(arguments).join(","))},map:function(a){return this.pushStack(d.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:D,sort:[].sort,splice:[].splice},d.fn.init.prototype=d.fn,d.extend=d.fn.extend=function(){var a,c,e,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i==="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!=="object"&&!d.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;y.resolveWith(c,[d]),d.fn.trigger&&d(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!x){x=!0;if(c.readyState==="complete")return setTimeout(d.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",A,!1),a.addEventListener("load",d.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",A),a.attachEvent("onload",d.ready);var b=!1;try{b=a.frameElement==null}catch(e){}c.documentElement.doScroll&&b&&I()}}},isFunction:function(a){return d.type(a)==="function"},isArray:Array.isArray||function(a){return d.type(a)==="array"},isWindow:function(a){return a&&typeof a==="object"&&"setInterval"in a},isNaN:function(a){return a==null||!l.test(a)||isNaN(a)},type:function(a){return a==null?String(a):H[B.call(a)]||"object"},isPlainObject:function(a){if(!a||d.type(a)!=="object"||a.nodeType||d.isWindow(a))return!1;if(a.constructor&&!C.call(a,"constructor")&&!C.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a){}return c===b||C.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!=="string"||!b)return null;b=d.trim(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return a.JSON&&a.JSON.parse?a.JSON.parse(b):(new Function("return "+b))();d.error("Invalid JSON: "+b)},parseXML:function(b,c,e){a.DOMParser?(e=new DOMParser,c=e.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),e=c.documentElement,(!e||!e.nodeName||e.nodeName==="parsererror")&&d.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(a){if(a&&i.test(a)){var b=c.getElementsByTagName("head")[0]||c.documentElement,e=c.createElement("script");e.type="text/javascript",d.support.scriptEval()?e.appendChild(c.createTextNode(a)):e.text=a,b.insertBefore(e,b.firstChild),b.removeChild(e)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,e){var f,g=0,h=a.length,i=h===b||d.isFunction(a);if(e){if(i){for(f in a)if(c.apply(a[f],e)===!1)break}else for(;g1?(g=Array(c),d.each(b,function(a,b){d.when(b).then(function(b){g[a]=arguments.length>1?E.call(arguments,0):b,--c||e.resolveWith(f,g)},e.reject)})):e!==a&&e.resolve(a);return f},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}d.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.subclass=this.subclass,a.fn.init=function b(b,c){c&&c instanceof d&&!(c instanceof a)&&(c=a(c));return d.fn.init.call(this,b,c,e)},a.fn.init.prototype=a.fn;var e=a(c);return a},browser:{}}),y=d._Deferred(),d.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){H["[object "+b+"]"]=b.toLowerCase()}),w=d.uaMatch(v),w.browser&&(d.browser[w.browser]=!0,d.browser.version=w.version),d.browser.webkit&&(d.browser.safari=!0),G&&(d.inArray=function(a,b){return G.call(b,a)}),i.test("Â ")&&(j=/^[\s\xA0]+/,k=/[\s\xA0]+$/),g=d(c),c.addEventListener?A=function(){c.removeEventListener("DOMContentLoaded",A,!1),d.ready()}:c.attachEvent&&(A=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",A),d.ready())});return a.jQuery=a.$=d}();(function(){d.support={};var b=c.createElement("div");b.style.display="none",b.innerHTML=" a ";var e=b.getElementsByTagName("*"),f=b.getElementsByTagName("a")[0],g=c.createElement("select"),h=g.appendChild(c.createElement("option"));if(e&&e.length&&f){d.support={leadingWhitespace:b.firstChild.nodeType===3,tbody:!b.getElementsByTagName("tbody").length,htmlSerialize:!!b.getElementsByTagName("link").length,style:/red/.test(f.getAttribute("style")),hrefNormalized:f.getAttribute("href")==="/a",opacity:/^0.55$/.test(f.style.opacity),cssFloat:!!f.style.cssFloat,checkOn:b.getElementsByTagName("input")[0].value==="on",optSelected:h.selected,deleteExpando:!0,optDisabled:!1,checkClone:!1,_scriptEval:null,noCloneEvent:!0,boxModel:null,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableHiddenOffsets:!0},g.disabled=!0,d.support.optDisabled=!h.disabled,d.support.scriptEval=function(){if(d.support._scriptEval===null){var b=c.documentElement,e=c.createElement("script"),f="script"+d.now();e.type="text/javascript";try{e.appendChild(c.createTextNode("window."+f+"=1;"))}catch(g){}b.insertBefore(e,b.firstChild),a[f]?(d.support._scriptEval=!0,delete a[f]):d.support._scriptEval=!1,b.removeChild(e),b=e=f=null}return d.support._scriptEval};try{delete b.test}catch(i){d.support.deleteExpando=!1}b.attachEvent&&b.fireEvent&&(b.attachEvent("onclick",function j(){d.support.noCloneEvent=!1,b.detachEvent("onclick",j)}),b.cloneNode(!0).fireEvent("onclick")),b=c.createElement("div"),b.innerHTML=" ";var k=c.createDocumentFragment();k.appendChild(b.firstChild),d.support.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,d(function(){var a=c.createElement("div"),b=c.getElementsByTagName("body")[0];if(b){a.style.width=a.style.paddingLeft="1px",b.appendChild(a),d.boxModel=d.support.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,d.support.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",d.support.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="";var e=a.getElementsByTagName("td");d.support.reliableHiddenOffsets=e[0].offsetHeight===0,e[0].style.display="",e[1].style.display="none",d.support.reliableHiddenOffsets=d.support.reliableHiddenOffsets&&e[0].offsetHeight===0,a.innerHTML="",b.removeChild(a).style.display="none",a=e=null}});var l=function(a){var b=c.createElement("div");a="on"+a;if(!b.attachEvent)return!0;var d=a in b;d||(b.setAttribute(a,"return;"),d=typeof b[a]==="function"),b=null;return d};d.support.submitBubbles=l("submit"),d.support.changeBubbles=l("change"),b=e=f=null}})();var e=/^(?:\{.*\}|\[.*\])$/;d.extend({cache:{},uuid:0,expando:"jQuery"+(d.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?d.cache[a[d.expando]]:a[d.expando];return!!a&&!d.isEmptyObject(a)},data:function(a,c,e,f){if(d.acceptData(a)){var g=d.expando,h=typeof c==="string",i,j=a.nodeType,k=j?d.cache:a,l=j?a[d.expando]:a[d.expando]&&d.expando;if((!l||f&&l&&!k[l][g])&&h&&e===b)return;l||(j?a[d.expando]=l=++d.uuid:l=d.expando),k[l]||(k[l]={}),typeof c==="object"&&(f?k[l][g]=d.extend(k[l][g],c):k[l]=d.extend(k[l],c)),i=k[l],f&&(i[g]||(i[g]={}),i=i[g]),e!==b&&(i[c]=e);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[c]:i}},removeData:function(b,c,e){if(d.acceptData(b)){var f=d.expando,g=b.nodeType,h=g?d.cache:b,i=g?b[d.expando]:d.expando;if(!h[i])return;if(c){var j=e?h[i][f]:h[i];if(j){delete j[c];if(!d.isEmptyObject(j))return}}if(e){delete h[i][f];if(!d.isEmptyObject(h[i]))return}var k=h[i][f];d.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},h[i][f]=k):g&&(d.support.deleteExpando?delete b[d.expando]:b.removeAttribute?b.removeAttribute(d.expando):b[d.expando]=null)}},_data:function(a,b,c){return d.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=d.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),d.fn.extend({data:function(a,c){var e=null;if(typeof a==="undefined"){if(this.length){e=d.data(this[0]);if(this[0].nodeType===1){var g=this[0].attributes,h;for(var i=0,j=g.length;i-1)return!0;return!1},val:function(a){if(!arguments.length){var c=this[0];if(c){if(d.nodeName(c,"option")){var e=c.attributes.value;return!e||e.specified?c.value:c.text}if(d.nodeName(c,"select")){var f=c.selectedIndex,g=[],h=c.options,j=c.type==="select-one";if(f<0)return null;for(var k=j?f:0,l=j?f+1:h.length;k=0;else if(d.nodeName(this,"select")){var f=d.makeArray(e);d("option",this).each(function(){this.selected=d.inArray(d(this).val(),f)>=0}),f.length||(this.selectedIndex=-1)}else this.value=e}})}}),d.extend({attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,e,f){if(!a||a.nodeType===3||a.nodeType===8||a.nodeType===2)return b;if(f&&c in d.attrFn)return d(a)[c](e);var g=a.nodeType!==1||!d.isXMLDoc(a),h=e!==b;c=g&&d.props[c]||c;if(a.nodeType===1){var i=j.test(c);if(c==="selected"&&!d.support.optSelected){var n=a.parentNode;n&&(n.selectedIndex,n.parentNode&&n.parentNode.selectedIndex)}if((c in a||a[c]!==b)&&g&&!i){h&&(c==="type"&&k.test(a.nodeName)&&a.parentNode&&d.error("type property can't be changed"),e===null?a.nodeType===1&&a.removeAttribute(c):a[c]=e);if(d.nodeName(a,"form")&&a.getAttributeNode(c))return a.getAttributeNode(c).nodeValue;if(c==="tabIndex"){var o=a.getAttributeNode("tabIndex");return o&&o.specified?o.value:l.test(a.nodeName)||m.test(a.nodeName)&&a.href?0:b}return a[c]}if(!d.support.style&&g&&c==="style"){h&&(a.style.cssText=""+e);return a.style.cssText}h&&a.setAttribute(c,""+e);if(!a.attributes[c]&&(a.hasAttribute&&!a.hasAttribute(c)))return b;var p=!d.support.hrefNormalized&&g&&i?a.getAttribute(c,2):a.getAttribute(c);return p===null?b:p}h&&(a[c]=e);return a[c]}});var o=/\.(.*)$/,p=/^(?:textarea|input|select)$/i,q=/\./g,r=/ /g,s=/[^\w\s.|`]/g,t=function(a){return a.replace(s,"\\$&")},u="events";d.event={add:function(c,e,f,g){if(c.nodeType!==3&&c.nodeType!==8){d.isWindow(c)&&(c!==a&&!c.frameElement)&&(c=a);if(f===!1)f=v;else if(!f)return;var h,i;f.handler&&(h=f,f=h.handler),f.guid||(f.guid=d.guid++);var j=d._data(c);if(!j)return;var k=j[u],l=j.handle;typeof k==="function"?(l=k.handle,k=k.events):k||(c.nodeType||(j[u]=j=function(){}),j.events=k={}),l||(j.handle=l=function(){return typeof d!=="undefined"&&!d.event.triggered?d.event.handle.apply(l.elem,arguments):b}),l.elem=c,e=e.split(" ");var m,n=0,o;while(m=e[n++]){i=h?d.extend({},h):{handler:f,data:g},m.indexOf(".")>-1?(o=m.split("."),m=o.shift(),i.namespace=o.slice(0).sort().join(".")):(o=[],i.namespace=""),i.type=m,i.guid||(i.guid=f.guid);var p=k[m],q=d.event.special[m]||{};if(!p){p=k[m]=[];if(!q.setup||q.setup.call(c,g,o,l)===!1)c.addEventListener?c.addEventListener(m,l,!1):c.attachEvent&&c.attachEvent("on"+m,l)}q.add&&(q.add.call(c,i),i.handler.guid||(i.handler.guid=f.guid)),p.push(i),d.event.global[m]=!0}c=null}},global:{},remove:function(a,c,e,f){if(a.nodeType!==3&&a.nodeType!==8){e===!1&&(e=v);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=d.hasData(a)&&d._data(a),w=s&&s[u];if(!s||!w)return;typeof w==="function"&&(s=w,w=w.events),c&&c.type&&(e=c.handler,c=c.type);if(!c||typeof c==="string"&&c.charAt(0)==="."){c=c||"";for(h in w)d.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+d.map(m.slice(0).sort(),t).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=w[h];if(!p)continue;if(!e){for(j=0;j=0&&(a.type=f=f.slice(0,-1),a.exclusive=!0),e||(a.stopPropagation(),d.event.global[f]&&d.each(d.cache,function(){var b=d.expando,e=this[b];e&&e.events&&e.events[f]&&d.event.trigger(a,c,e.handle.elem)}));if(!e||e.nodeType===3||e.nodeType===8)return b;a.result=b,a.target=e,c=d.makeArray(c),c.unshift(a)}a.currentTarget=e;var h=e.nodeType?d._data(e,"handle"):(d._data(e,u)||{}).handle;h&&h.apply(e,c);var i=e.parentNode||e.ownerDocument;try{e&&e.nodeName&&d.noData[e.nodeName.toLowerCase()]||e["on"+f]&&e["on"+f].apply(e,c)===!1&&(a.result=!1,a.preventDefault())}catch(j){}if(!a.isPropagationStopped()&&i)d.event.trigger(a,c,i,!0);else if(!a.isDefaultPrevented()){var k,l=a.target,m=f.replace(o,""),n=d.nodeName(l,"a")&&m==="click",p=d.event.special[m]||{};if((!p._default||p._default.call(e,a)===!1)&&!n&&!(l&&l.nodeName&&d.noData[l.nodeName.toLowerCase()])){try{l[m]&&(k=l["on"+m],k&&(l["on"+m]=null),d.event.triggered=!0,l[m]())}catch(q){}k&&(l["on"+m]=k),d.event.triggered=!1}}},handle:function(c){var e,f,g,h,i,j=[],k=d.makeArray(arguments);c=k[0]=d.event.fix(c||a.event),c.currentTarget=this,e=c.type.indexOf(".")<0&&!c.exclusive,e||(g=c.type.split("."),c.type=g.shift(),j=g.slice(0).sort(),h=new RegExp("(^|\\.)"+j.join("\\.(?:.*\\.)?")+"(\\.|$)")),c.namespace=c.namespace||j.join("."),i=d._data(this,u),typeof i==="function"&&(i=i.events),f=(i||{})[c.type];if(i&&f){f=f.slice(0);for(var l=0,m=f.length;l-1?d.map(a.options,function(a){return a.selected}).join("-"):"":a.nodeName.toLowerCase()==="select"&&(c=a.selectedIndex);return c},B=function B(a){var c=a.target,e,f;if(p.test(c.nodeName)&&!c.readOnly){e=d._data(c,"_change_data"),f=A(c),(a.type!=="focusout"||c.type!=="radio")&&d._data(c,"_change_data",f);if(e===b||f===e)return;if(e!=null||f){a.type="change",a.liveFired=b;return d.event.trigger(a,arguments[1],c)}}};d.event.special.change={filters:{focusout:B,beforedeactivate:B,click:function(a){var b=a.target,c=b.type;if(c==="radio"||c==="checkbox"||b.nodeName.toLowerCase()==="select")return B.call(this,a)},keydown:function(a){var b=a.target,c=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")return B.call(this,a)},beforeactivate:function(a){var b=a.target;d._data(b,"_change_data",A(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in z)d.event.add(this,c+".specialChange",z[c]);return p.test(this.nodeName)},teardown:function(a){d.event.remove(this,".specialChange");return p.test(this.nodeName)}},z=d.event.special.change.filters,z.focus=z.beforeactivate}c.addEventListener&&d.each({focus:"focusin",blur:"focusout"},function(a,b){function c(a){a=d.event.fix(a),a.type=b;return d.event.handle.call(this,a)}d.event.special[b]={setup:function(){this.addEventListener(a,c,!0)},teardown:function(){this.removeEventListener(a,c,!0)}}}),d.each(["bind","one"],function(a,c){d.fn[c]=function(a,e,f){if(typeof a==="object"){for(var g in a)this[c](g,e,a[g],f);return this}if(d.isFunction(e)||e===!1)f=e,e=b;var h=c==="one"?d.proxy(f,function(a){d(this).unbind(a,h);return f.apply(this,arguments)}):f;if(a==="unload"&&c!=="one")this.one(a,e,f);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},d.attrFn&&(d.attrFn[b]=!0)}),function(){function s(a,b,c,d,e,f){for(var g=0,h=d.length;g0){k=j;break}}j=j[a]}d[g]=k}}}function r(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,g=!1,h=!0;[0,0].sort(function(){h=!1;return 0});var i=function(b,d,e,g){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!=="string")return e;var l,m,o,p,q,r,s,u,v=!0,w=i.isXML(d),x=[],y=b;do{a.exec(""),l=a.exec(y);if(l){y=l[3],x.push(l[1]);if(l[2]){p=l[3];break}}}while(l);if(x.length>1&&k.exec(b))if(x.length===2&&j.relative[x[0]])m=t(x[0]+x[1],d);else{m=j.relative[x[0]]?[d]:i(x.shift(),d);while(x.length)b=x.shift(),j.relative[b]&&(b+=x.shift()),m=t(b,m)}else{!g&&x.length>1&&d.nodeType===9&&!w&&j.match.ID.test(x[0])&&!j.match.ID.test(x[x.length-1])&&(q=i.find(x.shift(),d,w),d=q.expr?i.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:n(g)}:i.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),m=q.expr?i.filter(q.expr,q.set):q.set,x.length>0?o=n(m):v=!1;while(x.length)r=x.pop(),s=r,j.relative[r]?s=x.pop():r="",s==null&&(s=d),j.relative[r](o,s,w)}else o=x=[]}o||(o=m),o||i.error(r||b);if(f.call(o)==="[object Array]")if(v)if(d&&d.nodeType===1)for(u=0;o[u]!=null;u++)o[u]&&(o[u]===!0||o[u].nodeType===1&&i.contains(d,o[u]))&&e.push(m[u]);else for(u=0;o[u]!=null;u++)o[u]&&o[u].nodeType===1&&e.push(m[u]);else e.push.apply(e,o);else n(o,e);p&&(i(p,h,e,g),i.uniqueSort(e));return e};i.uniqueSort=function(a){if(p){g=h,a.sort(p);if(g)for(var b=1;b0},i.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=j.order.length;e":function(a,b){var c,d=typeof b==="string",e=0,f=a.length;if(d&&!/\W/.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(/\\/g,"")},TAG:function(a,b){return a[1].toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||i.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&i.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(/\\/g,"");!f&&j.attrMap[g]&&(a[1]=j.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(/\\/g,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=i(b[3],null,null,c);else{var g=i.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(j.match.POS.test(b[0])||j.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!i(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){return"text"===a.type},radio:function(a){return"radio"===a.type},checkbox:function(a){return"checkbox"===a.type},file:function(a){return"file"===a.type},password:function(a){return"password"===a.type},submit:function(a){return"submit"===a.type},image:function(a){return"image"===a.type},reset:function(a){return"reset"===a.type},button:function(a){return"button"===a.type||a.nodeName.toLowerCase()==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=j.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||i.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,k=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=j.attrHandle[c]?j.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=j.setFilters[e];if(f)return f(a,c,b,d)}}},k=j.match.POS,l=function(a,b){return"\\"+(b-0+1)};for(var m in j.match)j.match[m]=new RegExp(j.match[m].source+/(?![^\[]*\])(?![^\(]*\))/.source),j.leftMatch[m]=new RegExp(/(^(?:.|\r|\n)*?)/.source+j.match[m].source.replace(/\\(\d+)/g,l));var n=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(o){n=function(a,b){var c=0,d=b||[];if(f.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length==="number")for(var e=a.length;c ",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(j.find.ID=function(a,c,d){if(typeof c.getElementById!=="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!=="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},j.filter.ID=function(a,b){var c=typeof a.getAttributeNode!=="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(j.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML=" ",a.firstChild&&typeof a.firstChild.getAttribute!=="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(j.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=i,b=c.createElement("div"),d="__sizzle__";b.innerHTML="
";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){i=function(b,e,f,g){e=e||c;if(!g&&!i.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return n(e.getElementsByTagName(b),f);if(h[2]&&j.find.CLASS&&e.getElementsByClassName)return n(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return n([e.body],f);if(h&&h[3]){var k=e.getElementById(h[3]);if(!k||!k.parentNode)return n([],f);if(k.id===h[3])return n([k],f)}try{return n(e.querySelectorAll(b),f)}catch(l){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e.getAttribute("id"),o=m||d,p=e.parentNode,q=/^\s*[+~]/.test(b);m?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),q&&p&&(e=e.parentNode);try{if(!q||p)return n(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(r){}finally{m||e.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)i[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector,d=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(e){d=!0}b&&(i.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!i.isXML(a))try{if(d||!j.match.PSEUDO.test(c)&&!/!=/.test(c))return b.call(a,c)}catch(e){}return i(c,null,null,[a]).length>0})}(),function(){var a=c.createElement("div");a.innerHTML="
";if(a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;j.order.splice(1,0,"CLASS"),j.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!=="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?i.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?i.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:i.contains=function(){return!1},i.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var t=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=j.match.PSEUDO.exec(a))e+=c[0],a=a.replace(j.match.PSEUDO,"");a=j.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(var g=c;g0},closest:function(a,b){var c=[],e,f,g=this[0];if(d.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(e=0,f=a.length;e-1:d(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=L.test(a)?d(a,b||this.context):null;for(e=0,f=this.length;e-1:d.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b)break}}c=c.length>1?d.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a==="string")return d.inArray(this[0],a?d(a):this.parent().children());return d.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a==="string"?d(a,b):d.makeArray(a),e=d.merge(this.get(),c);return this.pushStack(N(c[0])||N(e[0])?e:d.unique(e))},andSelf:function(){return this.add(this.prevObject)}}),d.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return d.dir(a,"parentNode")},parentsUntil:function(a,b,c){return d.dir(a,"parentNode",c)},next:function(a){return d.nth(a,2,"nextSibling")},prev:function(a){return d.nth(a,2,"previousSibling")},nextAll:function(a){return d.dir(a,"nextSibling")},prevAll:function(a){return d.dir(a,"previousSibling")},nextUntil:function(a,b,c){return d.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return d.dir(a,"previousSibling",c)},siblings:function(a){return d.sibling(a.parentNode.firstChild,a)},children:function(a){return d.sibling(a.firstChild)},contents:function(a){return d.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:d.makeArray(a.childNodes)}},function(a,b){d.fn[a]=function(c,e){var f=d.map(this,b,c),g=K.call(arguments);G.test(a)||(e=c),e&&typeof e==="string"&&(f=d.filter(e,f)),f=this.length>1&&!M[a]?d.unique(f):f,(this.length>1||I.test(e))&&H.test(a)&&(f=f.reverse());return this.pushStack(f,a,g.join(","))}}),d.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?d.find.matchesSelector(b[0],a)?[b[0]]:[]:d.find.matches(a,b)},dir:function(a,c,e){var f=[],g=a[c];while(g&&g.nodeType!==9&&(e===b||g.nodeType!==1||!d(g).is(e)))g.nodeType===1&&f.push(g),g=g[c];return f},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var P=/ jQuery\d+="(?:\d+|null)"/g,Q=/^\s+/,R=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,S=/<([\w:]+)/,T=/",""],legend:[1,""," "],thead:[1,""],tr:[2,""],td:[3,""],col:[2,""],area:[1,""," "],_default:[0,"",""]};X.optgroup=X.option,X.tbody=X.tfoot=X.colgroup=X.caption=X.thead,X.th=X.td,d.support.htmlSerialize||(X._default=[1,"div","
"]),d.fn.extend({text:function(a){if(d.isFunction(a))return this.each(function(b){var c=d(this);c.text(a.call(this,b,c.text()))});if(typeof a!=="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return d.text(this)},wrapAll:function(a){if(d.isFunction(a))return this.each(function(b){d(this).wrapAll(a.call(this,b))});if(this[0]){var b=d(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(d.isFunction(a))return this.each(function(b){d(this).wrapInner(a.call(this,b))});return this.each(function(){var b=d(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){d(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){d.nodeName(this,"body")||d(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=d(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,d(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,e;(e=this[c])!=null;c++)if(!a||d.filter(a,[e]).length)!b&&e.nodeType===1&&(d.cleanData(e.getElementsByTagName("*")),d.cleanData([e])),e.parentNode&&e.parentNode.removeChild(e);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&d.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!0:a,b=b==null?a:b;return this.map(function(){return d.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(P,""):null;if(typeof a!=="string"||V.test(a)||!d.support.leadingWhitespace&&Q.test(a)||X[(S.exec(a)||["",""])[1].toLowerCase()])d.isFunction(a)?this.each(function(b){var c=d(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);else{a=a.replace(R,"<$1>$2>");try{for(var c=0,e=this.length;c1&&l0?this.clone(!0):this).get();d(f[h])[b](j),e=e.concat(j)}return this.pushStack(e,a,f.selector)}}),d.extend({clone:function(a,b,c){var e=a.cloneNode(!0),f,g,h;if(!d.support.noCloneEvent&&(a.nodeType===1||a.nodeType===11)&&!d.isXMLDoc(a)){f=a.getElementsByTagName("*"),g=e.getElementsByTagName("*");for(h=0;f[h];++h)$(f[h],g[h]);$(a,e)}if(b){Z(a,e);if(c&&"getElementsByTagName"in a){f=a.getElementsByTagName("*"),g=e.getElementsByTagName("*");if(f.length)for(h=0;f[h];++h)Z(f[h],g[h])}}return e},clean:function(a,b,e,f){b=b||c,typeof b.createElement==="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var g=[];for(var h=0,i;(i=a[h])!=null;h++){typeof i==="number"&&(i+="");if(!i)continue;if(typeof i!=="string"||U.test(i)){if(typeof i==="string"){i=i.replace(R,"<$1>$2>");var j=(S.exec(i)||["",""])[1].toLowerCase(),k=X[j]||X._default,l=k[0],m=b.createElement("div");m.innerHTML=k[1]+i+k[2];while(l--)m=m.lastChild;if(!d.support.tbody){var n=T.test(i),o=j==="table"&&!n?m.firstChild&&m.firstChild.childNodes:k[1]===""&&!n?m.childNodes:[];for(var p=o.length-1;p>=0;--p)d.nodeName(o[p],"tbody")&&!o[p].childNodes.length&&o[p].parentNode.removeChild(o[p])}!d.support.leadingWhitespace&&Q.test(i)&&m.insertBefore(b.createTextNode(Q.exec(i)[0]),m.firstChild),i=m.childNodes}}else i=b.createTextNode(i);i.nodeType?g.push(i):g=d.merge(g,i)}if(e)for(h=0;g[h];h++)!f||!d.nodeName(g[h],"script")||g[h].type&&g[h].type.toLowerCase()!=="text/javascript"?(g[h].nodeType===1&&g.splice.apply(g,[h+1,0].concat(d.makeArray(g[h].getElementsByTagName("script")))),e.appendChild(g[h])):f.push(g[h].parentNode?g[h].parentNode.removeChild(g[h]):g[h]);return g},cleanData:function(a){var b,c,e=d.cache,f=d.expando,g=d.event.special,h=d.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&d.noData[j.nodeName.toLowerCase()])continue;c=j[d.expando];if(c){b=e[c]&&e[c][f];if(b&&b.events){for(var k in b.events)g[k]?d.event.remove(j,k):d.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[d.expando]:j.removeAttribute&&j.removeAttribute(d.expando),delete e[c]}}}});var ba=/alpha\([^)]*\)/i,bb=/opacity=([^)]*)/,bc=/-([a-z])/ig,bd=/([A-Z])/g,be=/^-?\d+(?:px)?$/i,bf=/^-?\d/,bg={position:"absolute",visibility:"hidden",display:"block"},bh=["Left","Right"],bi=["Top","Bottom"],bj,bk,bl,bm=function(a,b){return b.toUpperCase()};d.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return d.access(this,a,c,!0,function(a,c,e){return e!==b?d.style(a,c,e):d.css(a,c)})},d.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bj(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{zIndex:!0,fontWeight:!0,opacity:!0,zoom:!0,lineHeight:!0},cssProps:{"float":d.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,e,f){if(a&&a.nodeType!==3&&a.nodeType!==8&&a.style){var g,h=d.camelCase(c),i=a.style,j=d.cssHooks[h];c=d.cssProps[h]||h;if(e===b){if(j&&"get"in j&&(g=j.get(a,!1,f))!==b)return g;return i[c]}if(typeof e==="number"&&isNaN(e)||e==null)return;typeof e==="number"&&!d.cssNumber[h]&&(e+="px");if(!j||!("set"in j)||(e=j.set(a,e))!==b)try{i[c]=e}catch(k){}}},css:function(a,c,e){var f,g=d.camelCase(c),h=d.cssHooks[g];c=d.cssProps[g]||g;if(h&&"get"in h&&(f=h.get(a,!0,e))!==b)return f;if(bj)return bj(a,c,g)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]},camelCase:function(a){return a.replace(bc,bm)}}),d.curCSS=d.css,d.each(["height","width"],function(a,b){d.cssHooks[b]={get:function(a,c,e){var f;if(c){a.offsetWidth!==0?f=bn(a,b,e):d.swap(a,bg,function(){f=bn(a,b,e)});if(f<=0){f=bj(a,b,b),f==="0px"&&bl&&(f=bl(a,b,b));if(f!=null)return f===""||f==="auto"?"0px":f}if(f<0||f==null){f=a.style[b];return f===""||f==="auto"?"0px":f}return typeof f==="string"?f:f+"px"}},set:function(a,b){if(!be.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),d.support.opacity||(d.cssHooks.opacity={get:function(a,b){return bb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style;c.zoom=1;var e=d.isNaN(b)?"":"alpha(opacity="+b*100+")",f=c.filter||"";c.filter=ba.test(f)?f.replace(ba,e):c.filter+" "+e}}),c.defaultView&&c.defaultView.getComputedStyle&&(bk=function(a,c,e){var f,g,h;e=e.replace(bd,"-$1").toLowerCase();if(!(g=a.ownerDocument.defaultView))return b;if(h=g.getComputedStyle(a,null))f=h.getPropertyValue(e),f===""&&!d.contains(a.ownerDocument.documentElement,a)&&(f=d.style(a,e));return f}),c.documentElement.currentStyle&&(bl=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!be.test(d)&&bf.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bj=bk||bl,d.expr&&d.expr.filters&&(d.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!d.support.reliableHiddenOffsets&&(a.style.display||d.css(a,"display"))==="none"},d.expr.filters.visible=function(a){return!d.expr.filters.hidden(a)});var bo=/%20/g,bp=/\[\]$/,bq=/\r?\n/g,br=/#.*$/,bs=/^(.*?):\s*(.*?)\r?$/mg,bt=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bu=/^(?:GET|HEAD)$/,bv=/^\/\//,bw=/\?/,bx=/
+
--
cgit v1.2.3
From 5285471b7c6f2b4ef7dc02fb2a9c231e2216eef7 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Tue, 23 Aug 2011 15:46:22 -0700
Subject: Fixes #3355. Added ElggPriorityList. Adapted the externals system to
use it.
---
engine/classes/ElggPriorityList.php | 218 ++++++++++++++++--------------------
engine/lib/elgglib.php | 139 ++++++++---------------
engine/lib/views.php | 29 ++---
engine/tests/api/helpers.php | 167 +++++++++++++--------------
4 files changed, 241 insertions(+), 312 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/classes/ElggPriorityList.php b/engine/classes/ElggPriorityList.php
index 931138106..17ce228bc 100644
--- a/engine/classes/ElggPriorityList.php
+++ b/engine/classes/ElggPriorityList.php
@@ -2,40 +2,11 @@
/**
* Iterate over elements in a specific priority.
*
- * You can add, remove, and access elements using OOP or array interfaces:
- *
- * // OOP
* $pl = new ElggPriorityList();
* $pl->add('Element 0');
- * $pl->add('Element -5', -5);
* $pl->add('Element 10', 10);
* $pl->add('Element -10', -10);
*
- * $pl->remove('Element -5');
- *
- * $elements = $pl->getElements();
- * var_dump($elements);
- *
- * Yields:
- *
- * array(
- * -10 => 'Element -10',
- * 0 => 'Element 0',
- * 10 => 'Element 10',
- * )
- *
- *
- * // Array
- *
- * $pl = new ElggPriorityList();
- * $pl[] = 'Element 0';
- * $pl[-5] = 'Element -5';
- * $pl[10] = 'Element 10';
- * $pl[-10] = 'Element -10';
- *
- * $priority = $pl->getPriority('Element -5');
- * unset($pl[$priority]);
- *
* foreach ($pl as $priority => $element) {
* var_dump("$priority => $element");
* }
@@ -45,52 +16,84 @@
* 0 => Element 0
* 10 => Element 10
*
- *
- * Collisions with priority are handled by default differently in the OOP and the array interfaces.
- *
- * If using the OOP interface, the default is to insert the element as close to the requested
- * priority as possible.
+ * Collisions on priority are handled by inserting the element at or as close to the
+ * requested priority as possible:
*
* $pl = new ElggPriorityList();
* $pl->add('Element 5', 5);
* $pl->add('Colliding element 5', 5);
* $pl->add('Another colliding element 5', 5);
*
- * var_dump($pl->getElements());
+ * foreach ($pl as $priority => $element) {
+ * var_dump("$priority => $element");
+ * }
*
* Yields:
- * array(
* 5 => 'Element 5',
* 6 => 'Colliding element 5',
* 7 => 'Another colliding element 5'
- * )
*
- * If using the array interface, elements are added at exactly the priority, displacing other
- * elements if necessary. This behavior is also available by passing true as the 3rd argument to
- * ->add():
+ * You can do priority lookups by element:
*
* $pl = new ElggPriorityList();
- * $pl[5] = 'Element 5';
- * $pl[6] = 'Element 6';
- * $pl[5] = 'Colliding element 5'; // shifts the previous two up by one
- * $pl->add('Another colliding element 5', 5, true); // shifts the previous three up by one
+ * $pl->add('Element 0');
+ * $pl->add('Element -5', -5);
+ * $pl->add('Element 10', 10);
+ * $pl->add('Element -10', -10);
*
- * var_dump($pl->getElements());
+ * $priority = $pl->getPriority('Element -5');
+ *
+ * Or element lookups by priority.
+ * $element = $pl->getElement(-5);
*
- * Yields:
- * array(
- * 5 => 'Another colliding element 5',
- * 6 => 'Colliding element 5',
- * 7 => 'Element 5',
- * 8 => 'Element 6'
- * )
+ * To remove elements, pass the element.
+ * $pl->remove('Element -10');
+ *
+ * To check if an element exists:
+ * $pl->contains('Element -5');
+ *
+ * To move an element:
+ * $pl->move('Element -5', -3);
+ *
+ * ElggPriorityList only tracks priority. No checking is done in ElggPriorityList for duplicates or
+ * updating. If you need to track this use objects and an external map:
+ *
+ * function elgg_register_something($id, $display_name, $location, $priority = 500) {
+ * // $id => $element.
+ * static $map = array();
+ * static $list;
+ *
+ * if (!$list) {
+ * $list = new ElggPriorityList();
+ * }
+ *
+ * // update if already registered.
+ * if (isset($map[$id])) {
+ * $element = $map[$id];
+ * // move it first because we have to pass the original element.
+ * if (!$list->move($element, $priority)) {
+ * return false;
+ * }
+ * $element->display_name = $display_name;
+ * $element->location = $location;
+ * } else {
+ * $element = new stdClass();
+ * $element->display_name = $display_name;
+ * $element->location = $location;
+ * if (!$list->add($element, $priority)) {
+ * return false;
+ * }
+ * $map[$id] = $element;
+ * }
+ *
+ * return true;
+ * }
*
* @package Elgg.Core
* @subpackage Helpers
*/
-
class ElggPriorityList
- implements Iterator, ArrayAccess, Countable {
+ implements Iterator, Countable {
/**
* The list of elements
@@ -123,15 +126,11 @@ class ElggPriorityList
* maintains its priority and the new element is to the next available
* slot, taking into consideration all previously registered elements.
* Negative elements are accepted.
- * @param bool $exact If true, will put the element at exactly the priority specified, displacing
- * other elements.
* @return int The priority of the added element.
*/
public function add($element, $priority = null, $exact = false) {
if ($priority !== null && !is_numeric($priority)) {
return false;
- } elseif ($exact) {
- $this->shiftElementsSegment($priority);
} else {
$priority = $this->getNextPriority($priority);
}
@@ -163,16 +162,16 @@ class ElggPriorityList
/**
* Move an existing element to a new priority.
*
- * @param int $current_priority
- * @param int $new_priority
- * @param bool $exact
- * @return bool
+ * @param mixed $current_priority
+ * @param int $new_priority
+ *
+ * @return int The new priority.
*/
- public function move($current_priority, $new_priority, $exact = false) {
- $current_priority = (int) $current_priority;
+ public function move($element, $new_priority, $strict = false) {
$new_priority = (int) $new_priority;
-
- if (!isset($this->elements[$current_priority])) {
+
+ $current_priority = $this->getPriority($element, $strict);
+ if (!$current_priority) {
return false;
}
@@ -180,17 +179,16 @@ class ElggPriorityList
return true;
}
- $element = $this->elements[$current_priority];
+ // move the actual element so strict operations still work
+ $element = $this->getElement($current_priority);
unset($this->elements[$current_priority]);
-
- return $this->add($element, $new_priority, $exact);
+ return $this->add($element, $new_priority);
}
/**
* Returns the elements
*
- * @param type $elements
- * @param type $sort
+ * @return array
*/
public function getElements() {
$this->sortIfUnsorted();
@@ -238,29 +236,6 @@ class ElggPriorityList
}
}
- /**
- * Shift a segment of elements starting at $index up by one until the end of the array or
- * there's a gap in the indexes. This produces a space at $index to insert a new element.
- *
- * @param type $index The index to start
- * @return array
- */
- private function shiftElementsSegment($index) {
- $index = (int) $index;
- // @todo probably a better way.
- $replace_elements = array();
- while (isset($this->elements[$index])) {
- $replace_elements[$index + 1] = $this->elements[$index];
- unset($this->elements[$index]);
- $index++;
- }
-
- // insert old ones
- foreach ($replace_elements as $index => $element) {
- $this->elements[$index] = $element;
- }
- }
-
/**
* Returns the next priority available.
*
@@ -277,25 +252,45 @@ class ElggPriorityList
return $near;
}
-
/**
* Returns the priority of an element if it exists in the list.
*
- * @warning This can return 0 if the element's priority is 0. Use identical operator (===) to
- * check for false if you want to know if an element exists.
+ * @warning This can return 0 if the element's priority is 0.
*
- * @param mixed $element
+ * @param mixed $element The element to check for.
+ * @param bool $strict Use strict checking?
* @return mixed False if the element doesn't exists, the priority if it does.
*/
public function getPriority($element, $strict = false) {
return array_search($element, $this->elements, $strict);
}
+ /**
+ * Returns the element at $priority.
+ *
+ * @param int $priority
+ * @return mixed The element or false on fail.
+ */
+ public function getElement($priority) {
+ return (isset($this->elements[$priority])) ? $this->elements[$priority] : false;
+ }
+
+ /**
+ * Returns if the list contains $element.
+ *
+ * @param mixed $element The element to check.
+ * @param bool $strict Use strict checking?
+ * @return bool
+ */
+ public function contains($element, $strict = false) {
+ return $this->getPriority($element, $strict) !== false;
+ }
+
+
/**********************
- * Interfaces methods *
+ * Interface methods *
**********************/
-
/**
* Iterator
*/
@@ -356,29 +351,8 @@ class ElggPriorityList
return ($key !== NULL && $key !== FALSE);
}
- // Coutable
+ // Countable
public function count() {
return count($this->elements);
}
-
- // ArrayAccess
- public function offsetExists($offset) {
- return isset($this->elements[$offset]);
- }
-
- public function offsetGet($offset) {
- return isset($this->elements[$offset]) ? $this->elements[$offset] : null;
- }
-
- public function offsetSet($offset, $value) {
- // for $pl[] = 'New element'
- $exact = ($offset !== null);
- return $this->add($value, $offset, $exact);
- }
-
- public function offsetUnset($offset) {
- if (isset($this->elements[$offset])) {
- unset($this->elements[$offset]);
- }
- }
}
\ No newline at end of file
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index b6b603e79..198ffe60c 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -167,7 +167,7 @@ function forward($location = "", $reason = 'system') {
* @param string $name An identifier for the JavaScript library
* @param string $url URL of the JavaScript file
* @param string $location Page location: head or footer. (default: head)
- * @param int $priority Priority of the CSS file (lower numbers load earlier)
+ * @param int $priority Priority of the JS file (lower numbers load earlier)
*
* @return bool
* @since 1.8.0
@@ -288,28 +288,24 @@ function elgg_register_external_file($type, $name, $url, $location, $priority =
$url = elgg_format_url($url);
$url = elgg_normalize_url($url);
- if (!isset($CONFIG->externals)) {
- $CONFIG->externals = array();
- }
-
- if (!$CONFIG->externals[$type] instanceof ElggPriorityList) {
- $CONFIG->externals[$type] = new ElggPriorityList();
- }
+ elgg_bootstrap_externals_data_structure($type);
$name = trim(strtolower($name));
$priority = max((int)$priority, 0);
+ $item = elgg_extract($name, $CONFIG->externals_map[$type]);
- $index = elgg_get_external_file_priority($name, $type);
-
- if ($index !== false) {
+ if ($item) {
// updating a registered item
- $item = $CONFIG->externals[$type][$index];
+ // don't update loaded because it could already be set
$item->url = $url;
$item->location = $location;
- // remove old saved priority
- elgg_remove_external_file_priority($name, $type);
- $priority = $CONFIG->externals[$type]->move($index, $priority);
+ // if loaded before registered, that means it hasn't been added to the list yet
+ if ($CONFIG->externals[$type]->contains($item)) {
+ $priority = $CONFIG->externals[$type]->move($item, $priority);
+ } else {
+ $priority = $CONFIG->externals[$type]->add($item, $priority);
+ }
} else {
$item = new stdClass();
$item->loaded = false;
@@ -319,10 +315,9 @@ function elgg_register_external_file($type, $name, $url, $location, $priority =
$priority = $CONFIG->externals[$type]->add($item, $priority);
}
- // save priority map so we can update if added again
- elgg_save_external_file_priority($priority, $name, $type);
+ $CONFIG->externals_map[$type][$name] = $item;
- return true;
+ return $priority !== false;
}
/**
@@ -337,22 +332,14 @@ function elgg_register_external_file($type, $name, $url, $location, $priority =
function elgg_unregister_external_file($type, $name) {
global $CONFIG;
- if (!isset($CONFIG->externals)) {
- return false;
- }
-
- if (!$CONFIG->externals[$type] instanceof ElggPriorityList) {
- return false;
- }
+ elgg_bootstrap_externals_data_structure($type);
$name = trim(strtolower($name));
-
- $priority = elgg_get_external_file_priority($name, $type);
+ $item = elgg_extract($name, $CONFIG->externals_map[$type]);
- if ($priority !== false) {
- elgg_remove_external_file_priority($name, $type);
- unset($CONFIG->externals[$type][$priority]);
- return true;
+ if ($item) {
+ unset($CONFIG->externals_map[$type][$name]);
+ return $CONFIG->externals[$type]->remove($item);
}
return false;
@@ -370,21 +357,15 @@ function elgg_unregister_external_file($type, $name) {
function elgg_load_external_file($type, $name) {
global $CONFIG;
- if (!isset($CONFIG->externals)) {
- $CONFIG->externals = array();
- }
-
- if (!$CONFIG->externals[$type] instanceof ElggPriorityList) {
- $CONFIG->externals[$type] = new ElggPriorityList();
- }
+ elgg_bootstrap_externals_data_structure($type);
$name = trim(strtolower($name));
- $priority = elgg_get_external_file_priority($name, $type);
+ $item = elgg_extract($name, $CONFIG->externals_map[$type]);
- if ($priority !== false) {
+ if ($item) {
// update a registered item
- $CONFIG->externals[$type][$priority]->loaded = true;
+ $item->loaded = true;
} else {
$item = new stdClass();
$item->loaded = true;
@@ -392,59 +373,10 @@ function elgg_load_external_file($type, $name) {
$item->location = '';
$priority = $CONFIG->externals[$type]->add($item);
- elgg_save_external_file_priority($priority, $name, $type);
+ $CONFIG->externals_map[$type][$name] = $item;
}
}
-/**
- * Gets the priority of an external by name and type.
- *
- * @param type $name
- * @param type $type
- * @return type
- */
-function elgg_get_external_file_priority($name, $type) {
- global $CONFIG;
-
- if (!isset($CONFIG->externals_priorities[$type][$name])) {
- return false;
- }
-
- return $CONFIG->externals_priorities[$type][$name];
-}
-
-function elgg_save_external_file_priority($priority, $name, $type) {
- global $CONFIG;
-
- if (!isset($CONFIG->externals_priorities)) {
- $CONFIG->externals_priorities = array();
- }
-
- if (!isset($CONFIG->externals_priorities[$type])) {
- $CONFIG->externals_priorities[$type] = array();
- }
-
- $CONFIG->externals_priorities[$type][$name] = $priority;
-
- return true;
-}
-
-function elgg_remove_external_file_priority($name, $type) {
- global $CONFIG;
-
- if (!isset($CONFIG->externals_priorities)) {
- $CONFIG->externals_priorities = array();
- }
-
- if (!isset($CONFIG->externals_priorities[$type])) {
- $CONFIG->externals_priorities[$type] = array();
- }
-
- unset($CONFIG->externals_priorities[$type][$name]);
-
- return true;
-}
-
/**
* Get external resource descriptors
*
@@ -470,6 +402,31 @@ function elgg_get_loaded_external_files($type, $location) {
return array();
}
+/**
+ * Bootstraps the externals data structure in $CONFIG.
+ *
+ * @param string $type The type of external, js or css.
+ */
+function elgg_bootstrap_externals_data_structure($type) {
+ global $CONFIG;
+
+ if (!isset($CONFIG->externals)) {
+ $CONFIG->externals = array();
+ }
+
+ if (!$CONFIG->externals[$type] instanceof ElggPriorityList) {
+ $CONFIG->externals[$type] = new ElggPriorityList();
+ }
+
+ if (!isset($CONFIG->externals_map)) {
+ $CONFIG->externals_map = array();
+ }
+
+ if (!isset($CONFIG->externals_map[$type])) {
+ $CONFIG->externals_map[$type] = array();
+ }
+}
+
/**
* Returns a list of files in $directory.
*
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 7686a8bef..fe3265347 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1479,21 +1479,6 @@ function autoregister_views($view_base, $folder, $base_location_path, $viewtype)
return FALSE;
}
-/**
- * Add the core Elgg head elements that could be cached
- *
- * @return void
- */
-function elgg_views_register_core_head_elements() {
- $url = elgg_get_simplecache_url('js', 'elgg');
- elgg_register_js('elgg', $url, 'head', 10);
- elgg_load_js('elgg');
-
- $url = elgg_get_simplecache_url('css', 'elgg');
- elgg_register_css('elgg', $url, 10);
- elgg_load_css('elgg');
-}
-
/**
* Add the rss link to the extras when if needed
*
@@ -1548,12 +1533,17 @@ function elgg_views_boot() {
elgg_register_simplecache_view('css/ie6');
elgg_register_simplecache_view('js/elgg');
- elgg_register_js('jquery', '/vendors/jquery/jquery-1.6.2.min.js', 'head', 1);
- elgg_register_js('jquery-ui', '/vendors/jquery/jquery-ui-1.8.16.min.js', 'head', 2);
+ elgg_register_js('jquery', '/vendors/jquery/jquery-1.6.2.min.js', 'head');
+ elgg_register_js('jquery-ui', '/vendors/jquery/jquery-ui-1.8.16.min.js', 'head');
elgg_register_js('jquery.form', '/vendors/jquery/jquery.form.js');
+
+ $elgg_js_url = elgg_get_simplecache_url('js', 'elgg');
+ elgg_register_js('elgg', $elgg_js_url, 'head');
+
elgg_load_js('jquery');
elgg_load_js('jquery-ui');
elgg_load_js('jquery.form');
+ elgg_load_js('elgg');
elgg_register_simplecache_view('js/lightbox');
$lightbox_js_url = elgg_get_simplecache_url('js', 'lightbox');
@@ -1561,7 +1551,10 @@ function elgg_views_boot() {
$lightbox_css_url = 'vendors/jquery/fancybox/jquery.fancybox-1.3.4.css';
elgg_register_css('lightbox', $lightbox_css_url);
- elgg_register_event_handler('ready', 'system', 'elgg_views_register_core_head_elements');
+ $elgg_css_url = elgg_get_simplecache_url('css', 'elgg');
+ elgg_register_css('elgg', $elgg_css_url, 1);
+ elgg_load_css('elgg');
+
elgg_register_event_handler('pagesetup', 'system', 'elgg_views_add_rss_link');
// discover the built-in view types
diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php
index cceb762be..ee2e64cfe 100644
--- a/engine/tests/api/helpers.php
+++ b/engine/tests/api/helpers.php
@@ -31,7 +31,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
global $CONFIG;
unset($CONFIG->externals);
- unset($CONFIG->externals_priorities);
+ unset($CONFIG->externals_map);
}
/**
@@ -107,9 +107,16 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
// specify name
$result = elgg_register_js('key', 'http://test1.com', 'footer');
$this->assertTrue($result);
- $this->assertTrue(isset($CONFIG->externals_priorities['js']['key']));
- $index = $CONFIG->externals_priorities['js']['key'];
- $this->assertIdentical('http://test1.com', $CONFIG->externals['js'][$index]->url);
+ $this->assertTrue(isset($CONFIG->externals_map['js']['key']));
+
+ $item = $CONFIG->externals_map['js']['key'];
+ $this->assertTrue($CONFIG->externals['js']->contains($item));
+
+ $priority = $CONFIG->externals['js']->getPriority($item);
+ $this->assertTrue($priority !== false);
+
+ $item = $CONFIG->externals['js']->getElement($priority);
+ $this->assertIdentical('http://test1.com', $item->url);
// send a bad url
$result = @elgg_register_js('bad');
@@ -121,13 +128,20 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
*/
public function testElggRegisterCSS() {
global $CONFIG;
-
+
// specify name
$result = elgg_register_css('key', 'http://test1.com');
$this->assertTrue($result);
- $this->assertTrue(isset($CONFIG->externals_priorities['css']['key']));
- $index = elgg_get_external_file_priority('css', 'key');
- $this->assertIdentical('http://test1.com', $CONFIG->externals['css'][$index]->url);
+ $this->assertTrue(isset($CONFIG->externals_map['css']['key']));
+
+ $item = $CONFIG->externals_map['css']['key'];
+ $this->assertTrue($CONFIG->externals['css']->contains($item));
+
+ $priority = $CONFIG->externals['css']->getPriority($item);
+ $this->assertTrue($priority !== false);
+
+ $item = $CONFIG->externals['css']->getElement($priority);
+ $this->assertIdentical('http://test1.com', $item->url);
}
/**
@@ -139,6 +153,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$base = trim(elgg_get_site_url(), "/");
$urls = array('id1' => "$base/urla", 'id2' => "$base/urlb", 'id3' => "$base/urlc");
+
foreach ($urls as $id => $url) {
elgg_register_js($id, $url);
}
@@ -148,26 +163,33 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$js = $CONFIG->externals['js'];
$elements = $js->getElements();
- $this->assertFalse(isset($CONFIG->externals_priorities['js']['id1']));
+ $this->assertFalse(isset($CONFIG->externals_map['js']['id1']));
+
foreach ($elements as $element) {
$this->assertFalse($element->name == 'id1');
}
$result = elgg_unregister_js('id1');
$this->assertFalse($result);
+
$result = elgg_unregister_js('', 'does_not_exist');
$this->assertFalse($result);
$result = elgg_unregister_js('id2');
$elements = $js->getElements();
- $this->assertFalse(isset($CONFIG->externals_priorities['js']['id2']));
+
+ $this->assertFalse(isset($CONFIG->externals_map['js']['id2']));
foreach ($elements as $element) {
$this->assertFalse($element->name == 'id2');
}
- $this->assertTrue(isset($CONFIG->externals_priorities['js']['id3']));
- $priority = $CONFIG->externals_priorities['js']['id3'];
- $this->assertIdentical($urls['id3'], $CONFIG->externals['js'][$priority]->url);
+ $this->assertTrue(isset($CONFIG->externals_map['js']['id3']));
+
+ $priority = $CONFIG->externals['js']->getPriority($CONFIG->externals_map['js']['id3']);
+ $this->assertTrue($priority !== false);
+
+ $item = $CONFIG->externals['js']->getElement($priority);
+ $this->assertIdentical($urls['id3'], $item->url);
}
/**
@@ -180,6 +202,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
elgg_load_js('key');
$result = elgg_register_js('key', 'http://test1.com', 'footer');
$this->assertTrue($result);
+
$js_urls = elgg_get_loaded_js('footer');
$this->assertIdentical(array('http://test1.com'), $js_urls);
}
@@ -192,7 +215,12 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$base = trim(elgg_get_site_url(), "/");
- $urls = array('id1' => "$base/urla", 'id2' => "$base/urlb", 'id3' => "$base/urlc");
+ $urls = array(
+ 'id1' => "$base/urla",
+ 'id2' => "$base/urlb",
+ 'id3' => "$base/urlc"
+ );
+
foreach ($urls as $id => $url) {
elgg_register_js($id, $url);
elgg_load_js($id);
@@ -315,6 +343,28 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$this->assertIdentical($elements[2], $test_elements[2]);
}
+ public function testElggPriorityListMove() {
+ $pl = new ElggPriorityList();
+
+ $elements = array(
+ -5 => 'Test Element -5',
+ 0 => 'Test Element 0',
+ 5 => 'Test Element 5',
+ );
+
+ foreach ($elements as $priority => $element) {
+ $pl->add($element, $priority);
+ }
+
+ $this->assertTrue($pl->move($elements[-5], 10));
+
+ // check it's at the new place
+ $this->assertIdentical($elements[-5], $pl->getElement(10));
+
+ // check it's not at the old
+ $this->assertFalse($pl->getElement(-5));
+ }
+
public function testElggPriorityListConstructor() {
$elements = array(
10 => 'Test Element 10',
@@ -358,6 +408,25 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$this->assertIdentical(2, $pl->getPriority($elements[2]));
}
+ public function testElggPriorityListGetElement() {
+ $pl = new ElggPriorityList();
+ $priorities = array();
+
+ $elements = array(
+ 'Test element 0',
+ 'Test element 1',
+ 'Test element 2',
+ );
+
+ foreach ($elements as $element) {
+ $priorities[] = $pl->add($element);
+ }
+
+ $this->assertIdentical($elements[0], $pl->getElement($priorities[0]));
+ $this->assertIdentical($elements[1], $pl->getElement($priorities[1]));
+ $this->assertIdentical($elements[2], $pl->getElement($priorities[2]));
+ }
+
public function testElggPriorityListPriorityCollision() {
$pl = new ElggPriorityList();
@@ -378,31 +447,6 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$this->assertEqual(7, $pl->getPriority('Colliding element'));
}
- public function testElggPriorityListArrayAccess() {
- $pl = new ElggPriorityList();
-
- $pl[] = 'Test element 0';
- $pl[-10] = 'Test element -10';
- $pl[-1] = 'Test element -1';
- $pl[] = 'Test element 1';
- $pl[5] = 'Test element 5';
- $pl[0] = 'Test element collision with 0';
-
- $elements = array(
- -1 => 'Test element -1',
- 0 => 'Test element collision with 0',
- 1 => 'Test element 0',
- 2 => 'Test element 1',
- 5 => 'Test element 5',
- );
-
- $priority = $pl->getPriority('Test element -10');
- unset($pl[$priority]);
-
- $test_elements = $pl->getElements();
- $this->assertIdentical($elements, $test_elements);
- }
-
public function testElggPriorityListIterator() {
$elements = array(
-5 => 'Test element -5',
@@ -422,13 +466,13 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$this->assertEqual(0, count($pl));
- $pl[] = 'Test element 0';
+ $pl->add('Test element 0');
$this->assertEqual(1, count($pl));
- $pl[] = 'Test element 1';
+ $pl->add('Test element 1');
$this->assertEqual(2, count($pl));
- $pl[] = 'Test element 2';
+ $pl->add('Test element 2');
$this->assertEqual(3, count($pl));
}
@@ -461,43 +505,4 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$this->assertIdentical($elements_sorted_string, $test_elements);
}
-
- function testElggPriorityListShiftElementsSegment() {
- $elements = array(
- 0 => 'Element 0',
- 1 => 'Element 1',
- 2 => 'Element 2',
- 4 => 'Element 4',
- );
-
- $pl = new ElggPriorityList($elements);
-
- // add a new element directly at 1.
- $pl->add('New Element', 1, true);
-
- $elements_sorted = array(
- 0 => 'Element 0',
- 1 => 'New Element',
- 2 => 'Element 1',
- 3 => 'Element 2',
- 4 => 'Element 4',
- );
-
- $test_elements = $pl->getElements();
- $this->assertIdentical($elements_sorted, $test_elements);
-
- $pl->add('New Element 10', 10, true);
-
- $elements_sorted = array(
- 0 => 'Element 0',
- 1 => 'New Element',
- 2 => 'Element 1',
- 3 => 'Element 2',
- 4 => 'Element 4',
- 10 => 'New Element 10'
- );
-
- $test_elements = $pl->getElements();
- $this->assertIdentical($elements_sorted, $test_elements);
- }
}
\ No newline at end of file
--
cgit v1.2.3
From 946a4a008ab2bc3f3a530558ae47581f9d8fbbcb Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Wed, 24 Aug 2011 17:06:39 -0700
Subject: Refs #3750. Added annotation menu for generic comments (delete) and
default annotations (empty).
---
engine/lib/navigation.php | 26 ++++++++++++++++++++++++++
views/default/annotation/default.php | 25 ++++++++-----------------
views/default/annotation/generic_comment.php | 18 ++++++------------
views/default/css/elements/navigation.php | 12 ++++++------
4 files changed, 46 insertions(+), 35 deletions(-)
(limited to 'engine/lib')
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 1305ee3de..cefe40ecf 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -372,6 +372,31 @@ function elgg_entity_menu_setup($hook, $type, $return, $params) {
return $return;
}
+/**
+ * Adds a delete link to "generic_comment" annotations
+ */
+function elgg_annotation_menu_setup($hook, $type, $return, $params) {
+ $annotation = $params['annotation'];
+
+ if ($annotation->name == 'generic_comment' && $annotation->canEdit()) {
+ $url = elgg_http_add_url_query_elements('action/comments/delete', array(
+ 'annotation_id' => $annotation->id,
+ ));
+
+ $options = array(
+ 'name' => 'delete',
+ 'href' => $url,
+ 'text' => " ",
+ 'confirm' => elgg_echo('deleteconfirm'),
+ 'text_encode' => false
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+
+ return $return;
+}
+
+
/**
* Navigation initialization
*/
@@ -379,6 +404,7 @@ function elgg_nav_init() {
elgg_register_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup');
elgg_register_plugin_hook_handler('register', 'menu:river', 'elgg_river_menu_setup');
elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_entity_menu_setup');
+ elgg_register_plugin_hook_handler('register', 'menu:annotation', 'elgg_annotation_menu_setup');
}
elgg_register_event_handler('init', 'system', 'elgg_nav_init');
diff --git a/views/default/annotation/default.php b/views/default/annotation/default.php
index a21fdee51..0e626ad9a 100644
--- a/views/default/annotation/default.php
+++ b/views/default/annotation/default.php
@@ -2,9 +2,9 @@
/**
* Elgg default annotation view
*
+ * @note To add or remove from the annotation menu, register handlers for the menu:annotation hook.
+ *
* @uses $vars['annotation']
- * @uses $vars['delete_action'] A custom action for the delete button.
- * The annotation ID is passed as 'annotation_id'.
*/
$annotation = $vars['annotation'];
@@ -16,28 +16,19 @@ if (!$owner) {
$icon = elgg_view_entity_icon($owner, 'tiny');
$owner_link = "getURL()}\">$owner->name ";
-$delete_action = elgg_extract('delete_action', $vars, '');
+$menu = elgg_view_menu('annotation', array(
+ 'annotation' => $annotation,
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz right',
+));
$text = elgg_view("output/longtext", array("value" => $annotation->value));
$friendlytime = elgg_view_friendly_time($annotation->time_created);
-$delete_button = '';
-if ($delete_action && $annotation->canEdit()) {
- $url = elgg_http_add_url_query_elements($delete_action, array(
- 'annotation_id' => $annotation->id,
- ));
- $delete_button = elgg_view("output/confirmlink", array(
- 'href' => $url,
- 'text' => " ",
- 'confirm' => elgg_echo('deleteconfirm'),
- 'text_encode' => false,
- ));
-}
-
$body = <<
- $delete_button
+ $menu
$owner_link
$friendlytime
diff --git a/views/default/annotation/generic_comment.php b/views/default/annotation/generic_comment.php
index 69520d102..a4fbf904e 100644
--- a/views/default/annotation/generic_comment.php
+++ b/views/default/annotation/generic_comment.php
@@ -29,23 +29,17 @@ $entity_title = $entity->title ? $entity->title : elgg_echo('untitled');
$entity_link = "getURL()}\">$entity_title ";
if ($full_view) {
-
- $delete_button = '';
- if ($comment->canEdit()) {
- $url = "action/comments/delete?annotation_id=$comment->id";
- $delete_button = elgg_view("output/confirmlink", array(
- 'href' => $url,
- 'text' => " ",
- 'confirm' => elgg_echo('deleteconfirm'),
- 'text_encode' => false,
- ));
- }
+ $menu = elgg_view_menu('annotation', array(
+ 'annotation' => $comment,
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz right',
+ ));
$comment_text = elgg_view("output/longtext", array("value" => $comment->value));
$body = <<
- $delete_button
+ $menu
$commenter_link
$friendlytime
diff --git a/views/default/css/elements/navigation.php b/views/default/css/elements/navigation.php
index 64b7c47b4..b5388715e 100644
--- a/views/default/css/elements/navigation.php
+++ b/views/default/css/elements/navigation.php
@@ -424,10 +424,10 @@ li:hover > .elgg-menu-site-more {
}
/* ***************************************
- ENTITY
+ ENTITY AND ANNOTATION
*************************************** */
-.elgg-menu-entity {
+.elgg-menu-entity, elgg-menu-annotation {
float: right;
margin-left: 15px;
font-size: 90%;
@@ -435,17 +435,17 @@ li:hover > .elgg-menu-site-more {
line-height: 16px;
height: 16px;
}
-.elgg-menu-entity > li {
+.elgg-menu-entity > li, .elgg-menu-annotation > li {
margin-left: 15px;
}
-.elgg-menu-entity > li > a {
+.elgg-menu-entity > li > a, .elgg-menu-annotation > li > a {
color: #aaa;
}
-.elgg-menu-entity > li > a {
+.elgg-menu-entity > li > a, .elgg-menu-annotation > li > a {
display: block;
}
-.elgg-menu-entity > li > span {
+.elgg-menu-entity > li > span, .elgg-menu-annotation > li > span {
vertical-align: baseline;
}
--
cgit v1.2.3