fixes a bug with changedetail when using a filter in media layout view of resources, a=chris

Chris Pollett [2022-11-29 21:Nov:th]
fixes a bug with changedetail when using a filter in media layout view of resources, a=chris
Filename
src/views/elements/WikiElement.php
diff --git a/src/views/elements/WikiElement.php b/src/views/elements/WikiElement.php
index e9662d3e4..edcf46d6e 100644
--- a/src/views/elements/WikiElement.php
+++ b/src/views/elements/WikiElement.php
@@ -1058,8 +1058,9 @@ class WikiElement extends Element implements CrawlConstants
                    earlier while processing resource list.
                    */
                 $i = 0;
+                $is_first = true;
                 foreach ($data['RESOURCES_INFO']['resources'] as $resource) {
-                    $this->renderResource($i, $resource, $base_url,
+                    $this->renderResource($i, $is_first, $resource, $base_url,
                         $token_string, $url_prefix, $url_is_folder_prefix,
                         $folder_prefix, $seen_resources, $read_mode, $logged_in,
                         $data);
@@ -1130,8 +1131,10 @@ class WikiElement extends Element implements CrawlConstants
      * Renders a single resource description from the list of resources for
      * a given wiki page
      * @param int $i index in list of resources the current resource is
-     *    (can be used to check if first resource)
-     * @param array $resource
+     *    (used when writing out element id's of tags to make unique)
+     * @param bool &$is_first is this the first resource to be drawn
+     * @param array $resource assiative array of information about the
+     *     resource to be rendered
      * @param string $base_url
      * @param string $token_string token_name=CRSF_TOKEN string for URL
      *      to stay logged in
@@ -1142,10 +1145,12 @@ class WikiElement extends Element implements CrawlConstants
      * @param string $read_mode whether the readering should be for a media
      *      list in read mode (valye "read"), a source mode (value "source"),
      *      or for use on the edit task of any wiki page (value "")
-     * @param bool $logged_in
-     * @param array $data
+     * @param bool $logged_in is the context for rendering the resource of
+     *      of someone who is looged in or not
+     * @param array $data associate array of values to be sent to and used by
+     *      view for rendering
      */
-    public function renderResource($i, $resource, $base_url,
+    public function renderResource($i, &$is_first, $resource, $base_url,
         $token_string, $url_prefix, $url_is_folder_prefix, $folder_prefix,
         &$seen_resources, $read_mode, $logged_in, $data)
     {
@@ -1312,7 +1317,8 @@ class WikiElement extends Element implements CrawlConstants
             $double_click_url = $current_url;
             $current_media_url = preg_replace('/arg=(media|edit|source)/',
                 $media_detail, $current_url);
-            if ($i == 0) {
+            if ($is_first) {
+                $is_first = false;
                 $detail_id = $data['PAGE_ID'];
                 $detail_id .= (empty($data['SUB_PATH'])) ?
                     "" : base64_encode($data['SUB_PATH']);
ViewGit