Kronolith::getView PHP Method

getView() public static method

Get a named Kronolith_View_* object and load it with the appropriate date parameters.
public static getView ( string $view )
$view string The name of the view.
    public static function getView($view)
    {
        switch ($view) {
            case 'Day':
            case 'Month':
            case 'Week':
            case 'WorkWeek':
            case 'Year':
                $class = 'Kronolith_View_' . $view;
                return new $class(self::currentDate());
            case 'Event':
            case 'EditEvent':
            case 'DeleteEvent':
            case 'ExportEvent':
                try {
                    if ($uid = Horde_Util::getFormData('uid')) {
                        $event = self::getDriver()->getByUID($uid);
                    } else {
                        $event = self::getDriver(Horde_Util::getFormData('type'), Horde_Util::getFormData('calendar'))->getEvent(Horde_Util::getFormData('eventID'), Horde_Util::getFormData('datetime'));
                    }
                } catch (Horde_Exception $e) {
                    $event = $e->getMessage();
                }
                switch ($view) {
                    case 'Event':
                        if (!is_string($event) && !$event->hasPermission(Horde_Perms::READ)) {
                            $event = _("Permission Denied");
                        }
                        return new Kronolith_View_Event($event);
                    case 'EditEvent':
                        /* We check for read permissions, because we can always save a
                         * copy if we can read the event. */
                        if (!is_string($event) && !$event->hasPermission(Horde_Perms::READ)) {
                            $event = _("Permission Denied");
                        }
                        return new Kronolith_View_EditEvent($event);
                    case 'DeleteEvent':
                        if (!is_string($event) && !$event->hasPermission(Horde_Perms::DELETE)) {
                            $event = _("Permission Denied");
                        }
                        return new Kronolith_View_DeleteEvent($event);
                    case 'ExportEvent':
                        if (!is_string($event) && !$event->hasPermission(Horde_Perms::READ)) {
                            $event = _("Permission Denied");
                        }
                        return new Kronolith_View_ExportEvent($event);
                }
        }
    }

Usage Example

Example #1
0
<?php

/**
 * Copyright 1999-2015 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author  Chuck Hagenbuch <*****@*****.**>
 * @package Kronolith
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('kronolith');
if (Kronolith::showAjaxView()) {
    Horde::url('', true)->setAnchor('day:' . Kronolith::currentDate()->dateString())->redirect();
}
$view = Kronolith::getView('Day');
$page_output->addScriptFile('tooltips.js', 'horde');
Kronolith::addCalendarLinks();
$page_output->header(array('body_class' => $prefs->getValue('show_panel') ? 'rightPanel' : null, 'title' => $view->getTime($prefs->getValue('date_format'))));
require KRONOLITH_TEMPLATES . '/javascript_defs.php';
$notification->notify(array('listeners' => 'status'));
Kronolith::tabs($view);
$view->html(KRONOLITH_TEMPLATES);
require KRONOLITH_TEMPLATES . '/calendar_titles.inc';
$page_output->footer();
All Usage Examples Of Kronolith::getView