static function render($options, $default) { $tab = Url::tryQueryParam("tab", $default); if (Util::tryEmpty($tab)) { $tab = $default; } if (!array_key_exists($tab, $options)) { $tab = $default; } $buffer = ''; $item = '<li class="%s"> <a href="%s">%s</a></li>'; foreach ($options as $key => $value) { $pageURI = Url::addQueryParameters($_SERVER['REQUEST_URI'], array("tab" => $key)); $class = $tab == $key ? 'active' : ''; $strItem = sprintf($item, $class, $pageURI, $value); $buffer .= $strItem; } $buffer = '<ul class="nav nav-tabs">' . $buffer . '</ul>'; $data = array("buffer" => $buffer, "active" => $tab); return $data; }
private function loadHomePage($gpage) { $pageSize = Config::getInstance()->get_value("main.page.items"); $postDao = new \com\indigloo\sc\dao\Post(); $fp_size = $pageSize - 14; $fp_size = $fp_size <= 4 ? 4 : $fp_size; $featuredDBRows = $this->getFeaturedPosts($postDao, $fp_size); $userDBRows = array(); // Do we have a login session? 4 user posts $loginId = Login::tryLoginIdInSession(); if ($loginId != null) { $userDBRows = $postDao->getOnLoginId($loginId, 4); } $short = $pageSize - (sizeof($featuredDBRows) + sizeof($userDBRows)); // if page size is less than feature + user DB rows // even then we need to fetch few latest DB rows to make the // pagination right. $short = $short <= 4 ? 4 : $short; // atleast 4 latest items, at max page size of latest items $latestDBRows = $postDao->getLatest($short); $bucket = array_merge($userDBRows, $featuredDBRows); shuffle($bucket); $count = sizeof($bucket); for ($i = 0; $i < $count; $i++) { $this->combine($bucket[$i]); } for ($i = $count; $i < sizeof($latestDBRows); $i++) { $this->combine($latestDBRows[$i]); } $endId = NULL; if (sizeof($latestDBRows) > 0) { $endId = $latestDBRows[sizeof($latestDBRows) - 1]['id']; } $endId = base_convert($endId, 10, 36); $nparams = array('gpa' => $endId, 'gpage' => 2); $nextPageUrl = Url::addQueryParameters("/", $nparams); $pageTitle = SeoData::getHomePageTitleWithNumber($gpage); $metaKeywords = SeoData::getHomeMetaKeywords(); $metaDescription = SeoData::getHomeMetaDescriptionWithNumber($gpage); $file = APP_WEB_DIR . '/home.php'; include $file; }
function render($homeURI, $startId, $endId, $gNumRecords) { if ($this->pageNo == 1 && $gNumRecords < $this->pageSize) { return; } printf("<ul class=\"pager\">"); if ($this->hasPrevious()) { $startId = $this->convert ? base_convert($startId, 10, 36) : $startId; $bparams = array('gpb' => $startId, 'gpage' => $this->previousPage()); $q = array_merge($this->qparams, $bparams); $ignore = array('gpa'); $previousURI = Url::addQueryParameters($homeURI, $q, $ignore); printf("<li> <a rel=\"nofollow prev\" href=\"%s\">← Previous</a> </li>", $previousURI); } if ($this->hasNext($gNumRecords)) { $endId = $this->convert ? base_convert($endId, 10, 36) : $endId; $nparams = array('gpa' => $endId, 'gpage' => $this->nextPage()); $q = array_merge($this->qparams, $nparams); $ignore = array('gpb'); $nextURI = Url::addQueryParameters($homeURI, $q, $ignore); printf("<li> <a rel=\"nofollow next\" href=\"%s\">Next →</a> </li>", $nextURI); } printf("</ul>"); }
use com\indigloo\sc\Constants as AppConstants; use com\indigloo\ui\Pagination; use com\indigloo\ui\Filter; //url decoded parameters $qparams = Url::getRequestQueryParams(); //copy URL parameters $fparams = $qparams; // unset extra ft params and search token param unset($fparams["ft"]); unset($fparams["gt"]); //ft urls start with page 1 $fparams["gpage"] = 1; //create filter Urls $ftBaseUrl = Url::createUrl("/monitor/posts.php", $fparams); $ftFeaturedUrl = Url::addQueryParameters($ftBaseUrl, array("ft" => "featured")); $ft24hoursUrl = Url::addQueryParameters($ftBaseUrl, array("ft" => "24hours")); //search clear link $sparams = $qparams; unset($sparams["gt"]); $clearSearchUrl = Url::createUrl("/monitor/posts.php", $sparams); //post filters $filters = array(); $model = new \com\indigloo\sc\model\Post(); $ft = Url::tryQueryParam("ft"); $ftname = ""; $gtoken = Util::tryArrayKey($qparams, "gt"); $itemId = NULL; if (empty($ft) && strlen($gtoken) > 5 && strcmp(substr($gtoken, 0, 5), "item:") == 0) { $ft = "item"; $itemId = substr($gtoken, 5); //reset search token