/** * 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); }
/** * 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); }
/** * 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); }
} 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');
$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');
/** * 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(); }
/** * Parse the datagrid. * * @return void */ private function parse() { // has results if ($this->source->getNumResults() > 0) { // fetch records $aRecords = $this->source->getData($this->getOffset(), $this->getPagingLimit(), $this->getOrder(), $this->getSort()); // has results if (count($aRecords) != 0) { // compile directory $compileDirectory = $this->compileDirectory !== null ? $this->compileDirectory : dirname(realpath(__FILE__)); $this->tpl->setCompileDirectory($compileDirectory); // only force compiling when debug is enabled if ($this->debug) { $this->tpl->setForceCompile(true); } // table attributes $this->parseAttributes(); // table summary $this->parseSummary(); // caption/description $this->parseCaption(); // header row $this->parseHeader(); // actual rows $this->parseBody($aRecords); // pagination $this->parseFooter(); // parse to buffer ob_start(); $this->tpl->display($this->getTemplatePath()); $this->content = ob_get_clean(); } } // update parsed status $this->parsed = true; }
// 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');
/** * Displays the parsed client template. */ protected function display() { $this->tpl->display('layout/templates/index.tpl'); }
//loading $tpl->assign('title', SITE_TITLE); $tpl->assign('base_url', BASE_URL); $tpl->assign('css_path', BASE_URL . '/' . CONTENTS_PATH . '/css/style.css'); $tpl->assign('jquery_path', BASE_URL . '/' . CONTENTS_PATH . '/js/jquery-1.6.4.min.js'); $tpl->assign('profiles_total', count($mysql->getRecords('SELECT `id` FROM `profiles` WHERE `status` != \'trash\''))); $tpl->assign('expired', round(($_SESSION['expired'] - time()) / 60, 1)); //expired time in minutes $tpl->assign('adminname', md5(ADMINNAME)); $tpl->assign('adminpw', md5(ADMINPASSWORD)); } if (defined('IN_LOGIN')) { $tpl->assign('login', true); } if (defined('LOAD_TEMPLATE') && defined('LOAD_HEADER')) { $tpl->display(ROOT_PATH . '/' . TEMPLATE_PATH . '/header.tpl.php'); } function setMulAttributes(&$frm, array $id, $key, $value, $type = 'Text') { $function = "add" . $type; foreach ($id as $element) { $frm->{$function}($element)->setAttribute($key, $value); } } function setCompanyValue(&$frm, $value) { $values = explode(', ', $value); $count = -1; for ($i = 1; $i < 6; $i++) { $frm->addText('company' . $i, $values[$count += 1])->setAttribute("placeholder", "公司名字 company name"); $frm->addText('registerno' . $i, $values[$count += 1])->setAttribute("placeholder", "注册号码 registration number");