Пример #1
0
 /**
  * Parse the data into the template
  */
 protected function parse()
 {
     // the URL to call the API
     $url = SITE_URL . str_replace('client/', 'index.php', $_SERVER['REQUEST_URI']);
     $this->tpl->assign('url', $url);
     $this->tpl->assign('modules', $this->modules);
 }
Пример #2
0
 /**
  * Parses the html for this filefield.
  *
  * @param \SpoonTemplate $template The template to parse the element in.
  * @return string
  */
 public function parse($template = null)
 {
     // get upload_max_filesize
     $uploadMaxFilesize = ini_get('upload_max_filesize');
     if ($uploadMaxFilesize === false) {
         $uploadMaxFilesize = 0;
     }
     // reformat if defined as an integer
     if (\SpoonFilter::isInteger($uploadMaxFilesize)) {
         $uploadMaxFilesize = $uploadMaxFilesize / 1024 . 'MB';
     }
     // reformat if specified in kB
     if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'K') {
         $uploadMaxFilesize = substr($uploadMaxFilesize, 0, -1) . 'kB';
     }
     // reformat if specified in MB
     if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'M') {
         $uploadMaxFilesize .= 'B';
     }
     // reformat if specified in GB
     if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'G') {
         $uploadMaxFilesize .= 'B';
     }
     // name is required
     if ($this->attributes['name'] == '') {
         throw new \SpoonFormException('A name is required for a file field. Please provide a name.');
     }
     // start html generation
     $output = '<input type="file"';
     // add attributes
     $output .= $this->getAttributesHTML(array('[id]' => $this->attributes['id'], '[name]' => $this->attributes['name'])) . ' />';
     // add help txt if needed
     if (!$this->hideHelpTxt) {
         if (isset($this->attributes['extension'])) {
             $output .= '<span class="helpTxt">' . sprintf(Language::getMessage('HelpFileFieldWithMaxFileSize', 'core'), $this->attributes['extension'], $uploadMaxFilesize) . '</span>';
         } else {
             $output .= '<span class="helpTxt">' . sprintf(Language::getMessage('HelpMaxFileSize'), $uploadMaxFilesize) . '</span>';
         }
     }
     // parse to template
     if ($template !== null) {
         $template->assign('file' . \SpoonFilter::toCamelCase($this->attributes['name']), $output);
         $template->assign('file' . \SpoonFilter::toCamelCase($this->attributes['name']) . 'Error', $this->errors != '' ? '<span class="formError">' . $this->errors . '</span>' : '');
     }
     return $output;
 }
Пример #3
0
 /**
  * Output the template into the browser
  * Will also assign the interfacelabels and all user-defined constants.
  *
  * @param string $template The path for the template.
  */
 public function display($template)
 {
     $this->parseConstants();
     $this->parseAuthenticatedUser();
     $this->parseDebug();
     $this->parseLabels();
     $this->parseLocale();
     $this->parseVars();
     parent::display($template);
 }
Пример #4
0
 /**
  * Output the template into the browser
  * Will also assign the interfacelabels and all user-defined constants.
  *
  * @param string $template The path for the template.
  * @param bool[optional] $customHeaders Are there custom headers set?
  */
 public function display($template, $customHeaders = false)
 {
     $this->parseConstants();
     $this->parseAuthenticatedUser();
     $this->parseDebug();
     $this->parseLabels();
     $this->parseLocale();
     $this->parseVars();
     // parse headers
     if (!$customHeaders) {
         SpoonHTTP::setHeaders('Content-type: text/html;charset=' . SPOON_CHARSET);
     }
     parent::display($template);
 }
 public function testGetAssignedValue()
 {
     $tpl = new SpoonTemplate();
     $tpl->assign('name', 'value');
     $tpl->assign('list', array('name' => 'Erik Bauffman'));
     $this->assertEquals('value', $tpl->getAssignedValue('name'));
     $this->assertEquals(array('name' => 'Erik Bauffman'), $tpl->getAssignedValue('list'));
     $this->assertEquals(null, $tpl->getAssignedValue('wtf-this-is-super-cool'));
 }
Пример #6
0
 /**
  * @param int $step The step to load.
  */
 public function __construct($step)
 {
     // set setp
     $this->step = (int) $step;
     // skip step 1
     if ($this->step > 1) {
         // include path
         set_include_path($_SESSION['path_library'] . PATH_SEPARATOR . get_include_path());
         // load spoon
         require_once $_SESSION['path_library'] . '/spoon/spoon.php';
         // create template
         $this->tpl = new SpoonTemplate();
         $this->tpl->setForceCompile(true);
         $this->tpl->setCompileDirectory(dirname(__FILE__) . '/../cache/');
         // assign the path
         if (defined('PATH_WWW')) {
             $this->tpl->assign('PATH_WWW', PATH_WWW);
         }
         // create form
         $this->frm = new SpoonForm('step' . $step, 'index.php?step=' . $step);
         $this->frm->setParameter('class', 'forkForms submitWithLink');
         $this->frm->setParameter('id', 'installForm');
     }
 }
Пример #7
0
 /**
  * Output the template into the browser
  * Will also assign the interfacelabels and all user-defined constants.
  *
  * @return	void
  * @param	string $template				The path for the template.
  * @param	bool[optional] $customHeaders	Are there custom headers set?
  */
 public function display($template, $customHeaders = false)
 {
     // parse constants
     $this->parseConstants();
     // parse authenticated user
     $this->parseAuthenticatedUser();
     // check debug
     $this->parseDebug();
     // parse the label
     $this->parseLabels();
     // parse locale
     $this->parseLocale();
     // parse some vars
     $this->parseVars();
     // parse headers
     if (!$customHeaders) {
         SpoonHTTP::setHeaders('Content-type: text/html;charset=utf-8');
     }
     // call the parent
     parent::display($template);
 }
Пример #8
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
/*
 * Start the register magic
 * @joenmaes
 */
// facebook php
require_once 'facebook/facebook.php';
// Create our Application instance
$facebook = new Facebook(array('appId' => '177481728946474', 'secret' => '6d5db3a0e538eb5aa7bebe6ae0bb2efe', 'cookie' => true));
$session = $facebook->getSession();
$me = null;
$uid = null;
// Session based API call.
if ($session) {
    try {
        $uid = $facebook->getUser();
        $me = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        error_log($e);
    }
}
Пример #9
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    // show the output of get()
    $uid = SpoonSession::get('public_uid');
    // make a connection
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $user = $db->getRecord('SELECT * FROM users WHERE user_id = ?', $uid);
    //Spoon::dump($user);
    if ($user['fb_uid'] != null) {
        $tpl->assign('fbu', $user['fb_uid']);
    } else {
        $tpl->assign('fbu', 1);
    }
    $tpl->assign('uname', $user['username']);
    $tpl->assign('firstname', $user['first_name']);
    $tpl->assign('lastname', $user['last_name']);
    $tpl->assign('email', $user['mail']);
    //spoon::dump($user);
    //$tpl->assign('gender', $user['gender']);
Пример #10
0
 /**
  * Parse the html for this button.
  *
  * @return	array
  * @param	SpoonTemplate[optional] $template
  */
 public function parse(SpoonTemplate $template = null)
 {
     // name required
     if ($this->name == '') {
         throw new SpoonFormException('A name is required for a radiobutton. Please provide a name.');
     }
     // loop values
     foreach ($this->values as $value => $label) {
         // init vars
         $name = 'rbt' . SpoonFilter::toCamelCase($this->name);
         $element = array();
         $element[$name] = '<input type="radio" name="' . $this->name . '" value="' . $value . '"';
         // checked status
         if ($value == $this->getChecked()) {
             $element[$name] .= ' checked="checked"';
         }
         // add attributes
         $element[$name] .= $this->getAttributesHTML($value, array('[id]' => $this->variables[$value]['id'], '[value]' => $value));
         // add variables to this element
         foreach ($this->variables[$value] as $variableKey => $variableValue) {
             $element[$variableKey] = $variableValue;
         }
         // end input tag
         $element[$name] .= ' />';
         // add checkbox
         $radioButtons[] = $element;
     }
     // template
     if ($template !== null) {
         $template->assign($this->name, $radioButtons);
         $template->assign('rbt' . SpoonFilter::toCamelCase($this->name) . 'Error', $this->errors != '' ? '<span class="formError">' . $this->errors . '</span>' : '');
     }
     return $radioButtons;
 }
Пример #11
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$latestCheckIn = CheckIn::getLatestCheckinByUserId(SpoonSession::get('id'));
$daysAgo = (SpoonDate::getDate("m.d.j") - SpoonDate::getDate("m.d.j", strtotime($latestCheckIn->timestamp))) * 100;
$timeAgo = SpoonDate::getDate("H:i:s") - SpoonDate::getDate("H:i:s", strtotime($latestCheckIn->timestamp));
//If the checkin is within 5 hours
//if($timeAgo > -6){
$tpl->assign('oCheckIn', true);
if (SpoonFilter::getGetValue('event', null, '') === 'plus') {
    $latestCheckIn->AddTab(SpoonFilter::getGetValue('drinkid', null, ''));
    SpoonHTTP::redirect('checkin.php');
} else {
    if (SpoonFilter::getGetValue('event', null, '') === 'min') {
        $latestCheckIn->DeleteTab(SpoonFilter::getGetValue('drinkid', null, ''));
        SpoonHTTP::redirect('checkin.php');
    }
}
Пример #12
0
 /**
  * Parses the html for this hidden field.
  *
  * @return	string
  * @param	SpoonTemplate[optional] $template
  */
 public function parse(SpoonTemplate $template = null)
 {
     // start html generation
     $output = '<input type="hidden" value="' . $this->getValue() . '"';
     // add attributes
     $output .= $this->getAttributesHTML(array('[id]' => $this->attributes['id'], '[name]' => $this->attributes['name'], '[value]' => $this->getValue())) . ' />';
     // parse hidden field
     if ($template !== null) {
         $template->assign('hid' . SpoonFilter::toCamelCase($this->attributes['name']), $output);
     }
     return $output;
 }
Пример #13
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
// facebook php
require_once 'facebook/facebook.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// check if the key exists
if (SpoonSession::exists('public_uid')) {
    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array('appId' => '118234134911012', 'secret' => 'a83b1fbf766dcf41a8238a13f53690bd', 'cookie' => true));
    //$facebook->setSession(null);
    $session = $facebook->getSession();
    //spoon::dump($session);
    // Session based API call.
    if ($session) {
        try {
            $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
            $record = array();
            //$record['fb_access_token'] = $facebook->getAccessToken();
            $record['fb_uid'] = $facebook->getUser();
            $record['fb_publish_stream'] = true;
            $uid = SpoonSession::get('public_uid');
            $rows = $db->update('users', $record, 'user_id = ?', $uid);
            SpoonHTTP::redirect('dashboardSettings.php');
        } catch (FacebookApiException $e) {
Пример #14
0
 /**
  * Builds & returns the pagination.
  *
  * @return	string
  * @param	string $URL
  * @param	int $offset
  * @param	string $order
  * @param	string $sort
  * @param	int $numResults
  * @param	int $numPerPage
  * @param	bool[optional] $debug
  * @param	string[optional] $compileDirectory
  */
 public static function getContent($URL, $offset, $order, $sort, $numResults, $numPerPage, $debug = true, $compileDirectory = null)
 {
     // current page
     $currentPage = ceil($offset / $numPerPage) + 1;
     // number of pages
     $numPages = ceil($numResults / $numPerPage);
     // load template
     $tpl = new SpoonTemplate();
     // compile directory
     if ($compileDirectory !== null) {
         $tpl->setCompileDirectory($compileDirectory);
     } else {
         $tpl->setCompileDirectory(dirname(__FILE__));
     }
     // force compiling
     $tpl->setForceCompile((bool) $debug);
     // previous url
     if ($currentPage > 1) {
         // label & url
         $previousLabel = self::$previous;
         $previousURL = str_replace(array('[offset]', '[order]', '[sort]'), array($offset - $numPerPage, $order, $sort), $URL);
         $tpl->assign('previousLabel', $previousLabel);
         $tpl->assign('previousURL', $previousURL);
     }
     // next url
     if ($currentPage < $numPages) {
         // label & url
         $nextLabel = self::$next;
         $nextURL = str_replace(array('[offset]', '[order]', '[sort]'), array($offset + $numPerPage, $order, $sort), $URL);
         $tpl->assign('nextLabel', $nextLabel);
         $tpl->assign('nextURL', $nextURL);
     }
     // limit
     $limit = 7;
     $breakpoint = 4;
     $items = array();
     /**
      * Less than or 7 pages. We know all the keys, and we put them in the array
      * that we will use to generate the actual pagination.
      */
     if ($numPages <= $limit) {
         for ($i = 1; $i <= $numPages; $i++) {
             $items[$i] = $i;
         }
     } else {
         // first page
         if ($currentPage == 1) {
             // [1] 2 3 4 5 6 7 8 9 10 11 12 13
             for ($i = 1; $i <= $limit; $i++) {
                 $items[$i] = $i;
             }
             $items[$limit + 1] = '...';
         } elseif ($currentPage == $numPages) {
             // 1 2 3 4 5 6 7 8 9 10 11 12 [13]
             $items[$numPages - $limit - 1] = '...';
             for ($i = $numPages - $limit; $i <= $numPages; $i++) {
                 $items[$i] = $i;
             }
         } else {
             // 1 2 3 [4] 5 6 7 8 9 10 11 12 13
             // define min & max
             $min = $currentPage - $breakpoint + 1;
             $max = $currentPage + $breakpoint - 1;
             // minimum doesnt exist
             while ($min <= 0) {
                 $min++;
                 $max++;
             }
             // maximum doesnt exist
             while ($max > $numPages) {
                 $min--;
                 $max--;
             }
             // create the list
             if ($min != 1) {
                 $items[$min - 1] = '...';
             }
             for ($i = $min; $i <= $max; $i++) {
                 $items[$i] = $i;
             }
             if ($max != $numPages) {
                 $items[$max + 1] = '...';
             }
         }
     }
     // init var
     $pages = array();
     // loop pages
     foreach ($items as $item) {
         // counter
         if (!isset($i)) {
             $i = 0;
         }
         // base details
         $pages[$i]['page'] = false;
         $pages[$i]['currentPage'] = false;
         $pages[$i]['otherPage'] = false;
         $pages[$i]['noPage'] = false;
         $pages[$i]['url'] = '';
         $pages[$i]['pageNumber'] = $item;
         // hellips
         if ($item == '...') {
             $pages[$i]['noPage'] = true;
         } else {
             // show page
             $pages[$i]['page'] = true;
             // current page ?
             if ($item == $currentPage) {
                 $pages[$i]['currentPage'] = true;
             } else {
                 // show the page
                 $pages[$i]['otherPage'] = true;
                 // url to this page
                 $pages[$i]['url'] = str_replace(array('[offset]', '[order]', '[sort]'), array($numPerPage * $item - $numPerPage, $order, $sort), $URL);
             }
         }
         // update counter
         $i++;
     }
     // first key needs to be zero
     $pages = SpoonFilter::arraySortKeys($pages);
     // assign pages
     $tpl->assign('pages', $pages);
     // cough it up
     ob_start();
     $tpl->display(dirname(__FILE__) . '/paging.tpl');
     return ob_get_clean();
 }
Пример #15
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    $tpl->assign('oNavMe', true);
    $uid = SpoonSession::get('public_uid');
    /*code max*/
    $recentDrinks = PublicApp::getRecentUserDrinks($uid);
    $recent = PublicApp::getRecentUserCheckins($uid);
    //$recent = array_merge($recentDrinks, $recentCheckins);
    function compare_time($a, $b)
    {
        return strnatcmp($b['timestamp'], $a['timestamp']);
    }
    usort($recent, 'compare_time');
    $test = array();
    for ($i = 0; $i < 100; $i++) {
        if ($recent[$i] !== null) {
            $test[] = $recent[$i];
        }
    }
Пример #16
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
//Content layout
if (SpoonSession::exists('public_uid')) {
    //show logout
    $tpl->assign('oLogout', true);
}
// show the output
$tpl->assign('content', $tpl->getContent('templates/drinks.tpl'));
$tpl->display('templates/layout.tpl');
Пример #17
0
 /**
  * Parses the summary.
  *
  * @return	void
  */
 private function parseSummary()
 {
     if ($this->summary !== null) {
         $this->tpl->assign('summary', $this->summary);
     }
 }
Пример #18
0
 /**
  * Parses the html for this dropdown.
  *
  * @return	string
  * @param	SpoonTemplate[optional] $template	The template to parse the element in.
  */
 public function parse(SpoonTemplate $template = null)
 {
     // name is required
     if ($this->attributes['name'] == '') {
         throw new SpoonFormException('A name is required for a dropdown menu. Please provide a name.');
     }
     // name?
     if (!$this->single) {
         $this->attributes['name'] .= '[]';
     }
     // init var
     $selected = $this->getSelected();
     // start html generation
     $output = "\r\n" . '<select';
     // add attributes
     $output .= $this->getAttributesHTML(array('[id]' => $this->attributes['id'], '[name]' => $this->attributes['name']));
     // end select tag
     $output .= ">\r\n";
     // default element?
     if (count($this->defaultElement) != 0) {
         // create option
         $output .= "\t" . '<option value="' . $this->defaultElement[1] . '"';
         // multiple
         if (!$this->single) {
             // if the value is within the selected items array
             if (is_array($selected) && count($selected) != 0 && in_array($this->defaultElement[1], $selected)) {
                 $output .= ' selected="selected"';
             }
         } else {
             // if the current value is equal to the submitted value
             if ($this->defaultElement[1] == $selected && $selected !== null) {
                 $output .= ' selected="selected"';
             }
         }
         // end option
         $output .= '>' . $this->defaultElement[0] . "</option>\r\n";
     }
     // loop all values
     foreach ($this->values as $label => $value) {
         // value is an optgroup?
         if ($this->optionGroups[$label]) {
             // create optgroup
             $output .= "\t" . '<optgroup label="' . $label . '">' . "\n";
             // loop value
             foreach ($value as $key => $option) {
                 // create option
                 $output .= "\t\t" . '<option value="' . $key . '"';
                 // multiple
                 if (!$this->single) {
                     // if the value is within the selected items array
                     if (is_array($selected) && count($selected) != 0 && in_array($key, $selected)) {
                         $output .= ' selected="selected"';
                     }
                 } else {
                     // if the current value is equal to the submitted value
                     if ($key == $selected) {
                         $output .= ' selected="selected"';
                     }
                 }
                 // add custom attributes
                 if (isset($this->optionAttributes[(string) $key])) {
                     // loop each attribute
                     foreach ($this->optionAttributes[(string) $key] as $attrKey => $attrValue) {
                         // add to the output
                         $output .= ' ' . $attrKey . '="' . $attrValue . '"';
                     }
                 }
                 // end option
                 $output .= ">{$option}</option>\r\n";
             }
             // end optgroup
             $output .= "\t" . '</optgroup>' . "\n";
         } else {
             // create option
             $output .= "\t" . '<option value="' . $label . '"';
             // multiple
             if (!$this->single) {
                 // if the value is within the selected items array
                 if (is_array($selected) && count($selected) != 0 && in_array($label, $selected)) {
                     $output .= ' selected="selected"';
                 }
             } else {
                 // if the current value is equal to the submitted value
                 if ($this->getSelected() !== null && $label == $selected) {
                     $output .= ' selected="selected"';
                 }
             }
             // add custom attributes
             if (isset($this->optionAttributes[(string) $label])) {
                 // loop each attribute
                 foreach ($this->optionAttributes[(string) $label] as $attrKey => $attrValue) {
                     // add to the output
                     $output .= ' ' . $attrKey . '="' . $attrValue . '"';
                 }
             }
             // end option
             $output .= ">{$value}</option>\r\n";
         }
     }
     // end html
     $output .= "</select>\r\n";
     // parse to template
     if ($template !== null) {
         $template->assign('ddm' . SpoonFilter::toCamelCase(str_replace('[]', '', $this->attributes['name'])), $output);
         $template->assign('ddm' . SpoonFilter::toCamelCase(str_replace('[]', '', $this->attributes['name'])) . 'Error', $this->errors != '' ? '<span class="formError">' . $this->errors . '</span>' : '');
     }
     return $output;
 }
Пример #19
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
$tpl->assign('formaction', $_SERVER['PHP_SELF']);
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$pub = new Pub(SpoonFilter::getGetValue('id', null, ''));
//User clicks on Check in button
if (SpoonFilter::getPostValue('btnCheckIn', null, '') !== "") {
    $check = new CheckIn('');
    $check->pub = new Pub(SpoonFilter::getPostValue('pub_id', null, ''));
    $check->user = new User(SpoonSession::get('id'));
    $id = $check->Add();
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $user = $db->getRecord('SELECT * FROM users WHERE user_id = ?', SpoonSession::get('id'));
    /*post to facebook*/
    if ($user['fb_publish_stream']) {
        require_once 'facebook/facebook.php';
        // Create our Application instance (replace this with your appId and secret).
        $facebook = new Facebook(array('appId' => '118234134911012', 'secret' => 'a83b1fbf766dcf41a8238a13f53690bd', 'cookie' => true));
Пример #20
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
$tpl->assign('formaction', $_SERVER['PHP_SELF']);
SpoonSession::start();
//Content layout
$latestCheckIn = CheckIn::getLatestCheckinByUserId(SpoonSession::get('id'));
$timeAgo = SpoonDate::getDate("H:i:s", strtotime($latestCheckIn->timestamp)) - SpoonDate::getDate("H:i:s");
$user = new User(SpoonFilter::getGetValue('id', null, ''));
if ($user->user_id === null || SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$recent = $user->getRecentUserDrinks($user->user_id);
for ($i = 0; $i < sizeof($recent); $i++) {
    $recent[$i]['timestamp'] = SpoonDate::getTimeAgo(strtotime($recent[$i]['timestamp']));
    if (!$recent[$i]['fb_uid']) {
        //else, use standard fb icon
        $recent[$i]['fb_uid'] = 1;
        $user->fb_uid = 1;
    }
}
if ($recent !== null) {
    $tpl->assign('oRecent', true);
Пример #21
0
 /**
  * Parses the html for this filefield.
  *
  * @return	string
  * @param	SpoonTemplate[optional] $template	The template to parse the element in.
  */
 public function parse(SpoonTemplate $template = null)
 {
     // name is required
     if ($this->attributes['name'] == '') {
         throw new SpoonFormException('A name is required for a file field. Please provide a name.');
     }
     // start html generation
     $output = '<input type="file"';
     // add attributes
     $output .= $this->getAttributesHTML(array('[id]' => $this->attributes['id'], '[name]' => $this->attributes['name'])) . ' />';
     // parse to template
     if ($template !== null) {
         $template->assign('file' . SpoonFilter::toCamelCase($this->attributes['name']), $output);
         $template->assign('file' . SpoonFilter::toCamelCase($this->attributes['name']) . 'Error', $this->errors != '' ? '<span class="formError">' . $this->errors . '</span>' : '');
     }
     return $output;
 }
Пример #22
0
<?php

/*
 * search page for public
 *
 * @author  Jeroen Maes
 * @author  Maxime Jonckheere
 * @author  Jeroen Neyt
 * 
 */
date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// get search query from url
$query = SpoonFilter::getGetValue('q', null, '');
$tpl->assign('query', $query);
// show the output
$tpl->assign('content', $tpl->getContent('templates/search.tpl'));
$tpl->display('templates/layout.tpl');
Пример #23
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
$tpl->assign('formaction', $_SERVER['PHP_SELF']);
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$drinks = Drink::getAllDrinks();
$tpl->assign('iDrinks', $drinks);
// show the output
$tpl->assign('content', $tpl->getContent('templates/drinks.tpl'));
$tpl->display('templates/template.tpl');
Пример #24
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    $tpl->assign('oNavMe', true);
    $uid = SpoonSession::get('public_uid');
    $user = new User($uid);
    if ($user->GetFollowing() != null) {
        $values = $user->GetFollowing();
        $following = array();
        foreach ($values as $value) {
            $userFollowing = new User($value['friend']);
            if ($userFollowing->fb_uid == null) {
                $userFollowing->fb_uid = 1;
            }
            array_push($following, get_object_vars($userFollowing));
        }
        $tpl->assign('oFollowing', true);
        $tpl->assign('iFollowing', $following);
    } else {
        $tpl->assign('oNoFollowing', true);
Пример #25
0
 /**
  * Parses the html for this textarea.
  *
  * @return	string
  * @param	SpoonTemplate[optional] $template	The template to parse the element in.
  */
 public function parse(SpoonTemplate $template = null)
 {
     // name is required
     if ($this->attributes['name'] == '') {
         throw new SpoonFormException('A name is requird for a textarea. Please provide a valid name.');
     }
     // start html generation
     $output = '<textarea';
     // add attributes
     $output .= $this->getAttributesHTML(array('[id]' => $this->attributes['id'], '[name]' => $this->attributes['name'], '[value]' => $this->getValue()));
     // close first tag
     $output .= '>';
     // add value
     $output .= str_replace(array('"', '<', '>'), array('&quot;', '&lt;', '&gt;'), $this->getValue());
     // end tag
     $output .= '</textarea>';
     // template
     if ($template !== null) {
         $template->assign('txt' . SpoonFilter::toCamelCase($this->attributes['name']), $output);
         $template->assign('txt' . SpoonFilter::toCamelCase($this->attributes['name']) . 'Error', $this->errors != '' ? '<span class="formError">' . $this->errors . '</span>' : '');
     }
     return $output;
 }
Пример #26
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$drink = new Drink(SpoonFilter::getGetValue('id'));
$tpl->assign('name', $drink->name);
$query = array(array('id' => NULL, 'name' => $drink->name, 'type' => '/food/beer'));
$query_envelope = array('query' => $query);
$service_url = 'http://api.freebase.com/api/service/mqlread';
$url = $service_url . '?query=' . urlencode(json_encode($query_envelope));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$results = json_decode($response)->result;
Spoon::dump($results);
$tpl->assign('drinks', $results[0]);
// show the output
Пример #27
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
// do I know you?
if (SpoonSession::exists('public_uid')) {
    $tpl->assign('oLogout', true);
    $tpl->assign('oNavMe', true);
    $uid = SpoonSession::get('public_uid');
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $checkins = $db->getRecords('SELECT * FROM checkins WHERE user_id = ?', $uid);
    $user = new User($uid);
    $tpl->assign('daysActive', 'NOT ENOUGH DATA');
    $tpl->assign('checkins', count($checkins));
    $tpl->assign('avgDrinks', 'NOT ENOUGH DATA');
    $tpl->assign('avgDay', 'NOT ENOUGH DATA');
    $tpl->assign('topFriends', 'NOT ENOUGH DATA');
    if ($user->GetTopPubs(5) !== null) {
        $tpl->assign('oTopPubs', true);
        $tpl->assign('iTopPubs', $user->GetTopPubs(5));
    } else {
        $tpl->assign('oNoTopPubs', true);
    }
} else {
Пример #28
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$lat = SpoonFilter::getGetValue('lat', null, '');
$long = SpoonFilter::getGetValue('long', null, '');
$tpl->assign('formaction', $_SERVER['PHP_SELF'] . '?lat=' . $lat . '&long=' . $long);
$msgFault = '';
$pubname = SpoonFilter::getPostValue('pubname', null, '');
if (SpoonFilter::getPostValue('btnAdd', null, '')) {
    if ($pubname === "") {
        $msgFault = "Please fill in the name of the pub.";
    } else {
        if ($lat !== "" && $long !== "") {
            $pub = new Pub('');
            $pub->name = $pubname;
            $pub->latitude = $lat;
            $pub->longitude = $long;
            $id = $pub->Add();
Пример #29
0
<?php

date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
//Content layout
$pub = new Pub(SpoonFilter::getGetValue('id', null, ''));
if (SpoonSession::exists('public_uid')) {
    //show logout
    $tpl->assign('oLogout', true);
}
if ($pub->pub_id === null) {
    SpoonHTTP::redirect('index.php');
}
$recent = CheckIn::getCheckinsByPubId($pub->pub_id);
for ($i = 0; $i < sizeof($recent); $i++) {
    $recent[$i]['timestamp'] = SpoonDate::getTimeAgo(strtotime($recent[$i]['timestamp']));
    //check if the user has a fb account authenticated
    if (!$recent[$i]['fb_uid']) {
        //else, use standard fb icon
        $recent[$i]['fb_uid'] = 1;
    }
}
if ($recent !== null) {
    $tpl->assign('oRecent', true);
Пример #30
0
 /**
  * Is the cache for this item still valid.
  *
  * @param string $name The name of the cached block.
  * @return bool
  */
 public function isCached($name)
 {
     // never cached in debug
     if (SPOON_DEBUG) {
         return false;
     } else {
         return parent::isCached($name);
     }
 }