blog.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. $entity = elgg_extract("entity", $vars);
  3. // do we have a blog
  4. if (!($entity instanceof ElggBlog)) {
  5. return;
  6. }
  7. // does the blog have an image
  8. if (!$entity->icontime) {
  9. return;
  10. }
  11. $href = elgg_extract("href", $vars, $entity->getURL());
  12. $plugin_settings = elgg_extract("plugin_settings", $vars, false);
  13. $full_view = elgg_extract("full_view", $vars, false);
  14. $class = array("blog_tools_blog_image");
  15. if (isset($vars["class"])) {
  16. $class[] = $vars["class"];
  17. }
  18. $image_params = array(
  19. "alt" => $entity->title,
  20. "class" => elgg_extract("img_class", $vars, "")
  21. );
  22. // which view
  23. if (empty($plugin_settings)) {
  24. // default image behaviour
  25. $image_params["src"] = $entity->getIconURL(elgg_extract("size", $vars, "medium"));
  26. } elseif ($full_view) {
  27. // full view of a blog
  28. static $blog_tools_full_image_size;
  29. static $blog_tools_full_image_align;
  30. if (!isset($blog_tools_full_image_size)) {
  31. $blog_tools_full_image_size = "large";
  32. $setting = elgg_get_plugin_setting("full_size", "blog_tools");
  33. if (!empty($setting)) {
  34. $blog_tools_full_image_size = $setting;
  35. }
  36. }
  37. if (!isset($blog_tools_full_image_align)) {
  38. $blog_tools_full_image_align = "right";
  39. $setting = elgg_get_plugin_setting("full_align", "blog_tools");
  40. if (!empty($setting)) {
  41. $blog_tools_full_image_align = $setting;
  42. }
  43. }
  44. if ($blog_tools_full_image_align != "none") {
  45. $href = false;
  46. $image_params["src"] = $entity->getIconURL($blog_tools_full_image_size);
  47. $class[] = "blog-tools-blog-image-" . $blog_tools_full_image_size;
  48. if ($blog_tools_full_image_size != "master") {
  49. if ($blog_tools_full_image_align == "right") {
  50. $class[] = "float-alt";
  51. } else {
  52. $class[] = "float";
  53. }
  54. }
  55. } else {
  56. // no image
  57. return true;
  58. }
  59. } else {
  60. // listing view of a blog
  61. // full view of a blog
  62. static $blog_tools_lising_image_size;
  63. static $blog_tools_listing_image_align;
  64. if (!isset($blog_tools_lising_image_size)) {
  65. $blog_tools_lising_image_size = "small";
  66. $setting = elgg_get_plugin_setting("listing_size", "blog_tools");
  67. if (!empty($setting)) {
  68. $blog_tools_lising_image_size = $setting;
  69. }
  70. }
  71. if (!isset($blog_tools_listing_image_align)) {
  72. $blog_tools_listing_image_align = "right";
  73. $setting = elgg_get_plugin_setting("listing_align", "blog_tools");
  74. if (!empty($setting)) {
  75. $blog_tools_listing_image_align = $setting;
  76. }
  77. }
  78. if ($blog_tools_listing_image_align != "none") {
  79. $image_params["src"] = $entity->getIconURL($blog_tools_lising_image_size);
  80. $class[] = "blog-tools-blog-image-" . $blog_tools_lising_image_size;
  81. if ($blog_tools_listing_image_align == "right") {
  82. $class[] = "float-alt";
  83. } else {
  84. $class[] = "float";
  85. }
  86. } else {
  87. // no image
  88. return true;
  89. }
  90. }
  91. $image = elgg_view("output/img", $image_params);
  92. echo "<div class='" . implode(" ", $class) . "'>";
  93. if (!empty($href)) {
  94. $params = array(
  95. "href" => $href,
  96. "text" => $image,
  97. "is_trusted" => true,
  98. );
  99. $class = elgg_extract("link_class", $vars, "");
  100. if ($class) {
  101. $params["class"] = $class;
  102. }
  103. echo elgg_view("output/url", $params);
  104. } else {
  105. echo $image;
  106. }
  107. echo "</div>";