Beispiel #1
0
Datei: Home.php Projekt: rjha/sc
 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;
 }
Beispiel #2
0
 static function getPubWidget($row)
 {
     $view = new \stdClass();
     $template = NULL;
     $userId = $row["login_id"];
     $pubUserId = PseudoId::encode($userId);
     $pubUserUrl = Url::base() . "/pub/user/" . $pubUserId;
     $view->pubUserUrl = $pubUserUrl;
     $view->name = $row["name"];
     $view->srcImage = $row["photo_url"];
     $view->hasImage = !Util::tryEmpty($view->srcImage);
     // whoever is browsing this widget will become the follower
     // and follow the user of this widget
     $loginIdInSession = Login::tryLoginIdInSession();
     $view->followerId = empty($loginIdInSession) ? "{loginId}" : $loginIdInSession;
     $view->followingId = $userId;
     //template depends on image availabality
     $template = $view->hasImage ? "/fragments/graph/pub/widget/image.tmpl" : "/fragments/graph/pub/widget/noimage.tmpl";
     $html = Template::render($template, $view);
     return $html;
 }
Beispiel #3
0
Datei: Post.php Projekt: rjha/sc
 static function getTile($postDBRow)
 {
     $html = NULL;
     $template = NULL;
     $voptions = array("abbreviate" => true, "group" => true);
     $view = self::createPostView($postDBRow, $voptions);
     if ($view->hasImage) {
         $template = '/fragments/tile/image.tmpl';
         //Add thumbnail width and height
         $td = Util::foldX($view->width, $view->height, 190);
         $view->twidth = $td["width"];
         $view->theight = $td["height"];
     } else {
         $template = '/fragments/tile/text.tmpl';
     }
     $loginIdInSession = \com\indigloo\sc\auth\Login::tryLoginIdInSession();
     $view->hasLoginInSession = is_null($loginIdInSession) ? false : true;
     if (!$view->hasLoginInSession) {
         $params = array("item_id" => $view->itemId);
         $listUrl = "/user/dashboard/list/select.php";
         $listUrl = Url::createUrl($listUrl, $params);
         $view->saveUrl = "/user/login.php?q=" . base64_encode($listUrl);
     }
     $html = Template::render($template, $view);
     return $html;
 }
Beispiel #4
0
Datei: User.php Projekt: rjha/sc
 static function getPubHeader($userDBRow)
 {
     $html = NULL;
     $view = new \stdClass();
     $template = '/fragments/user/pub/header.tmpl';
     $view = self::createUserView($userDBRow);
     $view->followingId = $userDBRow["login_id"];
     //userId in session is follower
     $loginId = Login::tryLoginIdInSession();
     $view->followerId = empty($loginId) ? "{loginId}" : $loginId;
     $html = Template::render($template, $view);
     return $html;
 }
Beispiel #5
0
 function delete($commentId)
 {
     $loginId = \com\indigloo\sc\auth\Login::tryLoginIdInSession();
     mysql\Comment::delete($commentId, $loginId);
 }
Beispiel #6
0
<?php

//sc/user/invite.php
include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
use com\indigloo\Util;
use com\indigloo\Url;
use com\indigloo\ui\form\Sticky;
use com\indigloo\Constants;
use com\indigloo\ui\form\Message as FormMessage;
use com\indigloo\sc\auth\Login;
$gWeb = \com\indigloo\core\Web::getInstance();
$sticky = new Sticky($gWeb->find(Constants::STICKY_MAP, true));
$qUrl = Url::tryBase64QueryParam("q", "/");
$fUrl = Url::current();
$loginId = Login::tryLoginIdInSession();
//add security token to form
$formToken = Util::getBase36GUID();
$gWeb->store("form.token", $formToken);
$defaultMessage = \com\indigloo\sc\html\Site::getInvitationMessage();
?>

<!DOCTYPE html>
<html>

    <head>
        <title> 3mik.com - invite your friends</title>
        <?php 
include APP_WEB_DIR . '/inc/meta.inc';
?>
        <?php 
Beispiel #7
0
Datei: Post.php Projekt: rjha/sc
 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;
 }