<commit_before><?php
/**
 * This is the primary viewing interface for the events.
 * This would be the 'model/controller' if you follow that paradigm.
 *
 * This file contains functions used throughout the frontend views.
 *
 * PHP version 5
 *
 * @category  Events
 * @package   UNL_UCBCN_Frontend
 * @author    <NAME> <<EMAIL>>
 * @copyright 2009 Regents of the University of Nebraska
 * @license   http://www1.unl.edu/wdn/wiki/Software_License BSD License
 * @link      http://code.google.com/p/unl-event-publisher/
 * @todo      Add new output formats such as serialized PHP, XML, and JSON.
 */
namespace UNL\UCBCN\Frontend;

use UNL\UCBCN\RuntimeException;

use UNL\UCBCN\UnexpectedValueException;

/**
 * This is the basic frontend output class through which all output to the public is
 * generated. This class handles the determination of what view the user requested
 * and what information to send.
 *
 * @category  Events
 * @package   UNL_UCBCN_Frontend
 * @author    <NAME> <<EMAIL>>
 * @copyright 2009 Regents of the University of Nebraska
 * @license   http://www1.unl.edu/wdn/wiki/Software_License BSD License
 * @link      http://code.google.com/p/unl-event-publisher/
 */
class Controller
{
    /**
     * Calendar UNL_UCBCN_Calendar Object
     *
     * @var UNL_UCBCN_Calendar
     */
    public $calendar;
    
    /**
     * URI to the frontend
     *
     * @var string
     */
    public static $url = '/workspace/UNL_UCBCN_Frontend/www/';

    /**
     * URI to the management interface UNL_UCBCN_Manager
     *
     * @var string EG: http://events.unl.edu/manager/
     */
    public static $manager_url = '';

    /**
     * Configurable ID for the base/master calendar
     *
     * @var int
     */
    public static $default_calendar_id = 1;

    /**
     * Main content of the page sent to the client.
     *
     * @var mixed
     */
    public $output;

    /**
     * Options array
     * Will include $_GET vars
     */
    public $options = array(
        'model'  => false,
        'format' => 'html',
    );

    /**
     * Constructor for the frontend.
     *
     * @param array $options Associative array of options for the frontend.
     */
    public function __construct($options = array())
    {
        $this->options = $options + $this->options;

        try {
            $this->run();
        } catch (\Exception $e) {
            $this->output = $e;
        }

    }

    /**
     * Runs/builds the frontend object with the display parameters set.
     * This function will populate all of the output and member variables with the
     * data for the current view.
     *
     * @return void
     * @throws Exception if view is unregistered
     */
    public function run()
    {
        $this->determineCalendar();

        if (!isset($this->options['model'])
            || false === $this->options['model']) {
            throw new UnexpectedValueException('Un-registered view', 404);
        }

        if (is_callable($this->options['model'])) {
            $this->output = call_user_func($this->options['model'], $this->options);
        } else {
            $this->output = new $this->options['model']($this->options);
        }
    }

    protected function determineCalendar()
    {
        if (isset($this->options['calendar_shortname'])) {
            // Try and get by shortname
            $this->options['calendar'] = \UNL\UCBCN\Calendar::getByShortName($this->options['calendar_shortname']);
        } else {
            $this->options['calendar'] = \UNL\UCBCN\Calendar::getByID(self::$default_calendar_id);
        }

        if (!$this->options['calendar']) {
            throw new RuntimeException('No calendar could be found.', 404);
        }
    }

    public function getURL()
    {<commit_msg>Improve error message<commit_after><?php
/**
 * This is the primary viewing interface for the events.
 * This would be the 'model/controller' if you follow that paradigm.
 *
 * This file contains functions used throughout the frontend views.
 *
 * PHP version 5
 *
 * @category  Events
 * @package   UNL_UCBCN_Frontend
 * @author    <NAME> <<EMAIL>>
 * @copyright 2009 Regents of the University of Nebraska
 * @license   http://www1.unl.edu/wdn/wiki/Software_License BSD License
 * @link      http://code.google.com/p/unl-event-publisher/
 * @todo      Add new output formats such as serialized PHP, XML, and JSON.
 */
namespace UNL\UCBCN\Frontend;

use UNL\UCBCN\RuntimeException;

use UNL\UCBCN\UnexpectedValueException;

/**
 * This is the basic frontend output class through which all output to the public is
 * generated. This class handles the determination of what view the user requested
 * and what information to send.
 *
 * @category  Events
 * @package   UNL_UCBCN_Frontend
 * @author    <NAME> <<EMAIL>>
 * @copyright 2009 Regents of the University of Nebraska
 * @license   http://www1.unl.edu/wdn/wiki/Software_License BSD License
 * @link      http://code.google.com/p/unl-event-publisher/
 */
class Controller
{
    /**
     * Calendar UNL_UCBCN_Calendar Object
     *
     * @var UNL_UCBCN_Calendar
     */
    public $calendar;
    
    /**
     * URI to the frontend
     *
     * @var string
     */
    public static $url = '/workspace/UNL_UCBCN_Frontend/www/';

    /**
     * URI to the management interface UNL_UCBCN_Manager
     *
     * @var string EG: http://events.unl.edu/manager/
     */
    public static $manager_url = '';

    /**
     * Configurable ID for the base/master calendar
     *
     * @var int
     */
    public static $default_calendar_id = 1;

    /**
     * Main content of the page sent to the client.
     *
     * @var mixed
     */
    public $output;

    /**
     * Options array
     * Will include $_GET vars
     */
    public $options = array(
        'model'  => false,
        'format' => 'html',
    );

    /**
     * Constructor for the frontend.
     *
     * @param array $options Associative array of options for the frontend.
     */
    public function __construct($options = array())
    {
        $this->options = $options + $this->options;

        try {
            $this->run();
        } catch (\Exception $e) {
            $this->output = $e;
        }

    }

    /**
     * Runs/builds the frontend object with the display parameters set.
     * This function will populate all of the output and member variables with the
     * data for the current view.
     *
     * @return void
     * @throws Exception if view is unregistered
     */
    public function run()
    {
        $this->determineCalendar();

        if (!isset($this->options['model'])
            || false === $this->options['model']) {
            throw new UnexpectedValueException('Un-registered view', 404);
        }

        if (is_callable($this->options['model'])) {
            $this->output = call_user_func($this->options['model'], $this->options);
        } else {
            $this->output = new $this->options['model']($this->options);
        }
    }

    protected function determineCalendar()
    {
        if (isset($this->options['calendar_shortname'])) {
            // Try and get by shortname
            $this->options['calendar'] = \UNL\UCBCN\Calendar::getByShortName($this->options['calendar_shortname']);
        } else {
            $this->options['calendar'] = \UNL\UCBCN\Calendar::getByID(self::$default_calendar_id);
        }

        if (!$this->options['calendar']) {
            throw new RuntimeException('The calendar could not be found.', 404);
        }
    }

    public function getURL()
    {
{'fraction_non_alphanumeric': 0.12349277858751823, 'fraction_numerical': 0.004770107327414867, 'mean_word_length': 2.3047285464098075, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '351265', 'n_tokens_mistral': 2258, 'n_tokens_neox': 2180, 'n_words': 617}