function tryImageOnId($postId) { $row = mysql\Post::getOnId($postId); $json = $row["images_json"]; $images = json_decode($json); if (!empty($images) && sizeof($images) > 0) { $image = $images[0]; $imgv = \com\indigloo\sc\html\Post::convertImageJsonObj($image); return $imgv; } return NULL; }
<?php $startId = NULL; $endId = NULL; $gNumRecords = sizeof($postDBRows); $htmlItems = ""; if ($gNumRecords > 0) { $startId = $postDBRows[0]['id']; $endId = $postDBRows[$gNumRecords - 1]['id']; foreach ($postDBRows as $postDBRow) { $htmlItems .= \com\indigloo\sc\html\Post::getTile($postDBRow); } } else { $message = "No items found!"; $options = array("form" => "tile"); $htmlItems = \com\indigloo\sc\html\Site::getNoResult($message, $options); } ?> <!DOCTYPE html> <html> <head> <title> <?php echo $pageTitle; ?> </title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="keywords" content="<?php
<a class="help-popup" rel = "dashboard.list.create" href="#">create lists</a> / <a class="help-popup" rel = "dashboard.item.save" href="#">save items</a> </div> <div class="section1"> <?php echo \com\indigloo\sc\html\User::getCounters($counters); ?> <div class="clear"> </div> </div> <div class="section"> <strong>You may like</strong> <?php echo \com\indigloo\sc\html\Post::getImageGrid($postDBRows); ?> </div> </div> <!-- center --> <div class="span3"> <div class="adbox adbox-user"> <p class="comment-text"> Tell a friend about 3mik! </p> <a class="btn-adbox" href="<?php echo $linkInvitation;
echo \com\indigloo\sc\html\Post::getDetail($postView, $links); $likeHtml = \com\indigloo\sc\html\Post::getLikes($likeDBRows); $commentHtml = ''; echo \com\indigloo\sc\html\Post::getActivity($likeHtml, $commentHtml); ?> </div> </div> <div class="span3 wbg"> <?php echo \com\indigloo\sc\html\Post::getUserPanel($postView, $loginIdInSession); ?> <?php echo \com\indigloo\sc\html\Post::getGroups($postView); ?> </div> </div> </div> <!-- container --> <?php echo \com\indigloo\sc\util\Asset::version("/js/bundle.js"); ?> <script type="text/javascript"> $(document).ready(function(){
</div> <!-- page:header --> <div class="row"> <div class="span12"> <div id="tiles"> <?php $startId = NULL; $endId = NULL; $gNumRecords = sizeof($itemDBRows); if ($gNumRecords > 0) { $startId = $itemDBRows[0]["sort_id"]; $endId = $itemDBRows[$gNumRecords - 1]["sort_id"]; foreach ($itemDBRows as $itemDBRow) { $html = \com\indigloo\sc\html\Post::getListTile($itemDBRow); echo $html; } } else { $message = "No items in list "; echo \com\indigloo\sc\html\Site::getNoResult($message, $options); } ?> </div><!-- tiles --> <hr> </div> </div> <!-- row -->
$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> <head> <title> 3mik.com - post analytic </title> <?php include APP_WEB_DIR . '/inc/meta.inc'; ?> <?php echo \com\indigloo\sc\util\Asset::version("/css/bundle.css"); ?>
<div class="page-header"> <h2> Delete Post</h2> </div> <div class="alert"> <a class="close" data-dismiss="alert">×</a> <strong>Warning!</strong> There is no way to recover a deleted post. Please make sure that you really want to delete this post. </div> <?php FormMessage::render(); ?> <?php echo \com\indigloo\sc\html\Post::getWidget($postDBRow); ?> <div class="p10"> </div> <form id="web-form1" name="web-form1" action="/qa/form/delete.php" method="POST"> <div> <button class="btn btn-danger" type="submit" name="delete" value="Delete">Delete</button> <a href="<?php echo base64_decode($qUrl); ?> "><button class="btn" type="button">Cancel</a></button></a> </div> <input type="hidden" name="q" value="<?php echo $qUrl; ?> " /> <input type="hidden" name="post_id" value="<?php
<?php include 'sc-app.inc'; include APP_CLASS_LOADER; //pull one random image $postDao = new \com\indigloo\sc\dao\Post(); $rows = $postDao->getRandom(5); $tileHtml = ''; if (sizeof($rows) > 0) { $tileHtml = \com\indigloo\sc\html\Post::getTile($rows[0]); } ?> <!DOCTYPE html> <html> <head> <title> Thanks for visiting 3mik </title> <?php echo \com\indigloo\sc\util\Asset::version("/css/bundle.css"); ?> </head> <body> <?php include APP_WEB_DIR . '/inc/toolbar.inc'; ?> <div class="container mh800"> <div class="row">
<div class="row"> <div class="span8 offset1"> <div id="widgets"> <?php $startId = NULL; $endId = NULL; $gNumRecords = sizeof($itemDBRows); //@imp list can be created w/o items if ($gNumRecords > 0) { $startId = $itemDBRows[0]['sort_id']; $endId = $itemDBRows[$gNumRecords - 1]['sort_id']; foreach ($itemDBRows as $itemDBRow) { //output post widget html echo \com\indigloo\sc\html\Post::getListWidget($itemDBRow); } } else { $message = "No items in list!"; $options = array("hkey" => "dashboard.list.no-item"); echo \com\indigloo\sc\html\Site::getNoResult($message, $options); } ?> </div> <!-- widgets --> </div> <div class="span3"> <div class="section1"> <h4> <?php
static function deleteItems($loginId, $listId, $itemIds) { //input settype($loginId, "integer"); settype($listId, "integer"); if (empty($itemIds)) { return; } try { $dbh = PDOWrapper::getHandle(); // *** Tx start *** $dbh->beginTransaction(); // #1 : delete items $sqlt = " delete from sc_list_item where list_id = %d and item_id = %d "; foreach ($itemIds as $itemId) { settype($itemId, "integer"); $sql = sprintf($sqlt, $listId, $itemId); //fire SQL statement $dbh->exec($sql); } // #2: get items_json within this Tx $sql2 = " select post.id, post.images_json from sc_post post, sc_list_item li "; $sql2 .= " where li.item_id = post.id and li.list_id = %d limit 4 "; $sql2 = sprintf($sql2, $listId); $stmt2 = $dbh->prepare($sql2); $stmt2->execute(); $rows = $stmt2->fetchAll(); $stmt2->closeCursor(); $stmt2 = NULL; $bucket = array(); foreach ($rows as $row) { $itemId = $row["id"]; $json = $row["images_json"]; $images = json_decode($json); if (!empty($images) && sizeof($images) > 0) { $image = $images[0]; $imgv = \com\indigloo\sc\html\Post::convertImageJsonObj($image); $view = new \stdClass(); $view->id = $row["id"]; $view->thumbnail = $imgv["thumbnail"]; array_push($bucket, $view); } } $items_json = json_encode($bucket); if ($items_json === FALSE || $items_json == NULL) { $items_json = '[]'; $errorMsg = sprintf(" json encode error : list delete : id :: %d", $listId); Logger::getInstance()->error($errorMsg); } // #3 : update list.id.item_count and list.id.items_json $sql3 = " update sc_list set items_json = :items_json, "; $sql3 .= " item_count = (select count(id) from sc_list_item where list_id = :list_id)"; $sql3 .= " where id = :list_id "; $stmt3 = $dbh->prepare($sql3); $stmt3->bindParam(":list_id", $listId); $stmt3->bindParam(":items_json", $items_json); $stmt3->execute(); $stmt3 = NULL; // **** Tx end **** $dbh->commit(); $dbh = null; } catch (\PDOException $e) { $dbh->rollBack(); $dbh = null; throw new DBException($e->getMessage(), $e->getCode()); } catch (\Exception $ex) { $dbh->rollBack(); $dbh = null; throw new DBException($ex->getMessage(), $ex->getCode()); } }
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; }
echo \com\indigloo\sc\html\Post::getDetail($postView, $links, $siteDBRow); echo \com\indigloo\sc\html\Post::getToolbar($loginIdInSession, $postDBRow['login_id'], $itemId); //inject activity tile $activityDao = new \com\indigloo\sc\dao\Activity(); $feedDataObj = $activityDao->getPostFeeds($itemId, 10); $htmlObj = new \com\indigloo\sc\html\Activity(); $feedHtml = $htmlObj->getPostTile($feedDataObj); echo \com\indigloo\sc\html\Post::getActivity($feedHtml); echo \com\indigloo\sc\html\Comment::getFeedHtml($commentDBRows); include APP_WEB_DIR . '/qa/inc/comment.inc'; ?> <h3> explore 3mik </h3> <div id="tiles"> <?php foreach ($xrows as $xrow) { echo \com\indigloo\sc\html\Post::getSmallTile($xrow); } ?> </div> <!-- tiles --> </div> <div class="span3"> </div> </div>
</div> </div> <!-- page:header --> <?php FormMessage::render(); ?> <div class="row"> <div class="span9 offset1"> <div id="page-message" class="hide-me"> </div> <p class="muted"> To save this item, select a list below. You can also create a new list. </p> <?php echo \com\indigloo\sc\html\Post::getWidget($itemRow); ?> <div id="list-popup"> <?php echo $listHtml; ?> </div> </div> </div> </div> <!-- container --> <?php
<?php use com\indigloo\sc\html\User as UserHtml; use com\indigloo\sc\html\Post as PostHtml; use com\indigloo\sc\html\SocialGraph as GraphHtml; use com\indigloo\sc\html\Lists as ListHtml; $headerHtml = UserHtml::getPubHeader($userDBRow); $content = PostHtml::getImageGrid($postDBRows); $count = $ucounters["post_count"]; $options = array("title" => "Items", "tab" => "items", "max" => 8, "size" => $gNumDBRows["items"]); $itemsHtml = UserHtml::getPubWrapper($pageBaseUrl, $count, $content, $options); $content = PostHtml::getImageGrid($likeDBRows); $count = $ucounters["like_count"]; $options = array("title" => "Likes", "tab" => "likes", "max" => 8, "size" => $gNumDBRows["likes"]); $likesHtml = UserHtml::getPubWrapper($pageBaseUrl, $count, $content, $options); $content = GraphHtml::getTable($loginId, $followers, 1, $followerUIOptions); $count = $ucounters["follower_count"]; $options = array("title" => "Followers", "tab" => "followers", "max" => 5, "size" => $gNumDBRows["followers"]); $followersHtml = UserHtml::getPubWrapper($pageBaseUrl, $count, $content, $options); $content = GraphHtml::getTable($loginId, $followings, 2, $followingUIOptions); $count = $ucounters["following_count"]; $options = array("title" => "Followings", "tab" => "followings", "max" => 5, "size" => $gNumDBRows["followings"]); $followingsHtml = UserHtml::getPubWrapper($pageBaseUrl, $count, $content, $options); $htmlActivityObj = new \com\indigloo\sc\html\Activity(); $activityHtml = $htmlActivityObj->getHtml($feedDataObj); //reset content $content = ""; foreach ($listDBRows as $listDBRow) { $content .= ListHtml::getPubWidget($listDBRow); } $count = $ucounters["list_count"];