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; }
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; }
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; }
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; }
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; }
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; }
function process($params, $options) { $postDao = new \com\indigloo\sc\dao\Post(); //post featured filter $filters = array(); $model = new \com\indigloo\sc\model\Post(); $filter = new Filter($model); $filter->add($model::FEATURED, Filter::EQ, TRUE); array_push($filters, $filter); $limit = Config::getInstance()->get_value("search.page.items"); // fetch top N rows from sc_post that match our filter // this relies on the default sorting in mysql#Posts::getPosts() method $postDBRows = $postDao->getPosts($limit, $filters); $pageHeader = 'Editor\'s Pick'; $pageTitle = "items on 3mik selected by our editors "; $metaDescription = SeoData::getHomeMetaDescription(); $metaKeywords = SeoData::getHomeMetaKeywords(); $view = APP_WEB_DIR . '/view/tiles.php'; include $view; }
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; }
function process($params, $options) { if (is_null($params) || empty($params)) { $controller = new \com\indigloo\sc\controller\Http400(); $controller->process(); exit; } $siteId = Util::tryArrayKey($params, "site_id"); $cname = Url::tryQueryParam("cname"); if (empty($siteId) || empty($cname)) { $controller = new \com\indigloo\sc\controller\Http400(); $controller->process(); exit; } $siteDao = new \com\indigloo\sc\dao\Site(); $postDBRows = $siteDao->getPostsOnId($siteId, 50); $pageHeader = $cname; $pageTitle = SeoData::getHomePageTitle(); $metaDescription = SeoData::getHomeMetaDescription(); $metaKeywords = SeoData::getHomeMetaKeywords(); $file = APP_WEB_DIR . '/view/tiles.php'; include $file; }
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; }
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; }
function process($params, $options) { if (is_null($params) || empty($params)) { $controller = new \com\indigloo\sc\controller\Http400(); $controller->process(); exit; } $itemId = Util::getArrayKey($params, "item_id"); if ($itemId < 1200) { //@todo remove permanent redirect $redirectUrl = "/item/" . PseudoId::encode($itemId); header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $redirectUrl); exit; } $postDao = new \com\indigloo\sc\dao\Post(); $postId = PseudoId::decode($itemId); $postDBRow = $postDao->getOnId($postId); if (empty($postDBRow)) { //not found $controller = new \com\indigloo\sc\controller\Http404(); $controller->process(); exit; } $options = array(); $options["group"] = true; $postView = \com\indigloo\sc\html\Post::createPostView($postDBRow, $options); // links is separate from postView for historical reasons $linksJson = $postDBRow['links_json']; $dblinks = json_decode($linksJson); $links = array(); foreach ($dblinks as $link) { $link = Url::addHttp($link); array_push($links, $link); } /* data for facebook/google+ dialogs */ $itemObj = new \stdClass(); $itemObj->appId = Config::getInstance()->get_value("facebook.app.id"); $itemObj->host = Url::base(); /* google+ cannot redirect to local box */ $itemObj->netHost = "http://www.3mik.com"; $itemObj->callback = $itemObj->host . "/callback/fb-share.php"; if ($postView->hasImage) { /* use original image for og snippets, smaller images may be ignored */ /* facebook and google+ dialogs need absolute URL */ $itemObj->picture = $postView->srcImage; } else { $itemObj->picture = $itemObj->host . "/css/asset/sc/logo.png"; } //do not urlencode - as we use this value as canonical url $itemObj->link = $itemObj->host . "/item/" . $itemId; $itemObj->netLink = $itemObj->netHost . "/item/" . $itemId; // title in DB is 128 chars long. // here on page we want to use a 70 char title. // also used in item images alt text // item description should be 160 chars. $itemObj->title = Util::abbreviate($postView->title, 70); $itemObj->title = sprintf("item %s - %s", $itemId, $itemObj->title); $itemObj->description = Util::abbreviate($postView->description, 160); $itemObj->description = sprintf("item %s - %s by user %s", $itemId, $itemObj->description, $postView->userName); $strItemObj = json_encode($itemObj); //make the item json string form safe $strItemObj = Util::formSafeJson($strItemObj); /* likes data */ $bookmarkDao = new \com\indigloo\sc\dao\Bookmark(); $likeDBRows = $bookmarkDao->getLikeOnItemId($itemId); $gWeb = \com\indigloo\core\Web::getInstance(); /* sticky is used by comment form */ $sticky = new Sticky($gWeb->find(Constants::STICKY_MAP, true)); $gRegistrationPopup = false; $loginIdInSession = \com\indigloo\sc\auth\Login::tryLoginIdInSession(); //show registration popup if (is_null($loginIdInSession)) { $register_popup = $gWeb->find("sc:browser:registration:popup"); $register_popup = is_null($register_popup) ? false : $register_popup; if (!$register_popup) { $gRegistrationPopup = true; $gWeb->store("sc:browser:registration:popup", true); } } $group_slug = $postDBRow["group_slug"]; $groupDao = new \com\indigloo\sc\dao\Group(); $group_names = $groupDao->tokenizeSlug($group_slug, ",", true); $pageTitle = $itemObj->title; $metaKeywords = SeoData::getMetaKeywords($group_names); $pageUrl = Url::base() . Url::current(); $file = APP_WEB_DIR . '/view/item.php'; include $file; }
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; }