authorpic tags not saved in ep_cache_body

Found a bug? Tell us!!
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

authorpic tags not saved in ep_cache_body

Post by Oldy »

I'm sorry for my very bad English.
I'm sick... I want to view my local avatar within my posts. I have install plugins 'extended properties' and 'user profile'.
Avatar is displayed after I create new entry. But after editing and saving this entry I can't view avatar. Analizing mySQL table 'entryproperties' I saw that authorpic tags (<div class="serendipity_authorpic"> etc) not saved in ep_cache_body field after saving edited entry.

s9y v1.0b2, userprofile plugin v0.15

I need your help.

P.S. I don't understand why plugin displaying Gravatar's userpic by another way than local userpic. This way more right IMHO.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: authorpic tags not saved in ep_cache_body

Post by garvinhicking »

Hi!

In which order are the event plugins stacked? You must place the user profile plugin BEFORE the extended entry property plugin, because otherwise the cached version will not include the authorpic?

If the order is correct, I'll try to look at the plugin so please report back.
P.S. I don't understand why plugin displaying Gravatar's userpic by another way than local userpic. This way more right IMHO.
I'm not sure I understand what you mean? Gravatars are usually only meant for COMMENTs, not for entries themselves. That's why the gravatar plugin does not feel responsible for displaying author pictures in ENTRIES...?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

pligin's order

Post by Oldy »

Thanks for very fast answer.

About order you asked:

'plugins' DB table

sortorder, authorid, path

0, 0, 'serendipity_event_userprofiles'
1, 0, 'serendipity_event_unstrip_tags'
2, 0, ''
3, 0, ''
4, 0, ''
5, 0, ''
6, 0, ''
7, 0, 'serendipity_event_entryproperties'



Gravatars are usually only meant for COMMENTs, not for entries themselves. That's why the gravatar plugin does not feel responsible for displaying author pictures in ENTRIES...?
I meen that if I switch to 'Yes' 'Use Gravatar rather than local image' radio-button then authorpic (from www.gravatar.com) is displayed even I was edit the entry. But I want to use local image.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: pligin's order

Post by garvinhicking »

Hi!

Okay, I'll try to reproduce the ep_cache problem. Can you please give me a full listing of your plugins table? The paths are empty for plugins #2 to #6, so it would help me to know which those plugins are.
I meen that if I switch to 'Yes' 'Use Gravatar rather than local image' radio-button then authorpic (from www.gravatar.com) is displayed even I was edit the entry. But I want to use local image.
[/quote]

If you want to use the local image, then set "Use Gravatar rather than local image" to "No"...or do I still not understand you properly? :-)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

Post by Oldy »

I send full listing in html-file to you email.
If you want to use the local image, then set "Use Gravatar rather than local image" to "No"...or do I still not understand you properly?
Yes, you still not understand me properly :( .
I mean that setting to "Yes" resolve problem of correctly displayng authorpic. But I set this switch to 'No' because I wont use local image, not Gravatar. Why you can't repeat this feature for local image? What difference between these two methods to embed authorpic in entrypage?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

I tried to reproduce the problem, and created an entry having set to "Local image" and creating my authorpic. This is shown properly, also when I edit an entry - no matter if I have caching enabled or not.

So I suppose my general problem is to understand how you've set your plugin.

So, you do NOT want to use a local image? You want to show the gravatar for each author post? I'm afraid we're having a language barrier here...maybe you have a friend who could try to explain me your problem in "verbose english"? :-))

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

Post by Oldy »

I tried to reproduce the problem, and created an entry having set to "Local image" and creating my authorpic. This is shown properly, also when I edit an entry - no matter if I have caching enabled or not.
Authorpic not shown at all if I have not caching enabled.
Are you receive my email?
So, you do NOT want to use a local image?
:( No. I want.

Also I want to understand this thing.
Your plugin shows Gravatar by another method rather than local image, isn't it?
This method shown picture correctly no matter edited entry or not.

I haven't such friend, sorry.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
Authorpic not shown at all if I have not caching enabled.
Really? I thought you said if you set the option to "Local image" then it would show up!

Can you try to setup a second installation were you just install the entryproperties and userprofiles plugin and see if it works there? You have a lot of plugins installed; even though I think none of them should make confusion, it could still be that one of them is making a problem.
Also I want to understand this thing.
Your plugin shows Gravatar by another method rather than local image, isn't it?
This method shown picture correctly no matter edited entry or not.
No, the method to show a gravatar or local image are all the same:

Code: Select all

                    if (serendipity_db_bool($this->get_config('gravatar'))) {
                        $img = 'http://www.gravatar.com/avatar.php?'
                                . 'default=' . $this->get_config('gravatar_default','80')
                                . '&gravatar_id=' . md5($eventData['email'])
                                . '&size=' . $this->get_config('gravatar_size','80')
                                . '&border=&rating=' . $this->get_config('gravatar_rating','R');
                        $this->found_images[$eventData['author']] = '<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . htmlspecialchars($eventData['author']) . '" /><br>' . htmlspecialchars($eventData['author']) . '</div>';
                        $eventData['body'] = $this->found_images[$eventData['author']] . $eventData['body'];
                    } elseif (isset($this->found_images[$eventData['author']])) {
                        // Author image was already found previously. Display it.
                        $eventData['body'] = $this->found_images[$eventData['author']] . $eventData['body'];
                    } elseif ($img = serendipity_getTemplateFile('img/' . preg_replace('@[^a-z0-9]@i', '_', $eventData['author']) . '.' . $this->get_config('extension'))) {
                        // Author image exists, save it in cache and display it.
                        $this->found_images[$eventData['author']] = '<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . htmlspecialchars($eventData['author']) . '" /><br>' .htmlspecialchars($eventData['author']) . '</div>';
                        $eventData['body'] = $this->found_images[$eventData['author']] . $eventData['body'];
                    } else {
                         // No image found, do not try again in next article.
                        $this->found_images[$eventData['author']] = '';
                    }
What is your native language? Maybe I can find someone who can do translation for that, since I really have trouble understanding you....I'm really sorry!

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

Post by Oldy »

Really? I thought you said if you set the option to "Local image" then it would show up!
It's true. I mean if I set 'Allow to cache entries' to 'No' then userpic not showing ('Extended properties' plugin). But it's right, isn't it?


No, the method to show a gravatar or local image are all the same
Thanx, I get it.

My native language is Russian. But I think you understood me better than I speak. I'm very grateful for you. :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, actually the authorpic should always show, no matter if you set the Caching to Yes or No. Setting it to "no" should in all cases display the authorpic on the frontend! But then no "ep_cache_body" is created anymore.

So only if cachign is enabled, the ep_cache_body is populated/created! But on the frontend, the userpic should always show!
My native language is Russian. But I think you understood me better than I speak. I'm very grateful for you. :)
I'd really like to help, so I hope you're not mad at me with our language problems :) I know some russian serendipity contributors (they are mentioned in the language file) so maybe we can contact them to solve this more in depth if you like?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

Post by Oldy »

So only if cachign is enabled, the ep_cache_body is populated/created! But on the frontend, the userpic should always show!
I saw that userpic show up only if in the ep_cache_body contain string

<div class="serendipity_authorpic"... etc>
I thought this right. :(

so maybe we can contact them to solve this more in depth if you like?
Yes, I will do this.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

userpic is not contained in the "body" column of serendipity_entries, because it is only inserted there on call-time of Serendipity.

That means, the userprofile plugin takes care to insert the <div class="authorpic"> for each article time and again.

The caching plugin is there to now execute all this stuff over and over again, but to cache it in ep_cache_body - so this is only required when caching is turned on.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

Post by Oldy »

Dear Garvin!

I found a problem.

I'm russian and all of users our blog are russians. Their real names writing in russian alphabet, but lognames - in english. For example, my real name is Алексей (Alexej) and logname - 'negotiator' (don't laugh please :D).

In result $eventData['author'] return real names of author. This string in russian characters then transform to filename of userpic by expression preg_replace('@[^a-z0-9]@i', '_', $eventData['author']). So I get '_______.jpg'

Tell me please how I can get logname instead real user name?
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

Post by Oldy »

Dear Garvin!

I don't use PHP in my practice but I did follows. I have use global array from lang script and make transliteration for non-english strings.

Code: Select all

             case 'frontend_display_cache':
                    $this->showCommentcount($eventData);
		    $user_real_name = str_replace($GLOBALS['i18n_filename_from'], $GLOBALS['i18n_filename_to'], $eventData['author']);
and

Code: Select all

                    } elseif  ($img = serendipity_getTemplateFile('img/' . preg_replace('@[^a-z0-9]@i', '_', $user_real_name) . '.' . $this->get_config('extension'))) {
Thank you for useful discussion.
Oldy
Regular
Posts: 14
Joined: Sun Apr 30, 2006 11:57 pm

Post by Oldy »

Found another problem. Now after I built cache from admin panel userpic showing up twice :) . If I switch off caching - all right.
Post Reply