function renderHtml() { $result = $this->mdb2->query('SELECT id FROM fotogalleri WHERE active = 1 ORDER BY date_created DESC LIMIT 1'); if (PEAR::isError($result)) { throw new Exception($result->getUserInfo()); } if (!($row = $result->fetchRow())) { // @todo Make sure that there is some kind of standard and log it $data = array('content' => '<h1>Fotogalleri</h1><p>Kunne ikke finde nogen gallerier.</p>', 'content_sub' => $this->getSubContent()); } // HACK start $this->kernel->session_id = uniqid(); // HACK end $appender = new VIH_AppendFile($this->kernel, 'fotogalleri', $row['id']); $appender->getDBQuery()->setFilter('order_by', 'name'); $photos = $appender->getList(); $photo = array(); for ($i = 0, $max = count($photos); $i < $max; $i++) { $filehandler = new Ilib_Filehandler($this->kernel, $photos[$i]['file_handler_id']); $filehandler->createInstance('filgallerithumb'); $photos[$i]['instance'] = $filehandler->instance->get(); $photos[$i]['show_url'] = $this->url($photos[$i]['id']); } $tpl = $this->template->create('Fotogalleri/list'); if (empty($photos)) { $data = array('content' => '<h1>Fotogalleri</h1><p>Galleriet et tomt</p>', 'content_sub' => $this->getSubContent()); } else { $list = array('photos' => $photos); $data = array('content' => $tpl->render($this, $list), 'content_sub' => $this->getSubContent()); } $this->document->setTitle('Årets højdepunkter'); $this->document->theme = 'photogallery'; $tpl = $this->template->create('sidebar-wrapper'); return $tpl->render($this, $data); }
function renderHtml() { $result = $this->db->query('SELECT id, description, DATE_FORMAT(date_created, "%d-%m-%Y") AS dk_date_created, active FROM fotogalleri WHERE id = ' . intval($this->name())); if (PEAR::isError($result)) { throw new Exception($result->getUserInfo()); } $row = $result->fetchRow(); if (count($row) == 0) { throw new Exception('a valid id is needed'); } // HACK start $kernel = $this->kernel; $kernel->session_id = $this->SESSION->getSessionId(); // HACK end $appender = new VIH_AppendFile($kernel, 'fotogalleri', $row['id']); if (intval($this->query('return_redirect_id')) != 0) { $appender = new VIH_AppendFile($this->kernel, 'fotogalleri', $row['id']); $redirect = Ilib_Redirect::returns($this->session()->getSessionId(), $this->db_sql); foreach ($redirect->getParameter('file_handler_id') as $file_id) { $filehandler = new Ilib_FileHandler($kernel, $file_id); $appender->addFile($filehandler); } } if (intval($this->query('delete_append_file')) != 0) { $appender->delete($this->query('delete_append_file')); } $appender->getDBQuery()->setFilter('order_by', 'name'); $photos = $appender->getList(); for ($i = 0, $max = count($photos); $i < $max; $i++) { $filehandler = new Ilib_Filehandler($kernel, $photos[$i]['file_handler_id']); $photos[$i]['icon_uri'] = $filehandler->get('icon_uri'); $photos[$i]['icon_width'] = $filehandler->get('icon_width'); $photos[$i]['icon_height'] = $filehandler->get('icon_height'); $photos[$i]['url_delete'] = $this->url(NULL, array('delete_append_file' => $photos[$i]['id'])); } $list = array('photos' => $photos); $redirect = Ilib_Redirect::go($this->SESSION->getSessionId(), $this->db); $url = $redirect->setDestination($this->url('/filemanager/selectfile', array('images' => 1)), $this->url()); $redirect->askParameter('file_handler_id', 'multiple'); $this->document->setTitle('Tilføj billeder til galleriet' . $row['description']); $this->document->addOption('Tilføj billeder', $url); $this->document->addOption('Tilbage', $this->url('../')); $tpl = $this->template->create('fotogalleri/fotoliste'); return $tpl->render($data, $list); }
function renderHtml() { $result = $this->db->query('SELECT id FROM fotogalleri WHERE active = 1 ORDER BY date_created DESC LIMIT 1'); if (PEAR::isError($result)) { throw new Exception($result->getUserInfo()); } if ($row = $result->fetchRow()) { $this->kernel->session_id = $this->session()->sessionId(); $appender = new VIH_AppendFile($this->kernel, 'fotogalleri', $row['id']); $appender->getDBQuery()->setFilter('order_by', 'name'); $photos = $appender->getList(); $photo = array(); for ($i = 0, $max = count($photos); $i < $max; $i++) { if ($this->name == $photos[$i]['id']) { $photo = $photos[$i]; $index = $i; $filehandler = new Ilib_Filehandler($kernel, $photos[$i]['file_handler_id']); $filehandler->createInstance('medium'); $photo['instance'] = $filehandler->instance->get(); if ($filehandler->get('description') != $filehandler->get('file_name')) { $photo['description'] = $filehandler->get('description'); } break; } } if (empty($photo)) { return 'Ugyldigt billede'; } $previous = 0; if (isset($photos[$index - 1])) { $previous = $this->context->url($photos[$index - 1]['id']); } $next = 0; if (isset($photos[$index + 1])) { $next = $this->context->url($photos[$index + 1]['id']); } $list = array('photo' => $photo, 'previous' => $previous, 'next' => $next, 'list' => $this->context->url(NULL)); $this->document->setTitle('Årets højdepunkter'); $this->document->theme = 'photogallery'; $tpl = $this->template->create('sidebar-wrapper'); $tpl_foto = $this->template->create('Fotogalleri/foto'); return $tpl->render($this, array('content' => $tpl_foto->render($this, $list), 'content_sub' => '')); } }