[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [NEW] Add category support to file gallery list display

"UshindiG \(@GedeonTS\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68d3999964e9b_2cdf3cc516a1@gitlab-sidekiq-low-urgency-cpu-bound-v2-69d75bf97c-25p7m.mail>

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


Commits:
5322b70b by UshindiG at 2025-09-24T10:04:33+03:00
[NEW] Add category support to file gallery list display
---
* [NEW] Add category support to file gallery list display
---
* [NEW] Add category support to file gallery list display

See merge request tikiwiki/tiki!8170

(cherry picked from commit 4ea3baa86bfebc09766b14f06c0f3adb0df7336d)

See merge request tikiwiki/tiki!8632

- - - - -


2 changed files:

- templates/list_file_gallery_content.tpl
- tiki-list_file_gallery.php


Changes:

=====================================
templates/list_file_gallery_content.tpl
=====================================
@@ -145,6 +145,18 @@
                     {tr}Actions{/tr}
                 </th>
             {/if}
+            
+            {if ( $prefs.feature_categories eq 'y')}
+                {if isset($nbCols)}
+                    {$nbCols=$nbCols+1}
+                {else}
+                    {$nbCols=1}
+                {/if}
+                <th>
+                    {tr}Categories{/tr}
+                </th>
+            {/if}
+
 
             {if ( !empty($other_columns) or !empty($other_columns_selected))}
                 {if isset($nbCols)}
@@ -511,6 +523,19 @@
                     {$file=$files[changes]}{* For fgal_context_menu.tpl. Cannot be an include parameter, because "file" is a reserved name. *}
                     <td>{include file='fgal_context_menu.tpl'}</td>
                 {/if}
+                {if ( $prefs.feature_categories eq 'y')}
+                    <td>
+                    {if !empty($files[changes].categories)}
+                        {foreach from=$files[changes].categories item=cat name=cat}
+                            <a href="tiki-browse_categories.php?parentId={$cat.categId|escape}">
+                                {$cat.name|escape}
+                            </a>{if not $smarty.foreach.cat.last}, {/if}
+                        {/foreach}
+                    {else}
+                        <span class="text-muted">{tr}Uncategorized{/tr}</span>
+                    {/if}
+                    </td>
+                {/if}
 
                 {if isset($other_columns) and isset($other_columns_selected) and ( $other_columns neq '' or $other_columns_selected neq '' )}
                     <td>


=====================================
tiki-list_file_gallery.php
=====================================
@@ -1172,6 +1172,24 @@ if (isset($_GET['slideshow'])) {
     );
     $smarty->assign('offset', $_REQUEST['offset'] ?? 0);
     $smarty->assign('count', $files['count']);
+
+    if ($prefs['feature_categories'] == 'y') {
+        $categlib = TikiLib::lib('categ');
+        foreach ($files['data'] as &$file) {
+            $file['categs'] = $categlib->get_object_categories('file', $file['fileId']);
+            // var_dump($file['categs']);
+            if (is_array($file['categs'])) {
+                $file['categs'] = array_map(function ($c) {
+                    return $c['name'];
+                }, $file['categs']);
+            } else {
+                $file['categs'] = [];
+            }
+            $file['categs'] = implode(', ', $file['categs']);
+        }
+        unset($file);
+    }
+
     $smarty->assign_by_ref('files', $files['data']);
 
     $smarty->assign('show_find', 'n');
@@ -1248,7 +1266,6 @@ if (isset($_GET['slideshow'])) {
         }
         if ($view == 'page') {
             $smarty->assign('maxWidth', $_REQUEST['maxWidth'] ?? '300px');
-            //need to convert fileId to an offset to bring up a specific file for page view
             $smarty->assign('maxRecords', 1);
             $smarty->assign(
                 'metarray',
@@ -1261,6 +1278,30 @@ if (isset($_GET['slideshow'])) {
                 include_once 'lib/jquery_tiki/elfinder/tikiElFinder.php';
                 \tikiElFinder::loadJSCSS();
             }
+            if ($prefs['feature_categories'] == 'y') {
+                $categlib = TikiLib::lib('categ');
+
+                foreach ($files['data'] as &$file) {
+                    if (empty($file['categories']) || ! is_array($file['categories'])) {
+                        $file['categories'] = [];
+
+                        $cats = [];
+                        if (! empty($file['isgal']) && $file['isgal'] == 1) {
+                            $cats = $categlib->get_object_categories('file gallery', $file['id']);
+                        } elseif (! empty($file['fileId'])) {
+                            $cats = $categlib->get_object_categories('file', $file['fileId']);
+                        }
+
+                        foreach ($cats as $catId) {
+                            $file['categories'][] = [
+                                'categId' => $catId,
+                                'name'    => $categlib->get_category_name($catId),
+                            ];
+                        }
+                    }
+                }
+            }
+
             $smarty->assign_by_ref('files', $files['data']);
 
             $subs = 0;



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/5322b70b3db443720dc7209ce2eeb45f21664878
You're receiving this email because of your account on gitlab.com.

_______________________________________________
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.