Browse Source

Adding document preview final, need feedback see #2773

Julio Montoya 13 years ago
parent
commit
b5ec57a043

+ 17 - 8
main/css/base.css

@@ -10,7 +10,6 @@
     width:180px;
 }
 
-
 a.tag {
     background-color: #E0EAF1;
     border-bottom: 1px solid #3E6D8E;
@@ -1944,12 +1943,10 @@ input.maininput:focus {
 
 div.lp_resource {
     padding:5px 10px;
-    width:450px;
-    
+    width:380px;    
     list-style-type: none;
     margin: 0;
-    padding: 0;    
-    
+    padding: 0;
 }
 
 .lp_resource_element, .lp_resource_element_no_link {
@@ -1966,7 +1963,7 @@ div.lp_resource {
 }   
 
 .doc_resource {
-    margin:5px;
+    margin:6px;
 }
 
 div.lp_tree {
@@ -2249,10 +2246,22 @@ div.admin_section h4 {
 }
 
 .document_preview_container {
-	background-color: #ccc;
+	
+    -webkit-border-radius: 6px;
+    -opera-border-radius: 6px;
+    -moz-border-radius: 6px;
+    border-radius: 6px;
+        
+    -webkit-box-shadow: 0 2px 5px #C8C8C8;
+    -opera-box-shadow: 0 2px 5px #C8C8C8;
+    -moz-box-shadow: 0 2px 5px #C8C8C8;
+    box-shadow: 0 2px 5px #C8C8C8;   
+    
+	background-color: #F9F9F9;
+	
 	position: absolute;	  
     z-index: 20;
     margin:5px;
     padding:5px;
-    
+    width: 380px;    
 }

+ 13 - 3
main/document/document.php

@@ -60,9 +60,19 @@ unset($_SESSION['paint_dir']);
 // Create directory certificates
 DocumentManager::create_directory_certificate_in_course(api_get_course_id());
 
+
+$course_info = api_get_course_info();
+
 //Hack in order to use document.php?id=X 
 if (isset($_REQUEST['id'])) {
     $document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id());
+    
+    //Redirect to the file path
+    if (!empty($document_data['filetype']) && $document_data['filetype'] == 'file') {
+    	$url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$document_data['path'].'?'.api_get_cidreq();    	    	
+    	header("Location: $url");
+    	exit;
+    }  
     //@todo replace all 
     $_GET['curdirpath'] = $document_data['path'];    
 }
@@ -84,11 +94,11 @@ $curdirpathurl = urlencode($curdirpath);
 $document_id = DocumentManager::get_document_id($_course, $curdirpath);
 
 if (!$document_id) {    
-    $document_id = DocumentManager::get_document_id(api_get_course_info(), $curdirpath);
+    $document_id = DocumentManager::get_document_id($course_info, $curdirpath);
 }
 
 $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
-$parent_id     = DocumentManager::get_document_id(api_get_course_info(), dirname($document_data['path']));
+$parent_id     = DocumentManager::get_document_id($course_info, dirname($document_data['path']));
 
 if (!$parent_id) {
     $parent_id = 0; 
@@ -494,7 +504,7 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
         $my_get_move = intval($_REQUEST['move']);
 
         if (api_is_coach()) {
-            if (!DocumentManager::is_visible_by_id($my_get_move, api_get_course_info(), api_get_session_id())) {                    
+            if (!DocumentManager::is_visible_by_id($my_get_move, $course_info, api_get_session_id())) {                    
                 api_not_allowed();
             }
         }

+ 2 - 2
main/inc/ajax/document.ajax.php

@@ -44,7 +44,7 @@ switch($action) {
 		break;
 	case 'document_preview':
 		$course_info = api_get_course_info_by_id($_REQUEST['course_id']);
-		echo DocumentManager::get_document_preview($course_info);
+		echo DocumentManager::get_document_preview($course_info, false, '_blank');
 		break;		
-}	
+}
 exit;

+ 9 - 8
main/inc/lib/course.lib.php

@@ -2621,7 +2621,7 @@ class CourseManager {
      * @param int        user id
      * @return void
      */
-    function display_courses($user_id) {
+    function display_courses($user_id, $load_dirs = false) {
     
         global $_user, $_configuration;
     
@@ -2631,7 +2631,7 @@ class CourseManager {
         $all_user_categories = self :: get_user_course_categories();
     
         // Step 0: We display the course without a user category.
-        self :: display_courses_in_category(0, 'true');
+        self :: display_courses_in_category(0, $load_dirs);
     
         // Step 1: We get all the categories of the user.
         $tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
@@ -2648,7 +2648,7 @@ class CourseManager {
                         echo $row['title'];
                         echo '</span>';
                     echo '</li>';
-                    self :: display_courses_in_category($row['id']);
+                    self :: display_courses_in_category($row['id'], $load_dirs);
             echo '</ul>';
             echo '</div>';
         }
@@ -2659,7 +2659,7 @@ class CourseManager {
      *  @param int      User category id
      *  @return void
      */
-    function display_courses_in_category($user_category_id) {
+    function display_courses_in_category($user_category_id, $load_dirs = false) {
     
         global $_user;
         // Table definitions
@@ -2717,10 +2717,11 @@ class CourseManager {
             if (api_is_platform_admin()) {
                 echo '<div style="float:right;">';
                 
-                echo '<a id="document_preview_'.$course['id'].'" class="document_preview" href="#">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),22).'</a>';
-                echo '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),22).'</a>';
-                echo '<div class="clear"></div>';
-                echo Display::div('', array('id' => 'document_result_'.$course['id'], 'class'=>'document_preview_container'));
+                if ($load_dirs) {
+                	echo '<a id="document_preview_'.$course['id'].'" class="document_preview" href="#">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),22).'</a>';
+                	echo '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),22).'</a>';                
+                	echo Display::div('', array('id' => 'document_result_'.$course['id'], 'class'=>'document_preview_container not_active'));
+                }
                 
                 if ($course['status'] == COURSEMANAGER) {
                     //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;'));

+ 90 - 44
main/inc/lib/document.lib.php

@@ -2473,8 +2473,7 @@ return 'application/octet-stream';
         return $html;
     }
     
-    function get_document_preview($course_info, $lp_id = false) {
-    	
+    function get_document_preview($course_info, $lp_id = false, $target = '') {    	
     	if (!isset($course_info['dbName'])) {
     		$course_info = api_get_course_info($course_info['code']);
     	}
@@ -2498,54 +2497,89 @@ return 'application/octet-stream';
     	            	AND docs.path NOT LIKE '%_DELETED_%'
     	                AND last.tool = '".TOOL_DOCUMENT."' $condition_session ORDER BY docs.path ASC";
     	
-		$res_doc = Database::query($sql_doc);   	
-
-    	$return = '<div class="lp_resource">';
+		$res_doc = Database::query($sql_doc);
     	$resources = Database::store_result($res_doc);
     	
+    	$return = '';
+    	
     	$resources_sorted = array();
     	    	
     	if ($lp_id) {
 	    	$return .= '<div class="lp_resource_element">';    	
 	    	$return .= Display::return_icon('new_doc.gif', '', array(), 22);    	
-	    	$return .= Display::url(get_lang('NewDocument') , api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_DOCUMENT.'&lp_id='.$_SESSION['oLP']->lp_id);
+	    	$return .= Display::url(get_lang('NewDocument'), api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_DOCUMENT.'&lp_id='.$_SESSION['oLP']->lp_id);
 	    	$return .= '</div>';
+    	} else {
+    		$return .= Display::div(Display::url(Display::return_icon('delete.png', get_lang('Close'), array(), 22), '#', array('id'=>'close_div_'.$course_info['real_id'],'class' =>'close_div')), array('style' => 'position:absolute;right:10px'));
     	}
     	
     	// If you want to debug it, I advise you to do "echo" on the eval statements.
-    	
-    	foreach ($resources as $resource) {
-	    	$resource_paths = explode('/', $resource['path']);
-	    	array_shift($resource_paths);
-	    	$path_to_eval = $last_path = '';
-	    	$is_file = false;
-	    	foreach ($resource_paths as $key => $resource_path) {
-				if (strpos($resource_path, '.') === false && $key != count($resource_paths) - 1) {
-	    		// It's a folder.
-	    		$path_to_eval .= '["' . $resource_path . '"]["files"]';
-	    	} else
-	    		if (strpos($resource_path, '.') !== false)
-	    			$is_file = true;	    	
-	    			$last_path = $resource_path;
-	    	}
-	    	
-	    	if ($is_file) {
-	    		//for backward compatibility
-	    		if (empty($resource['title'])) {
-	    			$resource['title'] = basename($resource['path']);
-	    		}
-	    		eval ('$resources_sorted' . $path_to_eval . '[' . $resource['id'] . '] = "' .$resource['title']."/". $last_path. '";');
-	    	} else {
-	    		eval ('$resources_sorted' . $path_to_eval . '["' . $last_path . '"]["id"]=' . $resource['id'] . ';');
+    	if (!empty($resources)) {
+	    	foreach ($resources as $resource) {
+		    	$resource_paths = explode('/', $resource['path']);
+		    	array_shift($resource_paths);
+		    	$path_to_eval = $last_path = '';
+		    	$is_file = false;
+		    	foreach ($resource_paths as $key => $resource_path) {
+					if (strpos($resource_path, '.') === false && $key != count($resource_paths) - 1) {
+		    		// It's a folder.
+		    		$path_to_eval .= '["' . $resource_path . '"]["files"]';
+		    	} else
+		    		if (strpos($resource_path, '.') !== false)
+		    			$is_file = true;	    	
+		    			$last_path = $resource_path;
+		    	}
+		    	
+		    	if ($is_file) {
+		    		//for backward compatibility
+		    		if (empty($resource['title'])) {
+		    			$resource['title'] = basename($resource['path']);
+		    		}
+		    		eval ('$resources_sorted'.$path_to_eval.'['.$resource['id'].'] = "'.$resource['title']."/". $last_path.'";');
+		    	} else {
+		    		eval ('$resources_sorted'.$path_to_eval.'["'.$last_path.'"]["id"]='.$resource['id'].';');
+		    	}
 	    	}
     	}
     	
     	$label = get_lang('Documents');
     	$new_array[$label] = array('id' => 0, 'files' => $resources_sorted);
-    	$return .= self::write_resources_tree($course_info, $new_array, 0, $lp_id);    	    
-    	$return .= '</div>';
-    	return $return;
     	
+    	$return .= self::write_resources_tree($course_info, $new_array, 0, $lp_id, $target);    	
+    	
+    	$return = Display::div($return, array('class'=>'lp_resource'));    	
+    	$img_path = api_get_path(WEB_IMG_PATH);
+    	
+    	if ($lp_id == false) {
+    		$return .= "<script>
+    		    	$('.doc_folder').mouseover(function() {	
+    					var my_id = this.id.split('_')[2];			
+    					$('#'+my_id).show();    								
+    					$('#img_'+my_id).attr('src', '".$img_path."nolines_minus.gif' );			
+    				});
+    				
+    				$('.close_div').click(function() {
+    					var my_id = this.id.split('_')[2];			
+    					$('#document_result_'+my_id).hide();
+    					$('.lp_resource').remove();
+    				});
+    				</script>";
+    	} else {    		
+    		$return .=  "<script>
+    		
+    		function testResources(id, img) {
+	    		if (document.getElementById(id).style.display=='block'){
+	    			document.getElementById(id).style.display='none';
+	    			document.getElementById('img_'+id).src='".$img_path."nolines_plus.gif';
+	    		} else {
+	    			document.getElementById(id).style.display='block';
+    				document.getElementById('img_'+id).src='".$img_path."nolines_minus.gif';
+    			}
+    		}
+    		</script>"; 
+    	}
+    		  	
+    	return $return;    	
     }
     
     /**
@@ -2556,8 +2590,12 @@ return 'application/octet-stream';
     * @param	integer Enables the tree display by shifting the new elements a certain distance to the right
     * @return	string	The HTML list
     */
-    public function write_resources_tree($course_info, $resources_sorted, $num = 0, $lp_id = false) {
+    public function write_resources_tree($course_info, $resources_sorted, $num = 0, $lp_id = false, $target = '') {
     	require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
+    	
+    	$img_path = api_get_path(WEB_IMG_PATH);
+    	$web_code_path = api_get_path(WEB_CODE_PATH);
+    	
     	$return = '';
     	if (count($resources_sorted) > 0) {
     		foreach ($resources_sorted as $key => $resource) {
@@ -2586,16 +2624,22 @@ return 'application/octet-stream';
     				} elseif($key=='video') {
     					$key=get_lang('Video');
     				}
+    				
+    				$onclick = '';
+    				if ($lp_id) {
+    					$onclick = 'onclick="javascript: testResources(\'' . $resource['id'] . '\',\'img_' . $resource['id'] . '\')"';
+    				}    				
     
-    				$return .= '<div class="doc_resource">';
-    				$return .= '<div style="margin-left:' . ($num * 18) . 'px;margin-right:5px;">';
-    				    				
-    				$return .= '<img style="cursor: pointer;" src="../img/nolines_plus.gif" align="absmiddle" id="img_' . $resource['id'] . '" onclick="javascript: testResources(\'' . $resource['id'] . '\',\'img_' . $resource['id'] . '\')"><img alt="" src="../img/lp_folder.gif" title="" align="absmiddle" />&nbsp;
-    							<span onclick="javascript: testResources(\'' . $resource['id'] . '\',\'img_' . $resource['id'] . '\')" style="cursor: pointer;" >' . $key . '</span>
-    							</div><div style="display: none;" id="' . $resource['id'] . '">';
+    				$return .= '<div class="doc_resource">';    				
+    				$return .= '<div class="doc_folder"  id="doc_id_'.$resource['id'].'"  style="margin-left:'.($num * 18).'px; margin-right:5px;">';    				    				
+    				$return .= '<img style="cursor: pointer;" src="'.$img_path.'nolines_plus.gif" align="absmiddle" id="img_' . $resource['id'] . '"  '.$onclick.' >';
+    				$return .= '<img alt="" src="'.$img_path.'lp_folder.gif" title="" align="absmiddle" />&nbsp;';    				
+    				$return .= '<span '.$onclick.' style="cursor: pointer;" >'.$key.'</span>';    				
+    				$return .= '</div>
+    							<div style="display: none;" id="'.$resource['id'].'">';
     				
     				if (isset($resource['files'])) {
-    					$return .= self::write_resources_tree($course_info, $resource['files'], $num +1, $lp_id);
+    					$return .= self::write_resources_tree($course_info, $resource['files'], $num +1, $lp_id, $target);
     				}
     				$return .= '</div></div>';
     			} else {
@@ -2611,13 +2655,15 @@ return 'application/octet-stream';
 
     					// Show the "image name" not the filename of the image.
     					if ($lp_id) {
+    						//LP URL 
     						$lp_id = $this->lp_id;
     						$url  = api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=add_item&amp;type=' . TOOL_DOCUMENT . '&amp;file=' . $key . '&amp;lp_id=' .$lp_id;
     					} else {
-    						$url  = api_get_path(WEB_CODE_PATH).'document/document.php?cidReq='.$course_info['code'].'&id='.$key;
+    						//Direct document URL
+    						$url  = $web_code_path.'document/document.php?cidReq='.$course_info['code'].'&id='.$key;
     					}	
-    					
-    					$link = Display::url('<img alt="" src="../img/' . $icon . '" title="" />&nbsp;' . $my_file_title, $url);
+    					$img = $img_path.$icon;
+    					$link = Display::url('<img alt="" src="'.$img.'" title="" />&nbsp;' . $my_file_title, $url, array('target' => $target));
     					 
     					$return .= '<div class="doc_resource"><div style="margin-left:' . (($num +1) * 18) . 'px;margin-right:5px;">';    					
     					$return .= $link;

+ 1 - 10
main/inc/lib/javascript/dtree/dtree.js

@@ -695,13 +695,4 @@ if (!Array.prototype.pop) {
 
 };
 
-function testResources(id,img){
-	if(document.getElementById(id).style.display=='block'){
-		document.getElementById(id).style.display='none';
-		document.getElementById("img_"+id).src='../img/nolines_plus.gif';
-	}
-	else{
-		document.getElementById(id).style.display='block';
-		document.getElementById("img_"+id).src='../img/nolines_minus.gif';
-	}
-}
+

+ 0 - 17
main/newscorm/dtree.css

@@ -1,17 +0,0 @@
-/*--------------------------------------------------|
-| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
-|---------------------------------------------------|
-| Copyright (c) 2002-2003 Geir Landr�               |
-|--------------------------------------------------*/
-
-.dtree{color:#000000; font-size:12px; white-space:nowrap;}
-
-.dtree img{border:0; margin-right:5px; vertical-align:middle;}
-
-.dtree a{color:#000000; font-weight:normal; text-decoration:none;}
-	.dtree a.node,
-	.dtree a.nodeSel{padding:1px 2px 1px 2px; white-space: nowrap;}
-	.dtree a.node:hover, .dtree a.nodeSel:hover{color:#000000; text-decoration:none;}
-	.dtree a.nodeSel{background:#F8F8F8; border:1px dashed #999999;}
-
-.dtree .clip{overflow:hidden;}

+ 0 - 707
main/newscorm/dtree.js

@@ -1,707 +0,0 @@
-/*--------------------------------------------------|
-
-| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
-
-|---------------------------------------------------|
-
-| Copyright (c) 2002-2003 Geir Landr�               |
-
-|                                                   |
-
-| This script can be used freely as long as all     |
-
-| copyright messages are intact.                    |
-
-|                                                   |
-
-| Updated: 17.04.2003                               |
-
-|--------------------------------------------------*/
-
-
-
-// Node object
-
-function Node(id, pid, name, url, title, target, icon, iconOpen, open) {
-
-	this.id = id;
-
-	this.pid = pid;
-
-	this.name = name;
-
-	this.url = url;
-
-	this.title = title;
-
-	this.target = target;
-
-	this.icon = icon;
-
-	this.iconOpen = iconOpen;
-
-	this._io = open || true;
-
-	this._is = false;
-
-	this._ls = false;
-
-	this._hc = false;
-
-	this._ai = 0;
-
-	this._p;
-
-};
-
-
-
-// Tree object
-
-function dTree(objName) {
-
-	this.config = {
-
-		target					: null,
-
-		folderLinks			: true,
-
-		useSelection		: true,
-
-		useCookies			: true,
-
-		useLines				: true,
-
-		useIcons				: true,
-
-		useStatusText		: false,
-
-		closeSameLevel	: false,
-
-		inOrder					: false
-
-	}
-
-	this.icon = {
-
-		root				: '../img/icons/22/learnpath.png',
-
-		folder			: '../img/folder.gif',
-
-		folderOpen	: '../img/folderopen.gif',
-
-		node				: '../img/page.gif',
-
-		empty				: '../img/empty2.gif',
-
-		line				: '../img/line.gif',
-
-		join				: '../img/join.gif',
-
-		joinBottom	: '../img/joinbottom.gif',
-
-		plus				: '../img/plus.gif',
-
-		plusBottom	: '../img/plusbottom.gif',
-
-		minus				: '../img/minus.gif',
-
-		minusBottom	: '../img/minusbottom.gif',
-
-		nlPlus			: '../img/nolines_plus.gif',
-
-		nlMinus			: '../img/nolines_minus.gif'
-
-	};
-
-	this.obj = objName;
-
-	this.aNodes = [];
-
-	this.aIndent = [];
-
-	this.root = new Node(-1);
-
-	this.selectedNode = null;
-
-	this.selectedFound = false;
-
-	this.completed = false;
-
-};
-
-
-
-// Adds a new node to the node array
-
-dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
-
-	this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
-
-};
-
-
-
-// Open/close all nodes
-
-dTree.prototype.openAll = function() {
-
-	this.oAll(true);
-
-};
-
-dTree.prototype.closeAll = function() {
-
-	this.oAll(false);
-
-};
-
-
-
-// Outputs the tree to the page
-
-dTree.prototype.toString = function() {
-
-	var str = '<div class="dtree">\n';
-
-	if (document.getElementById) {
-
-		if (this.config.useCookies) this.selectedNode = this.getSelected();
-
-		str += this.addNode(this.root);
-
-	} else str += 'Browser not supported.';
-
-	str += '</div>';
-
-	if (!this.selectedFound) this.selectedNode = null;
-
-	this.completed = true;
-
-	return str;
-
-};
-
-
-
-// Creates the tree structure
-
-dTree.prototype.addNode = function(pNode) {
-
-	var str = '';
-
-	var n=0;
-
-	if (this.config.inOrder) n = pNode._ai;
-
-	for (n; n<this.aNodes.length; n++) {
-
-		if (this.aNodes[n].pid == pNode.id) {
-
-			var cn = this.aNodes[n];
-
-			cn._p = pNode;
-
-			cn._ai = n;
-
-			this.setCS(cn);
-
-			if (!cn.target && this.config.target) cn.target = this.config.target;
-
-			if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
-
-			if (!this.config.folderLinks && cn._hc) cn.url = null;
-
-			if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
-
-					cn._is = true;
-
-					this.selectedNode = n;
-
-					this.selectedFound = true;
-
-			}
-
-			str += this.node(cn, n);
-
-			if (cn._ls) break;
-
-		}
-
-	}
-
-	return str;
-
-};
-
-
-
-// Creates the node icon, url and text
-
-dTree.prototype.node = function(node, nodeId) {
-
-	var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
-
-	if (this.config.useIcons) {
-
-		if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
-
-		if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
-
-		if (this.root.id == node.pid) {
-
-			node.icon = this.icon.root;
-
-			node.iconOpen = this.icon.root;
-
-		}
-
-		str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
-
-	}
-
-	if (node.url) {
-
-		str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
-
-		if (node.title) str += ' title="' + node.title + '"';
-
-		if (node.target) str += ' target="' + node.target + '"';
-
-		if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
-
-		if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
-
-			str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
-
-		str += '>';
-
-	}
-
-	else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
-
-		str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
-
-	str += node.name;
-
-	if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
-
-	str += '</div>';
-
-	if (node._hc) {
-
-		str += '<div id="d' + this.obj + nodeId + '" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'block') + ';">';
-
-		str += this.addNode(node);
-
-		str += '</div>';
-
-	}
-
-	this.aIndent.pop();
-
-	return str;
-
-};
-
-
-
-// Adds the empty and line icons
-
-dTree.prototype.indent = function(node, nodeId) {
-
-	var str = '';
-
-	if (this.root.id != node.pid) {
-
-		for (var n=0; n<this.aIndent.length; n++)
-
-			str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
-
-		(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
-
-		if (node._hc) {
-
-			str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
-
-			if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
-
-			else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
-
-			str += '" alt="" /></a>';
-
-		} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
-
-	}
-
-	return str;
-
-};
-
-
-
-// Checks if a node has any children and if it is the last sibling
-
-dTree.prototype.setCS = function(node) {
-
-	var lastId;
-
-	for (var n=0; n<this.aNodes.length; n++) {
-
-		if (this.aNodes[n].pid == node.id) node._hc = true;
-
-		if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
-
-	}
-
-	if (lastId==node.id) node._ls = true;
-
-};
-
-
-
-// Returns the selected node
-
-dTree.prototype.getSelected = function() {
-
-	var sn = this.getCookie('cs' + this.obj);
-
-	return (sn) ? sn : null;
-
-};
-
-
-
-// Highlights the selected node
-
-dTree.prototype.s = function(id) {
-
-	if (!this.config.useSelection) return;
-
-	var cn = this.aNodes[id];
-
-	// Added by Ivan Tcholakov to prevent javascript error when the tree is empty.
-	if (!cn) return;
-
-	if (cn._hc && !this.config.folderLinks) return;
-
-	if (this.selectedNode != id) {
-
-		if (this.selectedNode || this.selectedNode==0) {
-
-			eOld = document.getElementById("s" + this.obj + this.selectedNode);
-
-			eOld.className = "node";
-
-		}
-
-		eNew = document.getElementById("s" + this.obj + id);
-
-		eNew.className = "nodeSel";
-
-		this.selectedNode = id;
-
-		if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
-
-	}
-
-};
-
-
-
-// Toggle Open or close
-
-dTree.prototype.o = function(id) {
-
-	var cn = this.aNodes[id];
-
-	this.nodeStatus(!cn._io, id, cn._ls);
-
-	cn._io = !cn._io;
-
-	if (this.config.closeSameLevel) this.closeLevel(cn);
-
-	if (this.config.useCookies) this.updateCookie();
-
-};
-
-
-
-// Open or close all nodes
-
-dTree.prototype.oAll = function(status) {
-
-	for (var n=0; n<this.aNodes.length; n++) {
-
-		if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
-
-			this.nodeStatus(status, n, this.aNodes[n]._ls)
-
-			this.aNodes[n]._io = status;
-
-		}
-
-	}
-
-	if (this.config.useCookies) this.updateCookie();
-
-};
-
-
-
-// Opens the tree to a specific node
-
-dTree.prototype.openTo = function(nId, bSelect, bFirst) {
-
-	if (!bFirst) {
-
-		for (var n=0; n<this.aNodes.length; n++) {
-
-			if (this.aNodes[n].id == nId) {
-
-				nId=n;
-
-				break;
-
-			}
-
-		}
-
-	}
-
-	var cn=this.aNodes[nId];
-
-	if (cn.pid==this.root.id || !cn._p) return;
-
-	cn._io = true;
-
-	cn._is = bSelect;
-
-	if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
-
-	if (this.completed && bSelect) this.s(cn._ai);
-
-	else if (bSelect) this._sn=cn._ai;
-
-	this.openTo(cn._p._ai, false, true);
-
-};
-
-
-
-// Closes all nodes on the same level as certain node
-
-dTree.prototype.closeLevel = function(node) {
-
-	for (var n=0; n<this.aNodes.length; n++) {
-
-		if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
-
-			this.nodeStatus(false, n, this.aNodes[n]._ls);
-
-			this.aNodes[n]._io = false;
-
-			this.closeAllChildren(this.aNodes[n]);
-
-		}
-
-	}
-
-}
-
-
-
-// Closes all children of a node
-
-dTree.prototype.closeAllChildren = function(node) {
-
-	for (var n=0; n<this.aNodes.length; n++) {
-
-		if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
-
-			if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
-
-			this.aNodes[n]._io = false;
-
-			this.closeAllChildren(this.aNodes[n]);
-
-		}
-
-	}
-
-}
-
-
-
-// Change the status of a node(open or closed)
-
-dTree.prototype.nodeStatus = function(status, id, bottom) {
-
-	eDiv	= document.getElementById('d' + this.obj + id);
-
-	eJoin	= document.getElementById('j' + this.obj + id);
-
-	if (this.config.useIcons) {
-
-		eIcon	= document.getElementById('i' + this.obj + id);
-
-		eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
-
-	}
-
-	eJoin.src = (this.config.useLines)?
-
-	((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
-
-	((status)?this.icon.nlMinus:this.icon.nlPlus);
-
-	eDiv.style.display = (status) ? 'block': 'none';
-
-};
-
-
-
-
-
-// [Cookie] Clears a cookie
-
-dTree.prototype.clearCookie = function() {
-
-	var now = new Date();
-
-	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
-
-	this.setCookie('co'+this.obj, 'cookieValue', yesterday);
-
-	this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
-
-};
-
-
-
-// [Cookie] Sets value in a cookie
-
-dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
-
-	document.cookie =
-
-		escape(cookieName) + '=' + escape(cookieValue)
-
-		+ (expires ? '; expires=' + expires.toGMTString() : '')
-
-		+ (path ? '; path=' + path : '')
-
-		+ (domain ? '; domain=' + domain : '')
-
-		+ (secure ? '; secure' : '');
-
-};
-
-
-
-// [Cookie] Gets a value from a cookie
-
-dTree.prototype.getCookie = function(cookieName) {
-
-	var cookieValue = '';
-
-	var posName = document.cookie.indexOf(escape(cookieName) + '=');
-
-	if (posName != -1) {
-
-		var posValue = posName + (escape(cookieName) + '=').length;
-
-		var endPos = document.cookie.indexOf(';', posValue);
-
-		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
-
-		else cookieValue = unescape(document.cookie.substring(posValue));
-
-	}
-
-	return (cookieValue);
-
-};
-
-
-
-// [Cookie] Returns ids of open nodes as a string
-
-dTree.prototype.updateCookie = function() {
-
-	var str = '';
-
-	for (var n=0; n<this.aNodes.length; n++) {
-
-		if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
-
-			if (str) str += '.';
-
-			str += this.aNodes[n].id;
-
-		}
-
-	}
-
-	this.setCookie('co' + this.obj, str);
-
-};
-
-
-
-// [Cookie] Checks if a node id is in a cookie
-
-dTree.prototype.isOpen = function(id) {
-
-	var aOpen = this.getCookie('co' + this.obj).split('.');
-
-	for (var n=0; n<aOpen.length; n++)
-
-		if (aOpen[n] == id) return true;
-
-	return false;
-
-};
-
-
-
-// If Push and pop is not implemented by the browser
-
-if (!Array.prototype.push) {
-
-	Array.prototype.push = function array_push() {
-
-		for(var i=0;i<arguments.length;i++)
-
-			this[this.length]=arguments[i];
-
-		return this.length;
-
-	}
-
-};
-
-if (!Array.prototype.pop) {
-
-	Array.prototype.pop = function array_pop() {
-
-		lastElement = this[this.length-1];
-
-		this.length = Math.max(this.length-1,0);
-
-		return lastElement;
-
-	}
-
-};
-
-function testResources(id,img){
-	if(document.getElementById(id).style.display=='block'){
-		document.getElementById(id).style.display='none';
-		document.getElementById("img_"+id).src='../img/nolines_plus.gif';
-	}
-	else{
-		document.getElementById(id).style.display='block';
-		document.getElementById("img_"+id).src='../img/nolines_minus.gif';
-	}
-}

+ 0 - 3
main/newscorm/lp_add.php

@@ -34,9 +34,6 @@ $language_file = 'learnpath';
 /* Header and action code */
 
 $currentstyle = api_get_setting('stylesheets');
-//$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'css/'.$currentstyle.'/learnpath.css"/>';
-//$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="learnpath.css" />'; //will be a merged with original learnpath.css
-$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="dtree.css" />'; //will be moved
 $htmlHeadXtra[] = '<script type="text/javascript">
 function setFocus(){
 $("#learnpath_title").focus();

+ 42 - 26
user_portal.php

@@ -54,8 +54,6 @@ require_once $libpath.'sessionmanager.lib.php';
 
 api_block_anonymous_users(); // Only users who are logged in can proceed.
 
-//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.toggle.js" type="text/javascript" language="javascript"></script>';
-
 /* Table definitions */
 
 // Database table definitions.
@@ -92,6 +90,10 @@ define('CONFVAL_dateFormatForInfosFromCourses', get_lang('dateFormatLong'));
 //define("CONFVAL_limitPreviewTo",SCRIPTVAL_NoTimeLimit);
 define("CONFVAL_limitPreviewTo", SCRIPTVAL_NewEntriesOfTheDayOfLastLogin);
 
+//$load_dirs = api_get_setting('courses_list_document_dynamic_dropdown');
+$load_dirs = true;
+
+
 // This is the main function to get the course list.
 $personal_course_list = UserManager::get_personal_session_course_list(api_get_user_id());
 
@@ -135,8 +137,6 @@ if (api_get_setting('go_to_course_after_login') == 'true') {
         header('location:'.$url);            
         exit;
     }
-    
-
    /*
         if (api_get_setting('hide_courses_in_sessions') == 'true') {
             //Check sessions
@@ -150,8 +150,7 @@ if (api_get_setting('go_to_course_after_login') == 'true') {
                 header('Location:'.api_get_path(WEB_CODE_PATH).'session/?session_id='.$session_list[$only_session_id]['id_session']);    
             }
         }
-    */
-    
+    */    
 }
 
 $nosession = false;
@@ -193,28 +192,45 @@ if (CONFVAL_showExtractInfo != SCRIPTVAL_UnderCourseList and $orderKey[0] != 'ke
     Header
     Include the HTTP, HTML headers plus the top banner.
 */
-$url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=document_preview';
 
-$htmlHeadXtra[] =  '<script type="text/javascript">
-
-$(document).ready( function() {
-	$(".document_preview").click(function() {
-		var my_id = this.id;
-		course_id = my_id.split("_")[2];
+if ($load_dirs) {
+	$url 			= api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=document_preview';
+	$folder_icon 	= api_get_path(WEB_IMG_PATH).'icons/22/folder.png';
+	$close_icon 	= api_get_path(WEB_IMG_PATH).'loading1.gif';
+	
+	$htmlHeadXtra[] =  '<script type="text/javascript">
+	
+	$(document).ready( function() {
 		
-		 
-		$.ajax({
-			url: "'.$url.'",
-			data: "course_id="+course_id,
-            success: function(return_value) {
-            	$("#document_result_" +course_id).html(return_value);
-            },
-        });
-        
+		$(".document_preview_container").hide();
+		
+		$(".document_preview").click(function() {
+			var my_id = this.id;
+			course_id = my_id.split("_")[2];
+			
+			//showing div
+			$(".document_preview_container").hide();
+					
+			$("#document_result_" +course_id).show();	
+			
+			//Loading		
+			var image = $("img", this);
+			image.attr("src", "'.$close_icon.'");		
+					
+			$.ajax({
+				url: "'.$url.'",
+				data: "course_id="+course_id,
+	            success: function(return_value) {
+	            	image.attr("src", "'.$folder_icon.'");
+	            	$("#document_result_" +course_id).html(return_value);
+	            	
+	            },
+	        });
+	        
+		});
 	});
-});
-
-</script>';
+	</script>';
+}
 
 
 Display :: display_header($nameTools);
@@ -401,7 +417,7 @@ if (is_array($courses_tree)) {
             if (!isset($_GET['history'])) { 
                // If we're not in the history view...
                 CourseManager :: display_special_courses(api_get_user_id());
-                CourseManager :: display_courses(api_get_user_id());
+                CourseManager :: display_courses(api_get_user_id(), $load_dirs);
             }
             // Independent sessions.
             foreach ($category['sessions'] as $session) {