5.5. phpMyEdit-calpopup


This extension is obsolete. Use integrated phpMyEdit-mce-cal extension instead.

phpMyEdit-calpopup extension provides support for a calendar popup helper to be put on any text field. This extension uses the free jsCalendar code from http://dynarch.com/mishoo/calendar.epl website.

The requirement is a properly installed jsCalendar script. All browsers supported by jsCalendar are supported by this extension.

This extension enables the display of a popup calendar selection against selected fields. In order to use it, you should:

  1. Load the jsCalendar scripts in the <head>...</head> section of your phpMyEdit calling program, substituting the correct paths:

    Example 5-3. CalPopup javascript

     <script type="text/javascript" src="js/calendar.js"></script> <script type="text/javascript" src="js/lang/calendar-en.js"></script> <script type="text/javascript" src="js/calendar-setup.js"></script>

  2. Choose your preferred jsCalendar CSS file (see jsCalendar documentation) and add the following in the <head>...</head> section of your phpMyEdit calling program, substituting the correct path:

    Example 5-4. CalPopup javascript

     <link rel="stylesheet" type="text/css" media="screen"         href="css/calendar-system.css">


    To avoid an unwanted side effect in the CSS style produced by phpMyEditSetup.php, add a 'width:auto' property into the '.calendar table' entry in your selected jsCalendar style sheet.

  3. Call to phpMyEdit-calpopup.class.php instead of phpMyEdit.class.php.

    Example 5-5. CalPopup extension enabling

     require_once 'extensions/phpMyEdit-calpopup.class.php'; new phpMyEdit_calpopup($opts);

  4. Add calendar parameter to the field definitions where you want a calendar popup in your phpMyEdit calling program.

    Example 5-6. CalPopup field enabling

    $opts['fdd']['col_name'] = array(  'name'     => 'Column',  'select'   => 'T',  'options'  => 'ACPVD',  'required' => true,  'calendar' => true );
    This is will display a button next to the field which pops up a calendar when clicked. If that field has a strftimemask parameter set, it will use this for the date format.

    For more advanced usage, you can set the calendar parameter to an array of valid jsCalendar Calendar.setup options (see jSCalendar document for details). Note that not all of these options make sense to use in phpMyEdit, and some of them will actively break the function.

    Example 5-7. CalPopup advanced field

    $opts['fdd']['col_name'] = array(  'name'     => 'Column',  'select'   => 'T',  'options'  => 'ACPVD',  'required' => true,  'calendar' => array(    'ifFormat'    => '%Y/%m/%d', // defaults to the ['strftimemask']    'firstDay'    => 1,          // 0 = Sunday, 1 = Monday    'singleClick' => true,       // single or double click to close    'weekNumbers' => true,       // Show week numbers    'showsTime'   => false,      // Show time as well as date    'timeFormat'  => '24',       // 12 or 24 hour clock    'label'       => '...',      // button label (used by phpMyEdit)    'date'        => '2003-12-19 10:00' // Initial date/time for popup                                        // (see notes below)  ) );

The popup will normally set the initial value to the current field value or to current date/time. date option will always override this, even if there is a current date/time value in the field. If you want a default value only if the field is currently empty, use the phpMyEdit default option.

Only the options listed above may be set by the user, any other options will be ignored.

This extension is contribution of Adam Hammond from London.

Bootstrap phpMyEdit PHP Form Generator