Exemple #1
0
 /**
  * Format an attachment to be outputted on the page, either in the attachment list
  * at the bottom of the post or embedded inside the post.
  *
  * @param array $attachment The attachment details.
  * @param bool $expanded Whether or not the attachment should be displayed in its
  * 		full form (i.e. whether or not the attachment is embedded in the post.)
  * @return string The HTML to output.
  */
 function formatAttachment($attachment, $expanded = false)
 {
     $extension = strtolower(pathinfo($attachment["filename"], PATHINFO_EXTENSION));
     $url = URL("attachment/" . $attachment["attachmentId"] . "_" . $attachment["filename"]);
     $filename = sanitizeHTML($attachment["filename"]);
     $displayFilename = ET::formatter()->init($filename)->highlight(ET::$session->get("highlight"))->get();
     // For images, either show them directly or show a thumbnail.
     if (in_array($extension, array("jpg", "jpeg", "png", "gif"))) {
         if ($expanded) {
             return "<span class='attachment attachment-image'><img src='" . $url . "' alt='" . $filename . "' title='" . $filename . "'></span>";
         } else {
             return "<a href='" . $url . "' class='' target='_blank'><img src='" . URL("attachment/thumb/" . $attachment["attachmentId"]) . "' alt='" . $filename . "' title='" . $filename . "'></a>";
         }
     }
     // Embed video.
     if (in_array($extension, array("mp4", "mov", "mpg", "avi", "m4v")) and $expanded) {
         return "<video width='400' height='225' controls><source src='" . $url . "'></video>";
     }
     // Embed audio.
     if (in_array($extension, array("mp3", "mid", "wav")) and $expanded) {
         return "<audio controls><source src='" . $url . "'></video>";
     }
     $icons = array("pdf" => "file-text-alt", "doc" => "file-text-alt", "docx" => "file-text-alt", "zip" => "archive", "rar" => "archive", "gz" => "archive");
     $icon = isset($icons[$extension]) ? $icons[$extension] : "file";
     return "<a href='" . $url . "' class='attachment' target='_blank'><i class='icon-{$icon}'></i><span class='filename'>" . $displayFilename . "</span></a>";
 }
Exemple #2
0
 public function memberController_about($sender, $member = "")
 {
     if (!($member = $sender->profile($member, "about"))) {
         return;
     }
     $about = @$member["preferences"]["about"];
     $about = ET::formatter()->init($about)->format()->get();
     $sender->data("about", $about);
     $sender->renderProfile($this->getView("about"));
 }
Exemple #3
0
 public function handler_conversationController_formatPostForTemplate($sender, &$formatted, $post, $conversation)
 {
     if ($post["deleteMemberId"]) {
         return;
     }
     // Lets check if the Likes plugin is active,
     // if so we need to output the signature HTML a bit different.
     if (in_array("Likes", C("esoTalk.enabledPlugins"))) {
         $signature = ET::formatter()->init($post["preferences"]["signature"])->format()->get();
         if ($signature != "") {
             addToArray($formatted["footer"], "<div class='signature'>" . substr($signature, 0, C("plugin.Signature.characters")) . "</div>", 0);
         }
     } else {
         $signature = $post["preferences"]["signature"];
         if ($signature != "") {
             addToArray($formatted["footer"], "<p class='signature-no-likes'>" . substr($signature, 0, C("plugin.Signature.characters")) . "</p>", 0);
         }
     }
 }
Exemple #4
0
 /**
  * The callback function used to replace URL BBCode with HTML anchor tags.
  *
  * @param array $matches An array of matches from the regular expression.
  * @return string The replacement HTML anchor tag.
  */
 public function linksCallback($matches)
 {
     return ET::formatter()->formatLink($matches[1] . $matches[2], $matches[3]);
 }
 /**
  * Returns a formatted email subject+body for the "post" activity type.
  *
  * @see mentionEmail() for parameter and return information.
  */
 public static function postEmail($item, $member)
 {
     $content = ET::formatter()->init($item["data"]["content"])->format()->get();
     $url = URL(conversationURL($item["data"]["conversationId"], $item["data"]["title"]) . "/unread", true);
     return array(sprintf(T("email.post.subject"), $item["data"]["title"]), sprintf(T("email.post.body"), name($item["fromMemberName"]), sanitizeHTML($item["data"]["title"]), $content, "<a href='{$url}'>{$url}</a>"));
 }
 /**
  * Format a post's content to be displayed.
  *
  * @param string $content The post content to format.
  * @return string The formatted post content.
  */
 protected function displayPost($content)
 {
     $words = ET::$session->get("highlight");
     return ET::formatter()->init($content)->highlight($words)->format()->get();
 }
Exemple #7
0
}
echo "</span> ";
// Output the conversation title, highlighting search keywords.
echo "<strong class='title'><a href='" . URL($conversationURL . ((ET::$session->user and $conversation["unread"]) ? "/unread" : "")) . "'>";
if (SWC_MAIN_THUMB_DISPLAY && $menuImgUrl) {
    // メニュー画像サムネイル出力
    echo "<img src='" . $menuImgUrl . "' width='28' height='20' alt='' title=''>";
}
echo highlight(sanitizeHTML($conversation["title"]), ET::$session->get("highlight")) . "</a></strong> ";
// 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 "<span class='controls'><a href='" . URL($conversationURL . "/?search=" . urlencode($data["fulltextString"])) . "' class='showMatchingPosts'>" . T("Show matching posts") . "</a></span>";
}
// If this conversation is stickied, output an excerpt from its first post.
if ($conversation["sticky"]) {
    echo "<div class='excerpt'>" . ET::formatter()->init($conversation["firstPost"])->inline(true)->firstLine()->clip(200)->format()->get() . "</div>";
}
?>
</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(array("memberId" => $conversation["lastPostMemberId"], "username" => $conversation["lastPostMember"], "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'>" . SwcUtils::getStrfTime($conversation["lastPostTime"]) . "</a>"), "</span>";
?>
</div>
<div class='col-replies'><?php 
echo "<span><a href='" . URL($conversationURL . "/unread") . "'>" . $conversation["replies"] . "</a></span>";
?>
Exemple #8
0
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"]) {
    ?>
			<a href='<?php 
    echo URL("conversation/unanswer/" . $conversation["conversationId"] . "?token=" . ET::$session->token);
    ?>
' title='<?php 
    echo T("Remove answer");
    ?>
' class='control-unanswer'><i class='icon-remove'></i></a>
			<?php 
}
?>
		</div>
	</div>

	<div class='postBody'>
		<?php 
$words = ET::$session->get("highlight");
echo ET::formatter()->init($post["content"])->highlight($words)->format()->get();
?>
	</div>
</div>
 /**
  * Create a post in the specified conversation.
  *
  * This function will go through the post content and notify any members who are @mentioned.
  *
  * @param int $conversationId The ID of the conversation to create the post in.
  * @param int $memberId The ID of the author of the post.
  * @param string $content The post content.
  * @param string $title The title of the conversation (so it can be added alongside the post, for fulltext purposes.)
  * @return bool|int The new post's ID, or false if there were errors.
  */
 public function create($conversationId, $memberId, $content, $title = "")
 {
     // Validate the post content.
     $this->validate("content", $content, array($this, "validateContent"));
     if ($this->errorCount()) {
         return false;
     }
     // Prepare the post details for the query.
     $data = array("conversationId" => $conversationId, "memberId" => $memberId, "time" => time(), "content" => $content, "title" => $title);
     $id = parent::create($data);
     // Update the member's post count.
     ET::SQL()->update("member")->set("countPosts", "countPosts + 1", false)->where("memberId", $memberId)->exec();
     // Update the channel's post count.
     ET::SQL()->update("channel")->set("countPosts", "countPosts + 1", false)->where("channelId", ET::SQL()->select("channelId")->from("conversation")->where("conversationId=:conversationId")->bind(":conversationId", $conversationId)->exec()->result())->exec();
     // Parse the post content for @mentions, and notify any members who were mentioned.
     if (C("esoTalk.format.mentions")) {
         $names = ET::formatter()->getMentions($content);
         if (count($names)) {
             // Get the member details from the database.
             $sql = ET::SQL()->where("m.username IN (:names)")->bind(":names", $names)->where("m.memberId != :userId")->bind(":userId", $memberId);
             $members = ET::memberModel()->getWithSQL($sql);
             $data = array("conversationId" => $conversationId, "postId" => (int) $id, "title" => $title);
             $emailData = array("content" => $content);
             $i = 0;
             foreach ($members as $member) {
                 // Only send notifications to the first 10 members who are mentioned to prevent abuse of the system.
                 if ($i++ > 10) {
                     break;
                 }
                 // Check if this member is allowed to view this conversation before sending them a notification.
                 $sql = ET::SQL()->select("conversationId")->from("conversation c")->where("conversationId", $conversationId);
                 ET::conversationModel()->addAllowedPredicate($sql, $member);
                 if (!$sql->exec()->numRows()) {
                     continue;
                 }
                 ET::activityModel()->create("mention", $member, ET::$session->user, $data, $emailData);
             }
         }
     }
     return $id;
 }
Exemple #10
0
 public function action_memberController_about($sender, $member = "")
 {
     if (!($member = $sender->profile($member, "about"))) {
         return;
     }
     $model = ET::getInstance("profileFieldModel");
     $fields = $model->getData($member["memberId"]);
     foreach ($fields as $k => &$field) {
         // If this field is hidden from guests and we're a guest, don't display it.
         if ($field["hideFromGuests"] and !ET::$session->user) {
             unset($fields[$k]);
         }
         switch ($field["type"]) {
             case "textarea":
                 $field["data"] = ET::formatter()->init($field["data"])->format()->get();
                 break;
             case "checkboxes":
                 $items = explode("\n", $field["data"]);
                 $items = array_map("sanitizeHTML", $items);
                 $field["data"] = implode("<br>", $items);
                 break;
             case "member":
                 $field["data"] = "<a href='" . URL("member/name/" . urlencode($field["data"])) . "'>" . sanitizeHTML($field["data"]) . "</a>";
                 break;
             default:
                 $field["data"] = ET::formatter()->init($field["data"])->inline(true)->format()->get();
         }
     }
     $sender->data("fields", $fields);
     $sender->renderProfile($this->view("about"));
 }
 /**
  * Returns a formatted activity item for the "post" activity type. For example, '[member] posted in [title]'.
  *
  * @param array $item The activity item's details.
  * @param array $member The details of the member this activity is for.
  * @return array 0 => activity title, 1 => activity body
  */
 public static function postActivity($item, $member)
 {
     return array(sprintf(T($item["start"] ? "%s started the conversation %s." : "%s posted in %s."), name($member["username"]), "<a href='" . URL(postURL($item["postId"])) . "'>" . sanitizeHTML($item["title"]) . "</a>"), ET::formatter()->init($item["content"])->basic(true)->removeQuotes()->format()->clip(250)->get());
 }
Exemple #12
0
 public static function postMemberEmail($item, $member)
 {
     $content = ET::formatter()->init($item["data"]["content"])->basic(true)->format()->get();
     return array(sprintf(T("email.postMember.subject"), name($item["fromMemberName"], false)), sprintf(T("email.postMember.body"), name($item["fromMemberName"]), sanitizeHTML($item["data"]["title"]), $content, URL(conversationURL($item["data"]["conversationId"], $item["data"]["title"]) . "/unread", true)));
 }
Exemple #13
0
 public function issueCallback($matches)
 {
     return ET::formatter()->formatLink($this->repositoryURL() . "/issues/" . $matches[1], $matches[0]);
 }