aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-31 13:51:57 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-31 13:51:57 +0000
commitc42862e15c82d0ffbb45d3bdc2bcfcea2d0c75f6 (patch)
treeea0c2c736c2b9cbcd4ca7b960190f300c358f79e /engine/lib/entities.php
parent31598136e807ed309c2cd7ea90dfca4da569a52a (diff)
downloadelgg-c42862e15c82d0ffbb45d3bdc2bcfcea2d0c75f6.tar.gz
elgg-c42862e15c82d0ffbb45d3bdc2bcfcea2d0c75f6.tar.bz2
Closes #151: Introducing getIcon($size)
git-svn-id: https://code.elgg.org/elgg/trunk@1629 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php38
1 files changed, 37 insertions, 1 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 663ac9c4e..47ad8f89c 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -43,7 +43,12 @@
/**
* If set, overrides the value of getURL()
*/
- protected $url_override;
+ protected $url_override;
+
+ /**
+ * Icon override, overrides the value of getIcon().
+ */
+ protected $icon_override;
/**
* Temporary cache for metadata, permitting meta data access before a guid has obtained.
@@ -498,6 +503,36 @@
}
/**
+ * Return a url for the entity's icon, trying multiple alternatives.
+ *
+ * @param string $size Either 'large','medium','small' or 'tiny'
+ * @return string The url or false if no url could be worked out.
+ */
+ public function getIcon($size = 'medium')
+ {
+ if (isset($this->icon_override[$size])) return $this->icon_override[$size];
+ return elgg_get_entity_icon_url($this, $size);
+ }
+
+ /**
+ * Set an icon override for an icon and size.
+ *
+ * @param string $url The url of the icon.
+ * @param string $size The size its for.
+ * @return bool
+ */
+ public function setIcon($url, $size = 'medium')
+ {
+ $url = sanitise_string($url);
+ $size = sanitise_string($size);
+
+ if (!$this->icon_override) $this->icon_override = array();
+ $this->icon_override[$size] = $url;
+
+ return true;
+ }
+
+ /**
* Tests to see whether the object has been fully loaded.
*
* @return bool
@@ -1632,6 +1667,7 @@
}
+
/**
* Gets the URL for an entity, given a particular GUID
*