hardcoded lanuage in cpmfetch hardcoded lanuage in cpmfetch
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

hardcoded lanuage in cpmfetch

Started by jerx, January 24, 2007, 06:18:40 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

jerx

I am using 1.9.7 and it works fine. The only problem I have is that cpm_showAlbumsUpdatedOverLastDays($numberOfDays,$options="") has some hard coded language. This is the only function I use, but I think there are other functions which might have the same problem.

I like to adjust the words to the selected/default language of my phpbb forum. If that is not possible, it would be nice to use the cpg language setting. I tried the ladder, but the language definition had not been recognized.

Can you please help me on this?

vuud

Quote from: jerx on January 24, 2007, 06:18:40 PM
I am using 1.9.7 and it works fine. The only problem I have is that cpm_showAlbumsUpdatedOverLastDays($numberOfDays,$options="") has some hard coded language. This is the only function I use, but I think there are other functions which might have the same problem.

I like to adjust the words to the selected/default language of my phpbb forum. If that is not possible, it would be nice to use the cpg language setting. I tried the ladder, but the language definition had not been recognized.

Can you please help me on this?

First, thanks for moving this... 

So there is only one part that is hard coded in there right?  The "we've added # photos since #" part...

Any you are looking to display that in how many languages? 

The first step is determining the current language... I can't imagine that being too hard. 

The next step is providing the different translations... 

My thoughts here are that I can change that function so that you pass it in a "format" for that text.  What you pass in would depend on what language you want.

I can also give you a function that would return the CPG default language if that would help.

Would that help? 













Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jerx

Quote from: vuud on January 24, 2007, 07:01:23 PM
So there is only one part that is hard coded in there right?  The "we've added # photos since #" part...
Any you are looking to display that in how many languages?

The first step is determining the current language... I can't imagine that being too hard. 

Yes, that is the phrase I like to translate into German. I only use German and English on my site. My default language is German.

QuoteThe next step is providing the different translations... 

My thoughts here are that I can change that function so that you pass it in a "format" for that text.  What you pass in would depend on what language you want.

I can also give you a function that would return the CPG default language if that would help.

Would that help? 

I am not sure if I understood you correctly. Is this all about one function, which returns the default language or was the first part another function?

I would rather prefer this solution:
Split the function into various parts, so that it does not return the whole block including table tags and language phrase, but only the contents of the block (images and stats of the images) without any language. This way I could add the functions into a formatted block on my homepage and add the translation to my phpbb files. But I am not sure if this will have a negative impact on speed, because cpmfetch has to be called three times (number of photos, date of update and photos).

If this is not possible to do, your function should be extended a little bit. It should not only return the phrase in default language, but also in language set by user, so that the phrase is displayed in the same language the coppermine gallery is displayed. This is not optimal, because there might be a mix of two languages on my start page (I haven' t been able to figure out how to make coppermine using the same language as my phpbb forum. Right now I have set cpg to detect the browser language automatically.).

vuud

Quote from: jerx on January 25, 2007, 07:45:41 AM

I would rather prefer this solution:
Split the function into various parts, so that it does not return the whole block including table tags and language phrase, but only the contents of the block (images and stats of the images) without any language. This way I could add the functions into a formatted block on my homepage and add the translation to my phpbb files. But I am not sure if this will have a negative impact on speed, because cpmfetch has to be called three times (number of photos, date of update and photos).

If this is not possible to do, your function should be extended a little bit. It should not only return the phrase in default language, but also in language set by user, so that the phrase is displayed in the same language the coppermine gallery is displayed. This is not optimal, because there might be a mix of two languages on my start page (I haven' t been able to figure out how to make coppermine using the same language as my phpbb forum. Right now I have set cpg to detect the browser language automatically.).

I think this may be a solution...

If you call it like so


$objCpm->cpm_setReturnType("resultset");
$arrayOfRows = $objCpm->cpm_showAlbumsUpdatedOverLastDays( ....


The $arrayOfRows should contain the data, use print_r($arrayOfRows) to get an idea how its formatted.
This works with most functions and allows for easy extensibility of cpmfetch (although not well documented).

To be honest, I have not tried it on this function - so if its not too good, let me know and I can improve it.

Vuud







Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jerx

Ok, I managed it, but I did not use the solution you provided (I did not know how to process the array). I deleted the language and table tags from cpmfetch.php, so that the html output had only the pictures in it. Then I added a table and language variables to my homepage and put the pictures into the table.

<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
  <tr>
    <th>{RECENTUPDATEDALBUMS_EXPLAIN}</th>
  </tr>
{RECENTUPDATEDALBUMS}
</table>

jerx

I forgot to mention that this is probably only suitable for me. I lost some information cpmfetch provided (added since which date and picture count).

Thanks for your help anyway!

vuud

Quote from: jerx on January 25, 2007, 10:39:06 PM
I forgot to mention that this is probably only suitable for me. I lost some information cpmfetch provided (added since which date and picture count).

Thanks for your help anyway!

Well, PHP's foreach function makes it pretty easy.  All the tough PHP cpmfetch does for you.

Anyway, as for the date and stuff...

If you can break up your language stuff into two parts like so:

QuoteSince somedate we've added # pictures

Becomes:

QuoteSince

Quotewe've added

Quotepictures

You can add the calls in to get the info...


QuoteSince
code to get date
Quotewe've added

<?php $objCpm->getMediaAddedSince($timestamp); ?>

Quotepictures


But of course, not all languages order stuff the same way...








Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jerx

I get this error:

QuoteWarning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /gallery/cpmfetch/cpmfetch_dao.php on line 946

I have added these to my phpbb file:
// cpmfetch
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setDateFormat("d.m.Y");
$objCpm->cpm_setReturnType("html");

$template->assign_vars(array(
'RECENTPICDATE' => date("l, F j Y",strtotime("-" . $numberOfDays . " day")),
'RECENTPICAMOUNT' => $objCpm->getMediaAddedSince($timestamp),
'RECENTUPDATEDALBUMS' => $objCpm->cpm_showAlbumsUpdatedOverLastDays(10, array('alttag' => '%a %w', 'subtitle' => '%a, %f', 'imagelink' => 'album')),


The error is produced by "'RECENTPICAMOUNT' => $objCpm->getMediaAddedSince($timestamp),".

I want to thank you for spending so much time on this problem. It is really nice of you. The solution without the number of pictures is good enough for me, so there is no real need to solve the above error. I can live without it.

vuud

Quote from: jerx on January 26, 2007, 12:02:00 AM
I get this error:

I have added these to my phpbb file:
// cpmfetch
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setDateFormat("d.m.Y");
$objCpm->cpm_setReturnType("html");

$template->assign_vars(array(
'RECENTPICDATE' => date("l, F j Y",strtotime("-" . $numberOfDays . " day")),
'RECENTPICAMOUNT' => $objCpm->getMediaAddedSince($timestamp),
'RECENTUPDATEDALBUMS' => $objCpm->cpm_showAlbumsUpdatedOverLastDays(10, array('alttag' => '%a %w', 'subtitle' => '%a, %f', 'imagelink' => 'album')),


The error is produced by "'RECENTPICAMOUNT' => $objCpm->getMediaAddedSince($timestamp),".

I want to thank you for spending so much time on this problem. It is really nice of you. The solution without the number of pictures is good enough for me, so there is no real need to solve the above error. I can live without it.

I have to apologize about that... i assumed a little too much when I wrote that.  I extracted this code from the cpmfetch.php file


$lwd = getdate(strtotime("-" . $numberOfDays . " day"));
$verbosedate = date("l, F j Y",strtotime("-" . $numberOfDays . " day"));
$timestamp = $lwd[0];



The $numberOfDays should be however many days you want to go back
The $verbosedate variable will them hold a formatted day representing that many days back
$timestamp can them be used in that function I sent you.

Hope that helps.



Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jerx

The error is gone now, but it only displays the word ARRAY instead of displaying a number. My code looks like this now:

// cpmfetch
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setDateFormat("d.m.Y");
$objCpm->cpm_setReturnType("html");

$lwd = getdate(strtotime("-" . $numberOfDays . " day"));
$verbosedate = date("l, F j Y",strtotime("-" . $numberOfDays . " day"));
$timestamp = $lwd[0];

$template->assign_vars(array(
'RECENTPICDATE' => date("l, F j Y",strtotime("-" . $numberOfDays . " day")),
'RECENTPICAMOUNT' => $objCpm->getMediaAddedSince($timestamp),
'RECENTUPDATEDALBUMS' => $objCpm->cpm_showAlbumsUpdatedOverLastDays(10, array('alttag' => '%a %w', 'subtitle' => '%a, %f', 'imagelink' => 'album')),

vuud

Quote from: jerx on January 26, 2007, 12:32:14 AM
The error is gone now, but it only displays the word ARRAY instead of displaying a number. My code looks like this now:

// cpmfetch
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setDateFormat("d.m.Y");
$objCpm->cpm_setReturnType("html");

$lwd = getdate(strtotime("-" . $numberOfDays . " day"));
$verbosedate = date("l, F j Y",strtotime("-" . $numberOfDays . " day"));
$timestamp = $lwd[0];

$template->assign_vars(array(
'RECENTPICDATE' => date("l, F j Y",strtotime("-" . $numberOfDays . " day")),
'RECENTPICAMOUNT' => $objCpm->getMediaAddedSince($timestamp),
'RECENTUPDATEDALBUMS' => $objCpm->cpm_showAlbumsUpdatedOverLastDays(10, array('alttag' => '%a %w', 'subtitle' => '%a, %f', 'imagelink' => 'album')),



You can remove this, html is the default
$objCpm->cpm_setReturnType("html");

Which thing that you output is saying array?

Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jerx

Quote from: vuud on January 26, 2007, 12:36:05 AM

You can remove this, html is the default
$objCpm->cpm_setReturnType("html");

Which thing that you output is saying array?



This:
'RECENTPICAMOUNT' => $objCpm->getMediaAddedSince($timestamp),

vuud

Quote from: jerx on January 26, 2007, 12:39:39 AM
This:
'RECENTPICAMOUNT' => $objCpm->getMediaAddedSince($timestamp),

Sorry, lost track of this one...

Is this still an issue?
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

jerx

It is not a problem on my setup, because I stripped off the language in that function and defined the language in my phpbb files.