|
|
|
@ -10,10 +10,6 @@ |
|
|
|
|
* @since 8/January/2011 |
|
|
|
|
* TODO:clean all file |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* Code |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/* INIT SECTION */ |
|
|
|
|
$language_file = array('document'); |
|
|
|
|
|
|
|
|
@ -35,7 +31,7 @@ if (api_get_setting('enabled_text2audio') == 'false'){ |
|
|
|
|
$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id()); |
|
|
|
|
if (empty($document_data)) { |
|
|
|
|
if (api_is_in_group()) { |
|
|
|
|
$group_properties = GroupManager::get_group_properties(api_get_group_id()); |
|
|
|
|
$group_properties = GroupManager::get_group_properties(api_get_group_id()); |
|
|
|
|
$document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']); |
|
|
|
|
$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id()); |
|
|
|
|
} |
|
|
|
@ -130,12 +126,12 @@ Display :: display_header($nameTools, 'Doc'); |
|
|
|
|
|
|
|
|
|
echo '<div class="actions">'; |
|
|
|
|
echo '<a href="document.php?id='.$document_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&dt2a=google">'.Display::return_icon('google.png',get_lang('GoogleAudio'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&dt2a=pediaphon">'.Display::return_icon('pediaphon.png', get_lang('Pediaphon'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo '</div>'; |
|
|
|
|
|
|
|
|
|
?> |
|
|
|
@ -191,30 +187,30 @@ $(document).ready(function(){ |
|
|
|
|
} elseif (Security::remove_XSS($_POST['text2voice_mode']) == 'pediaphon') { |
|
|
|
|
downloadMP3_pediaphon($filepath, $dir); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
|
|
|
$sql_select = "SELECT * FROM $tbl_admin_languages"; |
|
|
|
|
$result_select = Database::query($sql_select); |
|
|
|
|
$result_select = Database::query($sql_select); |
|
|
|
|
|
|
|
|
|
$options = $options_pedia = array(); |
|
|
|
|
$selected_language = null; |
|
|
|
|
|
|
|
|
|
while ($row = Database::fetch_array($result_select)) { |
|
|
|
|
if (api_get_setting('platformLanguage')==$row['english_name']) { |
|
|
|
|
|
|
|
|
|
while ($row = Database::fetch_array($result_select)) { |
|
|
|
|
if (api_get_setting('platformLanguage')==$row['english_name']) { |
|
|
|
|
//$selected_language = $row['isocode'];//lang default is the default platform language |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$options[$row['isocode']] =$row['original_name'].' ('.$row['english_name'].')'; |
|
|
|
|
|
|
|
|
|
if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))){ |
|
|
|
|
if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))){ |
|
|
|
|
$options_pedia[$row['isocode']] =$row['original_name'].' ('.$row['english_name'].')'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$icon = Display::return_icon('text2audio.png', get_lang('HelpText2Audio'),'',ICON_SIZE_MEDIUM); |
|
|
|
|
echo '<div class="page-header"><h2>'.$icon.get_lang('HelpText2Audio').'</h2></div>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo '<div class="page-header"><h2>'.$icon.get_lang('HelpText2Audio').'</h2></div>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(Security::remove_XSS($_GET['dt2a'])=='google'){ |
|
|
|
|
$selected_language = api_get_language_isocode();//lang default is the course language |
|
|
|
|
echo '<div>'; |
|
|
|
@ -222,70 +218,70 @@ $(document).ready(function(){ |
|
|
|
|
$form->addElement('hidden', 'text2voice_mode', 'google'); |
|
|
|
|
$form->addElement('hidden', 'document_id', $document_id); |
|
|
|
|
$form->addElement('text', 'title', get_lang('Title')); |
|
|
|
|
$form->addElement('select', 'lang', get_lang('Language'), $options); |
|
|
|
|
$form->addElement('select', 'lang', get_lang('Language'), $options); |
|
|
|
|
$form->addElement('textarea', 'text', get_lang('InsertText2Audio'), array('id' => 'textarea_google', 'class' =>'span6' )); |
|
|
|
|
//echo Display :: return_icon('info3.gif', get_lang('HelpGoogleAudio'), array('align' => 'absmiddle', 'hspace' => '3px'), false); |
|
|
|
|
$form->addElement('style_submit_button', 'submit', get_lang('SaveMP3'), 'class="save"'); |
|
|
|
|
$defaults = array(); |
|
|
|
|
$defaults['lang'] = $selected_language; |
|
|
|
|
$form->setDefaults($defaults); |
|
|
|
|
$defaults['lang'] = $selected_language; |
|
|
|
|
$form->setDefaults($defaults); |
|
|
|
|
$form->display(); |
|
|
|
|
|
|
|
|
|
echo '</div>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(Security::remove_XSS($_GET['dt2a'])=='pediaphon'){ |
|
|
|
|
//lang default is a default message |
|
|
|
|
$selected_language = "defaultmessage"; |
|
|
|
|
$options_pedia['defaultmessage'] =get_lang('FirstSelectALanguage'); |
|
|
|
|
$options['defaultmessage'] =get_lang('FirstSelectALanguage'); |
|
|
|
|
$options['defaultmessage'] =get_lang('FirstSelectALanguage'); |
|
|
|
|
echo '<div>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$form = new FormValidator('form2', 'post', null, '', array('id' => 'form2')); |
|
|
|
|
$form->addElement('hidden', 'text2voice_mode','pediaphon'); |
|
|
|
|
$form->addElement('hidden', 'document_id', $document_id); |
|
|
|
|
$form->addElement('text', 'title', get_lang('Title')); |
|
|
|
|
$form->addElement('select', 'lang', get_lang('Language'), $options_pedia, array('onclick' => 'update_voices(this.selectedIndex);')); |
|
|
|
|
$form->addElement('select', 'voices', get_lang('Voice'), array(get_lang('FirstSelectALanguage')), array()); |
|
|
|
|
$form->addElement('select', 'voices', get_lang('Voice'), array(get_lang('FirstSelectALanguage')), array()); |
|
|
|
|
$speed_options = array(); |
|
|
|
|
$speed_options['1'] = get_lang('Normal'); |
|
|
|
|
$speed_options['0.75'] = get_lang('GoFaster'); |
|
|
|
|
$speed_options['0.8'] = get_lang('Fast'); |
|
|
|
|
$speed_options['1.2'] = get_lang('Slow'); |
|
|
|
|
$speed_options['1.6'] = get_lang('SlowDown'); |
|
|
|
|
|
|
|
|
|
$form->addElement('select', 'speed', get_lang('Speed'), $speed_options, array()); |
|
|
|
|
|
|
|
|
|
$form->addElement('select', 'speed', get_lang('Speed'), $speed_options, array()); |
|
|
|
|
$form->addElement('textarea', 'text', get_lang('InsertText2Audio'), array('id' => 'textarea_pediaphon', 'class' =>'span6')); |
|
|
|
|
//echo Display :: return_icon('info3.gif', get_lang('HelpPediaphon'), array('align' => 'absmiddle', 'hspace' => '3px'), false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$form->addElement('style_submit_button', 'submit', get_lang('SaveMP3'), 'class="save"'); |
|
|
|
|
$defaults = array(); |
|
|
|
|
$defaults['lang'] = $selected_language; |
|
|
|
|
$form->setDefaults($defaults); |
|
|
|
|
$defaults['lang'] = $selected_language; |
|
|
|
|
$form->setDefaults($defaults); |
|
|
|
|
$form->display(); |
|
|
|
|
echo '</div>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- javascript form name form2 update voices --> |
|
|
|
|
<script type="text/javascript"> |
|
|
|
|
<script type="text/javascript"> |
|
|
|
|
var langslist=document.form2.lang |
|
|
|
|
var voiceslist=document.form2.voices |
|
|
|
|
var voiceslist=document.form2.voices |
|
|
|
|
var voices=new Array() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--German --> |
|
|
|
|
voices[0]=["<?php echo get_lang('Female').' (de1)'; ?>|de1", "<?php echo get_lang('Male').' (de2)'; ?>|de2", "<?php echo get_lang('Female').' (de3)'; ?>|de3", "<?php echo get_lang('Male').' (de4)'; ?>|de4", "<?php echo get_lang('Female').' (de5)'; ?>|de5", "<?php echo get_lang('Male').' (de6)'; ?>|de6", "<?php echo get_lang('Female').' (de7)'; ?>|de7", "<?php echo get_lang('Female').' (de8 HQ)'; ?>|de8"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--English --> |
|
|
|
|
voices[1]=["<?php echo get_lang('Male').' (en1)'; ?>|en1", "<?php echo get_lang('Male').' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female').' (us1)'; ?>| us1", "<?php echo get_lang('Male').' (us2)'; ?>|us2", "<?php echo get_lang('Male').' (us3)'; ?>|us3", "<?php echo get_lang('Female').'(us4 HQ)'; ?>|us4"]
|
|
|
|
|
|
|
|
|
|
voices[1]=["<?php echo get_lang('Male').' (en1)'; ?>|en1", "<?php echo get_lang('Male').' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female').' (us1)'; ?>| us1", "<?php echo get_lang('Male').' (us2)'; ?>|us2", "<?php echo get_lang('Male').' (us3)'; ?>|us3", "<?php echo get_lang('Female').'(us4 HQ)'; ?>|us4"]
|
|
|
|
|
|
|
|
|
|
<!--Spanish --> |
|
|
|
|
voices[2]=["<?php echo get_lang('Male').' (es5 HQ)'; ?>|es5"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--French --> |
|
|
|
|
voices[3]=["<?php echo get_lang('Female').' (fr8 HQ)'; ?>|fr8"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function update_voices(selectedvoicegroup){ |
|
|
|
|
voiceslist.options.length=0 |
|
|
|
|
for (i=0; i<voices[selectedvoicegroup].length; i++) |
|
|
|
@ -294,14 +290,14 @@ $(document).ready(function(){ |
|
|
|
|
</script> |
|
|
|
|
<?php |
|
|
|
|
}//end pediaphon |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//vozMe services |
|
|
|
|
//disabled for a time |
|
|
|
|
/* |
|
|
|
|
echo '<div> </div><input type="checkbox" value="1" name="checktext2voice" onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/> <img src="../img/file_sound.gif" title="'.get_lang('HelpvozMe').'" alt="'.get_lang('vozMe').'"/> '.get_lang('vozMe').''; |
|
|
|
|
echo ' <span id="msg_error3" style="display:none;color:red"></span>'; |
|
|
|
|
echo '<div id="option3" style="padding:4px; margin:5px; border:1px dotted; display:none;">'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo '<form id="form3" name="form3" method="post" action="http://vozme.com/text2voice.php" target="mymp3" class="formw">'; |
|
|
|
|
echo '<br/>'; |
|
|
|
|
echo '<label>'.get_lang('Language').': '; |
|
|
|
@ -352,36 +348,36 @@ Display :: display_footer(); |
|
|
|
|
* @author Juan Carlos Raña Trabado <herodoto@telefonica.net> |
|
|
|
|
* @version january 2011, chamilo 1.8.8 |
|
|
|
|
*/ |
|
|
|
|
function downloadMP3_google($filepath, $dir) |
|
|
|
|
function downloadMP3_google($filepath, $dir) |
|
|
|
|
{ |
|
|
|
|
$location='create_audio.php?'.api_get_cidreq().'&id='.Security::remove_XSS($_POST['document_id']).'&dt2a=google'; |
|
|
|
|
|
|
|
|
|
//security |
|
|
|
|
if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) { |
|
|
|
|
echo '<script>window.location.href="'.$location.'"</script>'; |
|
|
|
|
return; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
global $_course, $_user; |
|
|
|
|
$clean_title=trim($_POST['title']); |
|
|
|
|
$clean_text=trim($_POST['text']); |
|
|
|
|
if(empty($clean_title) || empty($clean_text)){ |
|
|
|
|
if(empty($clean_title) || empty($clean_text)){ |
|
|
|
|
echo '<script>window.location.href="'.$location.'"</script>'; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$clean_title=Security::remove_XSS($clean_title); |
|
|
|
|
$clean_title=Database::escape_string($clean_title); |
|
|
|
|
$clean_title=Database::escape_string($clean_title); |
|
|
|
|
$clean_title=str_replace(' ','_', $clean_title);//compound file names |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$clean_text=Security::remove_XSS($clean_text); |
|
|
|
|
$clean_lang=Security::remove_XSS($_POST['lang']); |
|
|
|
|
|
|
|
|
|
$clean_lang=Security::remove_XSS($_POST['lang']); |
|
|
|
|
|
|
|
|
|
$extension='mp3'; |
|
|
|
|
$audio_filename=$clean_title.'.'.$extension; |
|
|
|
|
$audio_filename=$clean_title.'.'.$extension; |
|
|
|
|
$audio_title = str_replace('_',' ',$clean_title); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//prevent duplicates |
|
|
|
|
if (file_exists($filepath.'/'.$clean_title.'.'.$extension)){ |
|
|
|
|
$i = 1; |
|
|
|
|
if (file_exists($filepath.'/'.$clean_title.'.'.$extension)){ |
|
|
|
|
$i = 1; |
|
|
|
|
while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) $i++; |
|
|
|
|
$audio_filename = $clean_title . '_' . $i . '.'.$extension; |
|
|
|
|
$audio_title = $clean_title . '_' . $i . '.'.$extension; |
|
|
|
@ -389,12 +385,12 @@ function downloadMP3_google($filepath, $dir) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$documentPath = $filepath.'/'.$audio_filename; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//prev for a fine unicode, borrowed from main api TODO:clean |
|
|
|
|
// Safe replacements for some non-letter characters (whitout blank spaces) |
|
|
|
|
$search = array("\0", "\t", "\n", "\r", "\x0B", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%'); |
|
|
|
|
$replace = array('', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'); |
|
|
|
|
$replace = array('', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'); |
|
|
|
|
$filename=$clean_text; |
|
|
|
|
// Encoding detection. |
|
|
|
|
$encoding = api_detect_encoding($filename); |
|
|
|
@ -404,7 +400,7 @@ function downloadMP3_google($filepath, $dir) |
|
|
|
|
$filename = api_transliterate($filename, 'x', $encoding); |
|
|
|
|
// Replacing remaining dangerous non-letter characters. |
|
|
|
|
$clean_text = str_replace($search, $replace, $filename); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//adding the file |
|
|
|
|
//add new file to disk |
|
|
|
|
file_put_contents($documentPath, file_get_contents("http://translate.google.com/translate_tts?tl=".$clean_lang."&q=".urlencode($clean_text)."")); |
|
|
|
@ -433,7 +429,7 @@ function downloadMP3_pediaphon($filepath, $dir){ |
|
|
|
|
//security |
|
|
|
|
if(!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) { |
|
|
|
|
echo '<script>window.location.href="'.$location.'"</script>'; |
|
|
|
|
return; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
global $_course, $_user; |
|
|
|
|
$clean_title=trim($_POST['title']); |
|
|
|
@ -445,19 +441,19 @@ function downloadMP3_pediaphon($filepath, $dir){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$clean_title=Security::remove_XSS($clean_title); |
|
|
|
|
$clean_title=Database::escape_string($clean_title); |
|
|
|
|
$clean_title=Database::escape_string($clean_title); |
|
|
|
|
$clean_title=str_replace(' ','_', $clean_title);//compound file names |
|
|
|
|
$clean_text=Security::remove_XSS($clean_text); |
|
|
|
|
$clean_lang=Security::remove_XSS($_POST['lang']); |
|
|
|
|
$clean_speed=Security::remove_XSS($_POST['speed']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$extension='mp3'; |
|
|
|
|
$audio_filename=$clean_title.'.'.$extension; |
|
|
|
|
$audio_title = str_replace('_',' ',$clean_title); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//prevent duplicates |
|
|
|
|
if (file_exists($filepath.'/'.$clean_title.'.'.$extension)){ |
|
|
|
|
$i = 1; |
|
|
|
|
if (file_exists($filepath.'/'.$clean_title.'.'.$extension)){ |
|
|
|
|
$i = 1; |
|
|
|
|
while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) $i++; |
|
|
|
|
$audio_filename = $clean_title . '_' . $i . '.'.$extension; |
|
|
|
|
$audio_title = $clean_title . '_' . $i . '.'.$extension; |
|
|
|
@ -469,7 +465,7 @@ function downloadMP3_pediaphon($filepath, $dir){ |
|
|
|
|
//prev for a fine unicode, borrowed from main api TODO:clean |
|
|
|
|
// Safe replacements for some non-letter characters (whitout blank spaces) |
|
|
|
|
$search = array("\0", "\t", "\n", "\r", "\x0B", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%'); |
|
|
|
|
$replace = array('', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'); |
|
|
|
|
$replace = array('', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'); |
|
|
|
|
$filename=$clean_text; |
|
|
|
|
// Encoding detection. |
|
|
|
|
$encoding = api_detect_encoding($filename); |
|
|
|
@ -479,9 +475,9 @@ function downloadMP3_pediaphon($filepath, $dir){ |
|
|
|
|
$filename = api_transliterate($filename, 'x', $encoding); |
|
|
|
|
// Replacing remaining dangerous non-letter characters. |
|
|
|
|
$clean_text = str_replace($search, $replace, $filename); |
|
|
|
|
|
|
|
|
|
//adding the file |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//adding the file |
|
|
|
|
|
|
|
|
|
if ($clean_lang=='de') { |
|
|
|
|
$url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi'; |
|
|
|
|
$find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/'; |
|
|
|
@ -498,11 +494,11 @@ function downloadMP3_pediaphon($filepath, $dir){ |
|
|
|
|
"Content-Length: " . strlen($data) . "\r\n", |
|
|
|
|
'content' => $data |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
); |
|
|
|
|
$context = stream_context_create($opts); |
|
|
|
|
// Download the whole HTML page |
|
|
|
|
$previous_returntext2voice = file_get_contents($url_pediaphon,false,$context); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//extract the audio file path |
|
|
|
|
$search_source=preg_match($find_t2v, $previous_returntext2voice, $hits); |
|
|
|
|
$souce_end=substr($hits[0], 0,-1); |
|
|
|
|