Browse Source

Using Thickbox to show images instead of yoxview see #3745

Julio Montoya 13 years ago
parent
commit
fac25689b6
3 changed files with 138 additions and 29 deletions
  1. 7 5
      main/document/document.inc.php
  2. 27 24
      main/document/document.php
  3. 104 0
      main/document/show_content.php

+ 7 - 5
main/document/document.inc.php

@@ -258,15 +258,17 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
 			     //|| (preg_match('/wav$/', urldecode($url)) && api_get_setting('enable_nanogong') == 'true')
             ) {
             	//yox view
-				$url = 'showinframesmin.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
-				$class = 'yoxview';
+				//$url = 'showinframesmin.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
+				//Simpler version of showinframesmin.php with no headers 
+				$url = 'show_content.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid.'&width=700&height=500';
+				$class = 'thickbox';
 				if ($visibility == false) {
-					$class = "yoxview invisible";
+					$class = "thickbox invisible";
 				}								
-				return '<a href="'.$url.'" class="'.$class.'" title="'.$tooltip_title_alt.'" target="yoxview" style="float:left">'.$title.'</a>'.$force_download_html.$copy_to_myfiles.$open_in_new_window_link.$pdf_icon;
+				return '<a href="'.$url.'" class="'.$class.'" title="'.$tooltip_title_alt.'" style="float:left">'.$title.'</a>'.$force_download_html.$copy_to_myfiles.$open_in_new_window_link.$pdf_icon;
 			} else {
 				$url = 'showinframes.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
-			    //No yoxview			
+			    //No plugin just the old and good showinframes.php page 			
             	return '<a href="'.$url.'" title="'.$tooltip_title_alt.'" style="float:left" '.$visibility_class.' >'.$title.'</a>'.$force_download_html.$copy_to_myfiles.$open_in_new_window_link.$pdf_icon;
 			}          
         } else {

+ 27 - 24
main/document/document.php

@@ -69,6 +69,19 @@ $session_id  = api_get_session_id();
 $course_code = api_get_course_id();
 $to_group_id = api_get_group_id();
 
+$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
+$group_member_with_upload_rights = false;
+
+// If the group id is set, we show them group documents
+$group_properties = array();
+$group_properties['directory'] = null;
+
+// For sessions we should check the parameters of visibility
+if (api_get_session_id() != 0) {
+	$group_member_with_upload_rights = $group_member_with_upload_rights && api_is_allowed_to_session_edit(false, true);
+}
+
+
 //Setting group variables 
 if (api_get_group_id()) {
 	// Needed for group related stuff
@@ -274,6 +287,7 @@ $tool_sql           = 'SELECT visibility FROM ' . $table_course_tool . ' WHERE n
 $tool_result        = Database::query($tool_sql);
 $tool_row           = Database::fetch_array($tool_result);
 $tool_visibility    = $tool_row['visibility'];
+
 if ($tool_visibility == '0' && $to_group_id == '0' && !($is_allowed_to_edit || $group_member_with_upload_rights)) {
     api_not_allowed(true);
 }
@@ -288,18 +302,6 @@ function confirmation (name) {
 }
 </script>";
 
-$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
-$group_member_with_upload_rights = false;
-
-// If the group id is set, we show them group documents
-$group_properties = array();
-$group_properties['directory'] = null;
-
-// For sessions we should check the parameters of visibility
-if (api_get_session_id() != 0) {
-    $group_member_with_upload_rights = $group_member_with_upload_rights && api_is_allowed_to_session_edit(false, true);
-}
-
 // If they are looking at group documents they can't see the root
 if ($to_group_id != 0 && $curdirpath == '/') {
     $curdirpath = $group_properties['directory'];
@@ -392,23 +394,25 @@ if (empty($document_data['parents'])) {
 if (isset($_GET['createdir'])) {
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('CreateDir'));
 }
-
-$htmlHeadXtra[] = api_get_jquery_js();
 $htmlHeadXtra[] = api_get_jquery_ui_js();
 
+$js_path 		= api_get_path(WEB_LIBRARY_PATH).'javascript/';
+/*
+$htmlHeadXtra[] = '<script type="text/javascript" src="'.$js_path.'yoxview/yox.js"></script>';
 $htmlHeadXtra[] = api_get_js('yoxview/yoxview-init.js');
-$js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/';   
-$htmlHeadXtra[] = '<link rel="stylesheet" href="'.$js_path.'yoxview/yoxview.css" type="text/css">';
+*/
+
 $htmlHeadXtra[] = '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skins/chamilo/jplayer.blue.monday.css" type="text/css">';
 $htmlHeadXtra[] = '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jquery.jplayer.min.js"></script>';
 
+
 $mediaplayer_path = api_get_path(WEB_LIBRARY_PATH).'mediaplayer/player.swf';
 
 //automatic loading the course language for yoxview
-$yoxview_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
+/*$yoxview_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
 $lang_yoxview  = api_get_language_isocode();
 $lang_yoxview = isset($yoxview_code_translation_table[$lang_yoxview]) ? $yoxview_code_translation_table[$lang_yoxview] : $lang_yoxview;
-
+*/
 $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, false);
 
 $file_list = $format_list = '';
@@ -443,15 +447,14 @@ foreach ($docs_and_folders  as $file) {
 }
  
 $htmlHeadXtra[] = '<script type="text/javascript">
-$(document).ready( function() {  
-	  
-    $(".yoxview").yoxview({
+$(document).ready( function() {
+	   /*
+    $(".yoxview").yoxview({ 
         lang: "'.$lang_yoxview.'",
         flashVideoPlayerPath: "'.$mediaplayer_path.'",
         allowInternalLinks:true,
-        defaultDimensions: { iframe: { width: 800}},
-        titleAttribute : "alt"        
-    });
+        defaultDimensions: { iframe: { width: 800}},              
+    });*/
         
     //Experimental changes to preview mp3, ogg files        
      '.$jquery.'              

+ 104 - 0
main/document/show_content.php

@@ -0,0 +1,104 @@
+<?php
+/* For licensing terms, see /license.txt */
+/**
+ *	@author jmontoya
+ *  
+ *	@package chamilo.document
+ */
+/**
+ * Code
+ */
+/*   INITIALIZATION */
+
+$language_file[] = 'document';
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'document.lib.php';
+require_once api_get_path(LIBRARY_PATH).'glossary.lib.php';
+require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
+
+// Protection
+api_protect_course_script();
+
+$noPHP_SELF = true;
+$header_file = Security::remove_XSS($_GET['file']);
+$document_id = intval($_GET['id']);
+
+$course_info = api_get_course_info();
+$course_code = api_get_course_id(); 
+
+if (empty($course_info)) {
+    api_not_allowed(true);
+}
+
+//Generate path 
+if (!$document_id) {
+    $document_id = DocumentManager::get_document_id($course_info, $header_file);
+}
+$document_data = DocumentManager::get_document_data_by_id($document_id, $course_code);
+
+if (empty($document_data)) {
+    api_not_allowed(true);
+}
+
+$header_file  = $document_data['path'];
+$name_to_show = cut($header_file, 80);
+
+$path_array = explode('/', str_replace('\\', '/', $header_file));
+$path_array = array_map('urldecode', $path_array);
+$header_file = implode('/', $path_array);
+
+$file = Security::remove_XSS(urldecode($document_data['path']));
+
+$file_root = $course_info['path'].'/document'.str_replace('%2F', '/', $file);
+$file_url_sys = api_get_path(SYS_COURSE_PATH).$file_root;
+$file_url_web = api_get_path(WEB_COURSE_PATH).$file_root;
+
+if (!file_exists($file_url_sys)) {
+    api_not_allowed(true);
+}
+
+if (is_dir($file_url_sys)) {
+    api_not_allowed(true);
+}
+
+//fix the screen when you try to access a protected course through the url
+$is_allowed_in_course = $_SESSION ['is_allowed_in_course'];
+
+if ($is_allowed_in_course == false) {
+    api_not_allowed(true);
+}
+
+//Check user visibility
+//$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
+$is_visible = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id());
+if (!api_is_allowed_to_edit() && !$is_visible) {
+    api_not_allowed(true);
+}
+
+//TODO:clean all code
+
+/*	Main section */
+header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
+//header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
+header('Last-Modified: Wed, 01 Jan 2100 00:00:00 GMT');
+header('Cache-Control: no-cache, must-revalidate');
+header('Pragma: no-cache');
+$browser_display_title = 'Documents - '.Security::remove_XSS($_GET['cidReq']).' - '.$file;
+
+$file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file.'?'.api_get_cidreq();
+
+$pathinfo = pathinfo($header_file);
+if ($pathinfo['extension']=='wav' && api_get_setting('enable_nanogong') == 'true'){
+	echo '<div align="center">';
+		echo '<br/>';
+		echo '<applet id="applet" archive="../inc/lib/nanogong/nanogong.jar" code="gong.NanoGong" width="160" height="40" >';
+			echo '<param name="SoundFileURL" value="'.$file_url_web.'" />';
+			echo '<param name="ShowSaveButton" value="false" />';
+			echo '<param name="ShowTime" value="true" />';
+			echo '<param name="ShowRecordButton" value="false" />';
+		echo '</applet>';
+	echo '</div>';
+} else {
+	if ($pathinfo['extension']=='swf') { $width='83%'; $height='83%';} else {$width='100%'; $height='100%';}	
+	echo '<iframe border="0" frameborder="0" scrolling="no" style="width:'.$width.'; height:'.$height.';background-color:#ffffff;" id="mainFrame" name="mainFrame" src="'.$file_url_web.'?'.api_get_cidreq().'&amp;rand='.mt_rand(1, 10000).'"></iframe>';
+}