Skip to content

Commit

Permalink
Work on generic filemanager
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 20, 2017
1 parent 818f43e commit e19ca7b
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 56 deletions.
1 change: 1 addition & 0 deletions htdocs/core/ajax/ajaxdirpreview.php
Expand Up @@ -234,6 +234,7 @@
$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
Expand Down
5 changes: 4 additions & 1 deletion htdocs/core/ajax/ajaxdirtree.php
Expand Up @@ -198,7 +198,10 @@
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>';
Expand Down
22 changes: 17 additions & 5 deletions htdocs/core/lib/ecm.lib.php
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/tpl/filemanager.tpl.php
Expand Up @@ -29,7 +29,7 @@
if (empty($module)) $module='ecm';

$permtoadd = 0;
$permtoupload = 1;
$permtoupload = 0;
if ($module == 'ecm')
{
$permtoadd = $user->rights->ecm->setup;
Expand Down
13 changes: 6 additions & 7 deletions htdocs/ecm/class/htmlecm.form.class.php
@@ -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
Expand All @@ -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
{
Expand Down Expand Up @@ -81,15 +79,16 @@ function selectAllSections($selected=0, $select_name='', $module='ecm')
$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 ';
}
else
{
$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>';
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions htdocs/ecm/docdir.php
@@ -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>
*
Expand Down Expand Up @@ -102,7 +102,7 @@
}
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;
}
}
Expand Down Expand Up @@ -227,7 +227,7 @@
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
Expand Down
5 changes: 3 additions & 2 deletions htdocs/ecm/docfile.php
Expand Up @@ -123,7 +123,7 @@
}
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;
}
}
Expand Down Expand Up @@ -242,7 +242,8 @@
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.'">';
}
Expand Down
73 changes: 46 additions & 27 deletions htdocs/ecm/docmine.php
Expand Up @@ -226,7 +226,7 @@
}


$head = ecm_prepare_head($ecmdir);
$head = ecm_prepare_head($ecmdir, $module, $section);
dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), -1, 'dir');


Expand All @@ -235,37 +235,46 @@
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)

$morehtml='';

$morehtmlref = '/'.$module.'/'.$relativepath;

if ($module == 'ecm')
{
$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='';
$result = 1;
$i=0;
$tmpecmdir=new EcmDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0)
{
$s=' -> '.$s;
$result=$tmpecmdir->fetch($tmpecmdir->fk_parent);
}
else
{
$tmpecmdir=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++;
}
$i++;

$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;
}

$morehtml='';

$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;

dol_banner_tab($object, '', $morehtml, 0, '', '', $morehtmlref);

Expand Down Expand Up @@ -307,15 +316,25 @@
}
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>';
Expand Down
16 changes: 7 additions & 9 deletions htdocs/ecm/search.php
Expand Up @@ -30,14 +30,7 @@
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;
Expand All @@ -52,6 +45,11 @@
$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');
Expand Down Expand Up @@ -123,7 +121,7 @@
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);


Expand Down
2 changes: 1 addition & 1 deletion htdocs/langs/en_US/ecm.lang
Expand Up @@ -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
Expand Down

0 comments on commit e19ca7b

Please sign in to comment.