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
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

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: 8347
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: 8347
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 8 guests