__FILE__, 'name' => 'SFCustomDateInput', 'version' => '0.1', 'author' => array( 'Patrick Nagel' ), 'description' => 'Provides a custom date (customdate) and a custom datetime (customdatetime) input for Semantic Forms', 'descriptionmsg' => 'SFCustomDateInput-desc', ); $wgExtensionFunctions[] = 'sfCustomDateInputSetup'; function sfCustomDateInputSetup() { global $wgParser, $wgExtensionCredits; // add the 'customdate' and 'customdatetime' form input types, if Semantic Forms is installed global $sfgFormPrinter; if ($sfgFormPrinter) { $sfgFormPrinter->setInputTypeHook('customdate', 'sfCustomDateInputHTML', array()); $sfgFormPrinter->setInputTypeHook('customdatetime', 'sfCustomDateTimeInputHTML', array()); } } function sfCustomDateInputHTML($date, $input_name, $is_mandatory, $is_disabled, $field_args) { global $sfgTabIndex, $sfgFieldNum, $sfgJSValidationCalls, $wgAmericanDates; // Use the normal dateEntryHTML function $normalDateEntryHTML = SFFormInputs::dateEntryHTML($date, $input_name, $is_mandatory, $is_disabled, $field_args); // Now add our customisations $input_id = "input_$sfgFieldNum"; $disabled_text = ($is_disabled) ? "disabled" : ""; // Today button $sfgTabIndex++; $normalDateEntryHTML[0] .= ' " . "\n"; // Yesterday button $normalDateEntryHTML[0] .= ' " . "\n"; return $normalDateEntryHTML; } function sfCustomDateTimeInputHTML($datetime, $input_name, $is_mandatory, $is_disabled, $field_args) { global $sfgTabIndex, $sfg24HourTime; // The following code is mostly copied from dateTimeEntryHTML (SF version 1.8, 2009-07-27) $include_timezone = $other_args['include_timezone']; if ($datetime) { // can show up here either as an array or a string, depending on // whether it came from user input or a wiki page if (is_array($datetime)) { if (isset($datetime['hour'])) $hour = $datetime['hour']; if (isset($datetime['minute'])) $minute = $datetime['minute']; if (! $sfg24HourTime) { if (isset($datetime['ampm24h'])) $ampm24h = $datetime['ampm24h']; } if (isset($datetime['timezone'])) $timezone = $datetime['timezone']; } else { $actual_date = strtotime($datetime); if ($sfg24HourTime) { $hour = date("G", $actual_date); } else { $hour = date("g", $actual_date); } $minute = date("i", $actual_date); if (! $sfg24HourTime) { $ampm24h = date("A", $actual_date); } $timezone = date("T", $actual_date); } } else { $cur_date = getdate(); $hour = null; $minute = null; $ampm24h = ""; $timezone = ""; } list($text, $javascript_text) = sfCustomDateInputHTML($datetime, $input_name, $is_mandatory, $is_disabled, $other_args); $disabled_text = ($is_disabled) ? "disabled" : ""; $text .= '  '; $sfgTabIndex++; $text .= ' :'; if (! $sfg24HourTime) { $sfgTabIndex++; $text .= '