* @package Kronolith
*/
class Kronolith_View_EditEvent
{
/**
*
* @var Kronolith_Event
*/
protected $_event;
/**
* @param mixed Kronolith_Event|string $event The event object or error
* string to display.
*/
public function __construct($event)
{
$this->_event = $event;
}
public function __get($property)
{
switch ($property) {
case 'event':
return $this->_event;
default:
throw new LogicException('Property does not exist.');
}
}
public function getTitle()
{
if (!$this->_event) {
return _("Not Found");
}
if (is_string($this->_event)) {
return $this->_event;
}
return sprintf(_("Edit %s"), $this->_event->getTitle());
}
public function link()
{
return $this->_event->getEditUrl();
}
public function html($active = true)
{
if (!$this->_event) {
echo '
';
if ($active && $GLOBALS['browser']->hasFeature('dom')) {
if ($this->_event->hasPermission(Horde_Perms::READ)) {
$view = new Kronolith_View_Event($this->_event);
$view->html(false);
}
if ($this->_event->hasPermission(Horde_Perms::DELETE)) {
$delete = new Kronolith_View_DeleteEvent($this->_event);
$delete->html(false);
}
}
}
public function getName()
{
return 'EditEvent';
}
}