diff --git a/README b/README.md similarity index 78% rename from README rename to README.md index 7d7f5ff..1890271 100644 --- a/README +++ b/README.md @@ -1,4 +1,4 @@ -====== Avatar Plugin for DokuWiki ====== +# Avatar Plugin for DokuWiki All documentation for the Avatar Plugin is available online at: @@ -7,4 +7,6 @@ All documentation for the Avatar Plugin is available online at: (c) 2005 - 2007 by Esther Brunner (c) 2008 - 2009 by Gina Häußge, Michael Klier (c) 2013 by Michael Hamann +(c) 2023 by Daniel Dias Rodrigues + See COPYING for license info. diff --git a/helper.php b/helper.php index 2a02a9a..2ebb0cc 100644 --- a/helper.php +++ b/helper.php @@ -61,8 +61,8 @@ function _getAvatarURL($user, &$title, &$size) { $ns = $this->getConf('namespace'); $formats = array('.png', '.jpg', '.gif'); foreach ($formats as $format) { - $user_img = mediaFN($ns.':'.$user.$format); - $name_img = mediaFN($ns.':'.$name.$format); + if(isset($user)) $user_img = mediaFN($ns.':'.$user.$format); + if(isset($name)) $name_img = mediaFN($ns.':'.$name.$format); if(@file_exists($user_img)) {; $src = ml($ns.':'.$user.$format, array('w' => $size, 'h' => $size)); break; diff --git a/lang/en/settings.php b/lang/en/settings.php index 26858b7..d576fb2 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -7,9 +7,9 @@ */ // for the configuration manager -$lang['namespace'] = 'namespace for local avatars'; -$lang['size'] = 'default size of avatar'; -$lang['rating'] = 'minimum rating for gravatars'; -$lang['default'] = 'type of default gravatars'; +$lang['namespace'] = 'Namespace for local avatars'; +$lang['size'] = 'Default size of avatar'; +$lang['rating'] = 'Minimum rating for gravatars'; +$lang['default'] = 'Type of default gravatars'; -//Setup VIM: ex: et ts=2 enc=utf-8 : \ No newline at end of file +//Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/lang/pt-br/settings.php b/lang/pt-br/settings.php index fe37b8f..72a9f8c 100644 --- a/lang/pt-br/settings.php +++ b/lang/pt-br/settings.php @@ -1,14 +1,15 @@ - * @author Marcus D'Alencar + * @author Daniel "Nerun" Rodrigues */ - + // for the configuration manager -$lang['size'] = 'tamanho padrão do avatar'; -$lang['rating'] = 'rating mínimo para os gravatars'; +$lang['namespace'] = 'Domínio para avatares locais'; +$lang['size'] = 'Tamanho padrão do avatar'; +$lang['rating'] = 'Rating mínimo para o gravatar'; +$lang['default'] = 'Tipo de gravatar padrão'; //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/plugin.info.txt b/plugin.info.txt index 490de77..bee43d0 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,8 +1,8 @@ # General Plugin Info base avatar -author Michael Hamann, Michael Klier, Gina Haeussge -email michael@content-space.de -date 2017-08-25 +author Daniel Rodrigues, Michael Hamann, Gina Häußge, Michael Klier, Esther Brunner +email danieldiasr@gmail.com +date 2023-08-17 name Avatar desc Displays avatar images url https://www.dokuwiki.org/plugin:avatar diff --git a/syntax.php b/syntax.php index b5006e0..85b0f03 100644 --- a/syntax.php +++ b/syntax.php @@ -15,49 +15,51 @@ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); -require_once(DOKU_PLUGIN.'syntax.php'); class syntax_plugin_avatar extends DokuWiki_Syntax_Plugin { - function getType() { return 'substition'; } - function getSort() { return 315; } - - function connectTo($mode) { - $this->Lexer->addSpecialPattern("{{(?:gr|)avatar>.+?}}",$mode,'plugin_avatar'); - } - - function handle($match, $state, $pos, Doku_Handler $handler) { - list($syntax, $match) = explode('>', substr($match, 0, -2), 2); // strip markup - list($user, $title) = explode('|', $match, 2); // split title from mail / username - - // Check alignment - $ralign = (bool)preg_match('/^ /', $user); - $lalign = (bool)preg_match('/ $/', $user); - if ($lalign & $ralign) $align = 'center'; - else if ($ralign) $align = 'right'; - else if ($lalign) $align = 'left'; - else $align = NULL; - - //split into src and size parameter (using the very last questionmark) - list($user, $param) = explode('?', trim($user), 2); - if (preg_match('/^s/', $param)) $size = 20; - else if (preg_match('/^m/', $param)) $size = 40; - else if (preg_match('/^l/', $param)) $size = 80; - else if (preg_match('/^xl/', $param)) $size = 120; - else $size = NULL; - - return array($user, $title, $align, $size); - } - - function render($mode, Doku_Renderer $renderer, $data) { - if ($mode == 'xhtml') { - if ($my =& plugin_load('helper', 'avatar')) - $renderer->doc .= ''. - $my->getXHTML($data[0], $data[1], $data[2], $data[3]). - ''; - return true; + function getType() { return 'substition'; } + function getSort() { return 315; } + + function connectTo($mode) { + $this->Lexer->addSpecialPattern("{{(?:gr|)avatar>.+?}}",$mode,'plugin_avatar'); + } + + function handle($match, $state, $pos, Doku_Handler $handler) { + list($syntax, $match) = explode('>', substr($match, 0, -2), 2); // strip markup + $one = explode('?', $match, 2); // [user|mail] ? [size]|[title] + $two = explode('|', $one[0], 2); // [user] & [mail] + $three = explode('|', $one[1], 2); // [size] & [title] + $user = $two[0]; + $title = $three[1]; + $param = $three[0]; + + // Check alignment + $ralign = (bool)preg_match('/^ /', $user); + $lalign = (bool)preg_match('/ $/', $user); + if ($lalign & $ralign) $align = 'center'; + else if ($ralign) $align = 'right'; + else if ($lalign) $align = 'left'; + else $align = NULL; + + if (preg_match('/^s/', $param)) $size = 20; + else if (preg_match('/^m/', $param)) $size = 40; + else if (preg_match('/^l/', $param)) $size = 80; + else if (preg_match('/^xl/', $param)) $size = 120; + else $size = NULL; + + return array($user, $title, $align, $size); + } + + function render($mode, Doku_Renderer $renderer, $data) { + if ($mode == 'xhtml') { + if ($my =& plugin_load('helper', 'avatar')) + $renderer->doc .= ''. + $my->getXHTML($data[0], $data[1], $data[2], $data[3]). + ''; + return true; + } + return false; } - return false; - } } // vim:ts=4:sw=4:et:enc=utf-8: