aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-06 19:56:06 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-06 19:56:06 +0000
commit1a792bebc590cdcfc1b888a33209df92be51400d (patch)
tree87e913b42593b74713a9280b7a7ea3ca4bb2f93e /engine
parentcfaa89dd2d32bc3c17d55def95a1fd49187e1667 (diff)
downloadelgg-1a792bebc590cdcfc1b888a33209df92be51400d.tar.gz
elgg-1a792bebc590cdcfc1b888a33209df92be51400d.tar.bz2
moved the count comments and likes functions into the ElggEntity class
git-svn-id: http://code.elgg.org/elgg/trunk@8047 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggEntity.php37
-rw-r--r--engine/lib/elgglib.php53
-rw-r--r--engine/lib/views.php21
3 files changed, 58 insertions, 53 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php
index 5e43ab582..13b08a122 100644
--- a/engine/classes/ElggEntity.php
+++ b/engine/classes/ElggEntity.php
@@ -593,6 +593,40 @@ abstract class ElggEntity extends ElggData implements
}
/**
+ * Count the number of comments attached to this entity.
+ *
+ * @return int Number of comments
+ * @since 1.8.0
+ */
+ function countComments() {
+ $type = $this->getType();
+ $params = array('entity' => $this);
+ $number = elgg_trigger_plugin_hook('comments:count', $type, $params, false);
+ if ($number) {
+ return $number;
+ } else {
+ return count_annotations($this->getGUID(), "", "", "generic_comment");
+ }
+ }
+
+ /**
+ * Count how many people have liked this entity.
+ *
+ * @return int Number of likes
+ * @since 1.8.0
+ */
+ function countLikes() {
+ $type = $this->getType();
+ $params = array('entity' => $this);
+ $number = elgg_trigger_plugin_hook('likes:count', $type, $params, false);
+ if ($number) {
+ return $number;
+ } else {
+ return count_annotations($this->getGUID(), "", "", "likes");
+ }
+ }
+
+ /**
* Gets an array of entities with a relationship to this entity.
*
* @param string $relationship Relationship type (eg "friends")
@@ -887,8 +921,11 @@ abstract class ElggEntity extends ElggData implements
* @param string $size The size its for.
*
* @return bool
+ * @deprecated 1.8 See getIconURL() for the plugin hook to use
*/
public function setIcon($url, $size = 'medium') {
+ elgg_deprecated_notice("icon_override on an individual entity is deprecated", 1.8);
+
$url = sanitise_string($url);
$size = sanitise_string($size);
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 3e8b9d43d..66477785e 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -334,59 +334,6 @@ function elgg_get_external_file($type, $location) {
}
/**
- * Returns the HTML for "likes" and "like this" on entities.
- *
- * @param ElggEntity $entity The entity to like
- *
- * @return string|false The HTML for the likes, or false on failure
- *
- * @since 1.8
- * @see @elgg_view core/likes/display
- */
-function elgg_view_likes($entity) {
- if (!($entity instanceof ElggEntity)) {
- return false;
- }
-
- $params = array('entity' => $entity);
-
- return elgg_view('core/likes/display', $params);
-}
-
-/**
- * Count the number of likes attached to an entity
- *
- * @param ElggEntity $entity The entity to count likes for
- *
- * @return int Number of likes
- * @since 1.8
- */
-function elgg_count_likes($entity) {
- if ($likeno = elgg_trigger_plugin_hook('likes:count', $entity->getType(),
- array('entity' => $entity), false)) {
- return $likeno;
- } else {
- return count_annotations($entity->getGUID(), "", "", "likes");
- }
-}
-
-/**
- * Count the number of comments attached to an entity
- *
- * @param ElggEntity $entity The entity to count comments for
- *
- * @return int Number of comments
- */
-function elgg_count_comments($entity) {
- if ($commentno = elgg_trigger_plugin_hook('comments:count', $entity->getType(),
- array('entity' => $entity), false)) {
- return $commentno;
- } else {
- return count_annotations($entity->getGUID(), "", "", "generic_comment");
- }
-}
-
-/**
* Returns a list of files in $directory.
*
* Only returns files. Does not recurse into subdirs.
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 72cfeb2b6..d76456d83 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1098,6 +1098,27 @@ function elgg_view_latest_comments($owner_guid, $type = 'object', $subtype = '',
);
return elgg_view('layout/objects/module', $params);
}
+
+/**
+ * Returns the HTML for "likes" on entities.
+ *
+ * @param ElggEntity $entity The entity to like
+ *
+ * @return string|false The HTML for the likes, or false on failure
+ *
+ * @since 1.8.0
+ * @see @elgg_view core/likes/display
+ */
+function elgg_view_likes($entity) {
+ if (!($entity instanceof ElggEntity)) {
+ return false;
+ }
+
+ $params = array('entity' => $entity);
+
+ return elgg_view('core/likes/display', $params);
+}
+
/**
* Wrapper function for the image block display pattern.
*