Skip to content

Commit

Permalink
add signature
Browse files Browse the repository at this point in the history
  • Loading branch information
skywalker512 committed Jul 6, 2018
1 parent a5e03b9 commit 775b521
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/languages/Chinese/definitions.Signature.php
@@ -1,6 +1,6 @@
<?php
$definitions["Characters"] = "字符";
$definitions["Enter the amount of signature characters allowed."] = "输入最大允许字符数";
$definitions["Enter the amount of signature characters allowed."] = "输入最大显示字符数";
$definitions["Signature"] = "签名";
$definitions["Max charaters:"] = "最多字符数:";
$definitions["BBCode Allowed"] = "允许BBCode代码";
47 changes: 47 additions & 0 deletions addons/plugins/Signature/.gitignore
@@ -0,0 +1,47 @@
.buildpath
.project
.settings
.htaccess
cache/*
config/*
uploads/*
robots.txt

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
*~
37 changes: 37 additions & 0 deletions addons/plugins/Signature/README.md
@@ -0,0 +1,37 @@
## esoTalk – Signature plugin

- Let users add their signature to posts.
- Works together or individually with the Likes plugin. You can enable them both, or either one.

### Installation

Browse to your esoTalk plugin directory:
```
cd WEB_ROOT_DIR/addons/plugins/
```

Clone the Signature plugin repo into the plugin directory:
```
git clone git@github.com:esoTalk-plugins/Signature.git Signature
```

Chown the Signature plugin folder to the right web user:
```
chown -R apache:apache Signature/
```

Navigate to the esoTalk /admin/plugins page and activate the Signature plugin!
And lastly, edit your signature in your profile settings page :smile:


### Translation

Add the following definitions to your translation file (or create a seperate definitions.Signature.php file):

```
$definitions["BBCode Allowed"] = "BBCode Allowed";
$definitions["Characters"] = "Characters";
$definitions["Enter the amount of signature characters allowed."] = "Enter the amount of signature characters allowed.";
$definitions["Max characters:"] = "Max characters:";
$definitions["Signature"] = "Signature";
```
Binary file added addons/plugins/Signature/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
91 changes: 91 additions & 0 deletions addons/plugins/Signature/plugin.php
@@ -0,0 +1,91 @@
<?php
// Copyright 2014 Tristan van Bokkem

if (!defined("IN_ESOTALK")) exit;

ET::$pluginInfo["Signature"] = array(
"name" => "个性签名",
"description" => "允许用户将自己的签名档添加到帖子的底部",
"version" => "1.1.3",
"author" => "Tristan van Bokkem",
"authorEmail" => "tristanvanbokkem@gmail.com",
"authorURL" => "http://www.bitcoinclub.nl",
"license" => "GPLv2",
"priority" => "0"
);

class ETPlugin_Signature extends ETPlugin {

function setup()
{
ET::writeConfig(array("plugin.Signature.characters" => "150"));
return true;
}

function handler_settingsController_initGeneral($sender, $form)
{
$form->addSection("signature", T("Signature"), array("after" => "privacy"));
$form->setValue("signature", ET::$session->preference("signature"));
$form->addField("signature", "signature", array($this, "fieldSignature"), array($this, "saveSignature"));
}

function fieldSignature($form)
{
if (!(ET::$session->preference("signature") == NULL))
{
return $form->input("signature", "text")." <small>(".T("Max charaters:")." ".C("plugin.Signature.characters").", ".T("BBCode Allowed").")</small><br /><br /><small>".ET::formatter()->init(ET::$session->preference("signature"))->format()->get()."</small>";
}
else
{
return $form->input("signature", "text")." <small>(".T("Max charaters:")." ".C("plugin.Signature.characters").", ".T("BBCode Allowed").")</small><br /><br /><small>-</small>";
}
}

public function saveSignature($form, $key, &$preferences)
{
$signature = $form->getValue($key);
$preferences["signature"] = $signature;
}

public function handler_conversationController_renderBefore($sender)
{
$sender->addCSSFile($this->resource("signature.css"));
$sender->addJSFile($this->resource("signature.js"));
}

public function handler_conversationController_formatPostForTemplate($sender, &$formatted, $post, $conversation)
{
if ($post["deleteMemberId"]) return;

$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);

}

public function settings($sender)
{
// Set up the settings form.
$form = ETFactory::make("form");
$form->action = URL("admin/plugins/settings/Signature");

// Set the values for the sitemap options.
$form->setValue("characters", C("plugin.Signature.characters", "150"));

// If the form was submitted...
if ($form->validPostBack()) {

// Construct an array of config options to write.
$config = array();
$config["plugin.Signature.characters"] = $form->getValue("characters");

// Write the config file.
ET::writeConfig($config);

$sender->redirect(URL("admin/plugins"));
}

$sender->data("SignatureSettingsForm", $form);
return $this->view("settings");
}
}
17 changes: 17 additions & 0 deletions addons/plugins/Signature/resources/signature.css
@@ -0,0 +1,17 @@
.signature {
border-top:1px solid #eee;
font-size:11px;
padding: 5px 12px;
margin: 1px 0 0;
color:#999;
word-wrap: break-word;
}
.signature p {margin-bottom:0}
.signature-no-likes {
border-top:1px solid #eee;
font-size:11px;
padding: 5px 12px;
margin:1px 0 0;
color:#999;
word-wrap: break-word;
}
19 changes: 19 additions & 0 deletions addons/plugins/Signature/resources/signature.js
@@ -0,0 +1,19 @@
$(function() {
if ($("p.likes").length) {
$("p.likes").css({'border': '0'});
$('p.likes').each(
function(){
$(this).insertBefore($(this).closest('.postFooter'));
});
}
});

$(document).ajaxComplete(function(){
if ($("p.likes").length) {
$("p.likes").css({'border': '0'});
$('p.likes').each(
function(){
$(this).insertBefore($(this).closest('.postFooter'));
});
}
})
28 changes: 28 additions & 0 deletions addons/plugins/Signature/views/settings.php
@@ -0,0 +1,28 @@
<?php
// Copyright 2014 Tristan van Bokkem

if (!defined("IN_ESOTALK")) exit;

$form = $data["SignatureSettingsForm"];
?>
<?php echo $form->open(); ?>

<div class='section'>

<ul class='form'>

<li>
<label><strong><?php echo T("Characters"); ?></strong></label>
<?php echo $form->input("characters", "number"); ?>
<small><?php echo T("Enter the amount of signature characters allowed."); ?></small>
</li>

</ul>

</div>

<div class='buttons'>
<?php echo $form->saveButton(); ?>
</div>

<?php echo $form->close(); ?>

0 comments on commit 775b521

Please sign in to comment.