aboutsummaryrefslogtreecommitdiff
path: root/views/default/icon
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/icon')
-rw-r--r--views/default/icon/default.php29
-rw-r--r--views/default/icon/user/default.php62
2 files changed, 71 insertions, 20 deletions
diff --git a/views/default/icon/default.php b/views/default/icon/default.php
index c5749ba04..22c20b3a7 100644
--- a/views/default/icon/default.php
+++ b/views/default/icon/default.php
@@ -5,9 +5,11 @@
* @package Elgg
* @subpackage Core
*
- * @uses $vars['entity'] The entity the icon represents - uses getIconURL() method
- * @uses $vars['size'] topbar, tiny, small, medium (default), large, master
- * @uses $vars['href'] Optional override for link
+ * @uses $vars['entity'] The entity the icon represents - uses getIconURL() method
+ * @uses $vars['size'] topbar, tiny, small, medium (default), large, master
+ * @uses $vars['href'] Optional override for link
+ * @uses $vars['img_class'] Optional CSS class added to img
+ * @uses $vars['link_class'] Optional CSS class for the link
*/
$entity = $vars['entity'];
@@ -18,25 +20,38 @@ if (!in_array($vars['size'], $sizes)) {
$vars['size'] = "medium";
}
+$class = elgg_extract('img_class', $vars, '');
+
if (isset($entity->name)) {
$title = $entity->name;
} else {
$title = $entity->title;
}
+$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false);
$url = $entity->getURL();
if (isset($vars['href'])) {
$url = $vars['href'];
}
-$img_src = $entity->getIconURL($vars['size']);
-$img = "<img src=\"$img_src\" alt=\"$title\" />";
+$img = elgg_view('output/img', array(
+ 'src' => $entity->getIconURL($vars['size']),
+ 'alt' => $title,
+ 'class' => $class,
+));
if ($url) {
- echo elgg_view('output/url', array(
+ $params = array(
'href' => $url,
'text' => $img,
- ));
+ 'is_trusted' => true,
+ );
+ $class = elgg_extract('link_class', $vars, '');
+ if ($class) {
+ $params['class'] = $class;
+ }
+
+ echo elgg_view('output/url', $params);
} else {
echo $img;
}
diff --git a/views/default/icon/user/default.php b/views/default/icon/user/default.php
index 6f5c6e2da..c0b0e7483 100644
--- a/views/default/icon/user/default.php
+++ b/views/default/icon/user/default.php
@@ -5,10 +5,14 @@
* Rounded avatar corners - CSS3 method
* uses avatar as background image so we can clip it with border-radius in supported browsers
*
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- * @uses $vars['size'] The size - tiny, small, medium or large. (medium)
- * @uses $vars['hover'] Display the hover menu? (true)
- * @uses $vars['class'] Optional class added to the .elgg-avatar div
+ * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
+ * @uses $vars['size'] The size - tiny, small, medium or large. (medium)
+ * @uses $vars['use_hover'] Display the hover menu? (true)
+ * @uses $vars['use_link'] Wrap a link around image? (true)
+ * @uses $vars['class'] Optional class added to the .elgg-avatar div
+ * @uses $vars['img_class'] Optional CSS class added to img
+ * @uses $vars['link_class'] Optional CSS class for the link
+ * @uses $vars['href'] Optional override of the link href
*/
$user = elgg_extract('entity', $vars, elgg_get_logged_in_user_entity());
@@ -22,11 +26,13 @@ if (isset($vars['class'])) {
$class = "$class {$vars['class']}";
}
+$use_link = elgg_extract('use_link', $vars, true);
+
if (!($user instanceof ElggUser)) {
return true;
}
-$name = htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8');
+$name = htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8', false);
$username = $user->username;
$icontime = $user->icontime;
@@ -35,15 +41,37 @@ if (!$icontime) {
}
$js = elgg_extract('js', $vars, '');
+if ($js) {
+ elgg_deprecated_notice("Passing 'js' to icon views is deprecated.", 1.8, 5);
+}
-$hover = elgg_extract('hover', $vars, true);
+$img_class = '';
+if (isset($vars['img_class'])) {
+ $img_class = $vars['img_class'];
+}
+
+$use_hover = elgg_extract('use_hover', $vars, true);
+if (isset($vars['override'])) {
+ elgg_deprecated_notice("Use 'use_hover' rather than 'override' with user avatars", 1.8, 5);
+ $use_hover = false;
+}
+if (isset($vars['hover'])) {
+ // only 1.8.0 was released with 'hover' as the key
+ $use_hover = $vars['hover'];
+}
$spacer_url = elgg_get_site_url() . '_graphics/spacer.gif';
-$icon_url = $user->getIconURL($size);
-$icon = "<img src=\"$spacer_url\" alt=\"$name\" title=\"$name\" $js style=\"background: url($icon_url) no-repeat;\" />";
+$icon_url = elgg_format_url($user->getIconURL($size));
+$icon = elgg_view('output/img', array(
+ 'src' => $spacer_url,
+ 'alt' => $name,
+ 'title' => $name,
+ 'class' => $img_class,
+ 'style' => "background: url($icon_url) no-repeat;",
+));
-$show_menu = $hover && (elgg_is_admin_logged_in() || !$user->isBanned());
+$show_menu = $use_hover && (elgg_is_admin_logged_in() || !$user->isBanned());
?>
<div class="<?php echo $class; ?>">
@@ -59,9 +87,17 @@ if ($show_menu) {
echo elgg_view_menu('user_hover', $params);
}
-echo elgg_view('output/url', array(
- 'href' => $user->getURL(),
- 'text' => $icon,
-));
+if ($use_link) {
+ $class = elgg_extract('link_class', $vars, '');
+ $url = elgg_extract('href', $vars, $user->getURL());
+ echo elgg_view('output/url', array(
+ 'href' => $url,
+ 'text' => $icon,
+ 'is_trusted' => true,
+ 'class' => $class,
+ ));
+} else {
+ echo "<a>$icon</a>";
+}
?>
</div>