public function imageAction() { $id = $this->getRequest()->getParam('file_id'); $cacheid = "Gallery_nodeDisplay_" . $id; $content = $this->checkCache($cacheid); if (!$content) { $item = Zoo::getService('content')->load($id, 'Display'); $this->view->assign('image', $item); // Get previous/next image $this->view->previous = Zoo::getService('link')->getPrevious($this->item->id, $item->id, 'gallery_image'); $this->view->next = Zoo::getService('link')->getNext($this->item->id, $item->id, 'gallery_image'); // Set colours $bg_image_style = $bg_color_style = ""; $top_image = Zoo::getService('link')->getLinkedNodes($this->item, 'top_image'); if (count($top_image) > 0) { $this->item->hooks['top_image'] = $top_image[0]; } $bg_image = Zoo::getService('link')->getLinkedNodes($this->item, 'bg_image'); if (count($bg_image) > 0) { $bg_image_style = "background-image: url('" . $bg_image[0]->hooks['filemanager_file']->getUrl() . "');"; } // Find Gallery node extra information $factory = new Gallery_Node_Factory(); $extra = $factory->find($this->item->id)->current(); if ($extra) { if (substr($extra->bgcolor, 0, 1) != "#") { $extra->bgcolor = "#" . $extra->bgcolor; } $bg_color_style = "background-color: " . $extra->bgcolor . ";"; } if ($bg_image_style || $bg_color_style) { $this->view->headStyle()->appendStyle(".gallery-node-item {{$bg_image_style}{$bg_color_style}}"); } $content = $this->getContent(); $this->cache($content, $cacheid, array('gallery', 'gallery_' . $item->pid, 'node_' . $item->pid)); $this->view->jQuery()->enable(); $next_js = $prev_js = ""; if ($this->view->next) { $next_js = "if(e.which == 78 || e.which == 39 ) {\n \t\t//n = next\n \t\tlocation.href = '" . $this->_helper->getHelper('url')->url(array('id' => $this->item->id, 'file_id' => $this->view->next->id), 'gallery_image', true) . "#image';\n \t}"; } if ($this->view->previous) { $prev_js = "if(e.which == 80 || e.which == 37) {\n \t\t//p = previous\n \t\tlocation.href = '" . $this->_helper->getHelper('url')->url(array('id' => $this->item->id, 'file_id' => $this->view->previous->id), 'gallery_image', true) . "#image';\n \t}"; } $js = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler() . "(document).keyup(function(e) {\n \t\t{$next_js}\n \t{$prev_js}\n \t\t\t });"; $this->view->jQuery()->addOnLoad($js); } $this->renderContent($content); }
/** * Hook for node save * * @param Zend_Form $form * @param array $arguments */ public function nodeSave(&$form, &$arguments) { $item = array_shift($arguments); $arguments = array_shift($arguments); if ($item->type == "gallery_node") { $values = $form->getValues(); // Remove existing background image link Zoo::getService('link')->remove($item->id, null, 'bg_image'); if ($values['gallery_bgimage']) { // Connect image to gallery_node Zoo::getService('link')->connect($item->id, $values['gallery_bgimage'], 'bg_image'); } // Remove existing top image link Zoo::getService('link')->remove($item->id, null, 'top_image'); if ($values['gallery_topimage']) { // Connect image to gallery_node Zoo::getService('link')->connect($item->id, $values['gallery_topimage'], 'top_image'); } // Set background $factory = new Gallery_Node_Factory(); // Save gallery fields $gnode = false; if ($item->id > 0) { // Fetch estate object $gnode = $factory->find($item->id)->current(); } if (!$gnode) { $gnode = $factory->createRow(); $gnode->nid = $item->id; } $arguments = $form->getValues(); $gnode->bgcolor = $arguments['gallery_bgcolor']; $gnode->save(); // Clear block cache for gallery listing block Zoo::getService('cache')->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('block_Gallery_Block_List')); } elseif ($item->type == "filemanager_file") { $connectTo = Zend_Controller_Front::getInstance()->getRequest()->getParam('connectTo'); if ($connectTo) { // Connect image to gallery_node Zoo::getService('link')->connect($connectTo, $item->id, 'gallery_image'); } } }