Skip to content

Commit 518ad54

Browse files
committed
Fixed issue dokufreaks#10; accepted PR dokufreaks#7; updated pt-br translation.
1 parent 141424d commit 518ad54

File tree

6 files changed

+62
-57
lines changed

6 files changed

+62
-57
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
====== Avatar Plugin for DokuWiki ======
1+
# Avatar Plugin for DokuWiki
22

33
All documentation for the Avatar Plugin is available online at:
44

@@ -7,4 +7,6 @@ All documentation for the Avatar Plugin is available online at:
77
(c) 2005 - 2007 by Esther Brunner <wikidesign@gmail.com>
88
(c) 2008 - 2009 by Gina Häußge, Michael Klier <dokuwiki@chimeric.de>
99
(c) 2013 by Michael Hamann <michael@content-space.de>
10+
(c) 2023 by Daniel Dias Rodrigues <danieldiasr@gmail.com>
11+
1012
See COPYING for license info.

helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ function _getAvatarURL($user, &$title, &$size) {
6161
$ns = $this->getConf('namespace');
6262
$formats = array('.png', '.jpg', '.gif');
6363
foreach ($formats as $format) {
64-
$user_img = mediaFN($ns.':'.$user.$format);
65-
$name_img = mediaFN($ns.':'.$name.$format);
64+
if(isset($user)) $user_img = mediaFN($ns.':'.$user.$format);
65+
if(isset($name)) $name_img = mediaFN($ns.':'.$name.$format);
6666
if(@file_exists($user_img)) {;
6767
$src = ml($ns.':'.$user.$format, array('w' => $size, 'h' => $size));
6868
break;

lang/en/settings.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88

99
// for the configuration manager
10-
$lang['namespace'] = 'namespace for local avatars';
11-
$lang['size'] = 'default size of avatar';
12-
$lang['rating'] = 'minimum rating for gravatars';
13-
$lang['default'] = 'type of default gravatars';
10+
$lang['namespace'] = 'Namespace for local avatars';
11+
$lang['size'] = 'Default size of avatar';
12+
$lang['rating'] = 'Minimum rating for gravatars';
13+
$lang['default'] = 'Type of default gravatars';
1414

15-
//Setup VIM: ex: et ts=2 enc=utf-8 :
15+
//Setup VIM: ex: et ts=2 enc=utf-8 :

lang/pt-br/settings.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22
/**
3-
* Portuguese language file
3+
* Brazilian Portuguese language file
44
*
55
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6-
* @author Flávio Roberto Santos <flavio.barata@gmail.com>
7-
* @author Marcus D'Alencar <marcus_dalencar@yahoo.com.br>
6+
* @author Daniel "Nerun" Rodrigues <danieldiasr@gmail.com>
87
*/
9-
8+
109
// for the configuration manager
11-
$lang['size'] = 'tamanho padrão do avatar';
12-
$lang['rating'] = 'rating mínimo para os gravatars';
10+
$lang['namespace'] = 'Domínio para avatares locais';
11+
$lang['size'] = 'Tamanho padrão do avatar';
12+
$lang['rating'] = 'Rating mínimo para o gravatar';
13+
$lang['default'] = 'Tipo de gravatar padrão';
1314

1415
//Setup VIM: ex: et ts=2 enc=utf-8 :

plugin.info.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# General Plugin Info
22
base avatar
3-
author Michael Hamann, Michael Klier, Gina Haeussge
4-
email michael@content-space.de
5-
date 2017-08-25
3+
author Daniel Rodrigues, Michael Hamann, Gina Häußge, Michael Klier, Esther Brunner
4+
email danieldiasr@gmail.com
5+
date 2023-08-17
66
name Avatar
77
desc Displays avatar images
88
url https://www.dokuwiki.org/plugin:avatar

syntax.php

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,51 @@
1515
if(!defined('DOKU_INC')) die();
1616

1717
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
18-
require_once(DOKU_PLUGIN.'syntax.php');
1918

2019
class syntax_plugin_avatar extends DokuWiki_Syntax_Plugin {
2120

22-
function getType() { return 'substition'; }
23-
function getSort() { return 315; }
24-
25-
function connectTo($mode) {
26-
$this->Lexer->addSpecialPattern("{{(?:gr|)avatar>.+?}}",$mode,'plugin_avatar');
27-
}
28-
29-
function handle($match, $state, $pos, Doku_Handler $handler) {
30-
list($syntax, $match) = explode('>', substr($match, 0, -2), 2); // strip markup
31-
list($user, $title) = explode('|', $match, 2); // split title from mail / username
32-
33-
// Check alignment
34-
$ralign = (bool)preg_match('/^ /', $user);
35-
$lalign = (bool)preg_match('/ $/', $user);
36-
if ($lalign & $ralign) $align = 'center';
37-
else if ($ralign) $align = 'right';
38-
else if ($lalign) $align = 'left';
39-
else $align = NULL;
40-
41-
//split into src and size parameter (using the very last questionmark)
42-
list($user, $param) = explode('?', trim($user), 2);
43-
if (preg_match('/^s/', $param)) $size = 20;
44-
else if (preg_match('/^m/', $param)) $size = 40;
45-
else if (preg_match('/^l/', $param)) $size = 80;
46-
else if (preg_match('/^xl/', $param)) $size = 120;
47-
else $size = NULL;
48-
49-
return array($user, $title, $align, $size);
50-
}
51-
52-
function render($mode, Doku_Renderer $renderer, $data) {
53-
if ($mode == 'xhtml') {
54-
if ($my =& plugin_load('helper', 'avatar'))
55-
$renderer->doc .= '<span class="vcard">'.
56-
$my->getXHTML($data[0], $data[1], $data[2], $data[3]).
57-
'</span>';
58-
return true;
21+
function getType() { return 'substition'; }
22+
function getSort() { return 315; }
23+
24+
function connectTo($mode) {
25+
$this->Lexer->addSpecialPattern("{{(?:gr|)avatar>.+?}}",$mode,'plugin_avatar');
26+
}
27+
28+
function handle($match, $state, $pos, Doku_Handler $handler) {
29+
list($syntax, $match) = explode('>', substr($match, 0, -2), 2); // strip markup
30+
$one = explode('?', $match, 2); // [user|mail] ? [size]|[title]
31+
$two = explode('|', $one[0], 2); // [user] & [mail]
32+
$three = explode('|', $one[1], 2); // [size] & [title]
33+
$user = $two[0];
34+
$title = $three[1];
35+
$param = $three[0];
36+
37+
// Check alignment
38+
$ralign = (bool)preg_match('/^ /', $user);
39+
$lalign = (bool)preg_match('/ $/', $user);
40+
if ($lalign & $ralign) $align = 'center';
41+
else if ($ralign) $align = 'right';
42+
else if ($lalign) $align = 'left';
43+
else $align = NULL;
44+
45+
if (preg_match('/^s/', $param)) $size = 20;
46+
else if (preg_match('/^m/', $param)) $size = 40;
47+
else if (preg_match('/^l/', $param)) $size = 80;
48+
else if (preg_match('/^xl/', $param)) $size = 120;
49+
else $size = NULL;
50+
51+
return array($user, $title, $align, $size);
52+
}
53+
54+
function render($mode, Doku_Renderer $renderer, $data) {
55+
if ($mode == 'xhtml') {
56+
if ($my =& plugin_load('helper', 'avatar'))
57+
$renderer->doc .= '<span class="vcard">'.
58+
$my->getXHTML($data[0], $data[1], $data[2], $data[3]).
59+
'</span>';
60+
return true;
61+
}
62+
return false;
5963
}
60-
return false;
61-
}
6264
}
6365
// vim:ts=4:sw=4:et:enc=utf-8:

0 commit comments

Comments
 (0)