1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11: class Ansel_Tile_Image
12: {
13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26: public function getTile($image, $style = null, $mini = false, $params = array())
27: {
28: global $conf, $registry;
29:
30: $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
31: if (is_null($style)) {
32: $style = $parent->getStyle();
33: }
34:
35: $page = isset($params['page']) ? $params['page'] : 0;
36: $view = isset($params['view']) ? $params['view'] : 'Gallery';
37: $date = $parent->getDate();
38:
39: if ($view == 'Results') {
40: $haveSearch = 1;
41: } else {
42: $haveSearch = 0;
43: }
44:
45:
46: $thumbstyle = $mini ? 'mini' : 'thumb';
47:
48:
49: $image_url = Horde::url('image.php')->add(
50: array_merge(
51: array('gallery' => $image->gallery,
52: 'page' => $page,
53: 'image' => $image->id,
54: 'havesearch' => $haveSearch),
55: $date));
56:
57: 58: 59: 60: 61:
62: $img_view_url = Ansel::getUrlFor('view', array_merge(
63: array('gallery' => $image->gallery,
64: 'slug' => $parent->get('slug'),
65: 'page' => $page,
66: 'view' => 'Image',
67: 'image'=> $image->id,
68: 'havesearch' => $haveSearch),
69: $date));
70:
71: if (!empty($params['image_view_src'])) {
72: $view_url = Ansel::getImageUrl($image->id, 'screen', true);
73: } elseif (empty($params['image_view_url'])) {
74: $view_url = new Horde_Url($img_view_url);
75: } else {
76: $view_url = new Horde_Url(
77: str_replace(array('%i', '%g', '%s'),
78: array($image->id, $image->gallery, $parent->get('slug')),
79: urldecode($params['image_view_url'])));
80:
81:
82: $img_view_url = $view_url;
83: }
84:
85:
86:
87: if (!empty($view) || basename($_SERVER['PHP_SELF']) == 'view.php') {
88: $gallery_url = Ansel::getUrlFor('view', array_merge(
89: array('gallery' => $parent->id,
90: 'slug' => $parent->get('slug'),
91: 'view' => 'Gallery',
92: 'havesearch' => $haveSearch),
93: $date));
94: }
95:
96: $thumb_url = Ansel::getImageUrl($image->id, $thumbstyle, true, $style);
97:
98: $option_select = $parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE);
99: $option_edit = $parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
100: $imgAttributes = (!empty($params['image_view_attributes']) ? $params['image_view_attributes'] : array());
101:
102: $imgOnClick = (!empty($params['image_onclick'])
103: ? str_replace('%i', $image->id, $params['image_onclick'])
104: : '');
105:
106: $imageCaption = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter(
107: $image->caption, 'text2html',
108: array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
109:
110: if (!empty($params['image_view_title']) &&
111: !empty($image->_data[$params['image_view_title']])) {
112: $title = $image->_data[$params['image_view_title']];
113: } else {
114: $title = $image->filename;
115: }
116:
117: Horde::startBuffer();
118:
119: if ($option_edit) {
120:
121: try {
122: $geometry = $image->getDimensions($thumbstyle);
123: $GLOBALS['injector']->createInstance('Horde_Core_Factory_Imple')->create(
124: array('ansel', 'EditCaption'),
125: array('domid' => $image->id . 'caption',
126: 'id' => $image->id,
127: 'width' => $geometry['width']));
128: } catch (Ansel_Exception $e) {
129: }
130: }
131: include ANSEL_BASE . '/templates/tile/image.inc';
132:
133: return Horde::endBuffer();
134: }
135: }
136: