PageRenderTime 44ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/dynamic-widgets/mods/date_module.php

https://bitbucket.org/Thane2376/death-edge.ru
PHP | 103 lines | 83 code | 11 blank | 9 comment | 5 complexity | 3c7e28a4ea60f8a093e4ad73cdc71678 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-3.0, AGPL-1.0
  1. <?php
  2. /**
  3. * Date Module
  4. * Can't use DWOpts object because value = the actual date
  5. *
  6. * @version $Id: date_module.php 937227 2014-06-23 15:10:15Z qurl $
  7. * @copyright 2011 Jacco Drabbe
  8. */
  9. class DW_Date extends DWModule {
  10. public static $option = array( 'date' => 'Date' );
  11. protected static $overrule = TRUE;
  12. protected static $type = 'custom';
  13. public static function admin() {
  14. $DW = $GLOBALS['DW'];
  15. parent::admin();
  16. $date_yes_selected = 'checked="checked"';
  17. $opt_date = $DW->getOpt($GLOBALS['widget_id'], 'date');
  18. if ( count($opt_date) > 0 ) {
  19. foreach ( $opt_date as $value ) {
  20. switch ( $value->name ) {
  21. case 'date_start':
  22. $date_start = $value->value;
  23. break;
  24. case 'date_end':
  25. $date_end = $value->value;
  26. break;
  27. }
  28. }
  29. $date_no_selected = $date_yes_selected;
  30. unset($date_yes_selected);
  31. }
  32. ?>
  33. <h4 id="date" title=" Click to toggle " class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"><b><?php _e('Date'); ?></b><?php echo ( count($opt_date) > 0 ) ? ' <img src="' . $DW->plugin_url . 'img/checkmark.gif" alt="Checkmark" />' : ''; ?></h4>
  34. <div id="date_conf" class="dynwid_conf ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
  35. <?php _e('Show widget always?', DW_L10N_DOMAIN); ?> <img src="<?php echo $DW->plugin_url; ?>img/info.gif" alt="info" title="<?php _e('Click to toggle info', DW_L10N_DOMAIN) ?>" onclick="divToggle('date_info');" /><br />
  36. <?php $DW->dumpOpt($opt_date); ?>
  37. <div>
  38. <div id="date_info" class="infotext">
  39. <?php _e('Next to the above role option, the date option is also very powerfull. You\'ve been warned!', DW_L10N_DOMAIN); ?><br />
  40. <?php _e('Enter dates in the YYYY-MM-DD format. You can also use the calender by clicking on the', DW_L10N_DOMAIN); ?> <img src="<?php echo $DW->plugin_url; ?>img/calendar.gif" alt="Calendar" /><br />
  41. <?php _e('Date ranges can be made by entering a From AND a To date<br />
  42. When you want the widget to be displayed from a specific date, only fill in the From date<br />
  43. When you want the widget to stop displaying on a specific date, only fill in the To date.
  44. ', DW_L10N_DOMAIN); ?>
  45. </div>
  46. </div>
  47. <input type="radio" name="date" value="yes" id="date-yes" <?php echo ( isset($date_yes_selected) ) ? $date_yes_selected : ''; ?> onclick="swTxt(cDate, true);" /> <label for="date-yes"><?php _e('Yes'); ?></label>
  48. <input type="radio" name="date" value="no" id="date-no" <?php echo ( isset($date_no_selected) ) ? $date_no_selected : ''; ?> onclick="swTxt(cDate, false)" /> <label for="date-no"><?php _e('No'); ?>, <?php _e('only', DW_L10N_DOMAIN); ?>:</label><br />
  49. <div id="date-select" class="condition-select">
  50. <table border="0" cellspacing="0" cellpadding="0">
  51. <tr>
  52. <td style="width:45px;"><?php _e('From', DW_L10N_DOMAIN); ?></td>
  53. <td><input id="date_start" type="text" name="date_start" value="<?php echo ( isset($date_start) ) ? $date_start : ''; ?>" size="10" maxlength="10" /> <img src="<?php echo $DW->plugin_url; ?>img/calendar.gif" alt="Calendar" onclick="showCalendar('date_start')" /></td>
  54. </tr>
  55. <tr>
  56. <td style="width:45px;"><?php _e('To', DW_L10N_DOMAIN); ?></td>
  57. <td><input id="date_end" type="text" name="date_end" value="<?php echo ( isset($date_end) ) ? $date_end : ''; ?>" size="10" maxlength="10" /> <img src="<?php echo $DW->plugin_url; ?>img/calendar.gif" alt="Calendar" onclick="showCalendar('date_end')" /></td>
  58. </tr>
  59. </table>
  60. </div>
  61. </div><!-- end dynwid_conf -->
  62. <script type="text/javascript">
  63. /* <![CDATA[ */
  64. function showCalendar(id) {
  65. if ( jQuery('#date-no').is(':checked') ) {
  66. var id = '#'+id;
  67. jQuery(function() {
  68. jQuery(id).datepicker({
  69. dateFormat: 'yy-mm-dd',
  70. minDate: new Date(<?php echo date('Y, n - 1, j'); ?>),
  71. onClose: function() {
  72. jQuery(id).datepicker('destroy');
  73. }
  74. });
  75. jQuery(id).datepicker('show');
  76. });
  77. } else {
  78. jQuery('#date-no').attr('checked', true);
  79. swTxt(cDate, false);
  80. showCalendar(id);
  81. }
  82. }
  83. var cDate = new Array('date_start', 'date_end');
  84. if ( jQuery('#date-yes').is(':checked') ) {
  85. swTxt(cDate, true);
  86. }
  87. /* ]]> */
  88. </script>
  89. <?php
  90. }
  91. }
  92. ?>