Exemple #1
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 #2
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… 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;

  }