Esempio n. 1
0
 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;
   }
 }
Esempio n. 2
0
 public static function summary( MEOW_Field $field ) {
   if (!$field->blank()) {
     return self::truncate_for_summary(self::summary_width(), $field->value());
   }
 }
Esempio n. 3
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 "";
  }
Esempio n. 4
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;

    
  }
Esempio n. 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() );

    $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;

  }
Esempio n. 6
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;

  }
Esempio n. 7
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;

  }
Esempio n. 8
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;

  }
Esempio n. 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;

    $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;

  }
Esempio n. 10
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;
    
  }
Esempio n. 11
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;

  }
Esempio n. 12
0
  public static function summary( MEOW_Field $field ) {
    
    $style = "";
    $value = "";

    if (!$field->blank()) {
      $value = $field->value();
      $style = "background-color: ".esc_attr($value).";";
    }

    $html = <<<HTML

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

HTML;

    return $html;

  }
Esempio n. 13
0
  public static function summary( MEOW_Field $field ) {

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

    $mode = "";
    $month = "";
    $year = "";
    $day = "";
    
    if (isset($options["mode"])) {
      $mode = $options["mode"];
    }

    if (!$field->blank()) {

      if ($mode != "start_end") {
        $time = strtotime($field->str());


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

      }

    }

$html = <<<HTML

      <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;
    }

    return $html;

  } 
Esempio n. 14
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;

  }
Esempio n. 15
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;
    
  }