Advanced search  

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]

Pages: [1]   Go Down

Author Topic: hardcoded lanuage in cpmfetch  (Read 9894 times)

0 Members and 1 Guest are viewing this topic.

jerx

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
hardcoded lanuage in cpmfetch
« 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?
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: hardcoded lanuage in cpmfetch
« Reply #1 on: January 24, 2007, 07:01:23 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? 













Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: hardcoded lanuage in cpmfetch
« Reply #2 on: January 25, 2007, 07:45:41 am »

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.

Quote
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? 

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.).
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: hardcoded lanuage in cpmfetch
« Reply #3 on: January 25, 2007, 06:56:27 pm »


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

Code: [Select]
$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







Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: hardcoded lanuage in cpmfetch
« Reply #4 on: January 25, 2007, 10:26:01 pm »

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.

Code: [Select]
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
  <tr>
    <th>{RECENTUPDATEDALBUMS_EXPLAIN}</th>
  </tr>
{RECENTUPDATEDALBUMS}
</table>
Logged

jerx

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: hardcoded lanuage in cpmfetch
« Reply #5 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!
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: hardcoded lanuage in cpmfetch
« Reply #6 on: January 25, 2007, 11:11:03 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:

Quote
Since somedate we've added # pictures

Becomes:

Quote
Since

Quote
we've added

Quote
pictures

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


Quote
Since
code to get date
Quote
we've added

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

Quote
pictures


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








Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: hardcoded lanuage in cpmfetch
« Reply #7 on: January 26, 2007, 12:02:00 am »

I get this error:

Quote
Warning: 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:
Code: [Select]
// 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.
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: hardcoded lanuage in cpmfetch
« Reply #8 on: January 26, 2007, 12:09:31 am »

I get this error:

I have added these to my phpbb file:
Code: [Select]
// 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

Code: [Select]
$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.



Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: hardcoded lanuage in cpmfetch
« Reply #9 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:

Code: [Select]
// 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')),
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: hardcoded lanuage in cpmfetch
« Reply #10 on: January 26, 2007, 12:36:05 am »

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

Code: [Select]
// 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
Code: [Select]
$objCpm->cpm_setReturnType("html");
Which thing that you output is saying array?

Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: hardcoded lanuage in cpmfetch
« Reply #11 on: January 26, 2007, 12:39:39 am »


You can remove this, html is the default
Code: [Select]
$objCpm->cpm_setReturnType("html");
Which thing that you output is saying array?



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

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: hardcoded lanuage in cpmfetch
« Reply #12 on: February 21, 2007, 05:52:20 am »

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

Sorry, lost track of this one...

Is this still an issue?
Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: hardcoded lanuage in cpmfetch
« Reply #13 on: February 22, 2007, 01:33:25 am »

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 15 queries.