コード例 #1
0
ファイル: mpft-image.php プロジェクト: verbazend/AWFA
  public static function options_form( $options ) {

    $mfs = WOOF_File::to_bytes(ini_get('upload_max_filesize'));
    $mps = WOOF_File::to_bytes(ini_get('post_max_size'));

    $html = "";
    
    $limit = self::get_filesize_limit();

    $limit_mb = WOOF_File::format_filesize($limit, "MB", false);

    $defaults = array(
      "filename_case" => "lowercase",
      "filename_sanitize" => "dashes",
      "filename_dashes_underscores" => "dashes",
      "allowed_maxsize" => $limit_mb,
      "allowed_types" => array("jpg","jpeg","png","gif")
    );

    $options = wp_parse_args( $options, $defaults );
    $p = self::type_prefix(__CLASS__);

    $allowed_types_label = __("Allowed File Types:", MASTERPRESS_DOMAIN);
    $allowed_maxsize_label = __("Maximum Size:", MASTERPRESS_DOMAIN);

    $filename_label = __("File Name Handling", MASTERPRESS_DOMAIN);
    $filename_label_note = __("specify how file names should be sanitized on upload", MASTERPRESS_DOMAIN);

    $filename_sanitize_label = __("Sanitize file name:", MASTERPRESS_DOMAIN);
    $filename_sanitize_note = __("Sanitization removes special characters and replaces word boundaries with the specified character", MASTERPRESS_DOMAIN);

    $filename_case_label = __("Change case to:", MASTERPRESS_DOMAIN);

    $filename_case_select = WOOF_HTML::select(
      array("id" => $p."filename_case", "name" => "type_options[filename_case]"), 
      array(
        "lower-case" => "lowercase", 
        "Title-Case" => "titlecase",
        "UPPER-CASE" => "uppercase",
        "Preserve (No Change)" => "none"
      ),
      $options["filename_case"]
    );

    $filename_sanitize_select = WOOF_HTML::select(
      array("id" => $p."filename_sanitize", "name" => "type_options[filename_sanitize]"), 
      array(
        __("With Dashes ( - )", MASTERPRESS_DOMAIN) => "dashes", 
        __("With Underscores ( _ )", MASTERPRESS_DOMAIN) => "underscores", 
        __("None (Don't Sanitize)", MASTERPRESS_DOMAIN) => "none"
      ),
      $options["filename_sanitize"]
    );

    $allowed_maxsize_note = __("( MB )", MASTERPRESS_DOMAIN);
    $allowed_maxsize_blank_note = sprintf(__("This value <strong>cannot exceed</strong> the maximum upload size<br />for your server, which is currently set to <strong>%s</strong>.", MASTERPRESS_DOMAIN), WOOF_File::format_filesize($limit, "MB", true, "&nbsp;"));

    $allowed_label = __("File Restrictions", MASTERPRESS_DOMAIN);
    $allowed_label_note = __("restrict allowable files by type and file size", MASTERPRESS_DOMAIN);

    $allowed_types_note = __("The image field type is intended only for images that are displayable on a website.<br />For other image types, use the <em>file</em> field type instead", MASTERPRESS_DOMAIN);

    MPFT::incl("file");

    foreach (array("jpg","jpeg","png","gif") as $ext) {
      $file_types_items[ MPFT_File::file_type_label($ext) ] = $ext;
    }

    $allowed_types_checkboxes = WOOF_HTML::input_checkbox_group( "type_options[allowed_types][]", $p."allowed-types-", $file_types_items, $options["allowed_types"], WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); 

    // setup variables to insert into the heredoc string
    // (this is required where we cannot call functions within heredoc strings)


    $html .= <<<HTML

    <div class="filename-handling-wrap">

    <h4><i class="highlighter"></i>{$filename_label}<span>&nbsp;&nbsp;-&nbsp;&nbsp;{$filename_label_note}</span></h4>

    <div class="f">
      <label for="{$p}filename_sanitize">{$filename_sanitize_label}</label>
      <div id="fw-{$p}filename_sanitize" class="fw">
        {$filename_sanitize_select}
        <p class="note">{$filename_sanitize_note}</p>
      </div>
    </div>
    <!-- /.f -->

    <div class="f">
      <label for="{$p}filename_case">{$filename_case_label}</label>
      <div id="fw-{$p}filename_case" class="fw">
        {$filename_case_select}
      </div>
    </div>
    <!-- /.f -->

    </div>


    <div class="allowed-wrap divider">

    <h4><i class="warning-shield"></i>{$allowed_label}<span>&nbsp;&nbsp;-&nbsp;&nbsp;{$allowed_label_note}</span></h4>


    <div class="f">
      <label for="{$p}allowed_maxsize">{$allowed_maxsize_label}</label>
      <div id="fw-{$p}allowed_maxsize" class="fw">
        <input id="{$p}allowed_maxsize" name="type_options[allowed_maxsize]" type="text" maxlength="4" value="{$options['allowed_maxsize']}" class="text" /><span class="note">{$allowed_maxsize_note}</span>
        <p class="note">{$allowed_maxsize_blank_note}</p>
      </div>
    </div>
    <!-- /.f -->

    <div class="f f-allowed-types">
      <p class="label">{$allowed_types_label}</p>
      <div class="fw">
      {$allowed_types_checkboxes}
      <div class="controls"><button type="button" class="button button-small select-all">Select All</button><button type="button" class="button button-small select-none">Select None</button></div>
      <p class="note">{$allowed_types_note}</p>

      </div>
    </div>
    <!-- /.f -->

    </div>

HTML;

    return $html;

  }
コード例 #2
0
ファイル: mpft-audio.php プロジェクト: verbazend/AWFA
  public static function options_form( $options ) {

    $html = "";
    
    $limit = self::get_filesize_limit();

    $limit_mb = WOOF_File::format_filesize($limit, "MB", false);


    $defaults = array(
      "filename_case" => "lowercase",
      "filename_sanitize" => "dashes",
      "allowed_types" => array("ogg","mp3","wav")
    );


    $options = wp_parse_args( $options, $defaults );
    $p = self::type_prefix(__CLASS__);

    $allowed_maxsize = self::option_value($options, "allowed_maxsize");
    $allowed_types = self::option_value($options, "allowed_types");

    $allowed_field = implode(",", $allowed_types);

    $allowed_types_label = __("Allowed File Types:", MASTERPRESS_DOMAIN);
    $allowed_maxsize_label = __("Maximum Size:", MASTERPRESS_DOMAIN);

    $allowed_field_label = __("More Allowed Types:", MASTERPRESS_DOMAIN);
    $allowed_field_note = __("Separate file extensions that you would like to allow with commas.<br /><strong>Important:</strong> in the interests of security, take care to avoid file types that are executable on your server that may be exploitable by malicious users.<br /><br />Alternatively, you can populate the list by selecting from the list of typical field types below:", MASTERPRESS_DOMAIN);

    $filename_label = __("File Name Handling", MASTERPRESS_DOMAIN);
    $filename_label_note = __("specify how file names should be sanitized on upload", MASTERPRESS_DOMAIN);

    $filename_sanitize_label = __("Sanitize file name:", MASTERPRESS_DOMAIN);
    $filename_sanitize_note = __("Sanitization removes special characters and replaces word boundaries with the specified character", MASTERPRESS_DOMAIN);

    $filename_case_label = __("Change case to:", MASTERPRESS_DOMAIN);

    $filename_case_select = WOOF_HTML::select(
      array("id" => $p."filename_case", "name" => "type_options[filename_case]"), 
      array(
        "lower-case" => "lowercase", 
        "Title-Case" => "titlecase", 
        "UPPER-CASE" => "uppercase", 
        "Preserve (No Change)" => "none"
      ),
      $options["filename_case"]
    );

    $filename_sanitize_select = WOOF_HTML::select(
      array("id" => $p."filename_sanitize", "name" => "type_options[filename_sanitize]"), 
      array(
        __("With Dashes ( - )", MASTERPRESS_DOMAIN) => "dashes", 
        __("With Underscores ( _ )", MASTERPRESS_DOMAIN) => "underscores", 
        __("None (Don't Sanitize)", MASTERPRESS_DOMAIN) => "none"
      ),
      $options["filename_sanitize"]
    );


    $allowed_maxsize_note = __("( MB )", MASTERPRESS_DOMAIN);
    $allowed_maxsize_blank_note = sprintf(__("This value <strong>cannot exceed</strong> the maximum upload size<br />for your server, which is currently set to <strong>%s</strong>.", MASTERPRESS_DOMAIN), WOOF_File::format_filesize($limit, "MB", true, "&nbsp;"));

    $allowed_label = __("File Restrictions", MASTERPRESS_DOMAIN);
    $allowed_label_note = __("restrict allowable files by type and file size", MASTERPRESS_DOMAIN);

    // setup variables to insert into the heredoc string
    // (this is required where we cannot call functions within heredoc strings)

    MPFT::incl("file");

    foreach (array("aac","aif","aiff","m4a", "ogg", "mid", "mp3", "mp4", "mpa", "wav", "wma") as $ext) {
      $file_types_items[ MPFT_File::file_type_label($ext) ] = $ext;
    }

    $allowed_types_checkboxes = WOOF_HTML::input_checkbox_group( "type_options[allowed_types][]", $p."allowed-types-", $file_types_items, $options["allowed_types"], WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); 



    $html .= <<<HTML

    <div class="filename-handling-wrap">

    <h4><i class="highlighter"></i>{$filename_label}<span>&nbsp;&nbsp;-&nbsp;&nbsp;{$filename_label_note}</span></h4>

    <div class="f">
      <label for="{$p}filename_sanitize">{$filename_sanitize_label}</label>
      <div id="fw-{$p}filename_sanitize" class="fw">
        {$filename_sanitize_select}
        <p class="note">{$filename_sanitize_note}</p>
      </div>
    </div>
    <!-- /.f -->

    <div class="f">
      <label for="{$p}filename_case">{$filename_case_label}</label>
      <div id="fw-{$p}filename_case" class="fw">
        {$filename_case_select}
      </div>
    </div>
    <!-- /.f -->

    </div>


    <div class="allowed-wrap divider">

    <h4><i class="warning-shield"></i>{$allowed_label}<span>&nbsp;&nbsp;-&nbsp;&nbsp;{$allowed_label_note}</span></h4>


    <div class="f">
      <label for="{$p}allowed_maxsize">{$allowed_maxsize_label}</label>
      <div id="fw-{$p}allowed_maxsize" class="fw">
        <input id="{$p}allowed_maxsize" name="type_options[allowed_maxsize]" type="text" maxlength="4" value="{$allowed_maxsize}" class="text" /><span class="note">{$allowed_maxsize_note}</span>
        <p class="note">{$allowed_maxsize_blank_note}</p>
      </div>
    </div>
    <!-- /.f -->



    <div class="f f-allowed-types">
      <p class="label">{$allowed_types_label}</p>
      <div class="fw">
      {$allowed_types_checkboxes}
      <div class="controls"><button type="button" class="button button-small select-all">Select All</button><button type="button" class="button button-small select-none">Select None</button></div>
      <p class="note">{$allowed_types_note}</p>

      </div>
    </div>
    <!-- /.f -->


    </div>

HTML;

    return $html;

  }