mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Close #18692 : Possibility to move directories in ecm
This commit is contained in:
parent
e89f2ffb38
commit
324af09415
|
|
@ -55,9 +55,10 @@ class FormEcm
|
|||
* @param int $selected Id of preselected section
|
||||
* @param string $select_name Name of HTML select component
|
||||
* @param string $module Module ('ecm', 'medias', ...)
|
||||
* @param array $ignore_id Arroy of id to ignore
|
||||
* @return string String with HTML select
|
||||
*/
|
||||
public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm')
|
||||
public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm', $ignore_id = array())
|
||||
{
|
||||
global $conf, $langs;
|
||||
$langs->load("ecm");
|
||||
|
|
@ -65,6 +66,9 @@ class FormEcm
|
|||
if ($select_name == '') {
|
||||
$select_name = "catParent";
|
||||
}
|
||||
if (!is_array($ignore_id)) {
|
||||
$ignore_id = array($ignore_id);
|
||||
}
|
||||
|
||||
$cate_arbo = null;
|
||||
if ($module == 'ecm') {
|
||||
|
|
@ -83,13 +87,15 @@ class FormEcm
|
|||
} else {
|
||||
$output .= '<option value="-1"> </option>';
|
||||
foreach ($cate_arbo as $key => $value) {
|
||||
$valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id'];
|
||||
if ($selected && $valueforoption == $selected) {
|
||||
$add = 'selected ';
|
||||
} else {
|
||||
$add = '';
|
||||
if (!in_array($cate_arbo[$key]['id'], $ignore_id)) {
|
||||
$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($valueforoption).'">'.(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>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php';
|
||||
|
||||
// Load translation files required by page
|
||||
$langs->loadLangs(array('ecm', 'companies', 'other'));
|
||||
|
|
@ -204,6 +205,12 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) {
|
|||
|
||||
// Fetch was already done
|
||||
$ecmdir->label = dol_sanitizeFileName(GETPOST("label"));
|
||||
$fk_parent = GETPOST("catParent", 'int');
|
||||
if ($fk_parent == "-1") {
|
||||
$ecmdir->fk_parent = "0";
|
||||
} else {
|
||||
$ecmdir->fk_parent = $fk_parent;
|
||||
}
|
||||
$ecmdir->description = GETPOST("description");
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $ecmdir);
|
||||
if ($ret < 0) {
|
||||
|
|
@ -219,8 +226,10 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) {
|
|||
}
|
||||
$result = $ecmdir->update($user);
|
||||
if ($result > 0) {
|
||||
$newdir = $ecmdir->getRelativePath(1);
|
||||
$newdir = $conf->ecm->dir_output.'/'.$newdir;
|
||||
// Try to rename file if changed
|
||||
if ($oldlabel != $ecmdir->label && file_exists($olddir)) {
|
||||
if (($oldlabel != $ecmdir->label && file_exists($olddir)) || ($olddir != $newdir && file_exists($olddir))) {
|
||||
$newdir = $ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory
|
||||
$newdir = $conf->ecm->dir_output.'/'.$newdir;
|
||||
//print $olddir.'-'.$newdir;
|
||||
|
|
@ -270,6 +279,7 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) {
|
|||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formecm = new FormEcm($db);
|
||||
|
||||
$object = new EcmDirectory($db); // Need to create a new one instance
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
|
@ -317,11 +327,7 @@ if ($module == 'ecm') {
|
|||
$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;
|
||||
}
|
||||
$s = $tmpecmdir->getNomUrl(1).$s;
|
||||
if ($tmpecmdir->fk_parent) {
|
||||
$s = ' -> '.$s;
|
||||
$result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
|
||||
|
|
@ -371,6 +377,16 @@ print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$l
|
|||
print $s;
|
||||
print '</td></tr>';*/
|
||||
if ($module == 'ecm') {
|
||||
if ($action == 'edit') {
|
||||
print '<tr><td class="titlefield tdtop">'.$langs->trans("ECMDirName").'</td><td>';
|
||||
print '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$ecmdir->label.'">';
|
||||
print '</td></tr>';
|
||||
print '<tr><td class="titlefield tdtop">'.$langs->trans("ECMParentDirectory").'</td><td>';
|
||||
print $formecm->selectAllSections($ecmdir->fk_parent, '', 'ecm', array($ecmdir->id));
|
||||
print '</td><td>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
|
||||
if ($action == 'edit') {
|
||||
print '<textarea class="flat quatrevingtpercent" name="description">';
|
||||
|
|
|
|||
|
|
@ -45,3 +45,5 @@ GenerateImgWebp=Duplicate all images with another version with .webp format
|
|||
ConfirmGenerateImgWebp=If you confirm, you will generate an image in .webp format for all images currently into this folder (subfolders are not included)...
|
||||
ConfirmImgWebpCreation=Confirm all images duplication
|
||||
SucessConvertImgWebp=Images successfully duplicated
|
||||
ECMDirName=Dir name
|
||||
ECMParentDirectory=Parent directory
|
||||
|
|
|
|||
|
|
@ -45,3 +45,5 @@ GenerateImgWebp=Dupliquer toutes les images avec une autre version au format .we
|
|||
ConfirmGenerateImgWebp=Si vous confirmez, vous générerez une image au format .webp pour toutes les images actuellement dans ce dossier (les sous-dossiers ne sont pas inclus)...
|
||||
ConfirmImgWebpCreation=Confirmer la duplication de toutes les images
|
||||
SucessConvertImgWebp=Images dupliquées avec succès
|
||||
ECMDirName=Nom du dossier
|
||||
ECMParentDirectory=Dossier parent
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user