From 732aed1cb888fece5548cf845c74aeefb18761ee Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 19 Jul 2012 18:13:02 +0200 Subject: [PATCH] Showing simple form if nanogong doesn't load see #4493 --- main/document/document.php | 23 +++----------- main/inc/lib/document.lib.php | 49 ++++++++++++++++++++++++++++-- main/inc/lib/nanogong.lib.php | 57 +++++++---------------------------- 3 files changed, 63 insertions(+), 66 deletions(-) diff --git a/main/document/document.php b/main/document/document.php index 21cd70aade..989e3cea08 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -492,24 +492,11 @@ if (!empty($docs_and_folders)) $extension = 'oga'; } //$("#jplayer_inspector_'.$count.'").jPlayerInspector({jPlayer:$("#jquery_jplayer_'.$count.'")}); - $jquery .= ' $("#jquery_jplayer_' . $count . '").jPlayer({ - ready: function() { - $(this).jPlayer("setMedia", { - ' . $extension . ' : "' . $document_data['direct_url'] . '" - }); - }, - play: function() { // To avoid both jPlayers playing together. - $(this).jPlayer("pauseOthers"); - }, - //errorAlerts: true, - //warningAlerts: true, - swfPath: "' . $js_path . 'jquery-jplayer", - //supplied: "m4a, oga, mp3, ogg, wav", - supplied: "' . $extension . '", - wmode: "window", - solution: "flash, html", // Do not change this setting - cssSelectorAncestor: "#jp_container_' . $count . '", - }); ' . "\n\n"; + $params = array('url' => $document_data['direct_url'], + 'extension' =>$extension, + 'count'=> $count + ); + $jquery .= DocumentManager::generate_jplayer_jquery($params); $count++; } } diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index bbc67c5544..16b69c4c8a 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2448,6 +2448,36 @@ class DocumentManager { } return true; } + + /** + * + * @param array paremeters: count, url, extension + * @return string + */ + + function generate_jplayer_jquery($params = array()) { + $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; + + $jplayer_definition = ' $("#jquery_jplayer_' . $params['count'] . '").jPlayer({ + ready: function() { + $(this).jPlayer("setMedia", { + ' . $params['extension'] . ' : "' . $params['url'] . '" + }); + }, + play: function() { // To avoid both jPlayers playing together. + $(this).jPlayer("pauseOthers"); + }, + //errorAlerts: true, + //warningAlerts: true, + swfPath: "' . $js_path . 'jquery-jplayer", + //supplied: "m4a, oga, mp3, ogg, wav", + supplied: "' . $params['extension'] . '", + wmode: "window", + solution: "flash, html", // Do not change this setting + cssSelectorAncestor: "#jp_container_' . $params['count'] . '", + }); ' . "\n\n"; + return $jplayer_definition; + } /** * @@ -2455,8 +2485,21 @@ class DocumentManager { * @param int * @return string html content */ - function generate_media_preview($i) { + function generate_media_preview($i, $type = 'simple') { $i = intval($i); + + $extra_controls = $progress = ''; + if ($type == 'advanced') { + $extra_controls = '
  • +
  • +
  • '; + $progress = '
    + +
    '; + } + //Shows only the play button $html = '
    @@ -2465,7 +2508,9 @@ class DocumentManager { + '.$extra_controls.' + + '.$progress.'
    '; diff --git a/main/inc/lib/nanogong.lib.php b/main/inc/lib/nanogong.lib.php index 77e92d771e..644c708c03 100644 --- a/main/inc/lib/nanogong.lib.php +++ b/main/inc/lib/nanogong.lib.php @@ -352,67 +352,32 @@ class Nanogong { $html .= ''; $html .= ''; - $html .= '
    '.Display::return_message(get_lang('BrowserNotSupportNanogongListen'),'warning').$download_button.'
    '; - + $html .= '
    '.Display::return_message(get_lang('BrowserNotSupportNanogongListen'),'warning').$download_button.'
    '; } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; $html .= ''; + //$html .= ''; $html .= ''; $html .= '
    '; $html .= '
    '.$actions.'



    '; - $jquery .= ' $("#audio_preview").jPlayer({ - ready: function() { - $(this).jPlayer("setMedia", { - '.$path_info['extension'].' : "'.$url.'" - }); - }, - swfPath: "'.$js_path.'jquery-jplayer", - supplied: "mp3, ogg, oga, wav", - solution: "flash, html", // Do not change this setting otherwise - width:0, - height:0, - });'; + $params = array('url' => $url, + 'extension' =>$path_info['extension'], + 'count'=> 1 + ); + $jquery = DocumentManager::generate_jplayer_jquery($params); + - $html .= ''; - - //@todo fix this - $html .= ' -
    -
    - -
    -
    '; + '; + $html .= DocumentManager::generate_media_preview(1, 'advanced'); } return $html; }