コード例 #1
0
ファイル: SF_DateInput.php プロジェクト: Tjorriemorrie/app
 public static function getMainHTML($date, $input_name, $is_mandatory, $is_disabled, $other_args)
 {
     global $sfgTabIndex, $wgAmericanDates;
     if ($date) {
         // 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($date)) {
             $year = $date['year'];
             $month = $date['month'];
             $day = $date['day'];
         } else {
             // handle 'default=now'
             if ($date == 'now') {
                 global $wgLocaltimezone;
                 if (isset($wgLocaltimezone)) {
                     $serverTimezone = date_default_timezone_get();
                     date_default_timezone_set($wgLocaltimezone);
                 }
                 $date = date('Y/m/d');
                 if (isset($wgLocaltimezone)) {
                     date_default_timezone_set($serverTimezone);
                 }
             }
             $actual_date = new SMWTimeValue('_dat');
             $actual_date->setUserValue($date);
             $year = $actual_date->getYear();
             // TODO - the code to convert from negative to
             // BC notation should be in SMW itself.
             if ($year < 0) {
                 $year = $year * -1 + 1 . ' BC';
             }
             $month = $actual_date->getMonth();
             $day = $actual_date->getDay();
         }
     } else {
         $cur_date = getdate();
         $year = $cur_date['year'];
         $month = $cur_date['month'];
         $day = null;
         // no need for day
     }
     $text = "";
     $disabled_text = $is_disabled ? 'disabled' : '';
     $monthInput = self::monthDropdownHTML($month, $input_name, $is_disabled);
     $dayInput = '	<input tabindex="' . $sfgTabIndex . '" class="dayInput" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>';
     if ($wgAmericanDates) {
         $text .= "{$monthInput}\n{$dayInput}\n";
     } else {
         $text .= "{$dayInput}\n{$monthInput}\n";
     }
     $text .= '	<input tabindex="' . $sfgTabIndex . '" class="yearInput" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4" ' . $disabled_text . '/>' . "\n";
     return $text;
 }
コード例 #2
0
ファイル: SF_DateInput.php プロジェクト: whysasse/kmwiki
 static function parseDateSMW($date)
 {
     $actual_date = new SMWTimeValue('_dat');
     $actual_date->setUserValue($date);
     $year = $actual_date->getYear();
     // TODO - the code to convert from negative to BC notation
     // should be in SMW itself.
     if ($year < 0) {
         $year = $year * -1 + 1 . ' BC';
     }
     // Use precision of the date to determine whether we should
     // also set the month and day.
     if (method_exists($actual_date->getDataItem(), 'getPrecision')) {
         $precision = $actual_date->getDataItem()->getPrecision();
         if ($precision > SMWDITime::PREC_Y) {
             $month = $actual_date->getMonth();
         }
         if ($precision > SMWDITime::PREC_YM) {
             $day = $actual_date->getDay();
         }
     } else {
         // There's some sort of error - make everything blank.
         $year = null;
     }
     return array($year, $month, $day);
 }
コード例 #3
0
 public static function getMainHTML($date, $input_name, $is_mandatory, $is_disabled, $other_args)
 {
     global $sfgTabIndex, $wgAmericanDates;
     $year = $month = $day = null;
     if ($date) {
         // 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($date)) {
             $year = $date['year'];
             $month = $date['month'];
             $day = $date['day'];
         } else {
             // handle 'default=now'
             if ($date == 'now') {
                 global $wgLocaltimezone;
                 if (isset($wgLocaltimezone)) {
                     $serverTimezone = date_default_timezone_get();
                     date_default_timezone_set($wgLocaltimezone);
                 }
                 $date = date('Y/m/d');
                 if (isset($wgLocaltimezone)) {
                     date_default_timezone_set($serverTimezone);
                 }
             }
             $actual_date = new SMWTimeValue('_dat');
             $actual_date->setUserValue($date);
             $year = $actual_date->getYear();
             // TODO - the code to convert from negative to
             // BC notation should be in SMW itself.
             if ($year < 0) {
                 $year = $year * -1 + 1 . ' BC';
             }
             // Use precision of the date to determine
             // whether we should also set the month and
             // day.
             if (method_exists($actual_date->getDataItem(), 'getPrecision')) {
                 $precision = $actual_date->getDataItem()->getPrecision();
                 if ($precision > SMWDITime::PREC_Y) {
                     $month = $actual_date->getMonth();
                 }
                 if ($precision > SMWDITime::PREC_YM) {
                     $day = $actual_date->getDay();
                 }
             } else {
                 // There's some sort of error - make
                 // everything blank.
                 $year = null;
             }
         }
     } else {
         // Just keep everything at null.
     }
     $text = "";
     $disabled_text = $is_disabled ? 'disabled' : '';
     $monthInput = self::monthDropdownHTML($month, $input_name, $is_disabled);
     $dayInput = '	<input tabindex="' . $sfgTabIndex . '" class="dayInput" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>';
     if ($wgAmericanDates) {
         $text .= "{$monthInput}\n{$dayInput}\n";
     } else {
         $text .= "{$dayInput}\n{$monthInput}\n";
     }
     $text .= '	<input tabindex="' . $sfgTabIndex . '" class="yearInput" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4" ' . $disabled_text . '/>' . "\n";
     return $text;
 }