示例#1
0
文件: Popular.php 项目: rjha/sc
 function process($params, $options)
 {
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $redis = new redis\Activity();
     $pageSize = Config::getInstance()->get_value("main.page.items");
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $zsetKey = Nest::score("post", "likes");
     $members = $redis->getPagedZSet($zsetKey, $paginator);
     //first one is id, second one is score
     $count = 0;
     $scores = array();
     $ids = array();
     for ($i = 1; $i < sizeof($members); $i++) {
         if ($i % 2 == 0) {
             array_push($scores, $members[$i - 1]);
         } else {
             $itemId = $members[$i - 1];
             $postId = PseudoId::decode($itemId);
             array_push($ids, $postId);
         }
     }
     //get post rows using ids
     $postDao = new \com\indigloo\sc\dao\Post();
     $postDBRows = $postDao->getOnSearchIds($ids);
     $pageHeader = 'Most popular';
     $pageBaseUrl = '/pub/popular';
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, "popular items");
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, "popular items");
     $file = APP_WEB_DIR . '/view/tiles-page.php';
     include $file;
 }
示例#2
0
文件: Category.php 项目: rjha/sc
 function process($params, $options)
 {
     $seoKey = Util::getArrayKey($params, "category_id");
     $collectionDao = new \com\indigloo\sc\dao\Collection();
     $zmember = $collectionDao->uizmemberOnSeoKey(Nest::ui_category(), $seoKey);
     if (is_null($zmember) || !isset($zmember["ui_code"])) {
         $controller = new \com\indigloo\sc\controller\Http404();
         $controller->process();
         exit;
     }
     $code = $zmember["ui_code"];
     $catName = $zmember["name"];
     $postDao = new \com\indigloo\sc\dao\Post();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $postDBRows = $postDao->getPagedOnCategory($paginator, $code);
     $pageHeader = $catName;
     $pageBaseUrl = "/category/{$seoKey}";
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $catName);
     $metaKeywords = SeoData::getMetaKeywords($catName);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $catName);
     $file = APP_WEB_DIR . '/view/tiles-page.php';
     include $file;
 }
示例#3
0
文件: Search.php 项目: rjha/sc
 function process($params, $options)
 {
     $token = Url::tryQueryParam("gt");
     if (empty($token)) {
         header("Location: / ");
     }
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $sphinx = new \com\indigloo\sc\search\SphinxQL();
     $qparams = Url::getRequestQueryParams();
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $ids = $sphinx->getPagedPosts($token, $paginator);
     $template = NULL;
     $searchTitle = NULL;
     if (sizeof($ids) > 0) {
         $pageHeader = "{$token}";
         $pageBaseUrl = "/search/site";
         $template = APP_WEB_DIR . '/view/search.php';
         $postDao = new \com\indigloo\sc\dao\Post();
         $postDBRows = $postDao->getOnSearchIds($ids);
     } else {
         $pageHeader = "No results";
         $template = APP_WEB_DIR . '/view/notiles.php';
     }
     $groupIds = $sphinx->getGroups($token, 0, 25);
     $groupDao = new \com\indigloo\sc\dao\Group();
     $groupDBRows = $groupDao->getOnSearchIds($groupIds);
     $sphinx->close();
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $token);
     $metaKeywords = SeoData::getMetaKeywords($token);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $token);
     include $template;
 }
示例#4
0
文件: Lists.php 项目: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     $plistId = Util::getArrayKey($params, "list_id");
     $listId = PseudoId::decode($plistId);
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     //@todo input check
     // people can type all sort of input garbage
     settype($listId, "int");
     $listDao = new \com\indigloo\sc\dao\Lists();
     $listDBRow = $listDao->getOnId($listId);
     if (empty($listDBRow)) {
         //not found
         $controller = new \com\indigloo\sc\controller\Http404();
         $controller->process();
         exit;
     }
     $listName = $listDBRow["name"];
     $listPubUrl = sprintf("%s/pub/list/%d/%s", Url::base(), $plistId, $listDBRow["seo_name"]);
     //get items from sc_list_item table
     $model = new \com\indigloo\sc\model\ListItem();
     $filter = new Filter($model);
     $filter->add($model::LIST_ID, Filter::EQ, $listId);
     $pageSize = Config::getInstance()->get_value("user.page.items");
     $filters = array();
     array_push($filters, $filter);
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $itemDBRows = $listDao->getPagedItems($paginator, $filters);
     $loginId = $listDBRow["login_id"];
     $userDao = new \com\indigloo\sc\dao\User();
     $userDBRow = $userDao->getOnLoginId($loginId);
     $template = APP_WEB_DIR . '/view/list/pub.php';
     //page variables
     $pageBaseUrl = $listPubUrl;
     $pageTitle = sprintf("page %d of %s", $gpage, $listDBRow["name"]);
     $description = Util::abbreviate($listDBRow["description"], 160);
     $metaDescription = SeoData::thisOrHomeDescription($description);
     $metaKeywords = SeoData::getHomeMetaKeywords();
     include $template;
 }
示例#5
0
文件: ItemsMap.php 项目: rjha/sc
 function process($params, $options)
 {
     $postDao = new \com\indigloo\sc\dao\Post();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("main.page.items");
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $postDBRows = $postDao->getPaged($paginator);
     $pageHeader = '';
     $pageBaseUrl = $options["path"];
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, "recent items");
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, "recent items");
     $file = APP_WEB_DIR . '/view/tiles-page.php';
     include $file;
 }
示例#6
0
文件: GroupsMap.php 项目: rjha/sc
 function spewRecent($params, $options)
 {
     $qparams = Url::getRequestQueryParams();
     $filters = array();
     $groupDao = new \com\indigloo\sc\dao\Group();
     $pageSize = 100;
     $paginator = new Pagination($qparams, $pageSize);
     $groups = $groupDao->getPaged($paginator, $filters);
     $startId = NULL;
     $endId = NULL;
     if (sizeof($groups) > 0) {
         $startId = $groups[0]["id"];
         $endId = $groups[sizeof($groups) - 1]["id"];
     }
     $pageBaseUrl = $options["path"];
     $title = "Recent groups";
     $file = APP_WEB_DIR . "/view/group/cards-page.php";
     include $file;
 }
示例#7
0
文件: Site.php 项目: rjha/sc
 static function getNoResult($message, $options = NULL)
 {
     $defaults = array("hkey" => NULL, "form" => "vanilla");
     $settings = Util::getSettings($options, $defaults);
     //get qparams from Url
     $qparams = \com\indigloo\Url::getRequestQueryParams();
     $gpage = -1;
     //hkey supplied - means show help on page #1.
     if (!empty($qparams) && isset($qparams["gpage"])) {
         $gpage = $qparams["gpage"];
         $gpage = intval($gpage);
     } else {
         $gpage = 1;
     }
     $html = NULL;
     $help_key = $settings["hkey"];
     if ($gpage <= 1 && !is_null($help_key)) {
         try {
             $html = self::getHelp($help_key);
             return $html;
         } catch (\Exception $ex) {
             $html = NULL;
             $errorMsg = $ex->getMessage();
             Logger::getInstance()->error($errorMsg);
             Logger::getInstance()->error($ex->getMessage());
         }
     }
     $view = new \stdClass();
     $template = NULL;
     $form = $settings["form"];
     switch ($form) {
         case "tile":
             $template = "/fragments/site/noresult/tile.tmpl";
             break;
         default:
             $template = "/fragments/site/noresult/vanilla.tmpl";
             break;
     }
     $view->message = $message;
     $html = Template::render($template, $view);
     return $html;
 }
示例#8
0
文件: Location.php 项目: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     // our router discards the query part from a URL so the
     // routing works with the query part as well (like /router/url?q1=x&q2=y
     $token = Util::getArrayKey($params, "location");
     if (is_null($token)) {
         header("Location: / ");
     }
     //search sphinx index
     $sphinx = new \com\indigloo\sc\search\SphinxQL();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $ids = $sphinx->getPagedPosts($token, $paginator);
     $sphinx->close();
     $template = NULL;
     $searchTitle = NULL;
     if (sizeof($ids) > 0) {
         $pageHeader = "{$token}";
         $pageBaseUrl = "/search/location/{$token}";
         $template = APP_WEB_DIR . '/view/tiles-page.php';
         $postDao = new \com\indigloo\sc\dao\Post();
         $postDBRows = $postDao->getOnSearchIds($ids);
     } else {
         $pageHeader = "No Results";
         $template = APP_WEB_DIR . '/view/notiles.php';
     }
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $token);
     $metaKeywords = SeoData::getMetaKeywords($token);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $token);
     include $template;
 }
示例#9
0
文件: Group.php 项目: rjha/sc
 function process($params, $options)
 {
     if (is_null($params) || empty($params)) {
         $controller = new \com\indigloo\sc\controller\Http400();
         $controller->process();
         exit;
     }
     $token = Util::getArrayKey($params, "name");
     // group controller is invoked via the fixed links
     // (as opposed to users typing in search box)
     // so we (exact) match this token against post_groups index.
     $sphinx = new \com\indigloo\sc\search\SphinxQL();
     $qparams = Url::getRequestQueryParams();
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $pageSize = Config::getInstance()->get_value("search.page.items");
     $paginator = new Pagination($qparams, $pageSize);
     $ids = $sphinx->getPagedPostByGroup($token, $paginator);
     $sphinx->close();
     $template = NULL;
     $searchTitle = NULL;
     $groupName = \com\indigloo\util\StringUtil::convertKeyToName($token);
     if (sizeof($ids) > 0) {
         $pageHeader = "{$groupName}";
         $pageBaseUrl = "/group/{$token}";
         $template = APP_WEB_DIR . '/view/tiles-page.php';
         $postDao = new \com\indigloo\sc\dao\Post();
         $postDBRows = $postDao->getOnSearchIds($ids);
     } else {
         $pageHeader = "No results";
         $template = APP_WEB_DIR . '/view/notiles.php';
     }
     $pageTitle = SeoData::getPageTitleWithNumber($gpage, $groupName);
     $metaKeywords = SeoData::getMetaKeywords($groupName);
     $metaDescription = SeoData::getMetaDescriptionWithNumber($gpage, $groupName);
     include $template;
 }
示例#10
0
文件: users.php 项目: rjha/sc
<?php

//sc/monitor/analytic/users.php
include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
include APP_WEB_DIR . '/inc/role/admin.inc';
use com\indigloo\Util;
use com\indigloo\Url;
use com\indigloo\Configuration as Config;
use com\indigloo\ui\Filter;
use com\indigloo\sc\redis;
use com\indigloo\sc\util\Nest;
use com\indigloo\sc\util\PseudoId;
$qparams = Url::getRequestQueryParams();
$redis = new redis\Activity();
$tab = isset($qparams["tab"]) ? $qparams["tab"] : 1;
settype($tab, "integer");
$sortVariable = "followers";
$pageSize = 25;
$paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
$baseURI = "/monitor/analytic/users.php";
$userDao = new \com\indigloo\sc\dao\User();
switch ($tab) {
    case 1:
        $sortVariable = "followers";
        break;
    case 2:
        $sortVariable = "likes";
        break;
    case 3:
        $sortVariable = "comments";
示例#11
0
文件: Home.php 项目: rjha/sc
 function loadNextPage($gpage)
 {
     $postDao = new \com\indigloo\sc\dao\Post();
     $qparams = Url::getRequestQueryParams();
     $pageSize = Config::getInstance()->get_value("main.page.items");
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $postDBRows = $postDao->getPaged($paginator);
     $pageHeader = '';
     $pageBaseUrl = '/';
     $pageTitle = SeoData::getHomePageTitleWithNumber($gpage);
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $metaDescription = SeoData::getHomeMetaDescriptionWithNumber($gpage);
     $file = APP_WEB_DIR . '/view/tiles-page.php';
     include $file;
 }
示例#12
0
文件: User.php 项目: rjha/sc
 private function processLists($params, $options)
 {
     $pubUserId = Util::getArrayKey($params, "login_id");
     $loginId = PseudoId::decode($pubUserId);
     $qparams = Url::getRequestQueryParams();
     $userDao = new \com\indigloo\sc\dao\User();
     $userDBRow = $userDao->getOnLoginId($loginId);
     $this->isValidUser($userDBRow);
     $gpage = Url::tryQueryParam("gpage");
     $gpage = empty($gpage) ? "1" : $gpage;
     $listDao = new \com\indigloo\sc\dao\Lists();
     $qparams = Url::getRequestQueryParams();
     $pageSize = Config::getInstance()->get_value("user.page.items");
     $paginator = new \com\indigloo\ui\Pagination($qparams, $pageSize);
     $listDBRows = $listDao->getPagedOnLoginId($paginator, $loginId);
     $template = APP_WEB_DIR . '/view/user/lists.php';
     //page variables
     $pageBaseUrl = "/pub/user/" . $pubUserId;
     $pageTitle = sprintf("page %d of lists by %s", $gpage, $userDBRow["name"]);
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $metaDescription = SeoData::getHomeMetaDescription();
     include $template;
 }