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

"franck franck kalunga \(@francksfkal\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69985749c2d2_3b186e9c5533e@gitlab-sidekiq-low-urgency-cpu-bound-v2-5c86845cdd-tc2vx.mail>

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


Commits:
6f6da255 by franck franck kalunga at 2026-02-20T14:35:23+02:00
[FIX] Plugin TrackerList Calendar feature
---
* [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

See merge request tikiwiki/tiki!9620

- - - - -


4 changed files:

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


Changes:

=====================================
lib/core/Services/Tracker/CalendarController.php
=====================================
@@ -17,7 +17,7 @@ class Services_Tracker_CalendarController
 
     public function action_list($input)
     {
-        global $prefs, $user, $tikilib;
+        global $user;
         static $id = 0;
         ++$id;
 
@@ -26,6 +26,8 @@ class Services_Tracker_CalendarController
 
         $start = 'tracker_field_' . $input->beginField->word();
         $end = 'tracker_field_' . $input->endField->word();
+        $title = 'tracker_field_' . $input->title->word();
+        $description = 'tracker_field_' . $input->description->word();
 
         if ($resource = $input->resourceField->word()) {
             $resource = 'tracker_field_' . $resource;
@@ -97,13 +99,12 @@ class Services_Tracker_CalendarController
             $formatBuilder->setCount($result->count());
             $formatBuilder->apply($innerMatches);
             $formatBuilder->setFormatterPlugin($plugin);
-            $formatter = $formatBuilder->getFormatter(isset($result->errorInQuery) && ! empty($result->errorInQuery));
+            $formatter = $formatBuilder->getFormatter(! empty($result->errorInQuery));
             $entries = $formatter->getPopulatedList($result, false);
         } else {
             $entries = [];
         }
 
-        $smarty = TikiLib::lib('smarty');
         $trklib = TikiLib::lib('trk');
         foreach ($result as $index => $row) {
             if ($entries) {
@@ -141,17 +142,17 @@ class Services_Tracker_CalendarController
 
             $response[] = [
                 'id'               => $row['object_id'],
-                'trackerId'        => isset($row['tracker_id']) ? $row['tracker_id'] : null,
-                'title'            => $row['title'],
-                'description'      => $row['description'],
+                'trackerId'        => $row['tracker_id'] ?? null,
+                'title'            => $row[$title] ?: $row['title'],
+                'extendedProps'      => ['description' => $row[$description] ?: $row['description']],
                 'url'              => smarty_modifier_sefurl($row['object_id'], $row['object_type']),
                 'allDay'           => false,
                 'start'            => $useTimestamp ? $dtStart : TikiLib::date_format("c", $dtStart, $user, 5, false),
                 'end'              => $useTimestamp ? $dtEnd : TikiLib::date_format("c", $dtEnd, $user, 5, false),
                 'editable'         => $item->canModify(),
-                'color'            => $this->getColor(isset($row[$coloring]) ? $row[$coloring] : '', $colormap),
+                'color'            => $row[$coloring] ? ($row[$coloring] ?: $row['coloring']) : ($this->getColor($row[$coloring] ?? '', $colormap)),
                 'textColor'        => '#000',
-                'resourceId'       => ($resource && isset($row[$resource])) ? strtolower($row[$resource]) : '',
+                'resourceId'       => strtolower($row[$resource] ?? ''),
                 'resourceEditable' => true,
             ];
         }


=====================================
lib/wiki-plugins/wikiplugin_trackerlist.php
=====================================
@@ -2271,6 +2271,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']);
@@ -2278,9 +2284,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)) {
@@ -2289,16 +2295,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(
+                    'fullCalendarParams',
+                    [
+                        '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
=====================================
@@ -12,7 +12,8 @@ $.fn.setupFullCalendar = 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);
@@ -186,7 +187,8 @@ $.fn.setupFullCalendar = 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
=====================================
@@ -22,14 +22,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").setupFullCalendar({{$fullCalendarParams|json_encode}}, calendarContainer, 'module-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}', returnUrl);
+                        $("#module-calendar").setupFullCalendar(paramOfModuleCalendar, 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").setupFullCalendar(paramOfModuleCalendar, calendarContainer, 'module-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}', returnUrl);
+                            $("#module-calendar").setupFullCalendar(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").addFullCalendarPrint('#module-calendar-pdf-btn', calendarContainer[0]);{/if}}
                     {/jq}
@@ -61,7 +64,7 @@
                         {/if}
                     </div>    
                 </div>
-                <input type="date" value="{$moduleCalendarFocusdate}" id="date-module-calendar">
+                <input type="date" class="form-control" value="{$moduleCalendarFocusdate}" id="date-module-calendar">
                 <div id='module-calendar'></div>
                 {if $viewlist eq 'list'}
                     {$out}



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/6f6da255c2844c11a04e8cbbabc75766b6aba7de
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.