Ejemplo n.º 1
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;

  }
Ejemplo n.º 2
0
  public static function ui( MEOW_Field $field ) {

    global $wf;

    $prop_inputs = self::prop_inputs($field, "attachment_id");

    
    $fileurl = "";
    $thumb = "";
    $width = "";
    $height = "";
    $filesize = "";
    $summary_thumb = "";
    $filename = "";
    $filetype = "";
    $empty = "";
    $orientation = "";
    
    $no_image = __("( no image )", MASTERPRESS_DOMAIN);

    $view_image = __("View Image", MASTERPRESS_DOMAIN);

    
    // setup defaults for an empty image

    list($tw, $th) = array(120, 90);
    list($stw, $sth) = array(82, 39);

    $empty = "empty";
    $orientation = "square";

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

      $image = $field->file();

      if ($image->exists()) {

        $empty = "";
         
        $width = $image->width();
        $height = $image->height();

        $orientation =  $height == $width ? "square" : ( $height > $width ? "portrait" : "landscape" );

        list($tw, $th) = self::thumb_wh($width, $height);
        list($stw, $sth) = self::summary_thumb_wh($width, $height);
        
        $filesize   = $image->filesize();
        $filename   = $image->basename();
        $filetype   = $image->filetype();
        
        if ($image->is_external()) {
          $fileurl    = $field->value();
          $source_url = $fileurl;
        } else {
          $fileurl    = $image->permalink();
        }

        $thumb = $image->mp_thumb(array("w" => $tw, "h" => $th, "no_image" => $no_image, "class" => "thumb managed", "href" => $fileurl));
        $summary_thumb = $image->mp_thumb(array("w" => $stw, "h" => $sth, "no_image" => $no_image, "class" => "managed summary-thumb", "thumb_only" => true ) );

      } 
          
    } else {
      $empty = "empty";
      $orientation = "square";
    }

    if (isset($source_url)) {
      $prop_source_url = $source_url;
    } else {
      $prop_source_url = $field->prop("source_url");
    }
    
    $prop_alt = esc_attr( $field->prop("alt") );
    $prop_title = esc_attr( $field->prop("title") );
      
    $replace_image_label = __("Replace Image:", MASTERPRESS_DOMAIN);
    $choose_image_label = __("Choose Image:", MASTERPRESS_DOMAIN);

    $attributes_label = __("Attributes", MASTERPRESS_DOMAIN);
    $attributes_title = __("Edit HTML attributes (alternate text / title)", MASTERPRESS_DOMAIN);

    $url_label = __("Enter Image URL:", MASTERPRESS_DOMAIN);

    $alt_label = __("Alternate Text:", MASTERPRESS_DOMAIN);
    $title_label = __("Title:", MASTERPRESS_DOMAIN);

    $attributes_title = __("Image Tag Attributes", MASTERPRESS_DOMAIN);

    $button_replace_label = __("Replace Image&hellip;", MASTERPRESS_DOMAIN);

    $button_from_computer_label = __("From Computer&hellip;", MASTERPRESS_DOMAIN);
    $button_from_media_library_label = __("From Media Library&hellip;", MASTERPRESS_DOMAIN);
    $button_from_url_label = __("From URL&hellip;", MASTERPRESS_DOMAIN);
    $button_from_existing_uploads_label = __("From Existing Uploads&hellip;", MASTERPRESS_DOMAIN);

    $button_from_media_library_data_library = MasterPress::use_new_media() ? "new" : "legacy";

    $button_clear_label = __("Clear", MASTERPRESS_DOMAIN);
    $button_delete_label = __("Delete", MASTERPRESS_DOMAIN);

    $button_download_label = __("Download", MASTERPRESS_DOMAIN);
    $button_cancel_label = __("Cancel", MASTERPRESS_DOMAIN);
    
    $button_clear_title = __("Clear field without deleting the image file", MASTERPRESS_DOMAIN);
    $button_delete_title = __("Clear field AND delete the image file", MASTERPRESS_DOMAIN);

    $w_times_h = __("width &times; height", MASTERPRESS_DOMAIN);

    $drop_label = __("Drop image<br />file here<br />to upload", MASTERPRESS_DOMAIN);

    $base_url = MASTERPRESS_CONTENT_URL;
    $dir = 'uploads/';

    $media_library_progress_message = __("Fetching URL from Media Library...", MASTERPRESS_DOMAIN);
    $upload_progress_message = __("Uploading...", MASTERPRESS_DOMAIN);
    $fetching_info_message = __("Fetching Image Information...", MASTERPRESS_DOMAIN);

    $dowloading_progress_message = __("Downloading Image...", MASTERPRESS_DOMAIN);

    $href = ' href="'.$fileurl.'" ';
      
    if ($fileurl == "") {
      $href = "";
    }
    
    // populate the media library dialog
    // $media_library_dialog 

    $upload_html = "";
    $download_html = "";
    $clear_html = "";
    $labels_html = "";
    $ml_html = "";
    
    $choose_html = "";
    
    $readonly = WOOF_HTML::readonly_attr( !$field->is_editable() );
    
    if ($wf->the_user->can("upload_files") && $field->is_editable()) {
      
      $choose_html = <<<HTML
      <div class="choose-controls">
        <h5 class="replace-label">{$replace_image_label}</h5>
        <h5 class="choose-label">{$choose_image_label}</h5>

        <div class="buttons">

          <div class="file-uploader { input: '#{{id}}', inputName: '{{id}}_file', ids: { drop: '{{id}}_drop_area' }, base_url: '{$base_url}', params: { dir: '{$dir}' }, limit: 1, lang: { buttonChoose: '{$button_from_computer_label}', buttonReplace: '{$button_from_computer_label}' } }">
            <input id="{{id}}" name="{{name}}" value="{$fileurl}" type="hidden" class="value" autocomplete="off" />
            <div class="uploader-ui"></div>
          </div>
          <!-- /.file-uploader -->

          <button type="button" class="button button-small button-from-url">{$button_from_url_label}</button>
          <button type="button" class="button button-small button-from-media-library" data-library="{$button_from_media_library_data_library}">{$button_from_media_library_label}</button>

        </div>
      
      </div>
      <!-- /.choose-controls -->
HTML;
   
    $clear_html = <<<HTML
    <ul class="controls">
      <li><button title="{$button_clear_title}" type="button" class="text with-icon clear">{$button_clear_label}</button></li>
    </ul>
HTML;

    } else {

      $choose_html = <<<HTML
<input id="{{id}}" name="{{name}}" value="{$fileurl}" type="hidden" class="value" autocomplete="off" />
HTML;

    }

    $html = <<<HTML

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

      {$prop_inputs}
    
      <div class="thumbs {$orientation}">

        <div id="{{id}}_drop_area" class="drop-area">{$drop_label}</div>

        {$summary_thumb}
        {$thumb}

      </div>
      <!-- /.thumbs -->

      <div class="info-controls">

        <div class="name-controls">
          <h5><a target="_blank" href="{$fileurl}" tabindex="-1" title="{$filename}" class="fancybox file-link with-icon"><span class="filename">{$view_image}</span></a></h5>
          {$clear_html}
        </div>

        <ul class="prop">
          <li class="filetype">{$filetype}</li>
          <li class="dimensions" title="{$w_times_h}"><span class="width">{$width}</span> &times; <span class="height">{$height}</span></li>
          <li class="filesize">{$filesize}</li>
          <li class="attributes"><button type="button" class="text with-icon attributes" title="{$attributes_title}">{$attributes_label}</button></li>
        </ul>

        {$choose_html}

        <div class="media-library-progress">
          <span class="fetching-message progress-message">{$media_library_progress_message}</span>  
          <span class="fetching-info-message progress-message">{$fetching_info_message}</span>  
        </div>
        <!-- /.media-library-progress -->
      
      
        <div class="upload-progress">

          <span class="name"></span>

          <div class="progress-bar-with-val">
            <div class="progress-bar"><div class="border"><div><span class="bar">&nbsp;</span></div></div></div>
            <div class="val">0%</div>
          </div>

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

        </div>
        <!-- /.upload-progress -->


        <div class="from-url-ui">
          <label for="{{id}}-url">{$url_label}</label>
          <input id="{{prop_id}}-source_url" name="{{prop_name}}[source_url]" type="text" value="{$prop_source_url}" class="text url" />

          <div class="buttons">
            <button type="button" class="button button-small download">{$button_download_label}</button>
            <button type="button" class="button button-small cancel">{$button_cancel_label}</button>
          </div>
        </div>
        <!-- /.from-url -->

        <div class="download-progress">
          <span class="downloading-message progress-message">{$dowloading_progress_message}</span>  
          <span class="fetching-info-message progress-message">{$fetching_info_message}</span>  
        </div>
        <!-- /.download-progress -->
      
      </div>
      <!-- /.info-controls -->

      <div class="dialogs">
        
        <div class="mpft-image-attributes-dialog mp-dialog mpv" data-title="{$attributes_title}">
          <div class="pad">
          
          <div class="f">
            <label for="{{prop_id}}-alt">{$alt_label}</label>
            <div class="fw">
              <input id="{{prop_id}}-alt" $readonly name="{{prop_name}}[alt]" value="{$prop_alt}" type="text" class="text alt" />
            </div>
            <!-- /.fw -->
          </div>
          <!-- /.f -->
        
          <div class="f">
            <label for="{{prop_id}}-title">{$title_label}</label>
            <div class="fw">
              <input id="{{prop_id}}-title" $readonly name="{{prop_name}}[title]" value="{$prop_title}" type="text" class="text title"  />
            </div>
            <!-- /.fw -->
          </div>
          <!-- /.f -->
        
          </div>
          <!-- /.pad -->
        </div>
    
      </div>
      <!-- /.dialogs -->
      
      
    </div>
    <!-- /.ui-state -->

HTML;

    return $html;

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

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

  }
Ejemplo n.º 4
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;

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

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

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

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

  }
Ejemplo n.º 9
0
  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;

  }
Ejemplo n.º 10
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;

  }