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"> </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; }
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; }
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; }
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 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; }
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; }
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 ) { 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… 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 = ' … ', false, true); $summary_display_title = WOOF::truncate_advanced($prop_title, 50, $etc = ' … ', 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; }
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; }
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"> </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; }