Giter Site home page Giter Site logo

plugin-avatar's People

Contributors

araname avatar foosel avatar lpaulsen93 avatar michitux avatar mogoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plugin-avatar's Issues

Undefined array keys and FIXES

My system

  • 2022-07-31a "Igor"
  • PHP 8.1
  • Plugin Avatar 2017-08-25

Warnings

Not copy / paste:

These happens if [size] & [title] are not provided:
    Undefined array key 1 in .../lib/plugins/avatar/syntax.php on line 31
    Undefined array key 1 in .../lib/plugins/avatar/syntax.php on line 4
These are uncommon and happens when $user and or $name are nulls:
    Lines 64 and 65

Fixes

syntax.php, starting at line 29:

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

Change to:

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

helper.php, lines 64 and 65:

        $user_img = mediaFN($ns.':'.$user.$format);
        $name_img = mediaFN($ns.':'.$name.$format);

Change to:

        if(isset($user)) {
            $user_img = mediaFN($ns.':'.$user.$format);
        }
        if(isset($name)) {
            $name_img = mediaFN($ns.':'.$name.$format);
        }

Please update version

It seems that the PR about different types of avatars has been merged but the version was not updated.
At least my DokuWiki installation didn't show any alert about the change.
I had to uninstall the plugin and install it again to get the changes.

Feature: control over fallback order

(Taken from the discussion at https://www.dokuwiki.org/plugin:avatar)

"Right now it seems that the order is Look for the avatar fileGenerate the monster ID (via gravatar)Use the default images (via gravatar)Get the gravatar. I don't want gravatar to see the image requests, but I'm sure that some people don't mind/care - to each his own. So, two things: don't talk to gravatar if you don't need to, and I'd like to be able to swap the fallback order in the config menu.

"Here is how I would do it in skeleton code:-

$fallbacks   = explode( ',', $this->getConf( 'fallback' ) );
$fallbacks[] = 'default';  // Make sure that there is a successful case
 
$src = false;
foreach ( $fallbacks as $fb )
{
    switch ( trim($fb) )
    {
        case 'localimage':
            // check first if a local image for the given user exists
            break;
 
        case 'monsterid':
            // build the URL for the local monster id
            break;
 
        case 'gravatar':
            // build the URL for the gravatar
            break;
 
        case 'default':
        default:
            // fall back to the fixed image sizes
    }
 
    if ( $src !== false )
        break;
}

"Hence, I can get what I achieve by setting $conf['fallback'] = 'localimage', and the current way by setting it to localimage,gravatar."

– Andy Turner 2009-07-14 15:10

Problem with case sensitivity in e-mail

I'm not sure, if dokuwiki self allow to enter user e-mails case sensitive, but we use external auth skript and supplied e-mail are exactly as users saved them. In this case, monster ids are shown instead of correct gravatar.

--- helper.php.old  2009-07-15 19:21:17.000000000 +0200
+++ helper.php  2009-07-15 19:21:14.000000000 +0200
@@ -72,7 +72,7 @@
     }

     if (!$src) {
-      $seed = md5($mail);
+      $seed = md5(strtolower($mail));

       if (function_exists('imagecreatetruecolor')) {
         // we take the monster ID as default

Feature: Allow @USER@ token in namespace configuration

(Taken from the discussion at https://www.dokuwiki.org/plugin:avatar)

"Instead of avatars coming from a fixed namespace, I would like to be able to specify a tokenized filename for the avatar. For example, I have my DW set up so that each user has a “user namespace” in which they have full permissions, and I would like that avatar to come from that namespace.

"This is a lot easier to manage since there is no a-priori avatar, and thus ACL permission cannot be granted to upload the file - I want users to be able to change their own avatars without other users being able to; since you can't grant delete permission to a namespace, there is no way to stop users overwriting each others' avatars unless they are in separate protected namespaces.

"This can be achieved by changing the namespace conf setting so that it looks something like user/@USER@/avatar (perhaps even renaming the configuration setting so that it is called filename, since that is a more meaningful description of the setting under this proposal). This is then resolved in _getAvatarURL into the right form, e.g. user/my_user_name/avatar, and then the files user/my_user_name/avatar.jpg etc are searched for.

"i.e. changing the line $avatar = $this→getConf('namespace').':'.$user; to read

$avatar = str_replace( '@USER@', $user, $this->getConf('filename') );

"Of course, the status quo can be achieved through this new system also, by setting the namespace/filename conf setting to user/@USER@."

– Andy Turner 2009-07-14 15:10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.