コード例 #1
0
ファイル: Category.php プロジェクト: rjha/sc
 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;
 }
コード例 #2
0
ファイル: Lists.php プロジェクト: rjha/sc
 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;
 }
コード例 #3
0
ファイル: SelectBox.php プロジェクト: rjha/webgloo
 static function render($rows, $options)
 {
     $name = Util::getArrayKey($options, 'name');
     $default = Util::tryArrayKey($options, 'default');
     $showEmpty = Util::tryArrayKey($options, 'empty');
     if (!is_null($showEmpty) && $showEmpty) {
         array_unshift($rows, array('ui_code' => '', 'name' => '--'));
     }
     $buffer = '';
     $option = '<option value="{ui_code}" {flag}> {name}</option>';
     foreach ($rows as $row) {
         $flag = !is_null($default) && $row['ui_code'] == $default ? 'selected' : '';
         $str = str_replace(array("{ui_code}", "{name}", "{flag}"), array($row['ui_code'], $row['name'], $flag), $option);
         $buffer = $buffer . $str;
     }
     $buffer = '<select name="' . $name . '"> ' . $buffer . ' </select>';
     return $buffer;
 }
コード例 #4
0
ファイル: Location.php プロジェクト: 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;
 }
コード例 #5
0
ファイル: Group.php プロジェクト: 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;
 }
コード例 #6
0
ファイル: lists.php プロジェクト: rjha/sc
<?php

// user/popup/list.php
// normal HTML output
// session pending action not possible.
include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
use com\indigloo\Util;
use com\indigloo\Url;
use com\indigloo\sc\auth\Login;
use com\indigloo\sc\ui\Constants as UIConstants;
set_exception_handler('webgloo_ajax_exception_handler');
// list popup is called via javascript on pages
// so actual "form caller " is what is coming in as
// qUrl (original window.location.href) from javascript POST
// this is base64 encoded
$qUrl = Util::getArrayKey($_POST, "qUrl");
if (!Login::hasSession()) {
    $message = "You need to login!";
    echo $message;
    exit;
}
$loginId = Login::getLoginIdInSession();
$itemId = Util::getArrayKey($_POST, "itemId");
$listDao = new \com\indigloo\sc\dao\Lists();
$listRows = $listDao->getOnLoginId($loginId);
// Add default rows to top of lists
//
$html = \com\indigloo\sc\html\Lists::getSelectPopup($listRows, $itemId, $qUrl);
echo $html;
コード例 #7
0
ファイル: Post.php プロジェクト: 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;
 }
コード例 #8
0
ファイル: User.php プロジェクト: rjha/sc
 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;
 }
コード例 #9
0
ファイル: bookmark.php プロジェクト: rjha/sc
<?php

header('Content-type: application/json');
include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
use com\indigloo\Util;
use com\indigloo\sc\auth\Login;
set_exception_handler('webgloo_ajax_exception_handler');
$message = NULL;
//user login is required for bookmarking
if (!Login::hasSession()) {
    $message = array("code" => 401, "message" => "Authentication failure: You need to login!");
    $html = json_encode($message);
    echo $html;
    exit;
}
// params
//@todo - pass parameters w/o any processing to command.
$params = new \stdClass();
$login = Login::getLoginInSession();
$params->loginId = $login->id;
$params->name = $login->name;
$params->action = Util::tryArrayKey($_POST, "action");
$params->itemId = Util::getArrayKey($_POST, "itemId");
$command = new \com\indigloo\sc\command\Bookmark();
$response = $command->execute($params);
$html = json_encode($response);
echo $html;
コード例 #10
0
ファイル: tag.php プロジェクト: rjha/sc
use com\indigloo\sc\ui\Constants as UIConstants;
use com\indigloo\sc\util\Nest;
use com\indigloo\sc\Constants as AppConstants;
use com\indigloo\exception\DBException;
set_exception_handler("webgloo_ajax_exception_handler");
//Admin login is required
if (!Login::isAdmin()) {
    $message = array("code" => 401, "message" => "Authentication failure! Admin credentials missing.");
    $html = json_encode($message);
    echo $html;
    exit;
}
$postId = Util::getArrayKey($_POST, "postId");
// Action from UI is ADD | REMOVE
// see com\indigloo\sc\ui\Constants file
$action = Util::getArrayKey($_POST, "action");
$postDao = new \com\indigloo\sc\dao\Post();
$message = NULL;
try {
    switch ($action) {
        case UIConstants::FEATURE_POST:
            $postDao->feature($postId);
            $message = sprintf("success! item %s added to featured posts", $postId);
            break;
        case UIConstants::UNFEATURE_POST:
            $postDao->unfeature($postId);
            $message = sprintf("success! item %s removed from featured posts", $postId);
            break;
        default:
            trigger_error("Unknown UI action", E_USER_ERROR);
    }
コード例 #11
0
ファイル: select.php プロジェクト: rjha/sc
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\Constants;
use com\indigloo\ui\form\Message as FormMessage;
use com\indigloo\ui\form\Sticky;
use com\indigloo\sc\auth\Login;
$gSessionLogin = Login::getLoginInSession();
$loginId = $gSessionLogin->id;
$loginName = $gSessionLogin->name;
if (is_null($loginId)) {
    trigger_error("Error : NULL login_id on user dashboard", E_USER_ERROR);
}
$qparams = Url::getRequestQueryParams();
$itemId = Util::getArrayKey($qparams, "item_id");
$qUrl = base64_encode("/item/" . $itemId);
$fUrl = Url::current();
$listDao = new \com\indigloo\sc\dao\Lists();
$listRows = $listDao->getOnLoginId($loginId);
$listHtml = \com\indigloo\sc\html\Lists::getSelectPopup($listRows, $itemId, $qUrl);
//get widget html
$postDao = new \com\indigloo\sc\dao\Post();
$itemRow = $postDao->getOnItemId($itemId);
?>


<!DOCTYPE html>
<html>

    <head>
コード例 #12
0
ファイル: tag.php プロジェクト: rjha/sc
$userDao = new \com\indigloo\sc\dao\User();
$message = NULL;
try {
    switch ($action) {
        case UIConstants::BAN_USER:
            $loginId = Util::getArrayKey($_POST, "loginId");
            $userDao->ban($loginId);
            $message = sprintf("success! user %s has been banned!", $loginId);
            break;
        case UIConstants::TAINT_USER:
            $userId = Util::getArrayKey($_POST, "userId");
            $userDao->taint($userId);
            $message = sprintf("success! user %s has been tainted!", $userId);
            break;
        case UIConstants::UNBAN_USER:
            $loginId = Util::getArrayKey($_POST, "loginId");
            $userDao->unban($loginId);
            $message = sprintf("success! user %s has been restored!", $loginId);
            break;
        default:
            trigger_error("Unknown UI action", E_USER_ERROR);
    }
} catch (DBException $ex) {
    //duplicate entry?
    if ($ex->getCode() == AppConstants::DUPKEY_ERROR_CODE) {
        $html = array("code" => 500, "message" => "Duplicate error: member is already in set!");
        $html = json_encode($html);
        echo $html;
        exit;
    } else {
        throw $ex;
コード例 #13
0
ファイル: Site.php プロジェクト: rjha/sc
 function processFBUrl($url, $path)
 {
     if (empty($path)) {
         $path = "/";
     }
     $route = $this->fbRouter->getRoute($path);
     $page = array();
     if (!is_null($route)) {
         $action = $route['action'];
         $params = $route["params"];
         switch ($action) {
             case 'home':
                 $page["canonicalUrl"] = $url;
                 $page["hash"] = "FB1";
                 $page["url"] = $url;
                 $page["host"] = "www.facebook.com";
                 break;
             case 'page':
             case 'people':
                 $fbId = Util::getArrayKey($params, "id");
                 $page["hash"] = empty($fbId) ? NULL : "FB" . $fbId;
                 $page["canonicalUrl"] = $url;
                 $page["url"] = $url;
                 $page["host"] = "www.facebook.com";
                 break;
             case 'name':
                 $token = Util::getArrayKey($params, "token");
                 $page["canonicalUrl"] = $url;
                 $fbId = Graph::getIdOnName($token);
                 $page["hash"] = empty($fbId) ? NULL : "FB" . $fbId;
                 $page["url"] = $url;
                 $page["host"] = "www.facebook.com";
                 break;
             case 'media':
             case 'photo':
                 $qparams = Url::getQueryParams($url);
                 $set = $qparams["set"];
                 $fbId = FacebookUtil::getObjectIdInSet($set);
                 //get object URL
                 $page["canonicalUrl"] = Graph::getLinkOnId($fbId);
                 $page["hash"] = empty($fbId) ? NULL : "FB" . $fbId;
                 $page["url"] = $url;
                 $page["host"] = "www.facebook.com";
                 break;
             case 'profile':
                 $qparams = Url::getQueryParams($url);
                 $fbId = $qparams["id"];
                 //get object URL
                 $page["canonicalUrl"] = Graph::getLinkOnId($fbId);
                 $page["hash"] = "FB" . $fbId;
                 $page["url"] = $url;
                 $page["host"] = "www.facebook.com";
                 break;
             case 'script':
                 $message = sprintf("UNKNOWN_FB_SCRIPT :: [%s]", $url);
                 Logger::getInstance()->error($message);
                 break;
             default:
                 break;
         }
     } else {
         $message = sprintf("UNKNOWN_FB_URL :: [%s]", $url);
         Logger::getInstance()->error($message);
     }
     if (Config::getInstance()->is_debug()) {
         $message = sprintf("FACEBOOK_URL ::  [%s] ", $url);
         Logger::getInstance()->debug($message);
         Logger::getInstance()->debug("Dump of router ::");
         Logger::getInstance()->dump($route);
     }
     return $page;
 }