Example #1
0
<?php

$THISPATH = dirname(dirname(__FILE__)) . '/';
require_once $THISPATH . 'lib/Timer.php';
Timer::start();
Timer::tick('started');
require_once '_include.php';
#Timer::tick('Include complete');
$config = SimpleSAML_Configuration::getInstance('foodle');
$fullURI = $_SERVER['PATH_INFO'];
$script = $_SERVER['SCRIPT_NAME'];
$path = substr($fullURI, strlen($script) + 1, strlen($fullURI) - strlen($script) - 1);
$parameters = explode('/', $path);
$availableLanguages = array('nb', 'en', 'sv');
$availableLanguages = json_decode(file_get_contents($THISPATH . 'dictionaries/languages.json'), true);
// print_r( $availableLanguages); exit;
try {
    $action = array_shift($parameters);
    switch ($action) {
        case '':
            $page = new Pages_PageFront($config, $parameters);
            $page->show();
            break;
            /*
             * API used by JS, and possibly others...
             */
        /*
         * API used by JS, and possibly others...
         */
        case 'api':
            if (count($parameters) < 1) {
Example #2
0
 function show()
 {
     $this->template->data['foodleid'] = $this->foodle->identifier;
     $this->template->data['user'] = $this->user;
     if ($this->user !== null) {
         // $this->template->data['userid'] = $this->user->userid;
         $this->template->data['userToken'] = $this->user->getToken();
     }
     $this->template->data['title'] = 'Foodle :: ' . $this->foodle->name;
     $this->template->data['foodle'] = $this->foodle;
     $this->template->data['optimize'] = $this->config->getValue('optimize', false);
     $this->template->data['gmapsAPI'] = $this->config->getValue('gmapsAPI');
     $this->template->data['authenticated'] = $this->auth->isAuth();
     $this->template->data['loginurl'] = $this->auth->getLoginURL();
     $this->template->data['logouturl'] = $this->auth->getLogoutURL('/');
     $this->template->data['url'] = FoodleUtils::getUrl() . 'foodle/' . $this->foodle->identifier;
     $this->template->data['bread'] = array(array('href' => '/' . $this->config->getValue('baseurlpath'), 'title' => 'bc_frontpage'), array('href' => '/foodle/' . $this->foodle->identifier, 'title' => $this->foodle->name));
     Timer::tick('Presenting page');
     $this->template->data['timer'] = Timer::getList();
     $this->template->show();
 }
Example #3
0
 public function test_percent_calcuations()
 {
     $timer = new Timer();
     $timer->set_total_items(100);
     $timer->tick();
     $timer->tick();
     $timer->tick();
     $timer->tick();
     $timer->tick();
     $this->assertEquals(5, $timer->percent_complete());
 }