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

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

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

    $select_none_label = __("Select None", MASTERPRESS_DOMAIN);

    $value = $field->value();


    $option_values = WOOF_HTML::option_values($options["values"]);

    $hidden = "";
    $name = "{{name}}";
    $id = "{{id}}";
    $buttons = "";
    
    if (!$field->is_editable()) {
      
      $hidden_name = $name;
      $hidden_id = $id;

      $name = "display_".$name;
      $id = "display_".$id;
      
      $hidden = '<input id="'.$hidden_id.'" name="'.$hidden_name.'" value="'.$value.'" type="hidden" />';
    
    } else {
      if (isset($options["allow_uncheck"]) && $allow_uncheck == "yes") {
      $controls = <<<HTML
      <div class="buttons">
        <button type="button" class="button button-small uncheck-all">{$select_none_label}</button>
      </div>
HTML;
      }

    }
    
    $radio_buttons = WOOF_HTML::input_radio_group( $name, $id, $option_values, $value, WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div"), !$field->is_editable()); 
    
    $html = <<<HTML

    <div class="f">
    <div class="fw">
    {$radio_buttons}
    {$hidden}
    </div>
    {$controls}
    </div>

HTML;

    return $html;

  }
Beispiel #2
0
  public static function options_radio_list( $p, $options, $radio_options, $key, $label, $note = "", $default_value = null) {

    $val = self::option_value($options, $key, $default_value);
    
    $select = WOOF_HTML::input_radio_group(
      "type_options[".$key."]", $p.$key,
      $radio_options,
      $val
    );

    if ($note != "") {
      $note = '<span class="note">'.$note.'</span>';
    }

    $html = <<<HTML

    <div id="{$p}{$key}-f" class="f {$key}-f">
      <label for="{$p}{$key}">{$label}</label>
      <div id="fw-{$p}{$key}" class="fw">
        {$select}{$note}
      </div>
    </div>
    
HTML;
  
    return $html;
    
  }  
Beispiel #3
0
  public static function options_form( $options ) {

    $defaults = array();

    if (MPC::is_create()) {
      $defaults = array("default_tab" => "visual", "height" => 250, "html_editor" => "cm", "cm_theme" => "sunburst");
    }

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

    $p = self::type_prefix(__CLASS__);

    $height = self::option_value($options, "height");
    $mce_blockformats = self::option_value($options, "mce_blockformats");
    $mce_styles = self::option_value($options, "mce_styles");
    $default_tab = self::option_value($options, "default_tab");
    $cm_theme = self::option_value($options, "cm_theme");

    $height_label = __("Editor Height:", MASTERPRESS_DOMAIN);
    $height_note = __("(pixels)", MASTERPRESS_DOMAIN);

    $html_editor_label = __("HTML Editor:", MASTERPRESS_DOMAIN);
    $html_editor_note = __('<a href="http://codemirror.net" target="_blank">CodeMirror 2</a> is a wonderful JavaScript text editor that support live syntax-coloring, among other features.', MASTERPRESS_DOMAIN);
    $html_editor_select = WOOF_HTML::select(
      array("id" => $p."html-editor", "name" => "type_options[html_editor]"), 
      array(
        "CodeMirror 2" => "cm", 
        "Standard Textarea" => "textarea" 
      ),
      self::option_value($options, "html_editor")
      
    );

    $cm_theme_label = __("CodeMirror Theme:", MASTERPRESS_DOMAIN);
    $cm_theme_select = WOOF_HTML::select(
      array("id" => $p."cm-theme", "name" => "type_options[cm_theme]"), 
      array(
        "Default" => "default",
        "Cobalt" => "cobalt",
        "Elegant" => "elegant",
        "Neat" => "neat",
        "Night" => "night",
        "Sunburst" => "sunburst"
      ),
      $cm_theme
    );

    $mce_blockformats_label = __("Block Formats:", MASTERPRESS_DOMAIN);
    $mce_blockformats_note = __('Specify the block-level tags which appear in the <em>Format</em> dropdown list in TinyMCE.<br />Leave this value empty to use the same formats as the WordPress content editor. <a target="_blank" href="http://www.tinymce.com/wiki.php/Configuration:theme_advanced_blockformats">More Info</a>', MASTERPRESS_DOMAIN);

      
    
    $mce_styles_label = __("Styles:", MASTERPRESS_DOMAIN);
    $mce_styles_note = __('Specify the style names and the underlying CSS classes for these styles, in the form <span class="tt">label = css_class</span> separated by semi-colons (;). Leave this value empty to use the same formats as the WordPress content editor. <a target="_blank" href="http://www.tinymce.com/wiki.php/Configuration:theme_advanced_styles">More Info</a>', MASTERPRESS_DOMAIN);

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

    $default_tab_label = __("Default Tab:", MASTERPRESS_DOMAIN);

    $default_tab_select = WOOF_HTML::input_radio_group(
      "type_options[default_tab]", $p."default-tab-", 
      array( __("Visual <span>( TinyMCE )</span>", MASTERPRESS_DOMAIN) => "visual", __("HTML", MASTERPRESS_DOMAIN) => "html" ),
      $default_tab,
      WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")
    );

$html = <<<HTML

    <div class="f">
      <label for="{$p}default_tab">{$default_tab_label}</label>
      <div id="fw-{$p}default_tab" class="fw">
        {$default_tab_select}
      </div>
    </div>
    <!-- /.f -->

    <div class="f">
      <label for="{$p}height">{$height_label}</label>
      <div id="fw-{$p}height" class="fw">
        <input id="{$p}height" type="text" name="type_options[height]" value="{$height}" class="text" />
        <span class="note">{$height_note}</span>
      </div>
    </div>
    
    
    <div class="f">
      <label for="{$p}html_editor">{$html_editor_label}</label>
      <div id="fw-{$p}html_editor" class="fw">
        {$html_editor_select}
        <p class="note">{$html_editor_note}</p>
      </div>
    </div>
    <!-- /.f -->

    <div id="{$p}cm-theme-f" class="f">
      <label for="{$p}cm_theme">{$cm_theme_label}</label>
      <div id="fw-{$p}cm_theme" class="fw">
        {$cm_theme_select}
      </div>
    </div>
    <!-- /.f -->

    <div class="f">
      <label for="{$p}mce_blockformats">{$mce_blockformats_label}</label>
      <div id="fw-{$p}mce_blockformats" class="fw">
        <input id="{$p}mce_blockformats" type="text" name="type_options[mce_blockformats]" value="{$mce_blockformats}" class="text" />
        <p class="note">{$mce_blockformats_note}</p>
      </div>
    </div>
    <!-- /.f -->

    <div class="f">
      <label for="{$p}mce_styles">{$mce_styles_label}</label>
      <div id="fw-{$p}mce_styles" class="fw">
        <textarea id="{$p}mce_styles" name="type_options[mce_styles]" class="mono">{$mce_styles}</textarea>
        <p class="note">{$mce_styles_note}</p>
      </div>
    </div>
    <!-- /.f -->

HTML;

    return $html;

  }
Beispiel #4
0
  public static function options_form( $options ) {

    $defaults = array();

    if (MPC::is_create()) {
      $defaults = array("mode" => "single");
    }

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

    $mode = self::option_value($options, "mode");
    
    if ($mode == "") {
      $mode = "single";
    }

    $p = self::type_prefix(__CLASS__);



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

    $mode_label = __("Selection Mode:", MASTERPRESS_DOMAIN);

    $mode_select = WOOF_HTML::input_radio_group(
      "type_options[mode]", $p."mode-", 
      array(__("Single Date", MASTERPRESS_DOMAIN) => "single", __("Start / End Date", MASTERPRESS_DOMAIN) => "start_end" ),
      self::option_value($options, "mode"),
      WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")
    );

    $mindate_label = __("Minimum Date:", MASTERPRESS_DOMAIN);
    $maxdate_label = __("Maximum Date:", MASTERPRESS_DOMAIN);
    $default_value_label = __("Default Date:", MASTERPRESS_DOMAIN);

    $time_select_label = __("Allow Time Selection?", MASTERPRESS_DOMAIN);
    $time_select_checked_attr = WOOF_HTML::checked_attr(self::option_value($options, "timeselect") == "yes");

    $date_format_note = __("Note: for minumum, maximum, and default dates, you may also enter a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '-1y -1m').", MASTERPRESS_DOMAIN);

    $button_text = esc_js(__("choose&hellip;", MASTERPRESS_DOMAIN));

    $font_select = WOOF_HTML::select(
      array("id" => $p."font", "name" => "type_options[font]"), 
      array(
        "Sans-Serif&nbsp;&nbsp;-&nbsp;&nbsp;Helvetica, Arial, sans-serif" => "helvetica, arial, sans-serif", 
        "Serif&nbsp;&nbsp;-&nbsp;&nbsp;Georgia, Times New Roman, serif" => "georgia, 'times new roman', serif", 
        "Fixed Width&nbsp;&nbsp;-&nbsp;&nbsp;Consolas, Menlo, Andale Mono, Lucida Console, monospace" => "consolas, menlo, 'andale mono', 'lucida console', monospace"
      ),
      self::option_value($options, "font")
    );

 
    $mindate = esc_attr(self::option_value($options, "mindate"));
    $maxdate = esc_attr(self::option_value($options, "maxdate"));
    $default_value = esc_attr(self::option_value($options, "default_value"));

$html = <<<HTML


    <!--
    TODO - re-enable dual date support (not important right now)
    <div class="f">
      <label for="{$p}mode_select">{$mode_label}</label>
      <div id="fw-{$p}mode_select" class="fw">
        {$mode_select}
      </div>
    </div>
    -->
    <!-- /.f -->

    <div class="f">
      <label for="{$p}timeselect">{$time_select_label}</label>
      <div id="fw-{$p}timeselect" class="fw">
        <input id="{$p}timeselect" type="checkbox" name="type_options[timeselect]" {$time_select_checked_attr} value="yes" class="checkbox" />
      </div>
    </div>
    <!-- /.f -->

    <div class="f">
      <label for="{$p}mindate">{$mindate_label}</label>
      <div id="fw-{$p}mindate" class="fw">
        <input id="{$p}mindate" name="type_options[mindate]" type="text" maxlength="4" value="{$mindate}" class="text date { buttonText: '{$button_text}' }" />
      </div>
    </div>
    <!-- /.f -->


    <div class="f">
      <label for="{$p}maxdate">{$maxdate_label}</label>
      <div id="fw-{$p}maxdate" class="fw">
        <input id="{$p}maxdate" name="type_options[maxdate]" type="text" maxlength="4" value="{$maxdate}" class="text date { buttonText: '{$button_text}' }" />
      </div>
    </div>
    <!-- /.f -->

    <div class="f">
      <label for="{$p}default_value">{$default_value_label}</label>
      <div id="fw-{$p}default_value" class="fw">
        <input id="{$p}default_value" name="type_options[default_value]" type="text" defaultlength="4" value="{$default_value}" class="text date { buttonText: '{$button_text}' }" />
      </div>
    </div>
    <!-- /.f -->

    <p class="note format-note">
      {$date_format_note}
    </p>


HTML;

    return $html;

  }