Work on generic filemanager

This commit is contained in:
Laurent Destailleur 2017-11-20 18:19:41 +01:00
parent 818f43e7ad
commit e19ca7b6d4
10 changed files with 92 additions and 59 deletions

View File

@ -234,6 +234,7 @@ if ($type == 'directory')
$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'));
//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$website.'&pageid='.$pageid);
}
}
else

View File

@ -198,7 +198,10 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
print '</td>';
// Edit link
print '<td align="right" width="18"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?module='.urlencode($modulepart).'&section='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']).'">'.img_view($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle"').'</a></td>';
print '<td align="right" width="18"><a href="';
print DOL_URL_ROOT.'/ecm/docmine.php?module='.urlencode($modulepart).'&section='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']);
print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$website.'&pageid='.$pageid);
print '">'.img_view($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle"').'</a></td>';
// Add link
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';

View File

@ -68,18 +68,30 @@ function ecm_prepare_dasboard_head($object)
* Prepare array with list of tabs
*
* @param object $object Object related to tabs
* @param string $module Module
* @param string $section Section
* @return array Array of tabs to show
*/
function ecm_prepare_head($object)
function ecm_prepare_head($object, $module='ecm', $section='')
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/ecm/docmine.php?section='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
if ($module == 'ecm')
{
$head[$h][0] = DOL_URL_ROOT.'/ecm/docmine.php?section='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
}
else
{
$head[$h][0] = DOL_URL_ROOT.'/ecm/docmine.php?section='.$section.'&module='.$module;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
}
return $head;
}

View File

@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
if (empty($module)) $module='ecm';
$permtoadd = 0;
$permtoupload = 1;
$permtoupload = 0;
if ($module == 'ecm')
{
$permtoadd = $user->rights->ecm->setup;

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2008-2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,15 +17,13 @@
/**
* \file htdocs/ecm/class/htmlecm.form.class.php
* \brief Fichier de la classe des fonctions predefinie de composants html
* \brief File of class to manage HTML component for ECM and generic filemanager
*/
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
/**
* \class FormEcm
* \brief Classe permettant la generation de composants html
* \remarks Only common components must be here.
* Class to manage HTML component for ECM and generic filemanager
*/
class FormEcm
{
@ -81,7 +79,8 @@ class FormEcm
$output.= '<option value="-1">&nbsp;</option>';
foreach($cate_arbo as $key => $value)
{
if ($selected && $cate_arbo[$key]['id'] == $selected)
$valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id'];
if ($selected && $valueforoption == $selected)
{
$add = 'selected ';
}
@ -89,7 +88,7 @@ class FormEcm
{
$add = '';
}
$output.= '<option '.$add.'value="'.dol_escape_htmltag(empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id']).'">'.(empty($cate_arbo[$key]['fulllabel']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['fulllabel']).'</option>';
$output.= '<option '.$add.'value="'.dol_escape_htmltag($valueforoption).'">'.(empty($cate_arbo[$key]['fulllabel']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['fulllabel']).'</option>';
}
}
}

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2008-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
*
@ -102,7 +102,7 @@ if ($action == 'add' && $user->rights->ecm->setup)
}
else
{
header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager');
header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'.($module?'&module='.$module:''));
exit;
}
}
@ -227,7 +227,7 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth100" maxlength="32" value="'.$ecmdir->label.'"></td></tr>'."\n";
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $formecm->selectAllSections(! empty($_GET["catParent"]) ? $_GET["catParent"] : $ecmdir->fk_parent, 'catParent', $module);
print $formecm->selectAllSections((GETPOST("catParent",'alpha') ? GETPOST("catParent",'alpha') : $ecmdir->fk_parent), 'catParent', $module);
print '</td></tr>'."\n";
// Description

View File

@ -123,7 +123,7 @@ if ($cancel)
}
else
{
header("Location: ".DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($urlfile).'&section='.urlencode($section));
header("Location: ".DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($urlfile).'&section='.urlencode($section).($module?'&module='.urlencode($module):''));
exit;
}
}
@ -242,7 +242,8 @@ if ($action == 'edit')
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="section" value="'.$section.'">';
print '<input type="hidden" name="urlfile" value="'.$urlfile.'">';
print '<input type="hidden" name="urlfile" value="'.$urlfile.'">';
print '<input type="hidden" name="module" value="'.$module.'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
}

View File

@ -226,7 +226,7 @@ foreach($filearray as $key => $file)
}
$head = ecm_prepare_head($ecmdir);
$head = ecm_prepare_head($ecmdir, $module, $section);
dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), -1, 'dir');
@ -235,37 +235,46 @@ if ($action == 'edit')
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="section" value="'.$section.'">';
print '<input type="hidden" name="module" value="'.$module.'">';
print '<input type="hidden" name="action" value="update">';
}
$s='';
$result = 1;
$i=0;
$tmpecmdir=new EcmDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0)
{
$tmpecmdir->ref=$tmpecmdir->label;
if ($i == 0 && $action == 'edit')
{
$s='<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
}
else $s=$tmpecmdir->getNomUrl(1).$s;
if ($tmpecmdir->fk_parent)
{
$s=' -> '.$s;
$result=$tmpecmdir->fetch($tmpecmdir->fk_parent);
}
else
{
$tmpecmdir=0;
}
$i++;
}
$morehtml='';
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;
$morehtmlref = '/'.$module.'/'.$relativepath;
if ($module == 'ecm')
{
$s='';
$result = 1;
$i=0;
$tmpecmdir=new EcmDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0)
{
$tmpecmdir->ref=$tmpecmdir->label;
if ($i == 0 && $action == 'edit')
{
$s='<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
}
else $s=$tmpecmdir->getNomUrl(1).$s;
if ($tmpecmdir->fk_parent)
{
$s=' -> '.$s;
$result=$tmpecmdir->fetch($tmpecmdir->fk_parent);
}
else
{
$tmpecmdir=0;
}
$i++;
}
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;
}
dol_banner_tab($object, '', $morehtml, 0, '', '', $morehtmlref);
@ -307,15 +316,25 @@ else
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
print '/ecm/'.$relativepath;
if ($module == 'ecm')
{
print '/ecm/'.$relativepath;
}
else
{
print '/'.$module.'/'.$relativepath;
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
$nbofiles=count($filearray);
print $nbofiles;
// Test if nb is same than in cache
if ($nbofiles != $ecmdir->cachenbofdoc)
if ($ecmdir->id > 0)
{
$ecmdir->changeNbOfFiles((string) $nbofiles);
// Test if nb is same than in cache
if ($nbofiles != $ecmdir->cachenbofdoc)
{
$ecmdir->changeNbOfFiles((string) $nbofiles);
}
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>';

View File

@ -30,14 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
// Load traductions files
$langs->load("ecm");
$langs->load("companies");
$langs->load("other");
$langs->load("users");
$langs->load("orders");
$langs->load("propal");
$langs->load("bills");
$langs->load("contracts");
$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts"));
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@ -52,6 +45,11 @@ $action = GETPOST('action','alpha');
$section=GETPOST('section');
if (! $section) $section=0;
$module = GETPOST('module', 'alpha');
$website = GETPOST('website', 'alpha');
$pageid = GETPOST('pageid', 'int');
if (empty($module)) $module='ecm';
$upload_dir = $conf->ecm->dir_output.'/'.$section;
$sortfield = GETPOST("sortfield",'alpha');
@ -123,7 +121,7 @@ print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
// Tool bar
$head = ecm_prepare_head_fm($ecmdir);
$head = ecm_prepare_head_fm($ecmdir, $module, $section);
//dol_fiche_head($head, 'search_form', '', 1);

View File

@ -6,7 +6,7 @@ ECMSectionAuto=Automatic directory
ECMSectionsManual=Manual tree
ECMSectionsAuto=Automatic tree
ECMSections=Directories
ECMRoot=Root
ECMRoot=ECM Root
ECMNewSection=New directory
ECMAddSection=Add directory
ECMCreationDate=Creation date