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 ) { $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 $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; }