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;

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

    $tabs_class = "";
    
    if ($readonly) {
      $tabs_class = " readonly";
    }
    
    $visual_current = "current";
    $html_current = "";

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

    if ($default_tab == "html" ) {
      $visual_current = "";
      $html_current = "current";
    }

    $style = "";

    if (isset($options["height"]) && is_numeric($options["height"])) {
      $style .= "height: ".$options["height"]."px;";
    }

    $value = "";
    
    if (!$field->blank()) {
      $value = htmlspecialchars($field->clean());
    }

    $html = <<<HTML

    <div id="wp-{{id}}-wrap" class="wp-content-wrap editor-ui">

    <ul class="editor-tabs $tabs_class">
      <li><div class="tab-button visual {$visual_current}">Visual</div></li>
      <li><div class="tab-button html {$html_current}">HTML</div></li>
    </ul>

    <textarea id="{{id}}" name="{{name}}" $readonly class="mce">{$value}</textarea>

    </div>

HTML;

    return $html;

  }
Exemple #2
0
  public static function summary( MEOW_Field $field ) {

    $filename = "";
    $filesize = "";
    $filetype = "";
    $filename_trunc = "";
    $filetype_trunc = "";


    if (!$field->blank()) {
      $file = $field->file();

      if ($file && $file->exists()) {

        $filename = $file->basename();
        $filesize = $file->filesize();
        $filetype = $file->filetype();

        $filename_trunc = WOOF::truncate_advanced($filename, 26, $etc = ' &hellip; ', false, true);
        $filetype_trunc = WOOF::truncate_advanced($filetype, 25, $etc = ' &hellip; ', false, true);

      }
    }

    $html = <<<HTML

    <div class="summary">
      <span class="name" title="{$filename}">{$filename_trunc}</span>
      <span class="type-size"><span class="type" title="{$filetype}">{$filetype_trunc}</span>
      <br><span class="size">{$filesize}</span></span>
    </div>

HTML;

    return $html;

  }
Exemple #3
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;

  }
Exemple #4
0
  public static function summary( MEOW_Field $field ) {

    global $wf;

    $image = "";
    
    list($stw, $sth) = array(82, 39);

    $no_image = __("( no image )", MASTERPRESS_DOMAIN);

    $empty = "empty";
    $thumb = WOOF_Image::empty_mp_thumb(array("w" => $stw, "h" => $sth, "no_image" => $no_image, "class" => "summary-thumb") );
    
    if (!$field->blank()) {
      $image = $field->file();

      if ($image && $image->exists()) {
        $width = $image->width();
        $height = $image->height();

        list($stw, $sth) = self::summary_thumb_wh($width, $height);
        
        $thumb = $image->mp_thumb(array("w" => $stw, "h" => $sth, "no_image" => $no_image, "thumb_only" => true, "class" => "summary-thumb"));

      }
    }

    $html = $thumb;

    return $html;

  }
Exemple #5
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;

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

    $value = "";

    if (!$field->blank()) {
      $value = htmlspecialchars($field->raw());
      
      $hiddenmode = $field->prop("mode");

    } else {
      $hiddenmode = self::option_value($options, "mode");
    }

    
    
    $class = "";
    
    
    $mode_select = '';

    if (isset($options["modeselect"]) && $options["modeselect"] == "yes") {
      $mode_select = WOOF_HTML::open("div", array("class" => "modeselect-wrap"));
      $mode_select .= WOOF_HTML::tag("label", array(), __("Syntax Mode: ", MASTERPRESS_DOMAIN));
      
      $class = " editor-ui-with-modeselect";
      
      $attr = array("id" => "{{prop_id}}-mode", "name" => "{{prop_name}}[mode]", "class" => "modeselect");
      
      if ($readonly) {
        $attr["readonly"] = "readonly";
      }
      
      $mode_select .= WOOF_HTML::select(
        $attr,
        self::modes(),
        $hiddenmode
      );
    
      $mode_select .= WOOF_HTML::close("div");
      
    }
    
    $html = <<<HTML

    <div class="editor-ui{$class}">
    <textarea id="{{id}}" $readonly name="{{name}}">{$value}</textarea>
    <input type="hidden" name="hiddenmode" id="{{id}}-hiddenmode" class="hiddenmode" value="{$hiddenmode}" />
      {$mode_select}
    </div>

HTML;

    return $html;

  }
Exemple #6
0
  public static function select_ui( MEOW_Field $field, $class ) {
    
    $blank = $field->blank();
    $value = array();

    if (!$blank) {
      $value = $field->value();
    } 
    
    if (!is_array($value)) {
      $value = explode(",", $value);
    }
    
    
    $control_style = self::option_value($field->info->type_options, "control_style", "drop_down_list");

    if ($control_style == "dual_list_box") {
      $control_style = "list_box_multiple";
    }
    
    $input = "";
    
    $val = implode(",", $value);
    
    $row_style = self::option_value($field->info->type_options, "row_style", "icon_title");
    
    if ($control_style == "list_box_multiple") {
      $input = '<input type="hidden" id="{{id}}-value-input" name="{{name}}" data-row-style="'.$row_style.'" type="hidden" value="'.$val.'" class="select2-hidden" />';
    }

    $select = call_user_func_array( array( $class, "select" ), array($field->info->type_options, $value, $blank, $field->is_editable()) );
    
    $html = <<<HTML
      {$input}
      {$select}
HTML;

    return $html;
    
  }
 public static function summary( MEOW_Field $field ) {
   
   if (!$field->blank()) {
     $value = $field->value();
     $values = WOOF_HTML::option_values($field->info->options("values"));
     $key = array_search($value, $values);
     return $key;
   }
 }
  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;

  }
Exemple #9
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;

    $readonly = WOOF_HTML::readonly_attr( !$field->is_editable() );
    
    $checked_value = trim($options["value"]);
    
    $checked_checked_attr = WOOF_HTML::checked_attr($field->checked());
    
    if ($checked_value == "") {
      $checked_value = "true";
    }

    $lang_checked = esc_js( __("( checked )", MASTERPRESS_DOMAIN) );
    $lang_not_checked = esc_js( __("( not checked )", MASTERPRESS_DOMAIN) );
    
    
    
    if ($field->is_editable()) {
      
    $html = <<<HTML

    <input id="{{id}}" name="{{name}}" type="checkbox" {$checked_checked_attr} value="{$checked_value}" class="checkbox { lang: { 'checked' : '{$lang_checked}', 'not_checked' : '{$lang_checked}' } }" />

HTML;

    } else {
    
      // setup a hidden value for checkboxes that are currently checked, to simulate a "readonly" state
      
      if ($field->checked()) {
        // we only need submit the value if the the checkbox is currently checked
        $hidden = <<<HTML
        <input id="{{id}}" name="{{name}}" type="hidden" value="{$checked_value}"  />
HTML;

      } 
    
    $html = <<<HTML
    <input id="{{id}}-display" name="display_{{name}}" type="checkbox" disabled="disabled" {$checked_checked_attr} value="{$checked_value}" class="checkbox { lang: { 'checked' : '{$lang_checked}', 'not_checked' : '{$lang_checked}' } }" />
    $hidden
HTML;
  
      
    }
    
    return $html;
    
  }
Exemple #10
0
  public static function ui( MEOW_Field $field ) {

    global $wf;
    
    // $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;

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

    $no_url = __("( no URL entered )", MASTERPRESS_DOMAIN);
    $url_label = __("URL:", MASTERPRESS_DOMAIN);

    $button_refresh = __("Refresh Info", MASTERPRESS_DOMAIN);
    
    $fetching_info_message = __("Fetching video info&hellip; please wait", MASTERPRESS_DOMAIN);

    $visit_video_title = __("Visit video page", MASTERPRESS_DOMAIN);

    $watch_video_title = __("Watch video", MASTERPRESS_DOMAIN);
    
    $style = "";

    if (isset($options["height"]) && is_numeric($options["height"])) {
      $style .= "height: ".$options["height"]."px;";
    }

    $watch_url = "";
    $video_url = "";
    $host = "";
    $title = "";
    $value = "";
    $video_id = "";
    
    $empty = "empty";
    
    if (!$field->blank()) {
      $value = htmlspecialchars($field->value());
      $empty = "";
      $video_id = $field->prop("video_id");
      $host = $field->prop("host");

      $title = $field->prop("title");
      
      if ($title == "") {
        $empty = "empty";
      }
      
      if ($video_id && $video_id != "") {
        list($watch_url, $video_url) = self::urls($video_id, $host);
      }
      
    }

    $prop_inputs = self::prop_inputs($field, self::ui_prop());

    $summary_thumb = "";
    $thumb = "";
    
    
    $prop_title = $field->prop("title");
    $prop_host = $field->prop("host");
    $prop_duration = $field->prop("duration");
    $prop_published = self::format_date($field->prop("published"));
    $prop_updated = self::format_date($field->prop("updated"));
    $prop_thumbnail = $field->prop_val("thumbnail");
    
    $published_style = "";
    $updated_style = "";
    
    if ($field->prop("published") == "") {
      $published_style = ' style="display:none;" ';
    }

    if ($field->prop("updated") == "") {
      $updated_style = ' style="display:none;" ';
    }
    
    $prop_video_id = $field->prop("video_id");
      
    $display_title = WOOF::truncate_advanced($prop_title, 60, $etc = ' &hellip; ', false, true);
    $summary_display_title = WOOF::truncate_advanced($prop_title, 50, $etc = ' &hellip; ', false, true);


    $host_name = self::host_name($prop_host);
    
    
    list($tw, $th) = array(120, 90);
    list($stw, $sth) = array(84, 63);

    $orientation = "square";

    $thumb = WOOF_Image::empty_mp_thumb(array("w" => $tw, "h" => $th, "no_image" => $no_url, "class" => "managed thumb") );
    $summary_thumb = WOOF_Image::empty_mp_thumb(array("w" => $stw, "h" => $sth, "no_image" => $no_url, "class" => "managed summary-thumb" ) );


    if ($prop_thumbnail && $prop_thumbnail != "") {
      $img = $wf->image_from_url($prop_thumbnail);
      
      if ($img && $img->exists()) {

        $watermark = MPU::type_image("video", "play-overlay.png");
        $watermark_args = array("at" => "c", "h" => "60%");

        $thumb = $img->mp_thumb(array("w" => $tw, "h" => $th, "no_image" => $no_url, "watermark" => $watermark, "watermark_args" => $watermark_args, "link_attr" => array("class" => "thumb iframe", "href" => $watch_url), "class" => "thumb managed") );
        $summary_thumb = $img->mp_thumb(array("w" => $stw, "h" => $sth, "no_image" => $no_url, "class" => "managed summary-thumb", "thumb_only" => true ) );
      }
    
    }
    
    $html = <<<HTML

    <div class="state {$empty}">

      {$prop_inputs}

      <div class="summary-content">
        
        {$summary_thumb}
      
        <div class="summary-info">
          <span class="title">{$summary_display_title}</span>
          <span class="host"><span class="host-type {$prop_host}"><span class="host-name">{$host_name}</span><span class="duration">({$prop_duration})</span></span></span>
        </div>
      
      </div>
      
      <div class="ui-content">
       
      {$thumb}
      
      <div class="url-info">
        
        <div class="f f-url">
          <label for="{{id}}" class="{prop_host}">{$url_label}</label>
          <input id="{{id}}" name="{{name}}" autocomplete="off" {$readonly} type="text" value="{$value}" class="url text" />
        </div>
          
        <div class="info">

          <span class="error-message"><i></i>error</span>  
          
          <span class="fetching-info-message progress-message">{$fetching_info_message}</span>  

          <div class="title">
            <a href="{$video_url}" target="_blank" title="{$visit_video_title}" class="{$prop_host} title-link">{$display_title}</a>
            <button class="text refresh with-icon" title="{$button_refresh}" type="button">{$button_refresh}</button>
          </div>
        
          <div class="prop-wrap">
            
            
            <ul class="prop">
              <li class="duration">{$prop_duration}</li>
              <li class="published" {$published_style}>Published: <span class="val">{$prop_published}</span></li>
              <li class="updated" {$updated_style}>Updated: <span class="val">{$prop_updated}</span></li>
            </ul>
          </div>
        
          
        </div>
        
      </div>
      
      </div>

    </div>
    <!-- /.state -->

HTML;

    return $html;

  }
Exemple #11
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;

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

    $preview_class = "";
    
    if ($readonly) {
      $preview_class = " readonly";
    }
    
    $value = $field->value();

    $html = <<<HTML

      <div class="fw {$preview_class}">
        <div class="input-wrap">
        <input id="{{id}}" name="{{name}}" $readonly type="text" value="{$value}" class="text" />
        <span class="colorpreview {$preview_class}"></span>
        </div>
        <div class="colorpicker"></div>
      </div>

      <div class="color-info">
        <span class="well-wrap"><span class="well" style="background-color: {$value}"></span></span>
        <span class="value">{$value}</span>
      </div>

HTML;

    return $html;

  }  
Exemple #12
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;

  }
  public static function ui( MEOW_Field $field ) {

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

    $font = self::option_value($options, "font");
    $maxwidth = self::option_value($options, "maxwidth");
    $height = self::option_value($options, "height");
    $status = self::option_value($options, "status");
    
    $maxlength = self::option_value($options, "maxlength");

    if (is_numeric($height)) {
      $height = "{$height}px";
    } else {
      $height = "220px";
    }

    if (is_numeric($maxwidth)) {
      $maxwidth = "max-width: {$maxwidth}px; ";
    }

    $meta = "";
    $status = "";

    if (is_numeric($maxlength)) {
      $meta = " { maxlength: $maxlength }";

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

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

    $html = <<<HTML

    <div class="f">  
      <textarea id="{{id}}" name="{{name}}" type="text" value="{{value}}" {$readonly} class="text{$meta}" style="height: {$height}; min-height: {$height}; {$maxwidth} font-family: {$font}">{$value}</textarea>
      {$status}
    </div>

HTML;


    return $html;

  }
Exemple #14
0
  public static function summary( MEOW_Field $field ) {
    if (!$field->blank()) {
      $ret = self::truncate_for_summary(self::summary_width(), implode(", ", self::$values_keys));
      self::$values_keys[] = array(); // reset the cache
      return $ret;
    }

    return "";
  }
Exemple #15
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;

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

    $disabled = WOOF_HTML::disabled_attr(!$field->is_editable());
    
    $field_value = $field->value();
    
    if (!is_array($field_value)) {
      $field_value = array();
    }
    
    $selected_values = $field_value;

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

    self::$values_keys = array();

    if (!$field->blank()) {
      // populate the values
      $selected_values = array();

      foreach ($values as $key => $value) {
        if (in_array($value, $field_value)) {
          self::$values_keys[] = $key; // cache the keys for the summary, so we don't have to look them up again!
          $selected_values[] = $value;
        }
      }

    }

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

      $checkbox_name = "display_".$checkbox_name;
      $checkbox_id = "display_".$checkbox_id;
      
      foreach ($selected_values as $value) {
        $hidden .= '<input id="'.$hidden_id.'" name="'.$hidden_name.'" value="'.$value.'" type="hidden" />';
      }
      
    } else {
      
      $buttons = <<<HTML
      
      <div class="buttons">
        <button type="button" class="button button-small check-all">{$select_all_label}</button>
        <button type="button" class="button button-small uncheck-all">{$select_none_label}</button>
      </div>
HTML;

    }
    
    $checkboxes = WOOF_HTML::input_checkbox_group( "{{name}}[]", "{{id}}", $values, $selected_values, WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div"), !$field->is_editable()); 

    $html = <<<HTML

    <div class="f">
      <div class="fw">
      {$checkboxes}
      {$hidden}
      </div>
      {$buttons}
    </div>

HTML;

    return $html;

  }
Exemple #16
0
  public static function ui( MEOW_Field $field ) {

    $value = $field->value();

    $zoom = $field->prop("zoom");

    if (!$zoom) {
      $zoom = 1; // needs a default setting
    }

    $state = "";
    
    if ($field->blank()) {
      $state = "empty";
    }
    
    $no_location = __("( No Location Set )", MASTERPRESS_DOMAIN);
    
    $label_button_restore = __("Restore", MASTERPRESS_DOMAIN);
    $label_button_clear = __("Clear", MASTERPRESS_DOMAIN);

    $title_button_restore = __("Restore the location back to the currently stored latitude, longitude, and zoom level", MASTERPRESS_DOMAIN);
    $title_button_clear = __("Clear the location", MASTERPRESS_DOMAIN);
    
    $label_search = __("Use the map to set a new location, or enter a place to search for:", MASTERPRESS_DOMAIN);
    $label_search_empty = __("Click the map to begin location set up or search for a location below:", MASTERPRESS_DOMAIN);
    $label_button_search = __("Search", MASTERPRESS_DOMAIN);
    
    $label_lat = __("Latitude:", MASTERPRESS_DOMAIN);
    $label_lng = __("Longitude:", MASTERPRESS_DOMAIN);
    $label_zoom = __("Zoom:", MASTERPRESS_DOMAIN);
    
    $click_to_begin = __("Set Location", MASTERPRESS_DOMAIN);
    
    $editable = $field->is_editable();
    
    $search_html = "";
    $buttons_html = "";

    $data_readonly = ' data-readonly="true" ';
    
    $begin_html = <<<HTML
    <div class="map-obscure"></div>
HTML;
    
    if ( $editable ) {
      
      $begin_html = <<<HTML
      <a href="#" class="map-begin"><span>{$click_to_begin}</span></a>
HTML;

      $data_readonly = "";
    
      $buttons_html = <<<HTML
      <div class="buttons">
        <button type="button" title="{$title_button_restore}" class="button button-small restore">{$label_button_restore}</button>
        <button type="button" title="{$title_button_clear}" class="button button-small clear">{$label_button_clear}</button>
      </div>
HTML;
      
      $search_html = <<<HTML
      <div class="map-search">
        <p class="label-search">{$label_search}</p>
        <p class="label-search-empty">{$label_search_empty}</p>
        <input id="{{id}}-search" name="map_search" type="text" class="text search" />
        <button type="button" class="button button-small">{$label_button_search}</button>
      </div>
HTML;

    }
    
    $html = <<<HTML

    <input type="hidden" name="{{prop_name}}[zoom]" id="{{prop_id}}-{{id}}" value="{$zoom}" class="prop-zoom" />
    <input type="hidden" name="{{name}}" id="{{id}}" value="{$value}" class="value" />
    
    <div class="state {$state}">
      
      <div class="location clearfix">
        <i></i>
        <span class="no-location">{$no_location}</span>

        <ul>
          <li class="lat"><span>{$label_lat}<b class="value"></b></span></li>
          <li class="lng"><span>{$label_lng}<b class="value"></b></span></li>
          <li class="zoom"><span>{$label_zoom}<b class="value"></b></span></li>
        </ul>
    
        {$buttons_html}
      
      </div>
    
      {$search_html}
      
      <div class="map-wrap">
        <div class="map-canvas-wrap">
        <div class="map-canvas" {$data_readonly}>
      
        </div>
        </div>

        {$begin_html}

        
      </div>
    
    </div>
  
HTML;

    return $html;

    
  }
Exemple #17
0
  public static function field_ui_template_data(MEOW_FieldSet $set, MEOW_Field $field, $args = array()) {

    $r = wp_parse_args( $args,
      array("preview" => false, "readonly" => false, "preview_prefix" => "preview_", "id_base" => "mp_meta_", "name_base" => "mp_meta", "prop_name_base" => "mp_meta_prop", "prop_id_base" => "mp_meta_prop_" )
    );
    
    $set_info = $set->info();
    $field_info = $field->info();
    $ftc = MPFT::type_class($field_info->type);

    $i = $field->set_index();
    
    if (WOOF::is_true_arg($r, "creator")) {
      $i = "!!set_index!!";
    } else if ($field->creator) {
      // leave a placeholder for Handlebars to render into
      $i = "{{set_index}}";
    } 
    
    $prefix = "";
    
    if ($r["preview"]) {
      $prefix = $r["preview_prefix"];
    }
    
    $set_id = $prefix.$r["id_base"]."{$set_info->name}_$i"; 
    $set_name = $prefix.$r["name_base"]."[{$set_info->name}][$i]"; 

    if (WOOF::is_true_arg($r, "nested")) {
      $field_id = $prefix."{$set_id}_{$field_info->name}";
      $field_name = $prefix.$r["name_base"]."[{$i}][{$field_info->name}]";
      $field_prop_name = $prefix.$r["prop_name_base"]."[{$i}][{$field_info->name}]";
      $field_prop_id = $prefix.$r["prop_id_base"]."{$set_info->name}_{$i}_{$field_info->name}";
    
    } else {
      
      $field_id = $prefix."{$set_id}_{$field_info->name}";
      $field_name = $prefix."{$set_name}[{$field_info->name}]";
      $field_prop_name = $prefix.$r["prop_name_base"]."[{$set_info->name}][$i][{$field_info->name}]";
      $field_prop_id = $prefix.$r["prop_id_base"]."{$set_info->name}_{$i}_{$field_info->name}";
    }
    
    
    // prepare the data to return
    $d = array();
    
    $strip_whitespace = !call_user_func( array($ftc, "ui_preserve_whitespace") );
    
    if ($r["preview"]) {
      $field->_version_preview = true;
    }
  
    $d["type"] = $field_info->type;
    $d["ui"] = WOOF::render_template( call_user_func_array( array($ftc, "ui"), array($field)), array("id" => $field_id, "name" => $field_name, "prop_id" => $field_prop_id, "prop_name" => $field_prop_name), $strip_whitespace );
    
    return $d;
        
  }
Exemple #18
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;

  }
Exemple #19
0
  public static function ui( MEOW_Field $field ) {
    
    $options = $field->info->type_options;

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

    if (isset($options["height"])) {
      $height = $options["height"];
    }
  

    if (is_numeric($maxwidth)) {
      $maxwidth = "{$maxwidth}px";
    } else {
      $maxwidth = "580px";
    }
        
    if (is_numeric($height)) {
      $height = "{$height}px";
    } else {
      $height = "160px";
    }

    $size = "";
    
    $select_attr = array(
      "id" => "{{id}}", "name" => "{{name}}", "size" => "2", "style" => "max-width: {$maxwidth}; height: {$height};"
    );

    $allow_multiple = $options["allow_multiple"] == "yes";
    
    if ($allow_multiple) {
      $select_attr["multiple"] = "multiple";
      $select_attr["name"] = "{{name}}[]";
      $select_attr["data-placeholder"] = self::option_value($options, "placeholder", "-- Select an item --");
    }

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


    $values = WOOF_HTML::option_values($field->info->options("values"), "", true);

    $field_values = $field->values();
    $selected_values = $field_values;
    
    if (!is_array($field_values)) {
      $field_values = explode(",", $field_values);
    }
    
    self::$values_keys = array();
    
    if (!$field->blank()) {
      // populate the values
      $selected_values = array();
      
      foreach ($values as $key => $value) {
        
        if ($allow_multiple) {
          
          if (is_array($value)) {
            
            foreach ($value as $sub_key => $sub_value) {
              if (in_array($sub_value, $field_values)) {
                self::$values_keys[] = $sub_key; // cache the keys for the summary, so we don't have to look them up again!
                $selected_values[] = $sub_value;
              }
            }
            

          } else {

            if (in_array($value, $field_values)) {
              self::$values_keys[] = $key; // cache the keys for the summary, so we don't have to look them up again!
              $selected_values[] = $value;
            }

          }
          
        } else {
          
          if (is_array($value)) {
            
            foreach ($value as $sub_key => $sub_value) {
              if ($sub_value == $field_values) {
                self::$values_keys[] = $sub_key; // cache the keys for the summary, so we don't have to look them up again!
                $selected_values[] = $sub_value;
              }
            }
          
          }
          else {
            
            if ($value == $field_values) {
              self::$values_keys[] = $key; // cache the keys for the summary, so we don't have to look them up again!
              $selected_values = $value;
            }
          
          }
          
        }
        
      }

    }
      
    if (!$field->is_editable()) {
      $select_attr["disabled"] = "disabled";
      $select_attr["data-placeholder"] = __("-- None Selected --", MASTERPRESS_DOMAIN);
    }

    $basic = self::option_value($options, "basic") == "yes";

      
    $val = implode(",", $field_values);
    
    $select_attr["data-value-input"] = "{{id}}-value-input";
    $input = '<input type="hidden" id="{{id}}-value-input" name="{{name}}" type="hidden" value="'.$val.'" class="select2-hidden" />';
    
    if (!$basic) {
      // ensure the select control does not affect the values posted, the hidden input is responsible for this
      $select_attr["name"] = "src_".$select_attr["name"];
    }
    
    $select = WOOF_HTML::select( 
      $select_attr,
      $values,
      $selected_values
    );

    $buttons = "";

    if ($allow_multiple) {
    
      if (isset($options["buttons"])) {
        if (in_array("select_all", $options["buttons"])) {
          $buttons .= '<button type="button" class="button button-small select-all">'.$select_all_label.'</button>';
        }

        if (in_array("select_none", $options["buttons"])) {
          $buttons .= '<button type="button" class="button button-small select-none">'.$select_none_label.'</button>';
        }
      }
      
    }
  
    $html = "$input $select";
    
    return $html;
    
  }