diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index ddcf8eb62d8..9107b604e80 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/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 ''."\n"; //print ''."\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 ''."\n"; } -} +//} // Close db if mode is not noajax if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index f105ef78263..2a514f65f1f 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/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 ''."\n"; @@ -1023,6 +1027,7 @@ class FormFile } print ''; + //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); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7660b198313..6ca18fda666 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/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.='
'.$object->label.'
'; } - 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.='
'; $morehtmlref.=$object->getBannerAddress('refaddress',$object); diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 07c8b0aff00..bbb80f52cba 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/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 = '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; } diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index a329adfd116..ae16ad85eaf 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/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 ''; } diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index 339df01b88a..5a14b95291f 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -247,10 +247,9 @@ if ($action == 'edit') print ''; } -dol_fiche_head($head, 'card', $langs->trans("File"), 0, 'generic'); +dol_fiche_head($head, 'card', $langs->trans("File"), -1, 'generic'); + -print ''; -print ''; -/*print ''; -print ''; -*/ -print '
'.$langs->trans("Ref").''; $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').' '.$langs->trans("ECMRoot").' -> '; -print $s; -print ' -> '; -if ($action == 'edit') print ''; -else print $urlfile; -print '
'.$langs->trans("Description").''; -if ($action == 'edit') -{ - print ''; -} -else print dol_nl2br($ecmdir->description); -print '
'.$langs->trans("ECMCreationUser").''; -$userecm=new User($db); -$userecm->fetch($ecmdir->fk_user_c); -print $userecm->getNomUrl(1); -print '
'.$langs->trans("ECMCreationDate").''; +$s = img_picto('','object_dir').' '.$langs->trans("ECMRoot").' -> '.$s.' -> '; +if ($action == 'edit') $s .= ''; +else $s .= $urlfile; + +$object->ref=''; // Force to hide ref +dol_banner_tab($object, '', $morehtml, 0, '', '', $s); + +print '
'; + +print '
'; +print ''; +print ''; /*print ''; print '
'.$langs->trans("ECMCreationDate").''; print dol_print_date(dol_filemtime($fullpath),'dayhour'); print '
'.$langs->trans("ECMDirectoryForFiles").''; @@ -385,6 +374,7 @@ else print '
'; +print '
'; print ajax_autoselect('downloadinternallink'); print ajax_autoselect('downloadlink'); diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 56f9b692e94..8841778ce26 100644 --- a/htdocs/ecm/index.php +++ b/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 -?> - -
-
-'; - -// Toolbar -if ($user->rights->ecm->setup) -{ - print ''; - print ''; - print ''; -} -else -{ - print ''; - print ''; - print ''; -} -$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); -print ''; -print ''; -print ''; - - -// Start Add new file area -$nameforformuserfile = 'formuserfileecm'; - -print '
'; - -// 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')) - { - ?> - - form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, $nameforformuserfile); -} -else print ' '; - -print '
'; -// End Add new file area - - -print '
'; -// End top panel, toolbar - -?> -
-
-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 ''."\n"; - - print ''."\n"; - print ''."\n"; - print ''; - - $showonrightsize=''; - - // Manual section - $htmltooltip=$langs->trans("ECMAreaDesc2"); - - if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) - { - print ''; - } - else - { - print ''; - } - - - print "
'; - print ' '.$langs->trans("ECMSections"); - print '
'; - - // Show filemanager tree (will be filled by call of ajax enablefiletreeajax.tpl.php that execute ajaxdirtree.php) - print '
'; - - if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile'); - - print '
'; - - 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 '
'; - - $mode='noajax'; - $url=DOL_URL_ROOT.'/ecm/index.php'; - include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php'; - - print '
'; - print '
"; -} - - -// End left panel -?> -
-
-
-
- -
-
- -
- -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(); diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index 4be1bf1979a..3e77c0acd92 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -33,8 +33,8 @@ $(document).ready(function() { $('#filetree').fileTree({ root: '', - // Ajax called if we click to expand a dir (not a file). Parameter 'dir' is provided as a POST parameter by fileTree code. - script: '', + // 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: '', 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("#_section_dir").val(elem.attr('rel')); - jQuery("#_section_id").val(id); + jQuery("#_section_id").val(id); jQuery('#').show(); } ); @@ -73,7 +73,7 @@ function loadandshowpreview(filedirname,section) $('#ecmfileview').empty(); - var url = '?action=preview&module=§ion='+section+'&file='+urlencode(filedirname); + var url = '?action=preview&module=§ion='+section+'&file='+urlencode(filedirname); $.get(url, function(data) { //alert('Load of url '+url+' was performed : '+data); pos=data.indexOf("TYPE=directory",0); diff --git a/htdocs/ecm/tpl/filemanager.tpl.php b/htdocs/ecm/tpl/filemanager.tpl.php index e80e9fd3e83..c5216deb170 100644 --- a/htdocs/ecm/tpl/filemanager.tpl.php +++ b/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?'&module='.$module:'').($section?'&section='.$section:''))); - print ''; + $tmpurl=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); + print ''; print ''; print ''; } @@ -150,7 +150,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti print '
'; $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 '
'; @@ -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'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 79eca309e59..b3f1116d50c 100644 --- a/htdocs/website/index.php +++ b/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 '
'.$langs->trans("FeatureNotYetAvailable").''; $module = 'medias'; + if (empty($url)) $url=DOL_URL_ROOT.'/website/index.php'; include DOL_DOCUMENT_ROOT.'/ecm/tpl/filemanager.tpl.php'; }