1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11: class Ansel_Tile_Gallery
12: {
13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27:
28: public function getTile($gallery, $style = null, $mini = false, $params = array())
29: {
30: 31: 32: 33:
34: $view = Horde_Util::getFormData('view', 'Gallery');
35: $haveSearch = ($view == 'Results') ? 1 : 0;
36: if (($view == 'Results' || $view == 'List') ||
37: (basename($_SERVER['PHP_SELF']) == 'index.php' &&
38: $GLOBALS['prefs']->getValue('defaultview') == 'galleries')) {
39: $showOwner = true;
40: } else {
41: $showOwner = false;
42: }
43:
44:
45: if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
46: if (is_null($style)) {
47: $style = $gallery->getStyle();
48: }
49: $thumbstyle = $mini ? 'mini' : 'thumb';
50: if ($gallery->hasPasswd()) {
51: $gallery_image = Horde::img('gallery-locked.png');
52: } else {
53: $gallery_image = Ansel::getImageUrl(
54: $gallery->getKeyImage($style),
55: $thumbstyle,
56: true,
57: $style);
58: $gallery_image = '<img src="' . $gallery_image . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
59: }
60: } else {
61: $gallery_image = Horde::img('thumb-error.png');
62: }
63:
64:
65: if (!isset($params['gallery_view_url'])) {
66: $view_link = Ansel::getUrlFor('view',
67: array('gallery' => $gallery->id,
68: 'view' => 'Gallery',
69: 'havesearch' => $haveSearch,
70: 'slug' => $gallery->get('slug')))->link();
71: } else {
72: $view_link = new Horde_Url(
73: str_replace(array('%g', '%s'),
74: array($gallery->id, $gallery->get('slug')),
75: urldecode($params['gallery_view_url'])));
76: $view_link = $view_link->link();
77: }
78:
79: $image_link = $view_link . $gallery_image . '</a>';
80: $text_link = $view_link . htmlspecialchars($gallery->get('name'))
81: . '</a>';
82:
83: if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT) && !$mini) {
84: $properties_link = Horde::url('gallery.php', true)->add(
85: array('gallery' => $gallery->id,
86: 'actionID' => 'modify',
87: 'havesearch' => $haveSearch,
88: 'url' => Horde::selfUrl(true, false, true)));
89: $properties_link = $properties_link->link() . _("Gallery Properties") . '</a>';
90: }
91:
92: if ($showOwner && !$mini &&
93: $GLOBALS['registry']->getAuth() != $gallery->get('owner')) {
94: $owner_link = Ansel::getUrlFor('view',
95: array('view' => 'List',
96: 'owner' => $gallery->get('owner'),
97: 'groupby' => 'owner'),
98: true)->link();
99: $gallery_owner = $gallery->getIdentity();
100: $owner_string = $gallery_owner->getValue('fullname');
101: if (empty($owner_string)) {
102: $owner_string = $gallery->get('owner');
103: }
104: $owner_link .= htmlspecialchars($owner_string) . '</a>';
105: }
106:
107: $gallery_count = $gallery->countImages(true);
108: $background_color = $style->background;
109:
110: $date_format = $GLOBALS['prefs']->getValue('date_format');
111: $created = _("Created:") . ' '
112: . strftime($date_format, (int)$gallery->get('date_created'));
113: $modified = _("Modified") . ' '
114: . strftime($date_format, (int)$gallery->get('last_modified'));
115:
116: Horde::startBuffer();
117: include ANSEL_TEMPLATES . '/tile/gallery' . ($mini ? 'mini' : '') . '.inc';
118:
119: return Horde::endBuffer();
120: }
121:
122: }
123: