Browse Source

Work on filemanager generic component

Laurent Destailleur 7 năm trước cách đây
mục cha
commit
ab78007a54

+ 29 - 9
htdocs/core/ajax/ajaxdirpreview.php

@@ -86,7 +86,12 @@ else    // For no ajax call
     $relativepath=$ecmdir->getRelativePath();
     $upload_dir = $rootdirfordoc.'/'.$relativepath;
 }
-if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
+
+if (empty($url))
+{
+	if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php';
+	else $url=DOL_URL_ROOT.'/ecm/index.php';
+}
 
 // Load traductions files
 $langs->loadLangs(array("ecm","companies","other"));
@@ -153,6 +158,8 @@ print '<!-- ajaxdirpreview type='.$type.' -->'."\n";
 //print '<!-- Page called with mode='.dol_escape_htmltag(isset($mode)?$mode:'').' type='.dol_escape_htmltag($type).' module='.dol_escape_htmltag($module).' url='.dol_escape_htmltag($url).' '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
 
 $param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
+if (! empty($website)) $param.='&website='.$website;
+if (! empty($pageid))  $param.='&pageid='.$pageid;
 
 
 // Dir scan
@@ -222,6 +229,12 @@ if ($type == 'directory')
     		$relativepath=GETPOST('file','alpha');
     		if ($relativepath && $relativepath!= '/') $relativepath.='/';
     		$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
+   	    	if (GETPOSTISSET('website'))
+	    	{
+	    		$param.='&file_manager=1';
+	    		if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha'));
+	    		if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int'));
+	    	}
     	}
     	else
     	{
@@ -255,28 +268,35 @@ if ($type == 'directory')
 
     	if ($module == 'medias')
     	{
+    		$useinecm = 0;
     		$modulepart='medias';
-        	$perm=($user->rights->websites->creer || $user->rights->emailing->creer);
+        	$perm=($user->rights->website->write || $user->rights->emailing->creer);
+        	$title='none';
     	}
     	else
     	{
+    		$useinecm = 1;
     		$modulepart='ecm';
         	$perm=$user->rights->ecm->upload;
+        	$title='';	// Use default
     	}
 
-		$formfile->list_of_documents($filearray,'',$modulepart,$param,1,$relativepath,$perm,1,$textifempty,$maxlengthname,'',$url);
+    	// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
+    	// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
+    	//var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
+		$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
     }
 }
 
 
-if ($section)
-{
+//if ($section)
+//{
 	$useajax=1;
 	if (! empty($conf->dol_use_jmobile)) $useajax=0;
 	if (empty($conf->use_javascript_ajax)) $useajax=0;
 	if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0;
 
-	$param.=($param?'?':'').(preg_replace('/^&/','',$param));
+	//$param.=($param?'?':'').(preg_replace('/^&/','',$param));
 
 	if ($useajax || $action == 'delete')
 	{
@@ -295,14 +315,14 @@ if ($section)
 
 	if ($useajax)
 	{
-		// Enable jquery handlers on new generated HTML objects
+		// Enable jquery handlers button to delete files
 		print '<script type="text/javascript">'."\n";
 		print 'jQuery(document).ready(function() {'."\n";
-		print 'jQuery(".deletefilelink").click(function(e) { jQuery("#urlfile").val(jQuery(this).attr("rel")); jQuery("#dialog-confirm-deletefile").dialog("open"); return false; });'."\n";
+		print 'jQuery(".deletefilelink").click(function(e) { console.log("We click on button with class deletefilelink"); jQuery("#urlfile").val(jQuery(this).attr("rel")); jQuery("#dialog-confirm-deletefile").dialog("open"); return false; });'."\n";
 		print '});'."\n";
 		print '</script>'."\n";
 	}
-}
+//}
 
 // Close db if mode is not noajax
 if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();

+ 9 - 4
htdocs/core/class/html.formfile.class.php

@@ -914,10 +914,12 @@ class FormFile
 	 * 	@param	 int	$forcedownload		Force to open dialog box "Save As" when clicking on file.
 	 * 	@param	 string	$relativepath		Relative path of docs (autodefined if not provided), relative to module dir, not to MAIN_DATA_ROOT.
 	 * 	@param	 int	$permonobject		Permission on object (so permission to delete or crop document)
-	 * 	@param	 int	$useinecm			Change output for use in ecm module
+	 * 	@param	 int	$useinecm			Change output for use in ecm module:
+	 * 										0: Add a previw link. Show also rename and crop file
+	 * 										1: Add link to edit ECM entry
 	 * 	@param	 string	$textifempty		Text to show if filearray is empty ('NoFileFound' if not defined)
 	 *  @param   int	$maxlength          Maximum length of file name shown.
-	 *  @param	 string	$title				Title before list
+	 *  @param	 string	$title				Title before list. Use 'none' to disable title.
 	 *  @param	 string $url				Full url to use for click links ('' = autodetect)
 	 *  @param	 int	$showrelpart		0=Show only filename (default), 1=Show first level 1 dir
 	 *  @param   int    $permtoeditline     Permission to edit document line (You must provide a value, -1 is deprecated and must not be used any more)
@@ -977,7 +979,9 @@ class FormFile
 		}
 		else
 		{
-			$param = (isset($object->id)?'&id='.$object->id:'').$param;
+			if (! preg_match('/&id=/', $param) && isset($object->id)) $param.='&id='.$object->id;
+			$relativepathwihtoutslashend=preg_replace('/\/$/', '', $relativepath);
+			if ($relativepathwihtoutslashend) $param.= '&file='.urlencode($relativepathwihtoutslashend);
 
 			if ($permtoeditline < 0)  // Old behaviour for backward compatibility. New feature should call method with value 0 or 1
 			{
@@ -995,7 +999,7 @@ class FormFile
 			}
 
 			// Show list of existing files
-			if (empty($useinecm)) print load_fiche_titre($title?$title:$langs->trans("AttachedFiles"));
+			if (empty($useinecm) && $title != 'none') print load_fiche_titre($title?$title:$langs->trans("AttachedFiles"));
 			if (empty($url)) $url=$_SERVER["PHP_SELF"];
 
 			print '<!-- html.formfile::list_of_documents -->'."\n";
@@ -1023,6 +1027,7 @@ class FormFile
 			}
 
 			print '<tr class="liste_titre nodrag nodrop">';
+			//print $url.' sortfield='.$sortfield.' sortorder='.$sortorder;
 			print_liste_field_titre('Documents2',$url,"name","",$param,'align="left"',$sortfield,$sortorder);
 			print_liste_field_titre('Size',$url,"size","",$param,'align="right"',$sortfield,$sortorder);
 			print_liste_field_titre('Date',$url,"date","",$param,'align="center"',$sortfield,$sortorder);

+ 1 - 1
htdocs/core/lib/functions.lib.php

@@ -1478,7 +1478,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
 		if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>';
 	}
 
-	if ($object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories')
+	if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files')
 	{
 		$morehtmlref.='<div class="refidno">';
 		$morehtmlref.=$object->getBannerAddress('refaddress',$object);

+ 12 - 10
htdocs/ecm/class/ecmdirectory.class.php

@@ -411,31 +411,33 @@ class EcmDirectory // extends CommonObject
 	 *  @param	string	$option			Sur quoi pointe le lien
 	 *  @param	int		$max			Max length
 	 *  @param	string	$more			Add more param on a link
+     *  @param	int		$notooltip		1=Disable tooltip
 	 *  @return	string					Chaine avec URL
 	 */
-	function getNomUrl($withpicto=0,$option='',$max=0,$more='')
+	function getNomUrl($withpicto=0, $option='', $max=0, $more='', $notooltip=0)
 	{
 		global $langs;
 
 		$result='';
         //$newref=str_replace('_',' ',$this->ref);
         $newref=$this->ref;
-        $newlabel=$langs->trans("ShowECMSection").': '.$newref;
-        $linkclose='"'.($more?' '.$more:'').' title="'.dol_escape_htmltag($newlabel, 1).'" class="classfortooltip">';
+        $label=$langs->trans("ShowECMSection").': '.$newref;
+        $linkclose='"'.($more?' '.$more:'').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
 
-        $link = '<a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$this->id.$linkclose;
-        if ($option == 'index') $link = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
-        if ($option == 'indexexpanded') $link = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
-        if ($option == 'indexnotexpanded') $link = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
+        $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$this->id.$linkclose;
+        if ($option == 'index') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
+        if ($option == 'indexexpanded') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
+        if ($option == 'indexnotexpanded') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
         $linkend='</a>';
 
 		//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
 		$picto='dir';
 
+		$result .= $linkstart;
+		if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
+		if ($withpicto != 2) $result.= ($max?dol_trunc($newref,$max,'middle'):$newref);
+		$result .= $linkend;
 
-        if ($withpicto) $result.=($link.img_object($newlabel, $picto, 'class="classfortooltip"').$linkend);
-		if ($withpicto && $withpicto != 2) $result.=' ';
-		if ($withpicto != 2) $result.=$link.($max?dol_trunc($newref,$max,'middle'):$newref).$linkend;
 		return $result;
 	}
 

+ 2 - 37
htdocs/ecm/class/ecmfiles.class.php

@@ -43,6 +43,7 @@ class EcmFiles //extends CommonObject
 	 * @var string Name of table without prefix where object is stored
 	 */
 	public $table_element = 'ecm_files';
+	public $picto = 'generic';
 
 	/**
 	 */
@@ -752,43 +753,7 @@ class EcmFiles //extends CommonObject
 	static function LibStatut($status,$mode=0)
 	{
 		global $langs;
-
-		if ($mode == 0)
-		{
-			$prefix='';
-			if ($status == 1) return $langs->trans('Enabled');
-			if ($status == 0) return $langs->trans('Disabled');
-		}
-		if ($mode == 1)
-		{
-			if ($status == 1) return $langs->trans('Enabled');
-			if ($status == 0) return $langs->trans('Disabled');
-		}
-		if ($mode == 2)
-		{
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
-		}
-		if ($mode == 3)
-		{
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
-		}
-		if ($mode == 4)
-		{
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
-		}
-		if ($mode == 5)
-		{
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
-		}
-		if ($mode == 6)
-		{
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
-		}
+		return '';
 	}
 
 

+ 16 - 26
htdocs/ecm/docfile.php

@@ -247,10 +247,9 @@ if ($action == 'edit')
 	print '<input type="hidden" name="id" value="'.$object->id.'">';
 }
 
-dol_fiche_head($head, 'card', $langs->trans("File"), 0, 'generic');
+dol_fiche_head($head, 'card', $langs->trans("File"), -1, 'generic');
+
 
-print '<table class="border" width="100%">';
-print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
 $s='';
 $tmpecmdir=new EcmDirectory($db);	// Need to create a new one
 $tmpecmdir->fetch($ecmdir->id);
@@ -259,7 +258,7 @@ $i=0;
 while ($tmpecmdir && $result > 0)
 {
 	$tmpecmdir->ref=$tmpecmdir->label;
-    $s=$tmpecmdir->getNomUrl(1).$s;
+	$s=$tmpecmdir->getNomUrl(1).$s;
 	if ($tmpecmdir->fk_parent)
 	{
 		$s=' -> '.$s;
@@ -272,28 +271,18 @@ while ($tmpecmdir && $result > 0)
 	$i++;
 }
 
-print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
-print $s;
-print ' -> ';
-if ($action == 'edit') print '<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfile.'">';
-else print $urlfile;
-print '</td></tr>';
-/*print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
-if ($action == 'edit')
-{
-	print '<textarea class="flat" name="description" cols="80">';
-	print $ecmdir->description;
-	print '</textarea>';
-}
-else print dol_nl2br($ecmdir->description);
-print '</td></tr>';
-print '<tr><td>'.$langs->trans("ECMCreationUser").'</td><td>';
-$userecm=new User($db);
-$userecm->fetch($ecmdir->fk_user_c);
-print $userecm->getNomUrl(1);
-print '</td></tr>';
-*/
-print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>';
+$s = img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s.' -> ';
+if ($action == 'edit') $s .= '<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfile.'">';
+else $s .= $urlfile;
+
+$object->ref='';	// Force to hide ref
+dol_banner_tab($object, '', $morehtml, 0, '', '', $s);
+
+print '<div class="fichecenter">';
+
+print '<div class="underbanner clearboth"></div>';
+print '<table class="border" width="100%">';
+print '<tr><td class="titlefield">'.$langs->trans("ECMCreationDate").'</td><td>';
 print dol_print_date(dol_filemtime($fullpath),'dayhour');
 print '</td></tr>';
 /*print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
@@ -385,6 +374,7 @@ else
 print '</td></tr>';
 
 print '</table>';
+print '</div>';
 
 print ajax_autoselect('downloadinternallink');
 print ajax_autoselect('downloadlink');

+ 0 - 159
htdocs/ecm/index.php

@@ -337,165 +337,6 @@ dol_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECM
 $module='ecm';
 include DOL_DOCUMENT_ROOT.'/ecm/tpl/filemanager.tpl.php';
 
-
-/*
-// Start container of all panels
-?>
-<!-- Begin div id="containerlayout" -->
-<div id="containerlayout">
-<div id="ecm-layout-north" class="toolbar largebutton">
-<?php
-
-// Start top panel, toolbar
-print '<div class="inline-block toolbarbutton centpercent">';
-
-// Toolbar
-if ($user->rights->ecm->setup)
-{
-    print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
-    print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
-    print '</a>';
-}
-else
-{
-    print '<a href="#" class="inline-block valignmiddle toolbarbutton" title="'.$langs->trans("NotAllowed").'">';
-    print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
-    print '</a>';
-}
-$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'')));
-print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ReSyncListOfDir')).'">';
-print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
-print '</a>';
-
-
-// Start Add new file area
-$nameforformuserfile = 'formuserfileecm';
-
-print '<div class="inline-block valignmiddle floatright">';
-
-// To attach new file
-if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section))
-{
-	if ((empty($section) || $section == -1) && ($module != 'medias'))
-	{
-		?>
-		<script type="text/javascript">
-    	jQuery(document).ready(function() {
-			jQuery('#<?php echo $nameforformuserfile ?>').hide();
-    	});
-    	</script>
-		<?php
-	}
-
-    $formfile=new FormFile($db);
-	$formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, $nameforformuserfile);
-}
-else print '&nbsp;';
-
-print '</div>';
-// End Add new file area
-
-
-print '</div>';
-// End top panel, toolbar
-
-?>
-</div>
-<div id="ecm-layout-west" class="inline-block">
-<?php
-// Start left area
-
-
-// Confirmation de la suppression d'une ligne categorie
-if ($action == 'delete_section')
-{
-    print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
-}
-// End confirm
-
-
-if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete')
-{
-	print '<table width="100%" class="liste noborderbottom">'."\n";
-
-	print '<!-- Title for manual directories -->'."\n";
-	print '<tr class="liste_titre">'."\n";
-    print '<th class="liste_titre" align="left" colspan="6">';
-    print '&nbsp;'.$langs->trans("ECMSections");
-	print '</th></tr>';
-
-    $showonrightsize='';
-
-	// Manual section
-	$htmltooltip=$langs->trans("ECMAreaDesc2");
-
-    if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
-    {
-        print '<tr><td colspan="6">';
-
-    	// Show filemanager tree (will be filled by call of ajax enablefiletreeajax.tpl.php that execute ajaxdirtree.php)
-	    print '<div id="filetree" class="ecmfiletree"></div>';
-
-	    if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
-
-	    print '</td></tr>';
-    }
-    else
-    {
-        print '<tr><td colspan="6" style="padding-left: 20px">';
-
-        if (empty($module)) $module='ecm';
-
-        $_POST['modulepart'] = $module;
-        $_POST['openeddir'] = GETPOST('openeddir');
-        $_POST['dir'] = empty($_POST['dir'])?'/':$_POST['dir'];
-
-        // Show filemanager tree (will be filled by direct include of ajaxdirtree.php in mode noajax, this will return all dir - all levels - to show)
-        print '<div id="filetree" class="ecmfiletree">';
-
-        $mode='noajax';
-        $url=DOL_URL_ROOT.'/ecm/index.php';
-        include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php';
-
-    	print '</div>';
-    	print '</td></tr>';
-    }
-
-
-	print "</table>";
-}
-
-
-// End left panel
-?>
-</div>
-<div id="ecm-layout-center" class="inline-block">
-<div class="pane-in ecm-in-layout-center">
-<div id="ecmfileview" class="ecmfileview">
-<?php
-// Start right panel
-
-
-$mode='noajax';
-$url=DOL_URL_ROOT.'/ecm/index.php';
-include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
-
-
-// End right panel
-?>
-</div>
-</div>
-
-</div>
-</div> <!-- End div id="containerlayout" -->
-<?php
-
-
-if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
-	include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
-}
-*/
-
 // End of page
 dol_fiche_end();
 

+ 4 - 4
htdocs/ecm/tpl/enablefiletreeajax.tpl.php

@@ -33,8 +33,8 @@ $(document).ready(function() {
 
 	$('#filetree').fileTree({
 		root: '<?php print dol_escape_js($openeddir); ?>',
-		// Ajax called if we click to expand a dir (not a file). Parameter 'dir' is provided as a POST parameter by fileTree code.
-		script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart='.$module.'&openeddir='.urlencode($openeddir); ?>',
+		// Ajax called if we click to expand a dir (not a file). Parameter 'dir' is provided as a POST parameter by fileTree code to this following URL.
+		script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart='.$module.'&openeddir='.urlencode($openeddir).(empty($param)?'':$param); ?>',
 		folderEvent: 'click',	// 'dblclick'
 		multiFolder: false  },
 		// Called if we click on a file (not a dir)
@@ -46,7 +46,7 @@ $(document).ready(function() {
 		function(elem) {
 			id=elem.attr('id').substr(12);	// We get id that is 'fmdirlia_id_xxx' (id we want is xxx)
 			jQuery("#<?php echo $nameforformuserfile ?>_section_dir").val(elem.attr('rel'));
-   			jQuery("#<?php echo $nameforformuserfile ?>_section_id").val(id);
+			jQuery("#<?php echo $nameforformuserfile ?>_section_id").val(id);
 			jQuery('#<?php echo $nameforformuserfile ?>').show();
 		}
 	);
@@ -73,7 +73,7 @@ function loadandshowpreview(filedirname,section)
 
 	$('#ecmfileview').empty();
 
-	var url = '<?php echo dol_buildpath('/core/ajax/ajaxdirpreview.php',1); ?>?action=preview&module=<?php echo $module; ?>&section='+section+'&file='+urlencode(filedirname);
+	var url = '<?php echo dol_buildpath('/core/ajax/ajaxdirpreview.php',1); ?>?action=preview&module=<?php echo $module; ?>&section='+section+'&file='+urlencode(filedirname)<?php echo (empty($param)?'':"+'".$param."'"); ?>;
 	$.get(url, function(data) {
 		//alert('Load of url '+url+' was performed : '+data);
 		pos=data.indexOf("TYPE=directory",0);

+ 4 - 4
htdocs/ecm/tpl/filemanager.tpl.php

@@ -57,8 +57,8 @@ else
 }
 if ($module == 'ecm')
 {
-	$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'')));
-	print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ReSyncListOfDir')).'">';
+	$tmpurl=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'')));
+	print '<a href="'.$tmpurl.'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ReSyncListOfDir')).'">';
 	print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
 	print '</a>';
 }
@@ -150,7 +150,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
         print '<div id="filetree" class="ecmfiletree">';
 
         $mode='noajax';
-        $url=DOL_URL_ROOT.'/ecm/index.php';
+        if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
         include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php';
 
     	print '</div>';
@@ -173,7 +173,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
 
 
 $mode='noajax';
-$url=DOL_URL_ROOT.'/ecm/index.php';
+if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
 include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
 
 

+ 13 - 2
htdocs/website/index.php

@@ -52,7 +52,6 @@ $pageid=GETPOST('pageid', 'int');
 $pageref=GETPOST('pageref', 'aZ09');
 $action=GETPOST('action','alpha');
 
-
 if (GETPOST('delete')) { $action='delete'; }
 if (GETPOST('preview')) $action='preview';
 if (GETPOST('createsite')) { $action='createsite'; }
@@ -67,6 +66,18 @@ if (GETPOST('editcontent')) { $action='editcontent'; }
 if (GETPOST('createfromclone')) { $action='createfromclone'; }
 if (GETPOST('createpagefromclone')) { $action='createpagefromclone'; }
 
+// Load variable for pagination
+$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+//if (! $sortfield) $sortfield='name';
+//if (! $sortorder) $sortorder='ASC';
+
 if (empty($action)) $action='preview';
 
 $object=new Website($db);
@@ -111,7 +122,6 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain
 //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
 
 
-
 /*
  * Actions
  */
@@ -1792,6 +1802,7 @@ if ($action == 'file_manager')
 	//print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>';
 
 	$module = 'medias';
+	if (empty($url)) $url=DOL_URL_ROOT.'/website/index.php';
 	include DOL_DOCUMENT_ROOT.'/ecm/tpl/filemanager.tpl.php';
 }