OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



2 q's: Date class & Get array of params from Request class

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

2 q's: Date class & Get array of params from Request class

Postby mark » Wed Sep 24, 2008 11:41 pm

1. Is there a Date object in OJS? I'm doing an extension and need to store date information (2008-02-30) and do date calculations (e.g., new_date = date + 30; dayOfWeek = $date->dayOfWeek(); $date->getMonth(), etc). If not, can anyone recommend a well designed open source Date class for php?

2. I have a series of checkboxes that the user can click
<input type="checkbox" name="id" value="100">
<input type="checkbox" name="id" value="102">
<input type="checkbox" name="id" value="103">

Is there a routine that returns an array of the values if the user checks multiple boxes? Request::getUserVar("id") only returns a string.
mark
 
Posts: 31
Joined: Fri Jul 11, 2008 10:57 am

Re: 2 q's: Date class & Get array of params from Request class

Postby mark » Thu Sep 25, 2008 1:11 am

Answer to 1:
http://apptools.com/phptools/forms/forms3.php
Short answer is that the HTML checkbox name attribute needs to end with [] e.g., name="id[]"
Code is running now.

The Date class is more difficult... I'm not sure if what've found on-line is of the quality of the OJS code.
mark
 
Posts: 31
Joined: Fri Jul 11, 2008 10:57 am

Re: 2 q's: Date class & Get array of params from Request class

Postby asmecher » Thu Sep 25, 2008 8:50 am

Hi Mark,

We use Unix-style timestamps (i.e. the number of seconds since the Unix epoch), which is what you'll get with PKP's time() and strtotime() functions. They can be manipulated with relative ease and formatted using the PHP strftime function and Smarty date_format modifier. Math on these numbers is as simple as:

$currentTime = time();
$secondsPerDay = 60 * 60 * 24;
$currentTimePlusThirtyDays = $currentTime + ($secondsPerDay * 30);

The strftime function (see http://ca3.php.net/manual/en/function.strftime.php) will get you the day of the week etc.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: 2 q's: Date class & Get array of params from Request class

Postby mark » Thu Sep 25, 2008 3:40 pm

Is there rhyme or reason why no date class has been created in ~/classes/core/?
It seems like a common enough object that it would be a shoo-in for a Model Class. Although maybe in OJS, dates manipulation isn't extensive?
mark
 
Posts: 31
Joined: Fri Jul 11, 2008 10:57 am

Re: 2 q's: Date class & Get array of params from Request class

Postby asmecher » Thu Sep 25, 2008 7:01 pm

Hi Mark,

That's right -- we haven't had much need for it. OCS does a little more date manipulation than OJS, but still, not enough that we've gone ahead and added a date class.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 2 guests