-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
skywalker512
committed
Jul 8, 2018
1 parent
5f0c3fd
commit 70fe8c5
Showing
7 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
$definitions["Change your avatar on %s."] = "请到 %s 更改你的头像"; | ||
$definitions["Default imageset"] = "默认头像"; | ||
$definitions["Default"] = "Default"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.buildpath | ||
.project | ||
.settings | ||
.htaccess | ||
|
||
# Compiled source | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.so | ||
|
||
# Packages | ||
*.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 | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Gravatar Plugin | ||
|
||
Allows users to choose to use their Gravatar. | ||
|
||
## Installation | ||
|
||
[Download](https://github.com/esotalk/Gravatar/archive/master.zip) or clone the Gravatar plugin repo into your esoTalk plugin directory: | ||
|
||
cd ESOTALK_DIR/addons/plugins/ | ||
git clone [email protected]:esotalk/Gravatar.git Gravatar | ||
|
||
Navigate to the the admin/plugins page and activate the Gravatar plugin. | ||
|
||
## Translation | ||
|
||
Create `definitions.Gravatar.php` in your language pack with the following definitions: | ||
|
||
$definitions["Change your avatar on %s."] = "Change your avatar on %s."; | ||
$definitions["Default imageset"] = "Default imageset"; | ||
$definitions["Default"] = "Default"; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?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; | ||
|
||
ET::$pluginInfo["Gravatar"] = array( | ||
"name" => "Gravatar", | ||
"description" => "允许用户使用 Gravatar 头像", | ||
"version" => ESOTALK_VERSION, | ||
"author" => "Toby Zerner", | ||
"authorEmail" => "[email protected]", | ||
"authorURL" => "http://esotalk.org", | ||
"license" => "GPLv2", | ||
"dependencies" => array( | ||
"esoTalk" => "1.0.0g4" | ||
) | ||
); | ||
|
||
class ETPlugin_Gravatar extends ETPlugin { | ||
|
||
function init() | ||
{ | ||
// Override the avatar function. | ||
|
||
/** | ||
* Return an image tag containing a member's avatar. | ||
* | ||
* @param array $member An array of the member's details. (email is required in this implementation.) | ||
* @param string $avatarFormat The format of the member's avatar (as stored in the database - jpg|gif|png.) | ||
* @param string $className CSS class names to apply to the avatar. | ||
*/ | ||
function avatar($member = array(), $className = "") | ||
{ | ||
$default = C("plugin.Gravatar.default") ? C("plugin.Gravatar.default") : "mm"; | ||
|
||
$url = "https://cdn.v2ex.com/gravatar/".md5(strtolower(trim($member["email"])))."?d=".urlencode($default)."&s=64"; | ||
|
||
return "<img src='$url' alt='' class='avatar $className'/>"; | ||
} | ||
} | ||
|
||
// Change the avatar field on the settings page. | ||
function handler_settingsController_initGeneral($sender, $form) | ||
{ | ||
$form->removeField("avatar", "avatar"); | ||
$form->addField("avatar", "avatar", array($this, "fieldAvatar")); | ||
} | ||
|
||
function fieldAvatar($form) | ||
{ | ||
return sprintf(T("Change your avatar on %s."), "<a href='http://gravatar.com' target='_blank'>Gravatar.com</a>"); | ||
} | ||
|
||
/** | ||
* Construct and process the settings form for this skin, and return the path to the view that should be | ||
* rendered. | ||
* | ||
* @param ETController $sender The page controller. | ||
* @return string The path to the settings view to render. | ||
*/ | ||
public function settings($sender) | ||
{ | ||
// Set up the settings form. | ||
$form = ETFactory::make("form"); | ||
$form->action = URL("admin/plugins/settings/Gravatar"); | ||
$form->setValue("default", C("plugin.Gravatar.default", "mm")); | ||
|
||
// If the form was submitted... | ||
if ($form->validPostBack("save")) { | ||
|
||
// Construct an array of config options to write. | ||
$config = array(); | ||
$config["plugin.Gravatar.default"] = $form->getValue("default"); | ||
|
||
if (!$form->errorCount()) { | ||
|
||
// Write the config file. | ||
ET::writeConfig($config); | ||
|
||
$sender->message(T("message.changesSaved"), "success autoDismiss"); | ||
$sender->redirect(URL("admin/plugins")); | ||
|
||
} | ||
} | ||
|
||
$sender->data("gravatarSettingsForm", $form); | ||
return $this->view("settings"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
// Copyright 2011 Toby Zerner, Simon Zerner | ||
// This file is part of esoTalk. Please see the included license file for usage information. | ||
|
||
if (!defined("IN_ESOTALK")) exit; | ||
|
||
/** | ||
* Displays the settings form for the Gravatar plugin. | ||
* | ||
* @package esoTalk | ||
*/ | ||
|
||
$form = $data["gravatarSettingsForm"]; | ||
?> | ||
<style> | ||
#gravatarDefaults label { | ||
float:left; | ||
width:40%; | ||
margin-bottom:20px; | ||
} | ||
#gravatarDefaults img { | ||
display:block; | ||
} | ||
</style> | ||
|
||
<?php echo $form->open(); ?> | ||
|
||
<div class='section'> | ||
|
||
<ul class='form'> | ||
|
||
<li> | ||
<label><?php echo T("Default imageset"); ?></label> | ||
<div class='checkboxGroup' id='gravatarDefaults'> | ||
<label class='radio'><?php echo $form->radio("default", "mm"); ?> <img src='https://cdn.v2ex.com/gravatar/0?d=mm' class='avatar'> <?php echo T("Default"); ?></label> | ||
<label class='radio'><?php echo $form->radio("default", "identicon"); ?> <img src='https://cdn.v2ex.com/gravatar/0?d=identicon' class='avatar'> Identicon</label> | ||
<label class='radio'><?php echo $form->radio("default", "monsterid"); ?> <img src='https://cdn.v2ex.com/gravatar/0?d=monsterid' class='avatar'> MonsterID</label> | ||
<label class='radio'><?php echo $form->radio("default", "wavatar"); ?> <img src='https://cdn.v2ex.com/gravatar/0?d=wavatar' class='avatar'> Wavatar</label> | ||
<label class='radio'><?php echo $form->radio("default", "retro"); ?> <img src='https://cdn.v2ex.com/gravatar/0?d=retro' class='avatar'> Retro</label> | ||
</div> | ||
</li> | ||
|
||
</ul> | ||
|
||
</div> | ||
|
||
<div class='buttons'> | ||
<?php echo $form->saveButton(); ?> | ||
</div> | ||
|
||
<?php echo $form->close(); ?> |