function process($feedObj, $templates = array()) { $html = ''; $keys = array("subject", "subjectId", "object", "objectId"); $flag = $this->checkKeys($feedObj, $keys); $view = array(); if (empty($templates)) { $templates = array(AppConstants::FOLLOW_VERB => "/fragments/feed/vanilla.tmpl"); } if ($flag) { $view['subject'] = $feedObj->subject; $view['object'] = $feedObj->object; $pubId = PseudoId::encode($feedObj->subjectId); $view['subjectUrl'] = sprintf("%s/pub/user/%s", Url::base(), $pubId); $pubId = PseudoId::encode($feedObj->objectId); $view['objectUrl'] = sprintf("%s/pub/user/%s", Url::base(), $pubId); $view['verb'] = $this->getVerb($feedObj->verb); if (isset($templates[$feedObj->verb])) { $template = $templates[$feedObj->verb]; } else { trigger_error("invalid feed template", E_USER_ERROR); } $html = Template::render($template, $view); } return $html; }
function process($feedObj, $templates = array()) { $html = ''; $keys = array("subject", "subjectId", "title", "objectId"); $flag = $this->checkKeys($feedObj, $keys); $view = array(); if (empty($templates)) { $templates = array(AppConstants::LIKE_VERB => "/fragments/feed/image/post.tmpl", AppConstants::COMMENT_VERB => "/fragments/feed/image/comment.tmpl", AppConstants::POST_VERB => "/fragments/feed/image/post.tmpl", AppConstants::FOLLOW_VERB => NULL); } if ($flag) { // extra processing for comments // @imp: activity row for comment stores // post_id as object_id and not item_id if (strcmp($feedObj->verb, AppConstants::COMMENT_VERB) == 0) { if (property_exists($feedObj, 'content')) { $view['content'] = $feedObj->content; } $feedObj->objectId = PseudoId::encode($feedObj->objectId); } $view['subject'] = $feedObj->subject; $view['object'] = $feedObj->title; $pubId = PseudoId::encode($feedObj->subjectId); $view['subjectUrl'] = sprintf("%s/pub/user/%s", Url::base(), $pubId); $view['objectUrl'] = sprintf("%s/item/%s", Url::base(), $feedObj->objectId); $view['hasImage'] = false; //image for feed if (property_exists($feedObj, 'srcImage')) { if (!empty($feedObj->srcImage)) { $srcImage = $feedObj->srcImage; $m_bucket = \parse_url($srcImage, \PHP_URL_HOST); // aws s3 bucket mapping for cloud front // host is a CNAME mapped to amazon s3 bucket // format is store.bucket.mapto=<mapped-bucket> $mapKey = sprintf("s3.%s.mapto", $m_bucket); $bucket = Config::getInstance()->get_value($mapKey, $m_bucket); $view['srcImage'] = str_replace($m_bucket, $bucket, $srcImage); $view['nameImage'] = $feedObj->nameImage; $view['hasImage'] = true; } } $view['verb'] = $this->getVerb($feedObj->verb); if (isset($templates[$feedObj->verb])) { $template = $templates[$feedObj->verb]; } else { trigger_error("invalid feed template", E_USER_ERROR); } $html = Template::render($template, $view); } return $html; }
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($feedObj) { $html = ''; $keys = array("subject", "subjectId", "object", "objectId"); $flag = $this->checkKeys($feedObj, $keys); $view = array(); if ($flag) { $view['subject'] = $feedObj->subject; $view['object'] = "this item"; $pubId = PseudoId::encode($feedObj->subjectId); $view['subjectUrl'] = sprintf("%s/pub/user/%s", Url::base(), $pubId); $view['objectUrl'] = sprintf("%s/item/%s", Url::base(), $feedObj->objectId); $view['verb'] = $this->getVerb($feedObj->verb); $template = '/fragments/feed/vanilla.tmpl'; $html = Template::render($template, $view); } return $html; }
static function createView($loginId, $row) { $view = new \stdClass(); $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"]; // This is for follow action on my follower's page. // for follow action :- I will start following // so followerId - is me // for unfollow action :- I was following the user // so again, followerId is - me $view->followingId = $userId; $view->followerId = $loginId; return $view; }
static function getPubHeader($listDBRow, $userDBRow) { $view = self::createListView($listDBRow); $view->userName = $userDBRow["name"]; $view->photoUrl = $userDBRow["photo_url"]; if (empty($view->photoUrl)) { // @hardcoded $view->photoUrl = UIConstants::PH2_PIC; } $encodedId = PseudoId::encode($listDBRow["login_id"]); $view->userPubUrl = Url::base() . "/pub/user/" . $encodedId; $view->createdOn = AppUtil::convertDBTime($listDBRow['created_on']); $view->description = $listDBRow["description"]; $view->count = $listDBRow["item_count"]; $template = NULL; $template = "/fragments/lists/pub/header.tmpl"; $html = Template::render($template, $view); return $html; }
//sc/user/dashboard/posts.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; include APP_WEB_DIR . '/inc/role/user.inc'; use com\indigloo\Util; use com\indigloo\Url; use com\indigloo\Configuration as Config; use com\indigloo\sc\auth\Login; use com\indigloo\Constants; use com\indigloo\ui\Filter; use com\indigloo\sc\util\PseudoId; use com\indigloo\ui\form\Message as FormMessage; $gSessionLogin = Login::getLoginInSession(); $loginId = $gSessionLogin->id; $pubId = PseudoId::encode($loginId); $homeUrl = Url::base(); $pubUrl = $homeUrl . "/pub/user/" . $pubId; //data:1:user $userDao = new \com\indigloo\sc\dao\User(); $userDBRow = $userDao->getOnLoginId($loginId); $loginName = $gSessionLogin->name; if (is_null($loginId)) { trigger_error("Error : NULL login_id on user dashboard", E_USER_ERROR); } $analyticDao = new \com\indigloo\sc\dao\Analytic(); $counters = $analyticDao->getUserCounters($loginId); $activityDao = new \com\indigloo\sc\dao\Activity(); $feedDataObj = $activityDao->getUserFeeds($loginId, 20); //suggestions are editor picks right now $postDao = new \com\indigloo\sc\dao\Post(); //post featured filter
static function convertImageJsonObj($jsonObj) { $view = array(); if (strcmp($jsonObj->store, "s3") == 0 || strcmp($jsonObj->store, "local") == 0) { $view["name"] = $jsonObj->originalName; $prefix = $jsonObj->store == 's3' ? 'http://' : Url::base() . '/'; $fileName = NULL; //@imp: if thumbnail is not available then fallback on original image if (property_exists($jsonObj, "thumbnailName")) { $view["tname"] = $jsonObj->thumbnailName; $fileName = $jsonObj->thumbnail; } else { $view["tname"] = $jsonObj->originalName; $fileName = $jsonObj->storeName; } // aws s3 bucket mapping for cloud front $m_bucket = $jsonObj->bucket; // format is store.bucket.mapto=<mapped-bucket> $mapKey = sprintf("%s.%s.mapto", $jsonObj->store, $m_bucket); $bucket = Config::getInstance()->get_value($mapKey, $m_bucket); $view["source"] = $prefix . $bucket . '/' . $jsonObj->storeName; $view["thumbnail"] = $prefix . $bucket . '/' . $fileName; $view["width"] = $jsonObj->width; $view["height"] = $jsonObj->height; //@todo add thumbnail width and height to image json data } else { $view["name"] = "placeholder"; $view["tname"] = "placeholder"; $view["source"] = UIConstants::PH1_PIC; $view["thumbnail"] = UIConstants::PH1_PIC; $view["width"] = 48; $view["height"] = 48; $view["twidth"] = 40; $view["theight"] = 40; } return $view; }
header("Location: / "); } $qUrl = Url::tryBase64QueryParam("q", "/user/dashboard/index.php"); $fUrl = Url::current(); // should login do some action? $gSessionAction = Url::tryQueryParam("g_session_action"); if (!empty($gSessionAction)) { $gWeb->store("global.session.action", $gSessionAction); } $fUrl = Url::current(); $sticky = new Sticky($gWeb->find(Constants::STICKY_MAP, true)); $stoken = Util::getMD5GUID(); $gWeb->store("mik_state_token", $stoken); //Facebook OAuth2 $fbAppId = Config::getInstance()->get_value("facebook.app.id"); $host = Url::base(); $fbCallback = $host . "/callback/fb2.php"; $fbDialogUrl = "https://www.facebook.com/dialog/oauth?client_id=" . $fbAppId; $fbDialogUrl .= "&redirect_uri=" . urlencode($fbCallback) . "&scope=email&state=" . $stoken; //Google OAuth2 $googleClientId = Config::getInstance()->get_value("google.client.id"); $googleCallback = $host . "/callback/google2.php"; $googleAuthUrl = "https://accounts.google.com/o/oauth2/auth?scope="; //space delimited scope $googleScope = "https://www.googleapis.com/auth/userinfo.email"; $googleScope = $googleScope . Constants::SPACE . "https://www.googleapis.com/auth/userinfo.profile"; $googleAuthUrl .= urlencode($googleScope); $googleAuthUrl .= "&client_id=" . $googleClientId; $googleAuthUrl .= "&state=" . $stoken; $googleAuthUrl .= "&response_type=code"; $googleAuthUrl .= "&redirect_uri=" . urlencode($googleCallback);
$loginName = $gSessionLogin->name; if (is_null($loginId)) { trigger_error("Error : NULL or invalid login_id", E_USER_ERROR); } $plistId = Url::getQueryParam("list_id"); $listId = PseudoId::decode($plistId); settype($listId, "int"); $listDao = new \com\indigloo\sc\dao\Lists(); $listDBRow = $listDao->getOnId($listId); $listName = $listDBRow["name"]; //list owner check if (!Login::isOwner($listDBRow["login_id"])) { header("Location: /site/error/403.html"); exit; } $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); $baseURI = "/user/dashboard/list/detail.php"; $fUrl = Url::current(); ?> <!DOCTYPE html> <html>
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; }