Ejemplo n.º 1
0
  public static function ui( MEOW_Field $field ) {

    // $field here is a MEOW_Field, which is a class that encapsulates the value of a field AND the info associated with it

    $options = $field->info->type_options;
    
    $maxlength = "";
    $font = "";
    $maxwidth = "";
    $default = "";

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

    $maxwidth = self::option_value($options, "maxwidth");

    if (isset($options["maxlength"])) {
      $maxlength = $options["maxlength"];
    }
  
    if (isset($options["font"])) {
      $font = $options["font"];
    }
  
    if (isset($options["default"])) {
      $default = $options["default"];
    }
  
    if (is_numeric($maxwidth)) {
      $maxwidth = "{$maxwidth}px";
    } else {
      $maxwidth = "auto";
    }

    $maxlength_attr = "";
    
    $status = "";

    if ($maxlength && is_numeric($maxlength)) {
      $maxlength_attr = WOOF_HTML::attr("maxlength=$maxlength");

      if (trim($maxwidth) == "") {
        // if the maxlength is set, roughly match the width of the input to the number of characters
        $maxwidth = ($maxlength + 12)."ex";
      }
    }

    $value = $field->value();

    if ($field->blank()) {
      $value = self::option_value($options, "default");
    }
    
    $html = <<<HTML

    <div class="f">
      <div class="input-spinner">
        <input id="{{id}}" name="{{name}}" type="text" $readonly value="{$value}" autocomplete="off" class="text" {$maxlength_attr} style="max-width: {$maxwidth};" />
        <div class="buttons">
          <button tabindex="-1" type="button" class="ir up"><span>Up</span></button>
          <button tabindex="-1" type="button" class="ir down"><span>Down</span></button>
        </div>
      </div>
    </div>

HTML;

    return $html;

  }
Ejemplo n.º 2
0
  public static function ui( MEOW_Field $field ) {

    $readonly = WOOF_HTML::readonly_attr(!$field->is_editable());
    
    $options = $field->info->type_options;
    
    $maxlength = self::option_value($options, "maxlength");
    $font = self::option_value($options, "font");
    $status = self::option_value($options, "status");
    $maxwidth = self::option_value($options, "maxwidth");

    $maxlength_attr = "";

    if (is_numeric($maxwidth)) {
      $maxwidth = "{$maxwidth}px";
    } else {
      $maxwidth = "auto";
    }

    $status = "";

    if ($maxlength && is_numeric($maxlength)) {
      $maxlength_attr = WOOF_HTML::attr("maxlength=$maxlength");

      if ($status == "yes") {
        $status = '<div class="status">&nbsp;</div>';
      }

      if (trim($maxwidth) == "") {
        // if the maxlength is set, roughly match the width of the input to the number of characters
        $maxwidth = ($maxlength + 12)."ex";
      }
    }

    $value = htmlspecialchars($field->value());

    $html = <<<HTML

    <div class="f">
      <input id="{{id}}" name="{{name}}" type="text" $readonly value="{$value}" class="text" {$maxlength_attr} style="max-width: {$maxwidth}; font-family: {$font}" />
      $status
    </div>

HTML;

    return $html;

  }
Ejemplo n.º 3
0
  public static function options_form( $options ) {

    $defaults = array();

    if (MPC::is_create()) {
      $defaults = array("default_value" => "#");
    }

    $options = wp_parse_args( $options, $defaults );

    $p = self::type_prefix(__CLASS__);

    // setup variables to insert into the heredoc string
    // (this is required where we cannot call functions within heredoc strings)

    $value = self::option_value($options, "default_value", "");
    
    $style = "";
    
    if ($value != "") {
      $style = WOOF_HTML::attr(array("style" => "background-color: $value"));
      
    }
    
    $default_value_label = __("Default Color:", MASTERPRESS_DOMAIN);

$html = <<<HTML

    <div class="f">
      <label for="{$p}default-value">{$default_value_label}</label>
      <div id="fw-{$p}default-value" class="fw">
	    <div class="input-wrap">
	       <input id="{$p}default-value" name="type_options[default_value]" maxlength="7" type="text" value="{$options['default_value']}" class="text" />
	       <span id="{$p}colorpreview" {$style}></span>
		</div>
	
        <div id="{$p}colorpicker"></div>

      </div>


    </div>
    <!-- /.f -->


HTML;

    return $html;

  }