فهرست منبع

Fix PHP warning

Julio 8 سال پیش
والد
کامیت
41fe5e14f7
2فایلهای تغییر یافته به همراه45 افزوده شده و 26 حذف شده
  1. 25 12
      main/document/create_draw.php
  2. 20 14
      main/document/edit_draw.php

+ 25 - 12
main/document/create_draw.php

@@ -23,21 +23,21 @@ api_block_anonymous_users();
 $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
 if (empty($document_data)) {
     if (api_is_in_group()) {
-        $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());
+        $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());
     }
 }
 
-$document_id   = $document_data['id'];
-$dir           = $document_data['path'];
+$document_id = $document_data['id'];
+$dir = $document_data['path'];
 
 /*	Constants and variables */
 
 //path for svg-edit save
 $_SESSION['draw_dir'] = Security::remove_XSS($dir);
-if ($_SESSION['draw_dir']=='/'){
-    $_SESSION['draw_dir']='';
+if ($_SESSION['draw_dir'] == '/') {
+    $_SESSION['draw_dir'] = '';
 }
 
 $dir = isset($dir) ? Security::remove_XSS($dir) : (isset($_POST['dir']) ? Security::remove_XSS($_POST['dir']) : '/');
@@ -71,7 +71,10 @@ if (!is_dir($filepath)) {
 $groupId = api_get_group_id();
 
 if (!empty($groupId)) {
-	$interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
+	$interbreadcrumb[] = array (
+        "url" => "../group/group_space.php?".api_get_cidreq(),
+        "name" => get_lang('GroupSpace')
+    );
 	$noPHP_SELF = true;
 	$group = GroupManager :: get_group_properties($groupId);
 	$path = explode('/', $dir);
@@ -80,14 +83,21 @@ if (!empty($groupId)) {
 	}
 }
 
-$interbreadcrumb[] = array ("url" => "./document.php?".api_get_cidreq(), "name" => get_lang('Documents'));
+$interbreadcrumb[] = array(
+	"url" => "./document.php?".api_get_cidreq(),
+	"name" => get_lang('Documents')
+);
 
 if (!$is_allowed_in_course) {
 	api_not_allowed(true);
 }
 
 if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
-	DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir), api_get_session_id()))) {
+	DocumentManager::is_my_shared_folder(
+		api_get_user_id(),
+		Security::remove_XSS($dir),
+		api_get_session_id()))
+) {
 	api_not_allowed(true);
 }
 
@@ -111,8 +121,11 @@ $array_len = count($dir_array);
 if (empty($document_data['parents'])) {
     $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
 } else {
-    foreach($document_data['parents'] as $document_sub_data) {
-        $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
+    foreach ($document_data['parents'] as $document_sub_data) {
+        $interbreadcrumb[] = array(
+			'url' => $document_sub_data['document_url'],
+			'name' => $document_sub_data['title']
+		);
     }
 }
 Display :: display_header($nameTools, 'Doc');

+ 20 - 14
main/document/edit_draw.php

@@ -17,7 +17,11 @@ $this_section = SECTION_COURSES;
 api_protect_course_script(true);
 api_block_anonymous_users();
 
-$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
+$document_data = DocumentManager::get_document_data_by_id(
+    $_GET['id'],
+    api_get_course_id(),
+    true
+);
 
 if (empty($document_data)) {
     api_not_allowed();
@@ -26,7 +30,7 @@ if (empty($document_data)) {
     $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 = Security::remove_XSS($_GET['curdirpath']);
+    $my_cur_dir_path = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '';
 }
 
 $dir= str_replace('\\', '/',$dir);//and urlencode each url $curdirpath (hack clean $curdirpath under Windows - Bug #3261)
@@ -36,16 +40,16 @@ $current_session_id=api_get_session_id();
 $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'] = Security::remove_XSS($dir);
+if ($_SESSION['draw_dir'] == '/') {
+    $_SESSION['draw_dir'] = '';
 }
-$_SESSION['draw_file']=basename(Security::remove_XSS($file_path));
+$_SESSION['draw_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;
+$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);
@@ -79,7 +83,6 @@ if (!is_dir($filepath)) {
 
 //groups //TODO:clean
 if (!empty($group_id)) {
-	$req_gid = '&gidReq='.$group_id;
 	$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace'));
 	$group_document = true;
 	$noPHP_SELF = true;
@@ -88,7 +91,10 @@ if (!empty($group_id)) {
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
 
 if (!$is_certificate_mode)
-	$interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
+	$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'));
 
@@ -116,16 +122,16 @@ Event::event_access_tool(TOOL_DOCUMENT);
 Display :: display_header($nameTools, 'Doc');
 echo '<div class="actions">';
 		echo '<a href="document.php?id='.$parent_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
-		echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.$req_gid.'&origin=editdraw">'.Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
+		echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.'&origin=editdraw">'.Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
 echo '</div>';
 
 if (api_browser_support('svg')) {
-	//automatic loading the course language
+	// 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.'&amp;lang='.$langsvgedit;
+	$svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../courses/'.$courseDir.$dir.$file.'&amp;lang='.$langsvgedit;
 	?>
 	<script>
 	document.write('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo  $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');