Ejemplo n.º 1
0
Archivo: Search.php Proyecto: 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;
 }
Ejemplo n.º 2
0
Archivo: Popular.php Proyecto: 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;
 }
Ejemplo n.º 3
0
Archivo: Random.php Proyecto: rjha/sc
 function process($params, $options)
 {
     $postDao = new \com\indigloo\sc\dao\Post();
     $total = $postDao->getTotalCount();
     $rows1 = $postDao->getRandom(25);
     $ids = array();
     for ($i = 1; $i <= 25; $i++) {
         $ids[] = mt_rand(1, $total - 1);
     }
     $rows2 = $postDao->getOnSearchIds($ids);
     $postDBRows = array_merge($rows1, $rows2);
     $pageHeader = '<a href="/surprise/me">Try again?</a>';
     $pageTitle = SeoData::getHomePageTitle();
     $metaDescription = SeoData::getHomeMetaDescription();
     $metaKeywords = SeoData::getHomeMetaKeywords();
     $file = APP_WEB_DIR . '/view/tiles.php';
     include $file;
 }
Ejemplo n.º 4
0
Archivo: Location.php Proyecto: 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;
 }
Ejemplo n.º 5
0
Archivo: Group.php Proyecto: 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;
 }
Ejemplo n.º 6
0
Archivo: posts.php Proyecto: rjha/sc
$scores = array();
$ids = array();
if (sizeof($members) >= 2) {
    for ($i = 1; $i < sizeof($members); $i++) {
        // odd ones are members
        // evens are scores
        if ($i % 2 != 0) {
            $itemId = $members[$i - 1];
            $postId = PseudoId::decode($itemId);
            array_push($ids, $postId);
            //score is next one
            $scores[$itemId] = isset($members[$i]) ? $members[$i] : 0;
        }
    }
}
$rows = $postDao->getOnSearchIds($ids);
$pageNo = $paginator->getPageNo();
$startId = ($pageNo - 1) * $pageSize;
$endId = $startId + $pageSize - 1;
$rowsHtml = "";
$gNumRecords = sizeof($rows);
foreach ($rows as $row) {
    $score = isset($scores[$row["pseudo_id"]]) ? $scores[$row["pseudo_id"]] : 0;
    $rowsHtml .= \com\indigloo\sc\html\Post::getAdminWidget($row, $score);
}
?>


<!DOCTYPE html>
<html>