Plugin Directory

Changeset 961328


Ignore:
Timestamp:
08/06/2014 08:49:49 PM (12 years ago)
Author:
zubaka
Message:

Fix links/file name problem. For utf8 strings previous fix works bad, so - added some tests.

Location:
zbplayer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • zbplayer/tags/2.1.9/zbPlayer.php

    r961325 r961328  
    208208}
    209209
    210 
     210/**
     211 * Test if incoming parameter contain utf8 symbols
     212 *
     213 * @param mixed(string|array) $mixed
     214 * @return boolean
     215 */
    211216function zbp_is_utf8($mixed)
    212217{
     218    if (!function_exists('mb_detect_encoding')) {
     219        return true;
     220    }
    213221    if (is_array($mixed)) {
    214222        foreach ($mixed as $name) {
  • zbplayer/trunk/readme.txt

    r961284 r961328  
    55Requires at least: 3.5
    66Tested up to: 3.9.2
    7 Stable tag: 2.1.8
     7Stable tag: 2.1.9
    88License: Dual Licensed under the MIT and GPLv2 or later
    99
     
    5252== Changelog ==
    5353
    54 = 2.1.8 =
     54= 2.1.8/9 =
    5555*    Fix links/file name problem. Sometime flash player did not understand correctly file names to play.
    5656
  • zbplayer/trunk/zbPlayer.admin.php

    r961284 r961328  
    77 *
    88 *  zbPlayer.admin.php
    9  *  Release 2.1.8 August 2014
     9 *  Release 2.1.9 August 2014
    1010 */
    1111// connect wordpress color picker
  • zbplayer/trunk/zbPlayer.php

    r961284 r961328  
    44Plugin URI: http://gilevich.com/portfolio/zbplayer
    55Description: Converts mp3 files links to a small flash player and a link to download file mp3 file. Also you can share your mp3 files with that plugin.
    6 Version: 2.1.8
     6Version: 2.1.9
    77Author: Vladimir Gilevich
    88Author URI: http://gilevich.com/
     
    1010*/
    1111
    12 define('ZBPLAYER_VERSION', "2.1.8");
     12define('ZBPLAYER_VERSION', "2.1.9");
    1313define('ZBPLAYER_DEFAULT_WIDTH', "500");
    1414define('ZBPLAYER_DEFAULT_INITIALVOLUME', "60");
     
    107107            }
    108108            if (count($links)) {
     109                // test on utf-8 in links
     110                if (zbp_is_utf8($links)) {
     111                    foreach ($links as $key => $link) {
     112                        $links[$key] = zbp_urlencode($link);
     113                    }
     114                    $links = implode(',', $links);
     115                    $encode = '';
     116                } else {
     117                    $links = zbp_encode_source(implode(',', $links));
     118                    $encode = '&encode=yes';
     119                }
    109120                $loop = get_option('zbp_loop') == 'true' ? 'yes' : 'no';
    110121                $autostart = get_option('zbp_autostart') == 'true' ? 'yes' : 'no';
     
    117128                    . ' flashvars="loop='.$loop.'&animation='.$animation.'&playerID=zbPlayer&initialvolume='.$initialvolume . zbp_get_color_srt()
    118129                    . $titles
    119                     . '&encode=yes&soundFile='.zbp_encode_source(implode(',',$links))
     130                    . $encode.'&soundFile='.$links
    120131                    . '&amp;autostart='.$autostart.'" type="application/x-shockwave-flash" class="player" src="'.plugin_dir_url(__FILE__).'data/player.swf" id="zbPlayer"/></div>';
    121132                $content = str_replace(get_option('zbp_collect_field'), $player, $content);
     
    185196    $songname .= !empty($songname) ? '<br/>' : '';
    186197    $titles = (get_option('zbp_id3') == 'true') ? '' : '&amp;titles='.urlencode($titles);
    187 
     198    $encode = zbp_is_utf8($link) ? '' : '&amp;encode=yes';
    188199    $ret = '<div class="zbPlayer">' . $songname
    189200        . $shareInline
    190201        . '<embed width="'.$width.'" height="26" wmode="transparent" menu="false" quality="high"'
    191202        . ' flashvars="loop='.$loop.'&animation='.$animation.'&amp;playerID=zbPlayer&amp;initialvolume='.$initialvolume . zbp_get_color_srt()
    192         . $titles.'&amp;encode=yes&amp;soundFile='.zbp_encode_source($link)
     203        . $titles.$encode.'&amp;soundFile='.zbp_encode_source($link)
    193204        . '&amp;autostart='.$autostart.'" type="application/x-shockwave-flash" class="zbPlayerFlash" src="'.plugin_dir_url(__FILE__).'data/player.swf" id="zbPlayer"/>';
    194205    $ret .= '<audio class="zbPlayerNative" src="'.$link.'" controls preload="none"></audio>';
     
    198209
    199210/**
     211 * Test if incoming parameter contain utf8 symbols
     212 *
     213 * @param mixed(string|array) $mixed
     214 * @return boolean
     215 */
     216function zbp_is_utf8($mixed)
     217{
     218    if (!function_exists('mb_detect_encoding')) {
     219        return true;
     220    }
     221    if (is_array($mixed)) {
     222        foreach ($mixed as $name) {
     223            if (mb_detect_encoding($name) == 'UTF-8') {
     224                return true;
     225            }
     226        }
     227    } else {
     228        if (mb_detect_encoding($mixed) == 'UTF-8') {
     229            return true;
     230        }
     231    }
     232    return false;
     233}
     234
     235/**
    200236 * Encodes the given string for flash player
    201237 *
     
    205241function zbp_encode_source($string)
    206242{
     243    if (zbp_is_utf8($string)) {
     244        return zbp_urlencode($string);
     245    }
    207246    $source = utf8_decode($string);
    208247    $ntexto = "";
Note: See TracChangeset for help on using the changeset viewer.