PHP Classes

oCalendarPicker: Display calendars to pick dates for form inputs

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 59%Total: 1,182 All time: 3,202 This week: 110Up
Version License PHP version Categories
ocalendarpicker 1GNU Lesser Genera...5HTML, PHP 5, Time and Date
Description 

Author

This class can be used to display calendars to pick dates for form inputs.

It can generate HTML and Javascript to display an icon that when clicked will display a calendar to let the user choose a date.

The chosen date is used to fill a given text input in a given date format.

The text for the week days and month names is configurable.
Hightlight current selected date

Output is w3c compliant

Picture of Mathieu Lagana
Name: Mathieu Lagana <contact>
Classes: 2 packages by
Country: ???
Age: 47
All time rank: 1818
Week rank: 312 Up

Recommendations

date picker from forms
Pick a date in form

Example

<?php
 
/**
  *
  * Parameters documentation
  *
  * $aCalendarParams=array(
  * "iAction" => int : 0=>reloadCurrentPage with get param sDate,
  * 1=>fill field sFieldName
  * "sFieldName" => string : Id of field to fill (needed if iAction=1)
  * "iStyle" => int : 0=>display calendar,
  * 1=>display div on icon click
  * "sIconPath" => strin : Path Of Icon If Needed (needed if iStyle=1)
  * "aMonthNames" => array : array of localized monthes name
  * "aDaysNames" => array : array of localized days name
  * "sDateFormat" => string : outpu format in php date() function like syntax (needed if iAction=1)
  * );
  *
  *
  * Instanciation Documentation
  *
  * new oCalendarPicker($sNameInstance,$sDate, $aParams,$iUpdate=0,$sPath);
  *
  * $sNameInstance => string : Name for container div for calendar. Need to be unique in final document.
  * $sDate => string : Current date of instance
  * $aParams => array : Option for generation (see parameters documentation)
  * $iUpdate => int : Display for first time or Update exsiting 0=>display, 1=update (used by ajax request)
  * $sPath => string : path of current page (used by ajax request)
  *
  *
  */
 
require_once("./class/class.oCalendarPicker.php");
    
$aMonthNames=array(
        
"FR"=>array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"),
        
"EN"=>array("January","February","March","April","May","June","July","August","September","October","November","December")
     );
    
$aDaysNames=array(
        
"FR"=>array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"),
        
"EN"=>array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
    );
    
$sDateFormat=array(
        
"FR"=>"d/m/Y",
        
"EN"=>"Y-m-d"
   
);
   
   
$sDate=(!empty($_GET['sDate']))?$_GET['sDate']:date("Ymd");
?>


<html>
 <head>
 <script src="js/calendar.js" type="text/javascript"></script>
<link href="css/calendar.css" rel="stylesheet" type="text/css"/>

 </head>
 <body>
 <table cellspacing="0" cellpadding="30" border="1">
 <tr>
 <td>&nbsp;</td>
 <td>Reload Current Page</td>
 <td>Fill a text Field</td>
 </tr>
 <tr>
 <td>Calendar Display</td>
 <td><?php
 
/**
  *
  * Display Calendar and reload page
  *
  *
  */
 
$aCalendarParams=array(
 
"sIconPath" => "./img/calendar.png",
 
"iAction" => 0, //0=>reloadCurrentPage with get param sDate, 1=>fill field sFieldName
 
"sFieldName" => "",
 
"iStyle" => 0, //0=>display calendar, 1=>display div on icon click
 
"aMonthNames" => $aMonthNames["FR"],
 
"aDaysNames" => $aDaysNames["FR"],
 
"sDateFormat" => $sDateFormat["FR"]

 );
 new
oCalendarPicker("calFixe1",$sDate,$aCalendarParams);
     
?>
</td>
         <td>
 <?php
 
/**
  *
  * Display Calendar and fill field
  *
  *
  */
 
$aCalendarParams=array(
 
"sIconPath" => "./img/calendar.png",
 
"iAction" => 1, //0=>reloadCurrentPage with get param sDate, 1=>fill field sFieldName
 
"sFieldName" => "Date1",
 
"iStyle" => 0, //0=>display calendar, 1=>display div on icon click
 
"aMonthNames" => $aMonthNames["FR"],
 
"aDaysNames" => $aDaysNames["FR"],
 
"sDateFormat" => $sDateFormat["FR"]

 );
new
oCalendarPicker("calFixe2",$sDate,$aCalendarParams);
     
?><input type="text" name="Date1" id="Date1"/><br/>French Format
      </td>
 </tr>
 <tr>
     <td>Image and div</td>
     <td>
     <?php
 
/**
  *
  * Display Icon and reload page
  *
  *
  */
 
$aCalendarParams=array(
 
"sIconPath" => "./img/calendar.png",
 
"iAction" => 0, //0=>reloadCurrentPage with get param sDate, 1=>fill field sFieldName
 
"sFieldName" => "",
 
"iStyle" => 1, //0=>display calendar, 1=>display div on icon click
 
"aMonthNames" => $aMonthNames["FR"],
 
"aDaysNames" => $aDaysNames["FR"],
 
"sDateFormat" => $sDateFormat["FR"]

 );
new
oCalendarPicker("calFixe3",$sDate,$aCalendarParams);
     
?>
</td>
       <td
       <?php
 
/**
  *
  * Display Icon and Fill Field
  *
  *
  */
 
$aCalendarParams=array(
 
"sIconPath" => "./img/calendar.png",
 
"iAction" => 1, //0=>reloadCurrentPage with get param sDate, 1=>fill field sFieldName
 
"sFieldName" => "Date2",
 
"iStyle" => 1, //0=>display calendar, 1=>display div on icon click
 
"aMonthNames" => $aMonthNames["EN"],
 
"aDaysNames" => $aDaysNames["EN"],
 
"sDateFormat" => $sDateFormat["EN"]

 );
 new
oCalendarPicker("calFixe4",$sDate,$aCalendarParams);
     
?><input type="text" name="Date2" id="Date2"/><br/>English Format</td>
 </tr>
 </table>
 
     
</body>
</html>


Screenshots  
  • screenshot.png
  Files folder image Files  
File Role Description
Files folder imageclass (1 file)
Files folder imageajax (1 file)
Files folder imageimg (1 file)
Files folder imagejs (1 file)
Files folder imagecss (1 file)
Accessible without login Plain text file index.php Example Documentation and example

  Files folder image Files  /  class  
File Role Description
  Plain text file class.oCalendarPicker.php Class the class source

  Files folder image Files  /  ajax  
File Role Description
  Plain text file calendarUpdate.php Aux. Ajax update script

  Files folder image Files  /  img  
File Role Description
  Image file calendar.png Icon DatePicker icon

  Files folder image Files  /  js  
File Role Description
  Plain text file calendar.js Data javascript utilty

  Files folder image Files  /  css  
File Role Description
  Plain text file calendar.css Data CSS

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,182
This week:0
All time:3,202
This week:110Up
User Ratings User Comments (3)
 All time
Utility:87%StarStarStarStarStar
Consistency:79%StarStarStarStar
Documentation:-
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1224