예제 #1
0
  public static function ui( MEOW_Field $field ) {

    $options = $field->info->type_options;

    $readonly = WOOF_HTML::readonly_attr(!$field->is_editable());

    $value = $field->str();

    $mode = "";
    $year = "";
    $month = "";
    $day = "";

    if (isset($options["mode"])) {
      $mode = $options["mode"];
    }
    
    if ($mode != "start_end") {
      $time = strtotime($value);

      if ($time != 0) {
        $month = date("M", $time);
        $year = date("Y", $time);
        $day = date("d", $time);
      }

    }

    $start_date = __("Start Date:", MASTERPRESS_DOMAIN);
    $end_date = __("End Date:", MASTERPRESS_DOMAIN);

    $html = <<<HTML

    <div class="summary">
      <div class="mp-cal">
        <div class="cal-month-year">
          <span class="month">{$month}</span>&nbsp;
          <span class="year">{$year}</span>
        </div>

        <div class="cal-day">
          <span class="day">{$day}</span>
        </div>

      </div>
HTML;

    if ($mode == "start_end") {
      $html .= <<<HTML

      <div class="mp-cal cal-end">
        <div class="cal-month-year">
          <span class="month-end"></span>&nbsp;
          <span class="year-end"></span>
        </div>

        <div class="cal-day">
          <span class="day-end"></span>
        </div>

      </div>
HTML;

    }

    $html .= "</div>";

    if ($mode == "start_end") {
      $html .= <<<HTML

      <input id="{{id}}" name="{{name}}" {$readonly} type="hidden" value="{$value}" class="value" />

      <div class="wrap-pickers">

      <div class="wrap-picker wrap-picker-start">
        <label for="{{prop_id}}start" class="picker">{$start_date}</label>
        <input id="{{prop_id}}start" name="{{prop_name}}[start]" type="text" value="$value" class="text picker picker-start" />
      </div>

      <div class="wrap-picker wrap-picker-end">
        <label for="{{prop_id}}end" class="picker">{$end_date}</label>
        <input id="{{prop_id}}end" name="{{prop_name}}[end]" type="text" value="$value" class="text picker picker-end" />
      </div>

      </div>

HTML;

    } else {

      $html .= '<input id="{{id}}" name="{{name}}" '.$readonly.'" type="text" value="'.$value.'" class="text value picker" />';

    }

    return $html;

  }