Exemplo n.º 1
0
        $skip_javascripts[] = '	
			$( "#skip_filepreview_' . $this->params['id'] . '" ).attr( "src", $( "#skip_filename_' . $this->params['id'] . ' a" ).attr( "href" ) );
		';
        $html_before = '<div class="skip_file ui-state-default ui-corner-all">';
        $html_before .= '<div class="skip_filepreview">';
        $html_before .= '<img id="skip_filepreview_' . $this->params['id'] . '" class="skip_filepreview_image" />';
        if (isset($this->value['url'])) {
            $html_before .= '<div class="skip_filename" id="skip_filename_' . $this->params['id'] . '"><a href="' . $file_url . '" target="_blank">' . basename($file_path) . '</a></div>';
        }
        $html_before .= '</div>';
        $html_before .= '<div class="skip_fileuploader">';
        $html_after = '</div></div>';
        $this->before($html_before);
        $this->after($html_after);
        $this->add_param('class', 'skip_file_fileinput');
        return parent::render();
    }
    /**
	 * Saving Editor field
	 * @package Skip
	 * @since 1.0
	 */
    public function save()
    {
        if (array_key_exists('CONTENT_LENGTH', $_SERVER)) {
            if ($_SERVER['CONTENT_LENGTH'] > max_upload()) {
Exemplo n.º 2
0
 /**
  * WP Form constructor
  *
  * @package Skip
  * @since 1.0
  * 
  * @param string $name The name of the form
  * @param string $args Array of [ 'id' ], [ 'classes' ], [ 'before_element' ], [ 'after_element' ] and [ 'params' ]
  */
 function __construct($name, $args = array())
 {
     global $skip_form_name;
     /*
      * Additional parent args:
      * 'id'
      * 'classes'
      * 'before_element'
      * 'after_element'
      * 'params'
      */
     $defaults = array('enctype' => 'multipart/form-data', 'classes' => 'skip_form');
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     if ('' == $name) {
         return;
     }
     $method = 'POST';
     $action = $_SERVER['REQUEST_URI'];
     $args['close_tag'] = TRUE;
     parent::__construct('form', $args);
     $skip_form_name = $name;
     $this->add_param('name', $name);
     if ('' != $method) {
         $this->add_param('method', $method);
     }
     if ('' != $action) {
         $this->add_param('action', $action);
     }
     if ('' != $enctype) {
         $this->add_param('enctype', $enctype);
     }
     // Needed Fields for Form
     $needed_fields = wp_nonce_field('skip_form_' . $name, $name . '_wpnonce', TRUE, FALSE);
     $needed_fields .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . max_upload() . '" />';
     $this->add_element($needed_fields);
 }
 /**
  * Constructor
  * @package Skip
  * @since 1.0
  * @param string $tag The HTML Tag to use for element
  * @param string $name The name of the element where to save data
  * @param array $args Arguments
  */
 function __construct($tag, $name, $args = array())
 {
     global $skip_form_name;
     /*
      * Additional parent args:
      * 'id'
      * 'classes'
      * 'before_element'
      * 'after_element'
      * 'params'
      */
     $defaults = array('label' => '', 'description' => '', 'default' => FALSE, 'value' => '', 'array' => '', 'save' => TRUE, 'disabled' => FALSE, 'form_name' => $skip_form_name, 'errors' => array(1 => __('Form could not be verified. Field could not be saved.', 'skip_framework'), 2 => sprintf(__('Upload limit exceeded. %s Bytes uploaded, %s Bytes allowed. Please try to upload one file after another or choose a smaller file.', 'skip_framework'), array_key_exists('CONTENT_LENGTH', $_SERVER) ? $_SERVER['CONTENT_LENGTH'] : 0, max_upload())));
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     parent::__construct($tag, $args);
     $this->form_name = $form_name;
     $this->name = $name;
     $this->save = $save;
     $this->default = $default;
     // Setting up Array
     if (!is_array($array)) {
         $this->array = explode(',', $array);
         // For Values by param String
         if (count($this->array) == 1) {
             $this->array = $this->array[0];
         }
         // If array is given
     } else {
         $this->array = $array;
     }
     $this->errors = $errors;
     $this->field_name = $this->field_name();
     // Name of HTML Field
     $this->option_name = $this->option_name();
     // Name of WP Option Field
     if ($save) {
         $this->save();
     }
     // Register for saving
     if ('' == $value) {
         $this->value = $this->value();
     } else {
         $this->value = $value;
     }
     // Setting up Tag
     $this->add_param('name', $this->field_name);
     $this->add_param('value', $this->value);
     if (TRUE == $disabled) {
         $this->add_param('disabled', 'disabled');
     }
     $this->before('<div class="skip_field">');
     if ('' != $label) {
         $this->before('<div class="skip_field_row skip_field_row_' . $this->params['id'] . '"><label for="' . $this->params['id'] . '">' . $label . '</label><div class="skip_row_content">');
     }
     if ('' != $description) {
         $this->after('<div class="skip_field_description skip_field_description_' . $this->params['id'] . '">' . $description . '</div>');
     }
     if ('' != $label) {
         $this->after('</div><div class="clear"></div></div>');
     }
     $this->after('</div>');
 }