1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11: class Ansel_Tile_DateGallery
12: {
13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
30: public function getTile($dgallery, $style = null, $mini = false, $params = array())
31: {
32:
33: $date_format = $GLOBALS['prefs']->getValue('date_format');
34: $date_array = $dgallery->getDate();
35: if (empty($date_array['month'])) {
36: $date_array['month'] = 1;
37: }
38: if (empty($date_array['day'])) {
39: $date_array['day'] = 1;
40: }
41: $full_date = new Horde_Date($date_array);
42:
43:
44: $date_array = $dgallery->getDate();
45:
46:
47:
48: if (empty($date_array['month'])) {
49:
50: $caption = $full_date->strftime('%Y');
51: $next_date = array('year' => (int)$caption);
52: } elseif (empty($date_array['day'])) {
53:
54: $caption = $full_date->strftime('%B %Y');
55: $next_date = array(
56: 'year' => date('Y', $full_date->timestamp()),
57: 'month' => date('n', $full_date->timestamp()));
58: } else {
59:
60: $caption = $full_date->strftime($date_format);
61: $next_date = array('year' => date('Y', $full_date->timestamp()),
62: 'month' => date('n', $full_date->timestamp()),
63: 'day' => date('j', $full_date->timestamp()));
64: }
65:
66:
67: if ($dgallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
68: if (is_null($style)) {
69: $style = $dgallery->getStyle();
70: }
71:
72: $thumbstyle = $mini ? 'mini' : 'thumb';
73: $gallery_image = Ansel::getImageUrl(
74: $dgallery->getKeyImage(),
75: $thumbstyle,
76: true,
77: $style);
78:
79: $gallery_image = '<img src="' . $gallery_image . '" alt="' . $caption . '" />' ;
80: } else {
81: $gallery_image = Horde::img('thumb-error.png');
82: }
83:
84:
85: if (!isset($params['gallery_view_url'])) {
86: if (empty($params['style'])) {
87: $gstyle = $dgallery->getStyle();
88: } else {
89: $gstyle = $params['style'];
90: }
91: $params = array('gallery' => $dgallery->id,
92: 'view' => 'Gallery',
93: 'slug' => $dgallery->get('slug'));
94: $params = array_merge($params, $next_date);
95: $view_link = Ansel::getUrlFor('view', $params)->link();
96: } else {
97: $view_link = new Horde_Url(str_replace(array('%g', '%s'),
98: array($dgallery->id, $dgallery->get('slug')),
99: urldecode($params['gallery_view_url'])));
100: $view_link = $view_link->add($next_date)->link();
101: }
102:
103:
104: $image_link = $view_link . $gallery_image . '</a>';
105: $text_link = $view_link . htmlspecialchars($caption) . '</a>';
106: $gallery_count = $dgallery->countImages(true);
107:
108:
109: $background_color = $style->background;
110:
111: Horde::startBuffer();
112: include ANSEL_TEMPLATES . '/tile/dategallery' . ($mini ? 'mini' : '') . '.inc';
113: return Horde::endBuffer();
114: }
115: }
116: