echo "<span class='label label-{$label}'>" . T("label.{$label}") . "</span> "; } } echo "</span> "; // Output controls which apply to this conversation. echo "<span class='controls'>"; // If we're highlighting search terms (i.e. if we did a fulltext search), then output a "show matching posts" link. if (ET::$session->get("highlight")) { echo " <a href='" . URL($conversationURL . "/?search=" . urlencode($data["fulltextString"])) . "' class='showMatchingPosts'>" . T("Show matching posts") . "</a>"; } echo "</span>"; ?> </div> <div class='col-channel'><?php $channel = $data["channelInfo"][$conversation["channelId"]]; echo "<a href='" . URL(searchURL("", $channel["slug"])) . "' class='channel channel-{$conversation["channelId"]}' data-channel='{$channel["slug"]}'>{$channel["title"]}</a>"; ?> </div> <div class='col-replies'><?php echo "<span>" . Ts("%s reply", "%s replies", $conversation["replies"]) . "</span>"; // Output an "unread indicator", showing the number of unread posts. if (ET::$session->user and $conversation["unread"]) { echo " <a href='" . URL("conversation/markAsRead/" . $conversation["conversationId"] . "?token=" . ET::$session->token . "&return=" . urlencode(ET::$controller->selfURL)) . "' class='unreadIndicator' title='" . T("Mark as read") . "'>" . $conversation["unread"] . " new</a> "; } ?> </div> <div class='col-lastPost'><?php echo "<span class='action'>" . avatar(array("memberId" => $conversation["lastPostMemberId"], "avatarFormat" => $conversation["lastPostMemberAvatarFormat"], "email" => $conversation["lastPostMemberEmail"]), "thumb"), " ", sprintf(T("%s posted %s"), "<span class='lastPostMember name'>" . memberLink($conversation["lastPostMemberId"], $conversation["lastPostMember"]) . "</span>", "<a href='" . URL($conversationURL . "/unread") . "' class='lastPostTime'>" . relativeTime($conversation["lastPostTime"], true) . "</a>"), "</span>"; ?> </div> </li>
echo "<a href='" . URL("conversation/markAsRead/" . $conversation["conversationId"] . "?token=" . ET::$session->token . "&return=" . urlencode(ET::$controller->selfURL)) . "' class='unreadIndicator' title='" . T("Mark as read") . "'>" . $conversation["unread"] . "</a> "; } // Output controls which apply to this conversation. echo "<span class='controls'>"; // A Jump to last/unread link, depending on the user and the unread state. if (ET::$session->user and $conversation["unread"]) { echo "<a href='" . URL($conversationURL . "/unread") . "' class='jumpToUnread'>" . T("Jump to unread") . "</a>"; } else { echo "<a href='" . URL($conversationURL . "/last") . "' class='jumpToLast'>" . T("Jump to last") . "</a>"; } // If we're highlighting search terms (i.e. if we did a fulltext search), then output a "show matching posts" link. if (ET::$session->get("highlight")) { echo " <a href='" . URL($conversationURL . "/?search=" . urlencode($data["fulltextString"])) . "' class='showMatchingPosts'>" . T("Show matching posts") . "</a>"; } echo "</span>"; ?> </div> <div class='col-channel'><?php $channel = $data["channelInfo"][$conversation["channelId"]]; echo "<a href='" . URL(searchURL("", $channel["slug"])) . "' class='channel channel-{$conversation["channelId"]}' data-channel='{$channel["slug"]}'>{$channel["title"]}</a>"; ?> </div> <div class='col-lastPost'><?php echo "<span class='action'>" . avatar($conversation["lastPostMemberId"], $conversation["lastPostMemberAvatarFormat"], "thumb"), " ", sprintf(T("%s posted %s"), "<span class='lastPostMember name'>" . memberLink($conversation["lastPostMemberId"], $conversation["lastPostMember"]) . "</span>", "<span class='lastPostTime'>" . relativeTime($conversation["lastPostTime"], true) . "</span>"), "</span>"; ?> </div> <div class='col-replies'><?php echo "<span>" . Ts("%s reply", "%s replies", $conversation["replies"]) . "</span>"; ?> </div> </li>
* * @package esoTalk */ $member = $data["member"]; ?> <li data-index='<?php echo ctype_alpha($letter = strtolower($member["username"][0])) ? $letter : "0"; ?> '> <div class='col-member'> <?php echo avatar($member, "thumb"); ?> <strong><?php echo memberLink($member["memberId"], $member["username"]); ?> </strong> <?php // Online indicator. if (empty($member["preferences"]["hideOnline"])) { $lastAction = ET::memberModel()->getLastActionInfo($member["lastActionTime"], $member["lastActionDetail"]); if ($lastAction) { echo "<" . (!empty($lastAction[1]) ? "a href='{$lastAction[1]}'" : "span") . " class='online' title='" . T("Online") . ($lastAction[0] ? " (" . sanitizeHTML($lastAction[0]) . ")" : "") . "'><i class='icon-circle'></i></" . (!empty($lastAction[1]) ? "a" : "span") . ">"; } } ?> <span class='group subText'><?php echo memberGroup($member["account"], $member["groups"]);
// Go through the list of members/groups allowed and construct an array of formatted names. foreach ($conversation["membersAllowed"] as $member) { // Format the entity's name depending on its type. if ($member["type"] == "group") { $member["avatarFormat"] = null; $member["name"] = groupName($member["name"], true); } else { $member["name"] = name($member["name"]); } // Add the avatar. $name = "<span class='name'>" . avatar($member["id"], $member["avatarFormat"], "thumb"); // If we're able to remove entities from the list, wrap the name in links that will remove them. if (!empty($data["editable"])) { // Make the entity for the owner of the conversation non-removable unless it's the last name left. if ($count == 1 or $member["id"] != $conversation["startMemberId"] or $member["type"] != "member") { $name .= "<a href='" . URL("conversation/removeMember/{$conversation["conversationId"]}?{$member["type"]}={$member["id"]}&token=" . ET::$session->token) . "' class='deleteLink' data-type='{$member["type"]}' data-id='{$member["id"]}'>{$member["name"]}</a>"; } else { $name .= $member["name"]; } } else { $name .= $member["type"] == "member" ? memberLink($member["id"], $member["name"]) : groupLink($member["name"]); } $name .= "</span>"; $names[] = $name; } // Output the list of names. if (count($names)) { echo implode(" ", $names); } else { printf(T("%s " . ($conversation["countPosts"] > 0 ? "can" : "will be able to") . " view this conversation."), T("Everyone")); }
/** * Format post data into an array which can be used to display the post template view (conversation/post). * * @param array $post The post data. * @param array $conversation The details of the conversation which the post is in. * @return array A formatted array which can be used in the post template view. */ public function formatPostForTemplate($post, $conversation) { $canEdit = ET::postModel()->canEditPost($post, $conversation); $avatar = avatar($post); // Construct the post array for use in the post view (conversation/post). $formatted = array("id" => "p" . $post["postId"], "title" => memberLink($post["memberId"], $post["username"]), "avatar" => (!$post["deleteTime"] and $avatar) ? "<a href='" . URL(memberURL($post["memberId"], $post["username"])) . "'>{$avatar}</a>" : false, "class" => $post["deleteTime"] ? array("deleted") : array(), "info" => array(), "controls" => array(), "body" => !$post["deleteTime"] ? $this->displayPost($post["content"]) : false, "footer" => array(), "data" => array("id" => $post["postId"], "memberid" => $post["memberId"])); $date = smartTime($post["time"], true); // Add the date/time to the post info as a permalink. $formatted["info"][] = "<a href='" . URL(postURL($post["postId"])) . "' class='time' title='" . _strftime(T("date.full"), $post["time"]) . "' data-timestamp='" . $post["time"] . "'>" . (!empty($conversation["searching"]) ? T("Show in context") : $date) . "</a>"; // If the post isn't deleted, add a lot of stuff! if (!$post["deleteTime"]) { // Add the user's online status / last action next to their name. if (empty($post["preferences"]["hideOnline"])) { $lastAction = ET::memberModel()->getLastActionInfo($post["lastActionTime"], $post["lastActionDetail"]); if ($lastAction[0]) { $lastAction[0] = " (" . sanitizeHTML($lastAction[0]) . ")"; } if ($lastAction) { array_unshift($formatted["info"], "<" . (!empty($lastAction[1]) ? "a href='{$lastAction[1]}'" : "span") . " class='online' title='" . T("Online") . "{$lastAction[0]}'><i class='icon-circle'></i></" . (!empty($lastAction[1]) ? "a" : "span") . ">"); } } // Show the user's group type. $formatted["info"][] = "<span class='group'>" . memberGroup($post["account"], $post["groups"]) . "</span>"; $formatted["class"][] = "group-" . $post["account"]; foreach ($post["groups"] as $k => $v) { if ($k) { $formatted["class"][] = "group-" . $k; } } // If the post has been edited, show the time and by whom next to the controls. if ($post["editMemberId"]) { $formatted["controls"][] = "<span class='editedBy'>" . sprintf(T("Edited %s by %s"), "<span title='" . _strftime(T("date.full"), $post["editTime"]) . "' data-timestamp='" . $post["editTime"] . "'>" . relativeTime($post["editTime"], true) . "</span>", memberLink($post["editMemberId"], $post["editMemberName"])) . "</span>"; } // If the user can reply, add a quote control. if ($conversation["canReply"]) { $formatted["controls"][] = "<a href='" . URL(conversationURL($conversation["conversationId"], $conversation["title"]) . "/?quote=" . $post["postId"] . "#reply") . "' title='" . T("Quote") . "' class='control-quote'><i class='icon-quote-left'></i></a>"; } // If the user can edit the post, add edit/delete controls. if ($canEdit) { $formatted["controls"][] = "<a href='" . URL("conversation/editPost/" . $post["postId"]) . "' title='" . T("Edit") . "' class='control-edit'><i class='icon-edit'></i></a>"; $formatted["controls"][] = "<a href='" . URL("conversation/deletePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Delete") . "' class='control-delete'><i class='icon-remove'></i></a>"; } elseif (!$conversation["locked"] && !ET::$session->isSuspended() && $post["memberId"] == ET::$session->userId && (!$post["deleteMemberId"] || $post["deleteMemberId"] == ET::$session->userId) && C("esoTalk.conversation.editPostTimeLimit") == "reply") { $formatted["controls"][] = "<span title='" . sanitizeHTML(T("message.cannotEditSinceReply")) . "' class='control-edit disabled'><i class='icon-edit'></i></span>"; $formatted["controls"][] = "<span title='" . sanitizeHTML(T("message.cannotEditSinceReply")) . "' class='control-delete disabled'><i class='icon-remove'></i></span>"; } } else { // Add the "deleted by" information. if ($post["deleteMemberId"]) { $formatted["controls"][] = "<span>" . sprintf(T("Deleted %s by %s"), "<span title='" . _strftime(T("date.full"), $post["deleteTime"]) . "' data-timestamp='" . $post["deleteTime"] . "'>" . relativeTime($post["deleteTime"], true) . "</span>", memberLink($post["deleteMemberId"], $post["deleteMemberName"])) . "</span>"; } // If the user can edit the post, add a restore control. if ($canEdit) { $formatted["controls"][] = "<a href='" . URL("conversation/restorePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Restore") . "' class='control-restore'><i class='icon-reply'></i></a>"; } } $this->trigger("formatPostForTemplate", array(&$formatted, $post, $conversation)); return $formatted; }
<?php // If there are members online, list them. if (count($data["members"])) { ?> <div class='section' id='onlineList'> <ul class='list'> <?php foreach ($data["members"] as $memberId => $member) { ?> <li> <span class='action'> <?php echo avatar($memberId, $member["avatarFormat"], "thumb"), " ", memberLink($memberId, $member["username"]), " "; ?> </span> </li> <?php } ?> </ul> </div> <?php // Otherwise, display a 'no members online' message. } else { ?>
/** * Shows a summary of the members allowed in a conversation. * For example: Toby, Administrators, and 2 others can view this conversation. * * @package esoTalk */ $conversation = $data["conversation"]; $names = array(); $avatars = array(); $model = ET::memberModel(); // Go through the list of members/groups allowed and construct an array of formatted names. foreach ($conversation["membersAllowedSummary"] as $member) { // If this entity is a member, add their name as a link to their profile. Also add an avatar to be // displayed at the start of the list. if ($member["type"] == "member") { $names[] = "<span class='name'>" . memberLink($member["id"], $member["name"]) . "</span>"; if (count($avatars) < 3) { $avatars[] = avatar($member + array("memberId" => $member["id"]), "thumb"); } } else { $names[] = "<span class='name'>" . groupLink($member["name"]) . "</span>"; } } // If there are specific names, output the list! if (count($names)) { // Output a few avatars at the start. echo "<span class='avatars'>" . implode(" ", $avatars) . "</span> "; // If there's more than one name, construct the list so that it has the word "and" in it. if (count($names) > 1) { // If there're more than 3 names, chop off everything after the first 3 and replace them with a // "x others" link.
public function getNames($likes) { $names = array(); foreach ($likes as $id => $member) { $names[] = memberLink($id, $member["username"]); } // If there's more than one name, construct the list so that it has the word "and" in it. if (count($names) > 1) { // If there're more than 3 names, chop off everything after the first 3 and replace them with a // "x others" link. if (count($names) > 3) { $otherNames = array_splice($names, 3); $lastName = "<a href='#' class='showMore name'>" . sprintf(T("%s others"), count($otherNames)) . "</a>"; } else { $lastName = array_pop($names); } $members = sprintf(T("%s like this."), sprintf(T("%s and %s"), implode(", ", $names), $lastName)); } elseif (count($names)) { $members = sprintf(T("%s likes this."), $names[0]); } else { $members = ""; } return $members; }
<?php // If there are members online, list them. if (count($data["members"])) { ?> <div class='section' id='onlineList'> <ul class='list'> <?php foreach ($data["members"] as $memberId => $member) { ?> <li> <span class='action'> <?php echo avatar($member, "thumb"), " ", memberLink($memberId, $member["username"]), " "; ?> </span> </li> <?php } ?> </ul> </div> <?php // Otherwise, display a 'no members online' message. } else { ?>
<?php // Copyright 2013 Toby Zerner, Simon Zerner // This file is part of esoTalk. Please see the included license file for usage information. if (!defined("IN_ESOTALK")) { exit; } $conversation = $data["conversation"]; $post = $data["answer"]; ?> <div class='answer thing hasControls'> <div class='postHeader'> <div class='info'> <h3><i class="icon-ok-sign"></i> <?php printf(T("Answered by %s"), memberLink($post["memberId"], $post["username"])); ?> </h3> <a href='<?php echo URL(postURL($post["postId"])); ?> ' rel='post' data-id='<?php echo $post["postId"]; ?> '><?php echo T("See post in context"); ?> </a> </div> <div class='controls'> <?php if ($conversation["startMemberId"] == ET::$session->userId or $conversation["canModerate"]) {
/** * 投稿単位(post)の出力用編集メソッド * Format post data into an array which can be used to display the post template view (conversation/post). * * @param array $post The post data. * @param array $conversation The details of the conversation which the post is in. * @return array A formatted array which can be used in the post template view. */ protected function formatPostForTemplate($post, $conversation) { $canEdit = ET::postModel()->canEditPost($post, $conversation); $avatar = avatar($post); // Construct the post array for use in the post view (conversation/post). // title: SWCユーザ名を表示するように設定対応 // purl: 追加。SNSボタンリンク用に投稿単位の絶対urlを設定 // likeCnt: 追加。いいねボタンのカウント数設定 // mainPostFlg: 追加。テーマのメイン投稿(最初の投稿)フラグ $formatted = array("id" => "p" . $post["postId"], "conversationId" => $post["conversationId"], "title" => memberLink($post["memberId"], $post["username"]), "avatar" => (!$post["deleteMemberId"] and $avatar) ? "<a href='" . URL(memberURL($post["memberId"], $post["username"])) . "'>{$avatar}</a>" : false, "class" => $post["deleteMemberId"] ? array("deleted") : array(), "info" => array(), "controls" => array(), "body" => !$post["deleteMemberId"] ? $this->displayPost($post["content"]) : false, "footer" => array(), "purl" => URL(postURL($post["postId"]), TRUE), "likeCnt" => $post["likeCnt"], "mainPostFlg" => $post["mainPostFlg"], "data" => array("id" => $post["postId"], "memberid" => $post["memberId"])); // いいね済みフラグ $formatted["liked"] = $post["likeActivityId"] ? 1 : ""; // $date = smartTime($post["time"], true); $date = SwcUtils::getStrfTime($post["time"], T("date.short")); // Add the date/time to the post info as a permalink. $formatted["info"][] = "<a href='" . URL(postURL($post["postId"])) . "' class='time' title='" . strftime(T("date.full"), $post["time"]) . "'>" . (!empty($conversation["searching"]) ? T("Show in context") : $date) . "</a>"; // If the post isn't deleted, add a lot of stuff! if (!$post["deleteMemberId"]) { // Add the user's online status / last action next to their name. // if (empty($post["preferences"]["hideOnline"])) { // $lastAction = ET::memberModel()->getLastActionInfo($post["lastActionTime"], $post["lastActionDetail"]); // if ($lastAction[0]) $lastAction[0] = " (".sanitizeHTML($lastAction[0]).")"; // if ($lastAction) array_unshift($formatted["info"], "<".(!empty($lastAction[1]) ? "a href='{$lastAction[1]}'" : "span")." class='online' title='".T("Online")."{$lastAction[0]}'><i class='icon-circle'></i></".(!empty($lastAction[1]) ? "a" : "span").">"); // } // Show the user's group type. // $formatted["info"][] = "<span class='group'>".memberGroup($post["account"], $post["groups"])."</span>"; $formatted["class"][] = "group-" . $post["account"]; foreach ($post["groups"] as $k => $v) { if ($k) { $formatted["class"][] = "group-" . $k; } } // If the post has been edited, show the time and by whom next to the controls. if ($post["editMemberId"]) { $formatted["controls"][] = "<span class='editedBy'>" . sprintf(T("Edited %s by %s"), "<span title='" . strftime(T("date.full"), $post["editTime"]) . "'>" . relativeTime($post["editTime"], true) . "</span>", name($post["editMemberName"])) . "</span>"; } // If the user can reply, add a quote control. if ($conversation["canReply"]) { $formatted["controls"][] = "<a href='" . URL(conversationURL($conversation["conversationId"], $conversation["title"]) . "/?quote=" . $post["postId"] . "#reply") . "' title='" . T("Quote") . "' class='control-quote'><i class='icon-quote-left'></i></a>"; } // If the user can edit the post, add edit/delete controls. if ($canEdit) { $formatted["controls"][] = "<a href='" . URL("conversation/editPost/" . $post["postId"]) . "' title='" . T("Edit") . "' class='control-edit'><i class='icon-edit'></i></a>"; $formatted["controls"][] = "<a href='" . URL("conversation/deletePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Delete") . "' class='control-delete'><i class='icon-remove'></i></a>"; } } else { // Add the "deleted by" information. if ($post["deleteMemberId"]) { $formatted["controls"][] = "<span>" . sprintf(T("Deleted %s by %s"), "<span title='" . strftime(T("date.full"), $post["deleteTime"]) . "'>" . relativeTime($post["deleteTime"], true) . "</span>", name($post["deleteMemberName"])) . "</span>"; } // If the user can edit the post, add a restore control. if ($canEdit) { $formatted["controls"][] = "<a href='" . URL("conversation/restorePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Restore") . "' class='control-restore'><i class='icon-reply'></i></a>"; } } $this->trigger("formatPostForTemplate", array(&$formatted, $post, $conversation)); return $formatted; }
/** * Format post data into an array which can be used to display the post template view (conversation/post). * * @param array $post The post data. * @param array $conversation The details of the conversation which the post is in. * @return array A formatted array which can be used in the post template view. */ protected function formatPostForTemplate($post, $conversation) { $canEdit = $this->canEditPost($post, $conversation); $avatar = avatar($post["memberId"], $post["avatarFormat"]); // Construct the post array for use in the post view (conversation/post). $formatted = array("id" => "p" . $post["postId"], "title" => memberLink($post["memberId"], $post["username"]), "avatar" => (!$post["deleteMemberId"] and $avatar) ? "<a href='" . URL(memberURL($post["memberId"], $post["username"])) . "'>{$avatar}</a>" : false, "class" => $post["deleteMemberId"] ? array("deleted") : array(), "info" => array(), "controls" => array(), "body" => !$post["deleteMemberId"] ? $this->displayPost($post["content"]) : false, "data" => array("id" => $post["postId"], "memberid" => $post["memberId"])); // If the post was within the last 24 hours, show a relative time (eg. 2 hours ago.) if (time() - $post["time"] < 24 * 60 * 60) { $date = relativeTime($post["time"], true); } else { $date = date("M j", $post["time"]); } // Add the date/time to the post info as a permalink. $formatted["info"][] = "<a href='" . URL(postURL($post["postId"])) . "' class='time' title='" . date(T("date.full"), $post["time"]) . "'>" . (!empty($conversation["searching"]) ? T("Context") : $date) . "</a>"; // If the post isn't deleted, add a lot of stuff! if (!$post["deleteMemberId"]) { // Add the user's online status / last action next to their name. $lastAction = ET::memberModel()->getLastActionInfo($post["lastActionTime"], $post["lastActionDetail"]); if ($lastAction[0]) { $lastAction[0] = " (" . sanitizeHTML($lastAction[0]) . ")"; } if ($lastAction) { array_unshift($formatted["info"], "<" . (!empty($lastAction[1]) ? "a href='{$lastAction[1]}'" : "span") . " class='online' title='" . T("Online") . "{$lastAction[0]}'>" . T("Online") . "</" . (!empty($lastAction[1]) ? "a" : "span") . ">"); } // Show the user's group type. $formatted["info"][] = "<span class='group'>" . memberGroup($post["account"], $post["groups"]) . "</span>"; // If the post has been edited, show the time and by whom next to the controls. if ($post["editMemberId"]) { $formatted["controls"][] = "<span class='editedBy'>" . sprintf(T("Edited %s by %s"), "<span title='" . date(T("date.full"), $post["editTime"]) . "'>" . relativeTime($post["editTime"], true) . "</span>", $post["editMemberName"]) . "</span>"; } // If the user can reply, add a quote control. if ($conversation["canReply"]) { $formatted["controls"][] = "<a href='" . URL(conversationURL($conversation["conversationId"], $conversation["title"]) . "/?quote=" . $post["postId"] . "#reply") . "' title='" . T("Quote") . "' class='control-quote'>" . T("Quote") . "</a>"; } // If the user can edit the post, add edit/delete controls. if ($canEdit) { $formatted["controls"][] = "<a href='" . URL("conversation/editPost/" . $post["postId"]) . "' title='" . T("Edit") . "' class='control-edit'>" . T("Edit") . "</a>"; $formatted["controls"][] = "<a href='" . URL("conversation/deletePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Delete") . "' class='control-delete'>" . T("Delete") . "</a>"; } } else { // Add the "deleted by" information. if ($post["deleteMemberId"]) { $formatted["controls"][] = "<span>" . sprintf(T("Deleted %s by %s"), "<span title='" . date(T("date.full"), $post["deleteTime"]) . "'>" . relativeTime($post["deleteTime"], true) . "</span>", $post["deleteMemberName"]) . "</span>"; } // If the user can edit the post, add a restore control. if ($canEdit) { $formatted["controls"][] = "<a href='" . URL("conversation/restorePost/" . $post["postId"] . "?token=" . ET::$session->token) . "' title='" . T("Restore") . "' class='control-restore'>" . T("Restore") . "</a>"; } } $this->trigger("formatPostForTemplate", array(&$formatted, $post, $conversation)); return $formatted; }
<div class='sheetBody'> <div class='section' id='onlineList'> <ul class='list'> <?php if ($data["nearbyMembers"]) { ?> <?php foreach ($data["nearbyMembers"] as $member) { ?> <li> <span class='action'> <?php echo $member["rank"], ". ", $member["avatar"], " ", memberLink($member["memberId"], $member["username"]), " +", number_format($member["reputationPoints"]), " Reputation Points"; ?> </span> </li> <?php } ?> <?php } else { echo "Congrats! You're already in the top 10."; } ?> </ul>