From f64e37b5ed6072e346794a2117602226ce044609 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 5 Jul 2017 12:59:58 +0200 Subject: [PATCH] Minor - format code. --- main/document/document_slideshow.inc.php | 85 ++++++++-------- main/document/download.php | 6 +- main/document/download_scorm.php | 6 +- main/document/edit_document.php | 17 +++- main/document/edit_draw.php | 89 ++++++++-------- main/document/edit_odf.php | 3 +- main/document/edit_paint.php | 124 +++++++++++------------ main/document/exit_pixlr.php | 4 +- main/document/record_audio.php | 5 +- main/document/save_pixlr.php | 7 +- main/document/slideshowoptions.php | 44 ++++---- main/document/webcam_clip.php | 59 +++++------ 12 files changed, 226 insertions(+), 223 deletions(-) diff --git a/main/document/document_slideshow.inc.php b/main/document/document_slideshow.inc.php index d02e407248..ab76dd25b6 100755 --- a/main/document/document_slideshow.inc.php +++ b/main/document/document_slideshow.inc.php @@ -1,34 +1,35 @@ 0) { - while (list($key) = each($array_to_search)) { - $all_files[] = basename($array_to_search[$key]['path']); - //echo basename($array_to_search[$key]['path']).'
'; - } + while (list($key) = each($array_to_search)) { + $all_files[] = basename($array_to_search[$key]['path']); + //echo basename($array_to_search[$key]['path']).'
'; + } } // Always show gallery. $image_present = 1; /* if (isset($all_files) && is_array($all_files) && count($all_files) > 0) { - foreach ($all_files as & $file) { - $slideshow_extension = strrchr($file, '.'); - $slideshow_extension = strtolower($slideshow_extension); - if (in_array($slideshow_extension, $accepted_extensions)) { - $image_present = 1; - break; - } - } + foreach ($all_files as & $file) { + $slideshow_extension = strrchr($file, '.'); + $slideshow_extension = strtolower($slideshow_extension); + if (in_array($slideshow_extension, $accepted_extensions)) { + $image_present = 1; + break; + } + } }*/ $tablename_column = isset($_GET['tablename_column']) ? Security::remove_XSS($_GET['tablename_column']) : 0; if ($tablename_column == 0) { - $tablename_column = 1; + $tablename_column = 1; } else { - $tablename_column = intval($tablename_column) - 1; + $tablename_column = intval($tablename_column) - 1; } $image_files_only = sort_files($array_to_search); @@ -96,15 +97,19 @@ function sort_files($table) $final_array[] = $file_array[1]; } - return $final_array; + return $final_array; } -function sort_table($a, $b) { - global $tablename_column; - return strnatcmp($a[$tablename_column], $b[$tablename_column]); +function sort_table($a, $b) +{ + global $tablename_column; + + return strnatcmp($a[$tablename_column], $b[$tablename_column]); } -function rsort_table($a, $b) { - global $tablename_column; - return strnatcmp($b[$tablename_column], $a[$tablename_column]); +function rsort_table($a, $b) +{ + global $tablename_column; + + return strnatcmp($b[$tablename_column], $a[$tablename_column]); } diff --git a/main/document/download.php b/main/document/download.php index 5b64c9afe9..c90c917627 100755 --- a/main/document/download.php +++ b/main/document/download.php @@ -1,9 +1,9 @@ 'form-vertical')); + $form = new FormValidator( + 'formEdit', + 'post', + $action, + null, + array('class' => 'form-vertical') + ); // Form title $form->addElement('header', $nameTools); @@ -374,7 +378,12 @@ if ($owner_id == api_get_user_id() || $form->addElement('hidden', 'showedit'); $form->addElement('hidden', 'origin'); $form->addElement('hidden', 'origin_opt'); - $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus')); + $form->addText( + 'title', + get_lang('Title'), + true, + array('cols-size' => [2, 10, 0], 'autofocus') + ); $defaults['title'] = $document_data['title']; diff --git a/main/document/edit_draw.php b/main/document/edit_draw.php index e8dbf08566..687951f360 100755 --- a/main/document/edit_draw.php +++ b/main/document/edit_draw.php @@ -4,9 +4,9 @@ use ChamiloSession as Session; /** - * This file allows creating new svg and png documents with an online editor. + * This file allows creating new svg and png documents with an online editor. * - * @package chamilo.document + * @package chamilo.document * * @author Juan Carlos Ra�a Trabado * @since 25/september/2010 @@ -46,7 +46,7 @@ $group_id = api_get_group_id(); //path for svg-edit save $_SESSION['draw_dir'] = Security::remove_XSS($dir); if ($_SESSION['draw_dir'] == '/') { - $_SESSION['draw_dir'] = ''; + $_SESSION['draw_dir'] = ''; } $_SESSION['draw_file'] = basename(Security::remove_XSS($file_path)); $get_file = Security::remove_XSS($file_path); @@ -62,26 +62,26 @@ $is_allowed_to_edit = api_is_allowed_to_edit(null, true); /* Please, do not modify this dirname formatting */ if (strstr($dir, '..')) { - $dir = '/'; + $dir = '/'; } if ($dir[0] == '.') { - $dir = substr($dir, 1); + $dir = substr($dir, 1); } if ($dir[0] != '/') { - $dir = '/'.$dir; + $dir = '/'.$dir; } if ($dir[strlen($dir) - 1] != '/') { - $dir .= '/'; + $dir .= '/'; } $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; if (!is_dir($filepath)) { - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; - $dir = '/'; + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; + $dir = '/'; } //groups //TODO:clean @@ -90,8 +90,8 @@ if (!empty($group_id)) { 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace'), ); - $group_document = true; - $noPHP_SELF = true; + $group_document = true; + $noPHP_SELF = true; } $is_certificate_mode = DocumentManager::is_certificate_mode($dir); @@ -102,7 +102,10 @@ if (!$is_certificate_mode) { "name" => get_lang('Documents'), ); } else { - $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); + $interbreadcrumb[] = array( + 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], + 'name' => get_lang('Gradebook') + ); } // Interbreadcrumb for the current directory root path @@ -113,15 +116,17 @@ if (empty($document_data['parents'])) { if ($document_data['title'] == $document_sub_data['title']) { continue; } - $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']); + $interbreadcrumb[] = array( + 'url' => $document_sub_data['document_url'], + 'name' => $document_sub_data['title'] + ); } } -$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $groupRights || - DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); +$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $groupRights || DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); if (!$is_allowedToEdit) { - api_not_allowed(true); + api_not_allowed(true); } Event::event_access_tool(TOOL_DOCUMENT); @@ -135,33 +140,35 @@ echo '<p>Sorry, your browser does not handle frames</p>'); - function resizeIframe() { - var height = window.innerHeight -50; - //max lower size - if (height<550) { - height=550; - } - document.getElementById('frame').style.height = height +"px"; - }; - document.getElementById('frame').onload = resizeIframe; - window.onresize = resizeIframe; - - - + //automatic loading the course language + $svgedit_code_translation_table = array( + '' => 'en', + 'pt' => 'pt-Pt', + 'sr' => 'sr_latn' + ); + $langsvgedit = api_get_language_isocode(); + $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; + $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; + $svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit; + ?> + '; - echo ''; - echo ''; + echo ''; + echo ''; } else { - echo Display::return_message(get_lang('BrowserDontSupportsSVG'), 'error'); + echo Display::return_message(get_lang('BrowserDontSupportsSVG'), 'error'); } Display::display_footer(); diff --git a/main/document/edit_odf.php b/main/document/edit_odf.php index 9c1c401144..32e63af64d 100755 --- a/main/document/edit_odf.php +++ b/main/document/edit_odf.php @@ -42,8 +42,7 @@ $pathinfo = pathinfo($headerFile); $showOdfEditor = false; $webOdfSupportedFiles = DocumentManager::get_web_odf_extension_list(); -if ( - in_array(strtolower($pathinfo['extension']), $webOdfSupportedFiles) && +if (in_array(strtolower($pathinfo['extension']), $webOdfSupportedFiles) && api_get_configuration_value('enabled_support_odf') === true ) { $showOdfEditor = true; diff --git a/main/document/edit_paint.php b/main/document/edit_paint.php index 67d5747e27..7467bacd0f 100755 --- a/main/document/edit_paint.php +++ b/main/document/edit_paint.php @@ -4,10 +4,10 @@ use ChamiloSession as Session; /** - * This file allows creating new svg and png documents with an online editor. + * This file allows creating new svg and png documents with an online editor. * - * @package chamilo.document - * @todo used the document_id instead of the curdirpath + * @package chamilo.document + * @todo used the document_id instead of the curdirpath * * @author Juan Carlos Raña Trabado * @since 30/january/2011 @@ -30,10 +30,10 @@ $document_data = DocumentManager::get_document_data_by_id( if (empty($document_data)) { api_not_allowed(); } else { - $document_id = $document_data['id']; - $file_path = $document_data['path']; - $dir = dirname($document_data['path']); - $parent_id = DocumentManager::get_document_id(api_get_course_info(), $dir); + $document_id = $document_data['id']; + $file_path = $document_data['path']; + $dir = dirname($document_data['path']); + $parent_id = DocumentManager::get_document_id(api_get_course_info(), $dir); $my_cur_dir_path = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null; } @@ -47,62 +47,62 @@ if ($_SESSION['paint_dir'] == '/') { $_SESSION['paint_dir'] = ''; } $_SESSION['paint_file'] = basename(Security::remove_XSS($file_path)); - $get_file = Security::remove_XSS($file_path); - $file = basename($get_file); - $temp_file = explode(".", $file); $filename = $temp_file[0]; $nameTools = get_lang('EditDocument').': '.$filename; - $courseDir = $_course['path'].'/document'; - $is_allowed_to_edit = api_is_allowed_to_edit(null, true); /* Other initialization code */ /* Please, do not modify this dirname formatting */ - if (strstr($dir, '..')) { - $dir = '/'; + $dir = '/'; } if ($dir[0] == '.') { - $dir = substr($dir, 1); + $dir = substr($dir, 1); } if ($dir[0] != '/') { - $dir = '/'.$dir; + $dir = '/'.$dir; } if ($dir[strlen($dir) - 1] != '/') { - $dir .= '/'; + $dir .= '/'; } $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; - if (!is_dir($filepath)) { - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; - $dir = '/'; + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; + $dir = '/'; } //groups //TODO:clean if (!empty($groupId)) { - $interbreadcrumb[] = array( - 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), - 'name' => get_lang('GroupSpace'), - ); - $group_document = true; - $noPHP_SELF = true; + $interbreadcrumb[] = array( + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), + 'name' => get_lang('GroupSpace'), + ); + $group_document = true; + $noPHP_SELF = true; } $is_certificate_mode = DocumentManager::is_certificate_mode($dir); -if (!$is_certificate_mode) - $interbreadcrumb[] = array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents')); -else - $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); +if (!$is_certificate_mode) { + $interbreadcrumb[] = array( + "url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), + "name" => get_lang('Documents') + ); +} else { + $interbreadcrumb[] = array( + 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], + 'name' => get_lang('Gradebook') + ); +} // Interbreadcrumb for the current directory root path if (empty($document_data['parents'])) { @@ -120,7 +120,7 @@ $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $groupRights || DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); if (!$is_allowedToEdit) { - api_not_allowed(true); + api_not_allowed(true); } Event::event_access_tool(TOOL_DOCUMENT); @@ -142,31 +142,27 @@ $loc = $langpixlr; // deprecated ?? TODO:check pixlr read user browser $exit_path = api_get_path(WEB_CODE_PATH).'document/exit_pixlr.php'; $_SESSION['exit_pixlr'] = Security::remove_XSS($parent_id); - $referrer = "Chamilo"; - $target_path = api_get_path(WEB_CODE_PATH).'document/save_pixlr.php'; $target = $target_path; - $locktarget = "true"; $locktitle = "false"; if ($_SERVER['HTTP_HOST'] == "localhost") { - $path_and_file = api_get_path(SYS_PATH).'/crossdomain.xml'; - if (!file_exists($path_and_file)) { - $crossdomain = ' - - - - - - ';//more open domain="*" - @file_put_contents($path_and_file, $crossdomain); - } - $credentials = "true"; -} -else { - $credentials = "false"; + $path_and_file = api_get_path(SYS_PATH).'/crossdomain.xml'; + if (!file_exists($path_and_file)) { + $crossdomain = ' + + + + + + ';//more open domain="*" + @file_put_contents($path_and_file, $crossdomain); + } + $credentials = "true"; +} else { + $credentials = "false"; } //make temp images @@ -178,24 +174,22 @@ if (!file_exists($temp_folder)) { //make htaccess with allow from all, and file index.html into temp/images $htaccess = api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess'; if (!file_exists($htaccess)) { - - $htaccess_content = "order deny,allow\r\nallow from all\r\nOptions -Indexes"; - - $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w'); - if ($fp) { - fwrite($fp, $htaccess_content); - fclose($fp); - } + $htaccess_content = "order deny,allow\r\nallow from all\r\nOptions -Indexes"; + $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w'); + if ($fp) { + fwrite($fp, $htaccess_content); + fclose($fp); + } } $html_index = api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html'; if (!file_exists($html_index)) { - $html_index_content = ""; - $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w'); - if ($fp) { - fwrite($fp, $html_index_content); - fclose($fp); - } + $html_index_content = ""; + $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w'); + if ($fp) { + fwrite($fp, $html_index_content); + fclose($fp); + } } //encript temp name file @@ -217,9 +211,7 @@ $pixlr_url = api_get_protocol().'://pixlr.com/editor/?title='.$title.'&image='.$ //make frame an send image ?> - - @@ -69,7 +67,7 @@ echo Display::toolbarAction('toolbar-slideshow', [$actions]) ?>
-
+
';
- - - - + - - +
-