[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] Plugin TrackerList Calendar feature

"franck franck kalunga \(@francksfkal\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69977e001c65a_3b186ca8335b9@gitlab-sidekiq-low-urgency-cpu-bound-v2-787cb4fd49-gsk6h.mail>

franck franck kalunga pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
b0ee5707 by franck franck kalunga at 2026-02-19T23:09:34+02:00
[FIX] Plugin TrackerList Calendar feature
---
* [FIX] Plugin TrackerList Calendar feature
---
* [FIX] Plugin TrackerList Calendar feature

See merge request tikiwiki/tiki!9418

See merge request tikiwiki/tiki!9615

- - - - -


3 changed files:

- lib/wiki-plugins/wikiplugin_trackerlist.php
- src/js/jquery-tiki/tiki-calendar.js
- templates/modules/mod-calendar_new.tpl


Changes:

=====================================
lib/wiki-plugins/wikiplugin_trackerlist.php
=====================================
@@ -2259,6 +2259,12 @@ function wikiplugin_trackerlist($data, $params)
             }
 
             if (! empty($calendarfielddate)) {
+                $associatedWikiPage = [];
+
+                if (! ($prefs['feature_calendar'] == 'y' || $prefs['feature_action_calendar'] == 'y')) {
+                    Feedback::errorAndDie(tra("This feature is disabled, Please go into the settings and enable the calendar feature"), \Laminas\Http\Response::STATUS_CODE_401);
+                }
+
                 foreach ($items['data'] as $i => $item) {
                     if (! empty($wiki)) {
                         $smarty->assign('fields', $item['field_values']);
@@ -2266,9 +2272,9 @@ function wikiplugin_trackerlist($data, $params)
                         $smarty->assign('wiki', "wiki:$wiki");
                         $smarty->assign('showpopup', 'n');
                         try {
-                            $items['data'][$i]['over'] = $smarty->fetch('tracker_pretty_item.tpl');
+                            $associatedWikiPage[$items['data'][$i]['itemId']] = $smarty->fetch('tracker_pretty_item.tpl');
                         } catch (SmartyException $se) {
-                            $items['data'][$i]['over'] = $se->getMessage();
+                            $associatedWikiPage[$items['data'][$i]['itemId']] = $se->getMessage();
                         }
                     }
                     if (! empty($tplwiki)) {
@@ -2277,16 +2283,54 @@ function wikiplugin_trackerlist($data, $params)
                         $smarty->assign('wiki', "tplwiki:$tplwiki");
                         $smarty->assign('showpopup', 'n');
                         try {
-                            $items['data'][$i]['over'] = $smarty->fetch('tracker_pretty_item.tpl');
+                            $associatedWikiPage[$items['data'][$i]['itemId']] = $smarty->fetch('tracker_pretty_item.tpl');
                         } catch (SmartyException $se) {
-                            $items['data'][$i]['over'] = $se->getMessage();
+                            $associatedWikiPage[$items['data'][$i]['itemId']] = $se->getMessage();
                         }
                     }
-                    if (empty($items['data'][$i]['over'])) {
-                        $items['data'][$i]['over'] = $trklib->get_isMain_value($trackerId, $item['itemId']);
+
+                    if (empty($associatedWikiPage[$items['data'][$i]['itemId']])) {
+                        $associatedWikiPage[$items['data'][$i]['itemId']] = $trklib->get_isMain_value($trackerId, $item['itemId']);
                     }
                     $items['data'][$i]['visible'] = 'y';
                 }
+
+                $takePermNames = [];
+                foreach ($allfields['data'] as $value) {
+                    $takePermNames[$value['fieldId']] = $value["permName"];
+                }
+
+                $takeKeysOfTitleAndDescriptionOfEvent = [];
+                foreach (array_diff(array_keys($takePermNames), $calendarfielddate) as $value) {
+                    $takeKeysOfTitleAndDescriptionOfEvent[] = $value;
+                }
+                $urlOfFetchingData = [
+                    'title' => array_key_exists($takeKeysOfTitleAndDescriptionOfEvent[0], $takePermNames) ? $takePermNames[$takeKeysOfTitleAndDescriptionOfEvent[0]] : '',
+                    'description' => array_key_exists($takeKeysOfTitleAndDescriptionOfEvent[1], $takePermNames) ? $takePermNames[$takeKeysOfTitleAndDescriptionOfEvent[1]] : '',
+                    'trackerId' => $trackerId,
+                    'beginField' => $takePermNames[$calendarfielddate[0]],
+                    'endField' => array_key_exists($calendarfielddate[1], $takePermNames) ? $takePermNames[$calendarfielddate[0]] : null,
+                    'filters' => '',
+                    'maxRecords' => 200,
+                ];
+
+                $smarty->assign(
+                    'eventCalendarParams',
+                    [
+                        'firstDayofWeek'   => 0,
+                        'display_timezone' => $prefs['display_timezone'],
+                        'language'         => $prefs['language'],
+                        'minHourOfDay'     => 00,
+                        'maxHourOfDay'     => 23,
+                        'slotDuration'     => '00:' . str_pad($prefs['calendar_timespan'], 2, '0', STR_PAD_LEFT),
+                        'initialDate'      => date("Y-m-d"),
+                        'initialView'      => 'dayGridMonth',
+                    ]
+                );
+                $moduleCalendarFocusdate = date("Y-m-d");
+                $smarty->assign('associatedWikiPage', $associatedWikiPage);
+                $smarty->assign('moduleCalendarFocusdate', $moduleCalendarFocusdate);
+                $smarty->assign('urlOfFetchingData', $urlOfFetchingData);
                 $trklib->fillTableViewCell($items['data'], $calendarfielddate, $cell);
                 $smarty->assign('cell', $cell);
                 $smarty->assign('show_calendar_module', 'y');


=====================================
src/js/jquery-tiki/tiki-calendar.js
=====================================
@@ -9,7 +9,8 @@ $.fn.setupEventCalendar = function (
     calendarContainer,
     targetId = "calendar",
     urlEventSource = "tiki-ajax_services.php?controller=calendar&action=list_items",
-    returnUrl = "tiki-calendar.php"
+    returnUrl = "tiki-calendar.php",
+    associatedWikiPage = null
 ) {
     this.each(function () {
         const calendarEl = document.getElementById(targetId);
@@ -192,7 +193,8 @@ $.fn.setupEventCalendar = function (
                     }
                 }
                 const eventTitle = tooltipEscape(event.title);
-                const eventDescription = event.extendedProps.viewable === true ? event.extendedProps.description : "";
+                let eventDescription = event.extendedProps.viewable === true ? event.extendedProps.description : "";
+                eventDescription = associatedWikiPage?.[event.id] ? associatedWikiPage[event.id] : eventDescription;
                 element.attr("title", eventTitle + "|" + eventDescription);
                 element.addClass("tips");
                 // surely there's a better way?


=====================================
templates/modules/mod-calendar_new.tpl
=====================================
@@ -25,14 +25,17 @@
                         const moduleCalendarFocusDate = document.getElementById('date-module-calendar');
                         paramOfModuleCalendar['initialDate'] = $('#date-module-calendar').val();
                         let returnUrl = ('{{$returnURL}}');
+                        let associatedWikiPage = {{$associatedWikiPage|json_encode}} || null;
                         returnUrl = returnUrl.toString();
+                        let dataToBuildUrl = {{$urlOfFetchingData|json_encode}} || null;
+                        let urlOfFetchingData = $.service("tracker_calendar", "list", $.extend(dataToBuildUrl, dataToBuildUrl));
 
                         const calendarContainer = [window.moduleCalendar];
-                        $("#module-calendar").setupEventCalendar({{$eventCalendarParams|json_encode}}, calendarContainer, 'module-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}', returnUrl);
+                        $("#module-calendar").setupEventCalendar({{$eventCalendarParams|json_encode}}, calendarContainer, 'module-calendar',dataToBuildUrl ? urlOfFetchingData : 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}', returnUrl, associatedWikiPage);
                         moduleCalendarFocusDate.addEventListener('change', () => {
                             document.getElementById('module-calendar').innerHTML = "";
                             paramOfModuleCalendar['initialDate'] = $('#date-module-calendar').val();
-                            $("#module-calendar").setupEventCalendar(paramOfModuleCalendar, calendarContainer, 'module-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}', returnUrl);
+                            $("#module-calendar").setupEventCalendar(paramOfModuleCalendar, calendarContainer, 'module-calendar',dataToBuildUrl ? urlOfFetchingData : 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}', returnUrl, associatedWikiPage);
                         })
                         {{if $prefs.print_pdf_from_url neq 'none'}$("#module-calendar").addEventCalendarPrint('#module-calendar-pdf-btn', calendarContainer[0]);{/if}}
                     {/jq}



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/b0ee5707e54073ae13b71ca8c44c8a450864e1ea

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/b0ee5707e54073ae13b71ca8c44c8a450864e1ea
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.