From 0c5bb60c4751a7768c583d5e8e6cbee3ed15a80b Mon Sep 17 00:00:00 2001 From: yathish1618 Date: Sat, 1 Aug 2015 13:25:26 +0530 Subject: [PATCH 1/3] Settings added for the plugin Option added in settings to enable view count on home page or search results.. --- plugin.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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"); + } } From a6cd81107d97744e1d7a96aacbf0eeca52d24508 Mon Sep 17 00:00:00 2001 From: yathish1618 Date: Sat, 1 Aug 2015 13:29:14 +0530 Subject: [PATCH 2/3] Add span inside conversations list Duplicated conversation.php from core files to override original file. Span added to display view count on search results. --- views/conversations/conversation.php | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 views/conversations/conversation.php 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).""), + ""; +?>
    + +
  • From 2fe7cfe3c15e638fe136917520260560367b95b4 Mon Sep 17 00:00:00 2001 From: yathish1618 Date: Sat, 1 Aug 2015 13:29:56 +0530 Subject: [PATCH 3/3] Settings page Settings page added for views plugin. Only 1 setting - enabling/disabling show view count on search results. Built upon attachments plugin settings. --- views/settings.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 views/settings.php 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(); ?> + +
    + +
      + +
    • + +checkbox("allowSearchViews"); ?> + +View count wil also be shown in search results."); ?> +
    • + +
    + +
    + +
    +saveButton("viewsSave"); ?> +
    + +close(); ?>