File: D:/HostingSpaces/SBogers10/spire.komma-mediadesign.nl/wwwroot/kms/app/models/m_display.php
<?php
/**
This class returns output such as listitems which are used to display data to the user.
*/
class Display extends Template
{
/**
*
* @var string String containing the linkname used in the display.
*/
private $_linkname = URL_PAGE;
/**
*
* Constructor
*/
public function __construct()
{
global $template;
$this->lang = $template->lang;
}
/*
GET / SET
*/
/**
* Sets the linkname variable
*
* @access public
* @param int
* @return null
*/
public function setLinkname($str)
{
if( ! empty($str))
{
$this->_linkname = $str;
}
}
/**
* Creates an output string containing listitems to display
* Also creates an array of ids from items which are displayed in the list
* These two are returned in an array($output, $ids);
*
* @access public
* @param array(two-dimensional), boolean
* @return array
*/
public function createList($data, $editable = TRUE)
{
$output = 'Er zijn nog geen items gevonden.';
$ids = array();
if($data != NULL)
{
$i = 1;
$output = '';
// catch problems when only one 1 item is in data
$keys = array_keys($data);
if( is_string($keys[0]) )
{
$info = $data;
$data = array($info);
}
foreach($data as $info)
{
$ids[] = $info['id'];
if(isset($info['timest']))
{
$added = date('d / m / Y',$info['timest']);
}
else if(isset($info['lastUpdate']))
{
$added = date('d / m / Y',$info['lastUpdate']);
}
else
{
$added = '';
}
$output .= '<li';
if($i % 2 != 0) $output .= ' class="alt"';
$output .= '>';
$output .= '<div class="col cb">';
if($editable)
{
$output .= '<input type="checkbox" name="selected[]" value="'.$info['id'].'" />';
}
else
{
$output .= ' ';
}
$output .= '</div>';
$output .= '<div class="col title"><a href="'.LANG_ROOT.$this->_linkname.'/wijzig-item/'.$info['id'].'/">'.ucfirst($info['title']).'</a></div>';
$output .= '<div class="col added">'.$added.'</div>';
$output .= '<div class="col edit">';
if($editable)
{
/*
$output .= '<div class="subcol">';
$output .= '<a href="'.LANG_ROOT.$this->_linkname.'/publish/'.$info['id'].'/">';
$published = $this->checkPublished($info['id']);
if($published)
{
$output .= 'Depubliceer';
}
else
{
$output .= '<span class="publish">Publiceer</a>';
}
$output .= '</a>';
$output .= '</div>';
*/
$output .= '<div class="subcol">';
$output .= '<a href="'.LANG_ROOT.$this->_linkname.'/wijzig-item/'.$info['id'].'/">'.$this->lang['edit'].'</a>';
$output .= '</div>';
$output .= '<div class="subcol">';
$output .= '<a href="'.LANG_ROOT.$this->_linkname.'/verwijder-item/'.$info['id'].'/">'.$this->lang['delete'].'</a>';
$output .= '</div>';
$output .= '<div class="clear"></div>';
}
else
{
$output .= ' ';
}
$output .= '</div>';
$output .= '</li>';
$i++;
}
}
return array($output, $ids);
}
/**
* Creates an output string containing options for select
* Optional $value sets the current value to this $value;
*
* @param array, string, string, int/string (optional)
* @return string
*/
public function createOptions($data, $keyValue, $keyLabel, $value = NULL)
{
$output = '<option>Geen opties gevonden.</options>';
if($data != NULL)
{
$output = '';
foreach($data as $info)
{
$output .= '<option value="'.$info[$keyValue].'"';
if(isset($info['id']))
{
$output .= ' id="'.$info['id'].'" ';
}
if($value != NULL)
{
if($value == $info[$keyValue])
{
$output .= ' selected';
}
}
$output .= '>
<span class="style-option">'.$info[$keyLabel].'</span>
</option>';
}
}
return $output;
}
}