示例#1
0
文件: Comment.php 项目: rjha/sc
 static function getWidget($row, $options = NULL)
 {
     $html = NULL;
     $view = new \stdClass();
     $template = '/fragments/comment/text.tmpl';
     if (is_null($options)) {
         $options = ~UIConstants::COMMENT_ALL;
     }
     $view->id = $row['id'];
     $view->title = $row['title'];
     $view->postId = $row['post_id'];
     $view->itemId = PseudoId::encode($view->postId);
     $view->comment = $row['description'];
     $view->createdOn = AppUtil::convertDBTime($row['created_on']);
     $view->showUser = false;
     if ($options & UIConstants::COMMENT_USER) {
         $view->loginId = $row['login_id'];
         $view->pubUserId = PseudoId::encode($view->loginId);
         $view->userName = $row['user_name'];
         $view->showUser = true;
     }
     $encodedId = PseudoId::encode($view->id);
     $params = array('id' => $encodedId, 'q' => base64_encode(Url::current()));
     $view->editUrl = Url::createUrl('/qa/comment/edit.php', $params);
     $view->deleteUrl = Url::createUrl('/qa/comment/delete.php', $params);
     $html = Template::render($template, $view);
     return $html;
 }
示例#2
0
文件: Login.php 项目: rjha/sc
 static function get($row)
 {
     $html = NULL;
     $view = new \stdClass();
     $template = '/fragments/ui/login/view.tmpl';
     $view->name = $row['name'];
     $view->provider = $row['provider'];
     $view->createdOn = AppUtil::convertDBTime($row['created_on']);
     $html = Template::render($template, $view);
     return $html;
 }
示例#3
0
文件: Lists.php 项目: rjha/sc
 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;
 }
示例#4
0
文件: Post.php 项目: rjha/sc
 static function createPostView($row, $voptions = NULL)
 {
     $voptions = empty($voptions) ? array() : $voptions;
     //default options
     $options = array();
     $options["abbreviate"] = false;
     $options["image"] = true;
     $options["group"] = false;
     //override defaults
     foreach ($voptions as $key => $value) {
         $options[$key] = $value;
     }
     $imagesJson = $row["images_json"];
     $images = json_decode($imagesJson);
     $view = new \stdClass();
     $view->hasImage = false;
     $view->images = NULL;
     $view->hasGroups = false;
     $view->groups = array();
     $view->id = $row['id'];
     $view->itemId = PseudoId::encode($view->id);
     // 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
     // clean up bad utf-8 data for display
     $view->title = Util::filterBadUtf8($row['title']);
     $view->title = Util::abbreviate($view->title, 70);
     $view->description = Util::filterBadUtf8($row['description']);
     if ($options["abbreviate"]) {
         $view->description = Util::abbreviate($view->description, 160);
     }
     $view->userName = $row['user_name'];
     $view->createdOn = AppUtil::convertDBTime($row['created_on']);
     $view->pubUserId = PseudoId::encode($row['login_id']);
     $view->loginId = $row['login_id'];
     $view->userPageURI = "/pub/user/" . $view->pubUserId;
     //process post image.
     if (!empty($images) && sizeof($images) > 0 && $options["image"]) {
         /* process image #1 */
         $view->hasImage = true;
         $image = $images[0];
         $imgv = self::convertImageJsonObj($image);
         $view->thumbnail = $imgv["thumbnail"];
         $view->height = $imgv["height"];
         $view->width = $imgv["width"];
         $view->srcImage = $imgv["source"];
         /* assign all images */
         $view->images = $images;
     }
     //process groups
     if ($options["group"] === true) {
         $group_slug = $row['group_slug'];
         $groups = array();
         if (!is_null($group_slug) && strlen($group_slug) > 0) {
             $slugs = explode(Constants::SPACE, $group_slug);
             $display = NULL;
             foreach ($slugs as $slug) {
                 if (empty($slug)) {
                     continue;
                 }
                 //@imp @todo @hack
                 // dirty hack - for single quotes in group name - for old data
                 // anything indexed as flury's - should be converted to flury
                 // now we ignore the single quote in group name so we should be fine
                 $slug = str_replace("'s", "", $slug);
                 $display = StringUtil::convertKeyToName($slug);
                 $groups[] = array("slug" => $slug, "display" => $display);
             }
         }
         if (sizeof($groups) > 0) {
             $view->hasGroups = true;
             $view->groups = $groups;
         }
     }
     return $view;
 }
示例#5
0
文件: add-item-link.php 项目: rjha/sc
if (isset($_POST['save']) && $_POST['save'] == 'Save') {
    $gWeb = \com\indigloo\core\Web::getInstance();
    $fvalues = array();
    $fUrl = \com\indigloo\Url::tryFormUrl("fUrl");
    try {
        $fhandler = new Form\Handler("edit-form", $_POST);
        $fhandler->addRule("link", "item URL", array('required' => 1));
        $fhandler->addRule("list_id", "list id", array('required' => 1));
        $fvalues = $fhandler->getValues();
        $link = $fvalues["link"];
        if ($fhandler->hasErrors()) {
            throw new UIException($fhandler->getErrors());
        }
        $loginId = Login::getLoginIdInSession();
        $listDao = new \com\indigloo\sc\dao\Lists();
        $itemId = AppUtil::getItemIdInUrl($link);
        if (is_null($itemId)) {
            $message = "invalid item URL : please add a valid item URL ";
            throw new UIException(array($message));
        }
        $postDao = new \com\indigloo\sc\dao\Post();
        if (!$postDao->exists($itemId)) {
            $message = sprintf("item {%s} does not exists", $itemId);
            throw new UIException(array($message));
        }
        $listDao->addItem($loginId, $fvalues["list_id"], $itemId);
        $message = sprintf("success! item added to list ");
        $gWeb->store(Constants::FORM_MESSAGES, array($message));
        header("Location: " . $fUrl);
    } catch (UIException $ex) {
        $gWeb->store(Constants::STICKY_MAP, $fvalues);
示例#6
0
文件: User.php 项目: rjha/sc
 static function getAdminWidget($row, $score = 0)
 {
     $view = new \stdClass();
     //db fields
     $view->id = $row["id"];
     $view->loginId = $row["login_id"];
     $view->provider = $row["provider"];
     $view->email = $row["email"];
     $view->website = $row["website"];
     $view->name = $row["name"];
     $view->location = $row["location"];
     //display fields
     $view->pubId = PseudoId::encode($row["login_id"]);
     $view->createdOn = AppUtil::convertDBTime($row["created_on"]);
     $ts = Util::secondsInDBTimeFromNow($row["created_on"]);
     $span = 24 * 3600;
     $view->last24hr = $ts < $span ? true : false;
     $view->ban = $row["bu_bit"] == 0 ? true : false;
     $view->unban = $row["bu_bit"] == 1 ? true : false;
     $view->taint = $row["tu_bit"] == 0 ? true : false;
     $view->score = $score > 0 ? $score : "";
     $html = NULL;
     $template = "/fragments/user/admin/widget.tmpl";
     $html = Template::render($template, $view);
     return $html;
 }