コード例 #1
0
ファイル: Links.php プロジェクト: rjha/sc
 static function getHtml($map, $template, $classMap)
 {
     $currentUrl = Url::current();
     $pos = strpos($currentUrl, '?');
     //remove the part after ? from Url
     if ($pos !== false) {
         $currentUrl = substr($currentUrl, 0, $pos);
     }
     $bucket = array();
     $activeName = NULL;
     foreach ($map as $url => $name) {
         //links to store
         if (!array_key_exists($name, $bucket)) {
             $record = array();
             $record["name"] = $name;
             $record["url"] = $url;
             $record["class"] = $classMap["normal"];
             $bucket[$name] = $record;
         }
         if (strcmp($url, $currentUrl) == 0) {
             //name to highlight
             $activeName = $name;
         }
     }
     if (!is_null($activeName)) {
         $bucket[$activeName]["class"] = $classMap["active"];
     }
     $view = new \stdClass();
     $view->records = array_values($bucket);
     $html = Template::render($template, $view);
     return $html;
 }
コード例 #2
0
ファイル: GraphProcessor.php プロジェクト: rjha/sc
 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;
 }
コード例 #3
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;
 }
コード例 #4
0
ファイル: Login.php プロジェクト: rjha/sc
 static function getList($rows)
 {
     $html = NULL;
     $template = '/fragments/ui/login/list.tmpl';
     $html = Template::render($template, $rows);
     return $html;
 }
コード例 #5
0
ファイル: Group.php プロジェクト: rjha/sc
 static function getTile($groups)
 {
     $html = NULL;
     $view = new \stdClass();
     $view->groups = $groups;
     $template = '/fragments/group/tile.tmpl';
     $html = Template::render($template, $view);
     return $html;
 }
コード例 #6
0
ファイル: Activity.php プロジェクト: rjha/sc
 static function getAdminWidget($index, $content)
 {
     $html = NULL;
     $view = new \stdClass();
     $view->index = $index;
     $view->content = $content;
     $template = '/fragments/feed/admin/widget.tmpl';
     $html = Template::render($template, $view);
     return $html;
 }
コード例 #7
0
ファイル: PostProcessor.php プロジェクト: rjha/sc
 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;
 }
コード例 #8
0
ファイル: Feedback.php プロジェクト: rjha/sc
 static function get($row)
 {
     $html = NULL;
     $view = new \stdClass();
     $template = '/fragments/monitor/feedback.tmpl';
     $view->id = $row['id'];
     $params = array("id" => $row['id'], "q" => base64_encode(Url::current()));
     $view->deleteUrl = Url::createUrl("/monitor/feedback/delete.php", $params);
     $view->description = $row['feedback'];
     $view->name = $row['name'];
     $view->phone = $row['phone'];
     $view->email = $row['email'];
     $html = Template::render($template, $view);
     return $html;
 }
コード例 #9
0
ファイル: Mail.php プロジェクト: rjha/sc
 static function getSearchTokens($tokens)
 {
     $view = new \stdClass();
     $content = '';
     foreach ($tokens as $token) {
         $content .= sprintf(" %s ", $token);
     }
     $view->content = $content;
     $template = '/fragments/mail/text/search-tokens.tmpl';
     $text = Template::render($template, $view);
     $template = '/fragments/mail/html/search-tokens.tmpl';
     $html = Template::render($template, $view);
     $data = array('text' => $text, 'html' => $html);
     return $data;
 }
コード例 #10
0
ファイル: TextProcessor.php プロジェクト: rjha/sc
 function process($feedObj)
 {
     $text = '';
     $keys = array("subject", "object");
     $flag = $this->checkKeys($feedObj, $keys);
     $view = array();
     if ($flag) {
         $view['subject'] = $feedObj->subject;
         $title = $feedObj->verb == AppConstants::FOLLOW_VERB ? $feedObj->object : $feedObj->title;
         $view['object'] = $title;
         $view['verb'] = $this->getVerb($feedObj->verb);
         $template = '/fragments/feed/text/vanilla.tmpl';
         $text = Template::render($template, $view);
     }
     return $text;
 }
コード例 #11
0
ファイル: ItemProcessor.php プロジェクト: rjha/sc
 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;
 }
コード例 #12
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;
 }
コード例 #13
0
ファイル: Post.php プロジェクト: rjha/sc
 static function getListTile($postDBRow)
 {
     $html = NULL;
     // case when list_item.item_id is not null but post.id is NULL
     if (empty($postDBRow["id"]) && !empty($postDBRow["item_id"])) {
         $template = '/fragments/tile/lists/deleted-item.tmpl';
         $view = new \stdClass();
         $view->id = $postDBRow["item_id"];
         $view->itemId = PseudoId::encode($postDBRow["item_id"]);
         $html = Template::render($template, $view);
         return $html;
     }
     $html = self::getTile($postDBRow);
     return $html;
 }
コード例 #14
0
ファイル: User.php プロジェクト: rjha/sc
 static function getCounters($data)
 {
     $view = new \stdClass();
     $zero = '-:-';
     $view->posts = $data["post_count"];
     $view->comments = $data["comment_count"];
     $view->lists = $data["list_count"];
     $view->likes = $data["like_count"];
     $view->followers = $data["follower_count"];
     $view->following = $data["following_count"];
     $variables = get_object_vars($view);
     foreach ($variables as $prop => $value) {
         if (intval($view->{$prop}) == 0) {
             $view->{$prop} = $zero;
         }
     }
     $html = NULL;
     $template = '/fragments/user/counter/private.tmpl';
     $html = Template::render($template, $view);
     return $html;
 }
コード例 #15
0
ファイル: Site.php プロジェクト: rjha/sc
 static function getInvitationMessage()
 {
     $html = NULL;
     $view = new \stdClass();
     $template = '/fragments/site/invitation.tmpl';
     $html = Template::render($template, $view);
     return $html;
 }
コード例 #16
0
ファイル: SocialGraph.php プロジェクト: rjha/sc
 static function getTable($loginId, $rows, $source, $options)
 {
     $html = NULL;
     $view = new \stdClass();
     $defaults = array("ui" => "table", "image" => false);
     $settings = Util::getSettings($options, $defaults);
     $records = array();
     foreach ($rows as $row) {
         $record = array();
         $userId = $row['login_id'];
         $pubUserId = PseudoId::encode($userId);
         $pubUserUrl = "/pub/user/" . $pubUserId;
         $record['pubUserUrl'] = $pubUserUrl;
         $record['name'] = $row['name'];
         $record['followingId'] = $userId;
         $record['followerId'] = $loginId;
         $record['hasImage'] = false;
         /*
                         if(!Util::tryEmpty($row["photo_url"])) {
                             $record['srcImage'] = $row["photo_url"];
                             $record['hasImage'] = true ;
                         }else {
                              $record['srcImage'] = UIConstants::PH2_PIC;
                         } */
         $record['srcImage'] = UIConstants::PH3_PIC;
         $records[] = $record;
     }
     $view->records = $records;
     settype($source, "integer");
     $template = self::getTemplate($source, $settings["ui"], $settings["image"]);
     $html = Template::render($template, $view);
     return $html;
 }