File: D:/HostingSpaces/SBogers64/klimroosbudel.nl/wwwroot/app/models/m_photo_gallery.class.php
<?php
/**
* m_news.class.php
* Created by Komma Mediadesign.
* Author: mike
* Date: 11/02/14
*/
class Photo_Gallery_Model extends Site_Model
{
public function __construct()
{
parent::__construct();
}
/*
* Get News data
*/
public function get()
{
// Set name
$this->set('_name',strtolower('photo_albums'));
$this->set('_pageId',3);
// Get data
$data = $this->getTableData();
return $data;
}
/*
* Get album id
*/
public function getCurrentAlbum()
{
// Get data
$albums = $this->get();
// Default false
$current = 0;
// Create list
foreach($albums as $album)
{
if(Fn::encodeUrl($album['title']) == URL_SUB)
{
$current = $album;
}
}
return $current;
}
/*
CREATE OUTPUT
*/
/*
* Create output
*/
public function createAlbumList()
{
// Start output
$output = '';
$currentAlbum = $this->getCurrentAlbum();
// Create list
foreach($this->get() as $album)
{
// Define url
$url = SITE_ROOT . $this->urls['photo_gallery'] . '/' . Fn::encodeUrl($album['title']);
// Add list item to output
$output .= '<li';
if($currentAlbum['id'] == $album['id']) $output .= ' class="active"';
$output .= '><a href="' . $url . '">' . $album['title'] . '</a><span class="arrow"></span></li>';
}
return $output;
}
/*
* Create thumbnails
*/
public function createAlbumThumbs($album)
{
// Start output
$output = '';
foreach($album['images'] as $image)
{
$output .= '<li><a href="' . UPLOADS_ROOT . $image['filename'] . '" data-lightbox="album' . $album['id'] . '"><img src="' . UPLOADS_ROOT . $image['thumb'] . '" alt="' . $album['title'] . '" /></a></li>';
}
return $output;
}
}