Esempio n. 1
0
File: Index.php Progetto: vih/vih.dk
 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);
 }
Esempio n. 2
0
File: Show.php Progetto: vih/vih.dk
 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' => ''));
     }
 }