コード例 #1
0
 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'));
 }
コード例 #2
0
ファイル: Client.php プロジェクト: bwgraves/forkcms
 /**
  * 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);
 }
コード例 #3
0
ファイル: FormFile.php プロジェクト: bwgraves/forkcms
 /**
  * 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;
 }
コード例 #4
0
ファイル: step.php プロジェクト: naujasdizainas/forkcms
 /**
  * @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');
     }
 }
コード例 #5
0
ファイル: checkin.php プロジェクト: JonckheereM/Public
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');
    }
}
$tpl->assign('pub_id', $latestCheckIn->pub->pub_id);
$tpl->assign('name', $latestCheckIn->pub->name);
$tpl->assign('longitude', $latestCheckIn->pub->longitude);
$tpl->assign('latitude', $latestCheckIn->pub->latitude);
$tpl->assign('people', $latestCheckIn->pub->getNumberPeople());
$tpl->assign('checkins', $latestCheckIn->pub->getNumberCheckins());
コード例 #6
0
ファイル: register.php プロジェクト: JonckheereM/Public
// 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);
    }
}
// facebook javascript
$tpl->assign('appid', $facebook->getAppId());
$tpl->assign('session', json_encode($session));
// facebook buttons
if (!$me) {
    $tpl->assign('fbcbutton', '<fb:login-button perms="email"></fb:login-button>');
} else {
    $tpl->assign('fbcbutton', '<p class="connected"><img src="img/check.png">Connected to Facebook<p>');
}
// fill in form
if ($me) {
    //Spoon::dump($me);
    $tpl->assign('fname', $me['first_name']);
    $tpl->assign('lname', $me['last_name']);
    $tpl->assign('email', $me['email']);
    $tpl->assign('fb_uid', $uid);
}
コード例 #7
0
ファイル: radiobutton.php プロジェクト: JonckheereM/Public
 /**
  * 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;
 }
コード例 #8
0
ファイル: search.php プロジェクト: JonckheereM/Public
<?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');
コード例 #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);
    $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);
コード例 #10
0
ファイル: file.php プロジェクト: sunkangtaichi/library
 /**
  * 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;
 }
コード例 #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');
// 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];
        }
    }
コード例 #12
0
ファイル: pubDetail.php プロジェクト: JonckheereM/Public
<?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));
コード例 #13
0
ファイル: dropdown.php プロジェクト: richsage/forkcms
 /**
  * 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;
 }
コード例 #14
0
ファイル: form.php プロジェクト: ss23/ECommerce
 /**
  * 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;
 }
コード例 #15
0
ファイル: userDetail.php プロジェクト: JonckheereM/Public
<?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);
コード例 #16
0
ファイル: drink.php プロジェクト: JonckheereM/Public
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
$tpl->assign('content', $tpl->getContent('templates/drink.tpl'));
$tpl->display('templates/template.tpl');
コード例 #17
0
ファイル: drinks.php プロジェクト: JonckheereM/Public
<?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');
コード例 #18
0
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) {
            error_log($e);
        }
    } else {
        $tpl->assign('fbcbutton', '<fb:login-button perms="email,publish_stream"></fb:login-button>');
        //http://developers.facebook.com/docs/authentication/permissions
    }
    // facebook javascript
    $tpl->assign('appid', $facebook->getAppId());
} else {
    SpoonHTTP::redirect('login.php');
}
// show the output
$tpl->display('templates/facebookconnect.tpl');
コード例 #19
0
ファイル: email.php プロジェクト: richsage/forkcms
 /**
  * Returns the parsed content of a given template with optional variables.
  *
  * @return	string
  * @param	string $template			The path to (including the filename for) the template.
  * @param	array[optional] $variables	The variables to parse into $template.
  */
 private function getTemplateContent($template, array $variables = null)
 {
     // check if compile directory is set
     if (empty($this->compileDirectory)) {
         throw new SpoonEmailException('Compile directory is not set. Use setTemplateCompileDirectory.');
     }
     // declare template
     $tpl = new SpoonTemplate();
     $tpl->setCompileDirectory($this->compileDirectory);
     $tpl->setForceCompile(true);
     // parse variables in the template if any are found
     if (!empty($variables)) {
         $tpl->assign($variables);
     }
     // return template content
     return $tpl->getContent($template);
 }
コード例 #20
0
ファイル: drinks.php プロジェクト: JonckheereM/Public
<?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');
コード例 #21
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']);
コード例 #22
0
ファイル: datagrid.php プロジェクト: JonckheereM/Public
 /**
  * Parses the summary.
  *
  * @return	void
  */
 private function parseSummary()
 {
     if ($this->summary !== null) {
         $this->tpl->assign('summary', $this->summary);
     }
 }
コード例 #23
0
 /**
  * Builds & returns the pagination
  *
  * @param string $URL
  * @param int $offset
  * @param string $order The name of the column to sort on.
  * @param string $sort The sorting method, possible values are: asc, desc.
  * @param int $numResults
  * @param int $numPerPage The items per page.
  * @param bool[optional] $debug
  * @param string[optional] $compileDirectory
  * @return string
  */
 public static function getContent($URL, $offset, $order, $sort, $numResults, $numPerPage, $debug = true, $compileDirectory = null)
 {
     // if there is just one page we don't need paging
     if ($numResults < $numPerPage) {
         return '';
     }
     // load template
     $tpl = new SpoonTemplate();
     // compile directory
     if ($compileDirectory !== null) {
         $tpl->setCompileDirectory($compileDirectory);
     } else {
         $tpl->setCompileDirectory(dirname(__FILE__));
     }
     // force compiling
     $tpl->setForceCompile((bool) $debug);
     // init vars
     $pagination = null;
     $showFirstPages = false;
     $showLastPages = false;
     // current page
     $currentPage = ceil($offset / $numPerPage) + 1;
     // number of pages
     $numPages = ceil($numResults / $numPerPage);
     // populate count fields
     $pagination['num_pages'] = $numPages;
     $pagination['current_page'] = $currentPage;
     // as long as we are below page 7 we should show all pages starting from 1
     if ($currentPage < 8) {
         // init vars
         $pagesStart = 1;
         $pagesEnd = $numPages >= 7 ? 7 : $numPages;
         // show last pages
         if ($numPages > 8) {
             $showLastPages = true;
         }
     } elseif ($currentPage > $numPages - 7) {
         // init vars
         $pagesStart = $numPages == 9 ? $numPages - 6 : $numPages - 7;
         $pagesEnd = $numPages;
         // show first pages
         $showFirstPages = true;
     } else {
         // init vars
         $pagesStart = $currentPage - 2;
         $pagesEnd = $currentPage + 2;
         $showFirstPages = true;
         $showLastPages = true;
     }
     // show previous
     if ($currentPage > 1) {
         // set
         $pagination['show_previous'] = true;
         $pagination['previous_url'] = str_replace(array('[offset]', '[order]', '[sort]'), array($offset - $numPerPage, $order, $sort), $URL);
     }
     // show first pages?
     if ($showFirstPages) {
         // init var
         $pagesFirstStart = 1;
         $pagesFirstEnd = 2;
         // loop pages
         for ($i = $pagesFirstStart; $i <= $pagesFirstEnd; $i++) {
             // add
             $pagination['first'][] = array('url' => str_replace(array('[offset]', '[order]', '[sort]'), array($numPerPage * $i - $numPerPage, $order, $sort), $URL), 'label' => $i);
         }
     }
     // build array
     for ($i = $pagesStart; $i <= $pagesEnd; $i++) {
         // init var
         $current = $i == $currentPage;
         // add
         $pagination['pages'][] = array('url' => str_replace(array('[offset]', '[order]', '[sort]'), array($numPerPage * $i - $numPerPage, $order, $sort), $URL), 'label' => $i, 'current' => $current);
     }
     // show last pages?
     if ($showLastPages) {
         // init var
         $pagesLastStart = $numPages - 1;
         $pagesLastEnd = $numPages;
         // loop pages
         for ($i = $pagesLastStart; $i <= $pagesLastEnd; $i++) {
             // add
             $pagination['last'][] = array('url' => str_replace(array('[offset]', '[order]', '[sort]'), array($numPerPage * $i - $numPerPage, $order, $sort), $URL), 'label' => $i);
         }
     }
     // show next
     if ($currentPage < $numPages) {
         // set
         $pagination['show_next'] = true;
         $pagination['next_url'] = str_replace(array('[offset]', '[order]', '[sort]'), array($offset + $numPerPage, $order, $sort), $URL);
     }
     // multiple pages
     $pagination['multiple_pages'] = $numPages == 1 ? false : true;
     // assign pagination
     $tpl->assign('pagination', $pagination);
     // assign labels
     $tpl->assign('previousLabel', BL::lbl('PreviousPage'));
     $tpl->assign('nextLabel', BL::lbl('NextPage'));
     $tpl->assign('goToLabel', BL::lbl('GoToPage'));
     return $tpl->getContent(BACKEND_CORE_PATH . '/layout/templates/datagrid_paging.tpl');
 }
コード例 #24
0
ファイル: pubs.php プロジェクト: JonckheereM/Public
// 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, '');
$pubs = array();
if ($lat !== "" && $long !== "") {
    $tpl->assign('latitude', $lat);
    $tpl->assign('longitude', $long);
    $pubs = Pub::getPubsByLocation($lat, $long);
    for ($i = 0; $i < sizeof($pubs); $i++) {
        $pub = new Pub($pubs[$i]['pub_id']);
        $distance = $pub->calculateDistance($lat, $long, "k");
        if ($distance > 1) {
            $pubs[$i]["distance"] = round($distance, 3) . ' kilometer';
        } else {
            $pubs[$i]["distance"] = round($distance, 3) * 1000 . ' meter';
        }
    }
} else {
    $tpl->assign('latitude', "");
    $tpl->assign('longitude', "");
}
コード例 #25
0
ファイル: textarea.php プロジェクト: jincongho/clienthub
 /**
  * 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
ファイル: addPub.php プロジェクト: JonckheereM/Public
// 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();
            SpoonHTTP::redirect('pubDetail.php?id=' . $id);
        }
    }
コード例 #27
0
ファイル: dashboardStats.php プロジェクト: JonckheereM/Public
<?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
ファイル: pubDetail.php プロジェクト: JonckheereM/Public
<?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);
コード例 #29
0
ファイル: datagrid.php プロジェクト: ss23/ECommerce
 /**
  * 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();
 }
コード例 #30
0
ファイル: userDetail.php プロジェクト: JonckheereM/Public
<?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);
}
$user = new User(SpoonFilter::getGetValue('id', null, ''));
if ($user->user_id === null) {
    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']));
    //check if the user has a fb account authenticated
    if (!$recent[$i]['fb_uid']) {
        //else, use standard fb icon
        $recent[$i]['fb_uid'] = 1;
        $user->fb_uid = 1;
    }
}
if ($recent !== null) {