Skip to content

Commit

Permalink
Evarisk#1128 [Media] clean php8 warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Nov 27, 2024
1 parent 3ceee93 commit fd4cfd0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
1 change: 0 additions & 1 deletion class/task/saturnetask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ public function fetchAllTimeSpentAllUsers($morewherefilter = '', $sortfield = ''
$newobj->fk_project = $obj->project_id;
$newobj->project_ref = $obj->project_ref;
$newobj->project_label = $obj->project_label;
$newobj->public = $obj->project_public;

$newobj->fk_task = $obj->task_id;
$newobj->task_ref = $obj->task_ref;
Expand Down
12 changes: 6 additions & 6 deletions core/tpl/medias/medias_gallery_modal.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,18 @@
<div>
<div>
<?php print img_picto($langs->trans('Link'), 'link') . ' ' . $form->textwithpicto($langs->trans('UnlinkedMedias'), $langs->trans('ShowOnlyUnlinkedMedias'));
if (isset($user->conf->SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS) && $user->conf->SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS) {
print '<span id="del_unlinked_medias" value="0" class="valignmiddle linkobject toggle-unlinked-medias ' . (!empty($user->conf->SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS) ? '' : 'hideobject') . '">' . img_picto($langs->trans('Enabled'), 'switch_on') . '</span>';
if (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS')) {
print '<span id="del_unlinked_medias" value="0" class="valignmiddle linkobject toggle-unlinked-medias ' . (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS') ? '' : 'hideobject') . '">' . img_picto($langs->trans('Enabled'), 'switch_on') . '</span>';
} else {
print '<span id="set_unlinked_medias" value="1" class="valignmiddle linkobject toggle-unlinked-medias ' . (!empty($user->conf->SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS) ? 'hideobject' : '') . '">' . img_picto($langs->trans('Disabled'), 'switch_off') . '</span>';
print '<span id="set_unlinked_medias" value="1" class="valignmiddle linkobject toggle-unlinked-medias ' . (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS') ? 'hideobject' : '') . '">' . img_picto($langs->trans('Disabled'), 'switch_off') . '</span>';
} ?>
</div>
<div>
<?php print img_picto($langs->trans('Calendar'), 'calendar') . ' ' . $form->textwithpicto($langs->trans('Today'), $langs->trans('ShowOnlyMediasAddedToday'));
if (isset($user->conf->SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS) && $user->conf->SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS) {
print '<span id="del_today_medias" value="0" class="valignmiddle linkobject toggle-today-medias ' . (!empty($user->conf->SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS) ? '' : 'hideobject') . '">' . img_picto($langs->trans('Enabled'), 'switch_on') . '</span>';
if (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS')) {
print '<span id="del_today_medias" value="0" class="valignmiddle linkobject toggle-today-medias ' . (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS') ? '' : 'hideobject') . '">' . img_picto($langs->trans('Enabled'), 'switch_on') . '</span>';
} else {
print '<span id="set_today_medias" value="1" class="valignmiddle linkobject toggle-today-medias ' . (!empty($user->conf->SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS) ? 'hideobject' : '') . '">' . img_picto($langs->trans('Disabled'), 'switch_off') . '</span>';
print '<span id="set_today_medias" value="1" class="valignmiddle linkobject toggle-today-medias ' . (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS') ? 'hideobject' : '') . '">' . img_picto($langs->trans('Disabled'), 'switch_off') . '</span>';
} ?>
</div>
</div>
Expand Down
19 changes: 11 additions & 8 deletions lib/medias.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ function saturne_show_medias(string $moduleName, string $modulepart = 'ecm', str

$filearray = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC));

if ($user->conf->SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS == 1) {
if (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_TODAY_MEDIAS')) {
$yesterdayTimeStamp = dol_time_plus_duree(dol_now(), -1, 'd');
$filearray = array_filter($filearray, function($file) use ($yesterdayTimeStamp) {
return $file['date'] > $yesterdayTimeStamp;
});
}
if ($user->conf->SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS == 1) {
if (getDolUserInt('SATURNE_MEDIA_GALLERY_SHOW_UNLINKED_MEDIAS')) {
$moduleObjectMedias = dol_dir_list($conf->$moduleNameLowerCase->multidir_output[$conf->entity ?? 1], 'files', 1, '', '.odt|.pdf|barcode|_mini|_medium|_small|_large');
$filearray = array_filter($filearray, function($file) use ($conf, $moduleNameLowerCase, $moduleObjectMedias) {
$fileExists = array_search($file['name'], array_column($moduleObjectMedias, 'name'));
Expand All @@ -71,10 +71,11 @@ function saturne_show_medias(string $moduleName, string $modulepart = 'ecm', str
$filearray = dol_sort_array($filearray, $sortfield, $sortorder);
}

$moduleImageNumberPerPageConf = strtoupper($moduleName) . '_DISPLAY_NUMBER_MEDIA_GALLERY';
for ($i = (($offset - 1) * $conf->global->$moduleImageNumberPerPageConf); $i < ($conf->global->$moduleImageNumberPerPageConf + (($offset - 1) * $conf->global->$moduleImageNumberPerPageConf)); $i++) {
$confName = strtoupper($moduleName) . '_DISPLAY_NUMBER_MEDIA_GALLERY';
$moduleImageNumberPerPageConf = getDolGlobalInt($confName);
for ($i = (($offset - 1) * $moduleImageNumberPerPageConf); $i < ($moduleImageNumberPerPageConf + (($offset - 1) * $moduleImageNumberPerPageConf)); $i++) {

$fileName = $filearray[$i]['name'];
$fileName = $filearray[$i]['name'] ?? '';
if (image_format_supported($fileName) >= 0) {
$nbphoto++;

Expand Down Expand Up @@ -371,7 +372,7 @@ function saturne_get_thumb_name(string $filename, string $thumbType = 'small'):
* Return media linked elements count
*
* @param string $moduleName Module name
* @param string $fileName File name
* @param string $fileName File name
* @return string $output Show media linked element count
*
*/
Expand All @@ -398,14 +399,16 @@ function saturne_get_media_linked_elements(string $moduleName, string $fileName)
$object = new $className($db);

$mediaLinkedElements[$fileArray['name']][$element[0]]['picto'] = $object->picto;
$mediaLinkedElements[$fileArray['name']][$element[0]]['value']++;
if (isset($mediaLinkedElements[$fileArray['name']][$element[0]]['value'])) {
$mediaLinkedElements[$fileArray['name']][$element[0]]['value']++;
}
}

$output = '<div class="linked-element">';
foreach ($mediaLinkedElements as $mediaLinkedElement) {
foreach ($mediaLinkedElement as $key => $linkedElement) {
$output .= '<span class="paddingleft paddingright">' . img_picto($langs->trans(ucfirst($key)), $linkedElement['picto'], 'class="paddingright"');
$output .= $linkedElement['value'];
$output .= $linkedElement['value'] ?? 0;
$output .= '</span>';
}
}
Expand Down
11 changes: 6 additions & 5 deletions lib/saturne_functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ function saturne_banner_tab(object $object, string $paramId = 'ref', string $mor
if ($resHook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} else {
$customMoreHtmlRef = '';
if (!empty($hookmanager->resArray)) {
list($customMoreHtmlRef, $moreParams) = $hookmanager->resArray;
} else if (!empty($hookmanager->resPrint)) {
Expand Down Expand Up @@ -286,7 +287,7 @@ function saturne_banner_tab(object $object, string $paramId = 'ref', string $mor
}
} else {
$BannerElementObject->fetch($object->$objectKey);
if ($bannerElement == 'societe' || $bannerElement == $moreParams['bannerElement']) {
if ($bannerElement == 'societe' || !empty($moreParams['bannerElement']) && $bannerElement == $moreParams['bannerElement']) {
$saturneMoreHtmlRef .= $object->$objectKey > 0 ? $BannerElementObject->getNomUrl(1) : '';
} elseif ($bannerElement == 'project') {
$saturneMoreHtmlRef .= $object->$objectKey > 0 ? $BannerElementObject->getNomUrl(1, '', 1) : '';
Expand Down Expand Up @@ -315,16 +316,16 @@ function saturne_banner_tab(object $object, string $paramId = 'ref', string $mor
$resHook = $hookmanager->executeHooks('saturneBannerTabCustomSubdir', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($resHook > 0) {
if (!empty($hookmanager->resArray)) {
if ($hookmanager->resArray['modulepart']) {
if (!empty($hookmanager->resArray['modulepart'])) {
$modulePart = $hookmanager->resArray['modulepart'];
}
if ($hookmanager->resArray['dir']) {
if (!empty($hookmanager->resArray['dir'])) {
$baseDir = $hookmanager->resArray['dir'];
}
if ($hookmanager->resArray['subdir']) {
if (!empty($hookmanager->resArray['subdir'])) {
$subDir = $hookmanager->resArray['subdir'];
}
if ($hookmanager->resArray['photoLimit']) {
if (!empty($hookmanager->resArray['photoLimit'])) {
$photoLimit = $hookmanager->resArray['photoLimit'];
}
}
Expand Down

0 comments on commit fd4cfd0

Please sign in to comment.