PageRenderTime 75ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/php/lib/content_object_rendition/html/full.class.php

https://bitbucket.org/chamilo/chamilo-repository-dev/
PHP | 68 lines | 60 code | 8 blank | 0 comment | 3 complexity | b75d30507132389b1fccfd251327e911 MD5 | raw file
  1. <?php
  2. namespace repository;
  3. use common\libraries\Utilities;
  4. use common\libraries\Translation;
  5. use common\libraries\AttachmentSupport;
  6. use common\libraries\Theme;
  7. class HtmlFullContentObjectRendition extends HtmlContentObjectRendition
  8. {
  9. function render()
  10. {
  11. $object = $this->get_content_object();
  12. $html = array();
  13. $html[] = '<div class="content_object" style="background-image: url(' . Theme :: get_image_path(ContentObject :: get_content_object_type_namespace($object->get_type())) . 'logo/' . $object->get_icon_name() . ($object->is_latest_version() ? '' : '_na') . '.png);">';
  14. $html[] = '<div class="title">' . $object->get_title() . '</div>';
  15. $html[] = $this->get_description();
  16. $html[] = '</div>';
  17. $html[] = '<div class="clear"></div>';
  18. return implode("\n", $html);
  19. }
  20. function get_description()
  21. {
  22. $html[] = '<div class="description" style="overflow: auto;">';
  23. $renderer = new ContentObjectResourceRenderer($this, $this->get_content_object()->get_description());
  24. $html[] = $renderer->run();
  25. $html[] = '<div class="clear"></div>';
  26. if (method_exists($this->get_rendition_implementation(), 'get_description'))
  27. {
  28. $html[] = $this->get_rendition_implementation()->get_description();
  29. }
  30. $html[] = $this->get_attachments();
  31. $html[] = '</div>';
  32. return implode("\n", $html);
  33. }
  34. function get_attachments()
  35. {
  36. $object = $this->get_content_object();
  37. $html = array();
  38. if ($object instanceof AttachmentSupport)
  39. {
  40. $attachments = $object->get_attached_content_objects();
  41. if (count($attachments))
  42. {
  43. $html[] = '<div class="attachments" style="margin-top: 1em;">';
  44. $html[] = '<div class="attachments_title">' . htmlentities(Translation :: get('Attachments')) . '</div>';
  45. Utilities :: order_content_objects_by_title($attachments);
  46. $html[] = '<ul class="attachments_list">';
  47. foreach ($attachments as $attachment)
  48. {
  49. $url = $this->get_context()->get_content_object_display_attachment_url($attachment);
  50. $url = 'javascript:openPopup(\'' . $url . '\'); return false;';
  51. $html[] = '<li><a href="#" onClick="' . $url . '"><img src="' . Theme :: get_image_path(ContentObject :: get_content_object_type_namespace($attachment->get_type())) . 'logo/' . Theme :: ICON_MINI . '.png" alt="' . htmlentities(Translation :: get('TypeName', null, ContentObject :: get_content_object_type_namespace($attachment->get_type()))) . '"/> ' . $attachment->get_title() . '</a></li>';
  52. }
  53. $html[] = '</ul>';
  54. $html[] = '</div>';
  55. }
  56. }
  57. return implode("\n", $html);
  58. }
  59. }
  60. ?>