diff --git a/plugin.php b/plugin.php index bd36950..18a3222 100644 --- a/plugin.php +++ b/plugin.php @@ -77,5 +77,35 @@ public static function gambitOrderByViews(&$search, $term, $negate) $search->orderBy("c.views ".($negate ? "ASC" : "DESC")); $search->sql->useIndex("conversation_views"); } + + // Construct and process the settings form. + public function settings($sender) + { + // Set up the settings form. + $form = ETFactory::make("form"); + $form->action = URL("admin/plugins/settings/Views"); + $form->setValue("allowSearchViews",C("plugin.Views.allowSearchViews")); + + // If the form was submitted... + if ($form->validPostBack("viewsSave")) { + + // Construct an array of config options to write. + $config = array(); + $config["plugin.Views.allowSearchViews"] = $form->getValue("allowSearchViews"); + + if (!$form->errorCount()) { + + // Write the config file. + ET::writeConfig($config); + + $sender->message(T("message.changesSaved"), "success autoDismiss"); + $sender->redirect(URL("admin/plugins")); + + } + } + + $sender->data("viewsSettingsForm", $form); + return $this->view("settings"); + } } diff --git a/views/conversations/conversation.php b/views/conversations/conversation.php new file mode 100644 index 0000000..3271f4e --- /dev/null +++ b/views/conversations/conversation.php @@ -0,0 +1,76 @@ +user) $className .= " unread"; +if ($conversation["startMemberId"] == ET::$session->user) $className .= " mine"; +foreach ($conversation["labels"] as $label) $className .= " label-$label"; + +?> +
  • +user): ?> +
    user and $conversation["unread"]) + echo " "; +?>
    + +
    "; +foreach ($conversation["labels"] as $label) echo label($label, $label == "draft" ? URL($conversationURL."#reply") : ""); +echo " "; + +// Output the conversation title, highlighting search keywords. +echo "".highlight(sanitizeHTML($conversation["title"]), ET::$session->get("highlight"))." "; + +// 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 "".T("Show matching posts").""; + +// If this conversation is stickied, output an excerpt from its first post. +if ($conversation["sticky"]) + echo "
    ".ET::formatter()->init($conversation["firstPost"])->inline(true)->firstLine()->clip(200)->format()->get()."
    "; + +// Show view count on home page or search results of conversations (if config is set as enabled) + +if(C("plugin.Views.allowSearchViews")) echo "".Ts("%s view", "%s views", $data["conversation"]["views"]).""; + +?>
    +
    {$channel["title"]}"; +?>
    +
    ".avatar(array( + "memberId" => $conversation["lastPostMemberId"], + "username" => $conversation["lastPostMember"], + "avatarFormat" => $conversation["lastPostMemberAvatarFormat"], + "email" => $conversation["lastPostMemberEmail"] + ), "thumb"), " ", + sprintf(T("%s posted %s"), + "".memberLink($conversation["lastPostMemberId"], $conversation["lastPostMember"])."", + "".relativeTime($conversation["lastPostTime"], true).""), + ""; +?>
    +
    ".$conversation["replies"].""; +?>
    +
  • diff --git a/views/settings.php b/views/settings.php new file mode 100644 index 0000000..88527db --- /dev/null +++ b/views/settings.php @@ -0,0 +1,37 @@ + +open(); ?> + +
    + + + +
    + +
    +saveButton("viewsSave"); ?> +
    + +close(); ?>