EntityIcon.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace ColdTrick\BlogTools;
  3. /**
  4. * Router handling
  5. *
  6. * @package ColdTrick
  7. * @subpackage BlogTools
  8. */
  9. class EntityIcon {
  10. /**
  11. * Return the url for a blog icon (if any)
  12. *
  13. * @param string $hook "entity:icon:url"
  14. * @param string $entity_type "object"
  15. * @param string $returnvalue the current icon url
  16. * @param array $params supplied params
  17. *
  18. * @return string|void
  19. */
  20. public static function blogIcon($hook, $entity_type, $returnvalue, $params) {
  21. if (empty($params) || !is_array($params)) {
  22. return $returnvalue;
  23. }
  24. $entity = elgg_extract("entity", $params);
  25. if (empty($entity) || !elgg_instanceof($entity, "object", "blog")) {
  26. return $returnvalue;
  27. }
  28. $iconsizes = (array) elgg_get_config("icon_sizes");
  29. $size = strtolower(elgg_extract("size", $params));
  30. if (!array_key_exists($size, $iconsizes)) {
  31. $size = "medium";
  32. }
  33. $icontime = (int) $entity->icontime;
  34. if (!$icontime) {
  35. return $returnvalue;
  36. }
  37. $url = elgg_http_add_url_query_elements("mod/blog_tools/pages/thumbnail.php", array(
  38. "guid" => $entity->getOwnerGUID(),
  39. "blog_guid" => $entity->getGUID(),
  40. "size" => $size,
  41. "icontime" => $icontime
  42. ));
  43. return elgg_normalize_url($url);
  44. }
  45. }