Example #1
0
                $userFollowing->fb_uid = 1;
            }
            array_push($following, get_object_vars($userFollowing));
        }
        $tpl->assign('oFollowing', true);
        $tpl->assign('iFollowing', $following);
    } else {
        $tpl->assign('oNoFollowing', true);
    }
    if ($user->GetFollowers() != null) {
        $values = $user->GetFollowers();
        $followers = array();
        foreach ($values as $value) {
            $userFollower = new User($value['user_id']);
            if ($userFollower->fb_uid == null) {
                $userFollower->fb_uid = 1;
            }
            array_push($followers, get_object_vars($userFollower));
        }
        $tpl->assign('oFollowers', true);
        $tpl->assign('iFollowers', $followers);
    } else {
        $tpl->assign('oNoFollowers', true);
    }
} else {
    //GTFO!!!
    SpoonHTTP::redirect('index.php');
}
// show the output
$tpl->assign('content', $tpl->getContent('templates/dashboardFriends.tpl'));
$tpl->display('templates/layout.tpl');
Example #2
0
    usort($recentDrinks, 'compare_time');
    $test = array();
    for ($i = 0; $i < 100; $i++) {
        if ($recentDrinks[$i] !== null) {
            $test[] = $recentDrinks[$i];
        }
    }
    $recentDrinks = $test;
    for ($i = 0; $i < sizeof($recentDrinks); $i++) {
        $recentDrinks[$i]['timestamp'] = SpoonDate::getTimeAgo(strtotime($recentDrinks[$i]['timestamp']));
        //check if the user has a fb account authenticated
        if (!$recentDrinks[$i]['fb_uid']) {
            //else, use standard fb icon
            $recentDrinks[$i]['fb_uid'] = 1;
        }
    }
    if ($recent !== null) {
        //$tpl->assign('oRecent', true);
        $tpl->assign('iRecent', $recent);
        $tpl->assign('iRecentt', $recentDrinks);
    }
    //else
    //$tpl->assign('oNoRecent', true);
    /*end code max*/
} else {
    //GTFO!!!
    SpoonHTTP::redirect('index.php');
}
// show the output
$tpl->assign('content', $tpl->getContent('templates/dashboardHistory.tpl'));
$tpl->display('templates/layout.tpl');
Example #3
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');
Example #4
0
 /**
  * @return Response
  */
 public function display()
 {
     $content = $this->tpl->getContent(__DIR__ . '/../Client/Layout/Templates/Index.tpl');
     return new Response($content, 200);
 }
Example #5
0
    //spoon::dump($user);
    //$tpl->assign('gender', $user['gender']);
    //$tpl->assign('weight', $user['weight']);
    //  $tpl->assign('birth', $user['birth_date']);
    //$tpl->assign('password', $user['password']);
    if ($user['fb_publish_stream']) {
        $tpl->assign('fbstatus', '<span style="color:green;" class="authd">Authenticated</span>');
        //$tpl->assign('facebook', 'Access token: ' . $user['fb_access_token']);
        //$tpl->assign('facebook', '<a href="ajax/fbpost.php" class="button">Update status</a>');
        $tpl->assign('facebook', ' <input type="checkbox" id="twitterPublish" value="doPublish" checked/> Publish my check-ins to Facebook');
    } else {
        $tpl->assign('fbstatus', '<span style="color:red;">Not authenticated</span>');
        //$tpl->assign('facebook', '<input value="Connect" type="button" onclick="window.location.href=\'facebookconnect.php\'; " >');
        $tpl->assign('facebook', '<a href="facebookconnect.php" class="button">Connect</a>');
    }
    if ($user['twitter_uid']) {
        $tpl->assign('twitterstatus', '<span style="color:green;" class="authd"">Authenticated</span>');
        $tpl->assign('twitter', ' <input type="checkbox" id="facebookPublish" value="doPublish" checked/> Share my check-ins on Twitter');
        //$tpl->assign('twitter', '<a href="ajax/twitterpost.php" class="button">Tweet</a>');
    } else {
        $tpl->assign('twitterstatus', '<span style="color:red;">Not authenticated</span>');
        //$tpl->assign('twitter', '<input value="Connect" type="button" onclick="window.location.href=\'twitterconnect.php\'; " >');
        $tpl->assign('twitter', '<a href="twitterconnect.php" class="button">Connect</a>');
    }
} else {
    //GTFO!!!
    SpoonHTTP::redirect('index.php');
}
// show the output
$tpl->assign('content', $tpl->getContent('templates/dashboardSettings.tpl'));
$tpl->display('templates/layout.tpl');
Example #6
0
    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);
    $tpl->assign('iRecent', $recent);
} else {
    $tpl->assign('oNoRecent', true);
}
if (CheckIn::getTopCheckinsByPubId($pub->pub_id) !== null) {
    $tpl->assign('oTopCheckins', true);
    $tpl->assign('iTopCheckins', CheckIn::getTopCheckinsByPubId($pub->pub_id));
} else {
    $tpl->assign('oNoTopCheckins', true);
}
$tpl->assign('name', $pub->name);
$tpl->assign('longitude', $pub->longitude);
$tpl->assign('latitude', $pub->latitude);
$tpl->assign('people', $pub->getNumberPeople());
$tpl->assign('checkins', $pub->getNumberCheckins());
// show the output
$tpl->assign('content', $tpl->getContent('templates/pubDetail.tpl'));
$tpl->display('templates/layout.tpl');
Example #7
0
$tpl->assign('people', $latestCheckIn->pub->getNumberPeople());
$tpl->assign('checkins', $latestCheckIn->pub->getNumberCheckins());
$tabs = $latestCheckIn->getTabs();
if ($tabs[0] !== null) {
    $tpl->assign('iTabs', $tabs);
    $tpl->assign('oTabs', true);
} else {
    $tpl->assign('iTabs', array());
    $tpl->assign('oNoTabs', true);
}
//}else{
//    $tpl->assign('oNoCheckIn', true);
//}
$user = new User(SpoonSession::exists('id'));
if ($user->weight !== null && $user->gender !== null) {
    if ($daysAgo > 0) {
        $timeAgo = $daysAgo * 12 - $timeAgo;
    }
    $drinks = $latestCheckIn->getNumberTabs();
    $isLegal = $user->isLegalToDrive((int) $drinks["count"], $timeAgo);
    if ($isLegal) {
        $tpl->assign('oLegalToDrive', true);
    } else {
        $tpl->assign('oNotLegalToDrive', true);
    }
} else {
    $tpl->assign('oNotAbleLegalToDrive', true);
}
// show the output
$tpl->assign('content', $tpl->getContent('templates/checkin.tpl'));
$tpl->display('templates/template.tpl');
Example #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');
//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');
Example #9
0
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);
        }
    }
}
$tpl->assign('pubname', $pubname);
$tpl->assign('msgFault', $msgFault);
$tpl->assign('latitude', $lat);
$tpl->assign('longitude', $long);
// show the output
$tpl->assign('content', $tpl->getContent('templates/addPub.tpl'));
$tpl->display('templates/template.tpl');
Example #10
0
        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);
}
// reeds ingelogd
if (SpoonSession::exists('public_uid')) {
    SpoonHTTP::redirect('dashboard.php');
}
/*
 * End the register magic
 * @joenmaes
 */
// show the output
$tpl->assign('content', $tpl->getContent('templates/register.tpl'));
$tpl->display('templates/layout.tpl');
Example #11
0
 /**
  * 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);
 }
Example #12
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');
 }
Example #13
0
$recentCheckins = PublicApp::getRecentCheckins();
$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 < 10; $i++) {
    if ($recent[$i] !== null) {
        $test[] = $recent[$i];
    }
}
$recent = $test;
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);
    $tpl->assign('iRecent', $recent);
} else {
    $tpl->assign('oNoRecent', true);
}
// show the output
$tpl->assign('content', $tpl->getContent('templates/index.tpl'));
$tpl->display('templates/layout.tpl');
Example #14
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   $debug
  * @param string $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(__DIR__);
     }
     // 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 have more then 5 pages and are 5 pages from the end we should show all pages till the end
     if ($currentPage > 5 && $currentPage >= $numPages - 4) {
         // init vars
         $pagesStart = $numPages > 7 ? $numPages - 5 : $numPages - 6;
         $pagesEnd = $numPages;
         // fix for page 6
         if ($numPages == 6) {
             $pagesStart = 1;
         }
         // show first pages
         if ($numPages > 7) {
             $showFirstPages = true;
         }
     } elseif ($currentPage <= 5) {
         // as long as we are below page 5 and below 5 from the end we should show all pages starting from 1
         $pagesStart = 1;
         $pagesEnd = 6;
         if ($numPages == 7) {
             // when we have 7 pages, show 7 as end
             $pagesEnd = 7;
         } elseif ($numPages <= 6) {
             // when we have less then 6 pages, show the maximum page
             $pagesEnd = $numPages;
         }
         // show last pages
         if ($numPages > 7) {
             $showLastPages = true;
         }
     } else {
         // page 6
         $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', BackendLanguage::lbl('PreviousPage'));
     $tpl->assign('nextLabel', BackendLanguage::lbl('NextPage'));
     $tpl->assign('goToLabel', BackendLanguage::lbl('GoToPage'));
     return $tpl->getContent(BACKEND_CORE_PATH . '/Layout/Templates/DatagridPaging.tpl');
 }