1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Base
24: {
25: 26: 27: 28: 29:
30: public function html()
31: {
32:
33: $node = $this->_params['container'];
34: if (empty($node)) {
35: return '';
36: }
37:
38:
39: $galleries = !empty($this->_params['gallery_slug']) ? explode(':', $this->_params['gallery_slug']) : '';
40: $haveSlugs = true;
41: if (empty($galleries)) {
42: $galleries = !empty($this->_params['gallery_id']) ? explode(':', $this->_params['gallery_id']) : null;
43: $haveSlugs = false;
44: }
45:
46:
47: $thumbsize = empty($this->_params['thumbsize']) ? 'thumb' : $this->_params['thumbsize'];
48: $images = array();
49: foreach ($galleries as $id) {
50: try {
51: if ($haveSlugs) {
52: $gallery = $this->_getGallery(null, $id);
53: } else {
54: $gallery = $this->_getGallery($id);
55: }
56: } catch (Horde_Exception $e) {
57: Horde::logMessage($e, 'ERR');
58: exit;
59: }
60: if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
61: return '';
62: }
63:
64:
65:
66:
67: $gallery_style = empty($this->_params['style']) ? 'ansel_default' : $this->_params['style'];
68: $images[] = $gallery->getKeyImage(Ansel::getStyleDefinition($gallery_style));
69:
70: }
71: $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, null, true, $thumbsize, true);
72:
73: $GLOBALS['injector']->getInstance('Horde_Themes_Css')->addThemeStylesheet('jsembed.css');
74: Horde::startBuffer();
75: Horde::includeStylesheetFiles(array(
76: 'nobase' => true,
77: 'nohorde' => true), true);
78: $css = Horde::endBuffer();
79:
80:
81: $js_path = $GLOBALS['registry']->get('jsuri', 'horde');
82: $pturl = Horde::url($js_path . '/prototype.js', true);
83: $ansel_js_path = $GLOBALS['registry']->get('jsuri', 'ansel');
84: $jsurl = Horde::url($ansel_js_path . '/embed.js', true);
85:
86:
87:
88: $html = <<<EOT
89: //<![CDATA[
90: // Old fashioned way to play nice with Safari 2 (Adding script inline with the
91: // DOM won't work). Need two seperate files output here since the incldued
92: // files don't seem to be parsed until after the entire page is loaded, so we
93: // can't include prototype on the same page it's needed.
94:
95: if (typeof anseljson == 'undefined') {
96: if (typeof Prototype == 'undefined') {
97: document.write('<script type="text/javascript" src="$pturl"></script>');
98: }
99: anselnodes = new Array();
100: anseljson = new Object();
101: document.write('$css');
102: document.write('<script type="text/javascript" src="$jsurl"></script>');
103: }
104: anselnodes[anselnodes.length] = '$node';
105: anseljson['$node'] = new Object();
106: anseljson['$node']['data'] = $json;
107: anseljson['$node']['perpage'] = 0;
108: anseljson['$node']['page'] = 0;
109: anseljson['$node']['hideLinks'] = false;
110: anseljson['$node']['linkToGallery'] = true;
111: //]]>
112: EOT;
113:
114: return $html;
115: }
116:
117: }
118: