1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Images;
13
14 use ICanBoogie\I18n;
15 use ICanBoogie\Operation;
16
17 use Brickrouge\Element;
18
19 class GalleryBlock extends ManageBlock
20 {
21 static protected function add_assets(\Brickrouge\Document $document)
22 {
23 parent::add_assets($document);
24
25 $document->css->add('gallery.css');
26 }
27
28 public function __construct($module, array $tags=array())
29 {
30 parent::__construct
31 (
32 $module, $tags + array
33 (
34 self::T_ORDER_BY => 'title',
35 self::T_BLOCK => 'gallery'
36 )
37 );
38 }
39
40 protected function resolve_options($name, array $modifiers)
41 {
42 return parent::resolve_options($name . '/gallery', $modifiers);
43 }
44
45 protected function render_body()
46 {
47 global $core;
48
49 $rendered_columns_cells = $this->render_columns_cells($this->columns);
50 $rows = $this->columns_to_rows($rendered_columns_cells);
51
52 $html = '';
53
54 foreach ($rows as $i => $row)
55 {
56 $record = $this->records[$i];
57 $title = $record->title;
58
59 $label = new Element
60 (
61 'a', array
62 (
63 Element::INNER_HTML => \ICanBoogie\escape($title),
64
65 'class' => 'goto-edit',
66 'title' => I18n\t('Edit this item'),
67 'href' => \ICanBoogie\Routing\contextualize("/admin/{$record->constructor}/{$record->nid}/edit")
68 )
69 );
70
71 $img = $record->thumbnail('$gallery')->to_element(array(
72
73 'title' => $title,
74 'alt' => $title
75
76 ));
77
78 $html .= <<<EOT
79 <div class="thumbnailer-wrapper" data-key="{$record->nid}" style="width: 128px;">
80 <a href="{$record->path}" rel="lightbox[]">$img</a>
81 $label
82 </div>
83 EOT;
84 }
85
86 $colspan = count($this->columns) + 1;
87
88 return <<<EOT
89 <tr id="gallery">
90 <td colspan="{$colspan}" class="gallery-inner">
91 <div class="gallery-contents">$html</div>
92 </td>
93 </tr>
94 EOT;
95 }
96 }