Warning: The author of this contribution does not provide support for it anymore.

phpBB Gallery

Option "Maximum length for descriptions" does not work - phpBB Gallery

Option "Maximum length for descriptions" does not work

by Pawwwle » Thu Jan 09, 2014 12:48 am

I have "phpBB Gallery 1.1.6". Probably I found a bug. Option "Maximum length for descriptions" does not work:

Code: Select all

'description_length' => array('lang' => 'IMAGE_DESC_MAX_LENGTH', 'validate' => 'int', 'type' => 'text:7:5', 'gallery' => true, 'explain' => false, 'append' => 'CHARACTERS'),

If descriptions is too long, not displayed:

Code: Select all

'DESC_TOO_LONG' => 'Your description is too long',

How to fix it? :)
My English is poor. ;)
Pawwwle
Registered User
Posts: 19
Joined: Fri May 31, 2013 8:29 am
Contact:

Re: Option "Maximum length for descriptions" does not work

by Pawwwle » Wed Oct 28, 2015 11:35 am

Below my patch for this problem.

In the file gallery\posting.php

Find

Code: Select all

         $process->set_descriptions(request_var('message', array(''), true));

Replace

Code: Select all

         $image_descs = request_var('message', array(''), true);
         $process->set_descriptions($image_descs);


Find

Code: Select all

         $success = true;

Add before

Code: Select all

         $num_image = 0;
         $errors = array();
         foreach ($process->images as $image_id)
         {
            $image_desc = $image_descs[$num_image];
            if (utf8_strlen($image_desc) > phpbb_gallery_config::get('description_length'))
            {
               $errors[] = $user->lang['DESC_TOO_LONG'];
            }
            $num_image++;
         }

         $error = implode('<br />', $errors);

         if (!$error)
         {


Find

Code: Select all

         meta_refresh($meta_refresh_time, $album_backlink);
         trigger_error($message);

Add after

Code: Select all

         }


Find

Code: Select all

         'S_ALLOW_ROTATE'   => $s_can_rotate,

Add after

Code: Select all

         'S_DESCRIPTION_LENGTH'   => phpbb_gallery_config::get('description_length'),


Find

Code: Select all

         if (empty($sql_ary['image_name_clean']))
         {
            $errors[] = $user->lang['MISSING_IMAGE_NAME'];
         }

Add after

Code: Select all

         if (utf8_strlen($image_desc) > phpbb_gallery_config::get('description_length'))
         {
            $errors[] = $user->lang['DESC_TOO_LONG'];
         }


In the file styles\prosilver\template\gallery\posting_body.html

Find

Code: Select all

               <dd class="simulate-dd"><textarea name="message[{image.S_ROW_COUNT}]" id="message_{image.S_ROW_COUNT}" rows="4" cols="76" tabindex="3" onchange="set_text_field({image.S_ROW_COUNT});

Replace

Code: Select all

               <dd class="simulate-dd"><textarea name="message[{image.S_ROW_COUNT}]" id="message_{image.S_ROW_COUNT}" rows="4" cols="76"<!-- IF S_UPLOAD_EDIT -->  maxlength="{S_DESCRIPTION_LENGTH}"<!-- ENDIF --> tabindex="3" onchange="set_text_field({image.S_ROW_COUNT});
My English is poor. ;)
Pawwwle
Registered User
Posts: 19
Joined: Fri May 31, 2013 8:29 am
Contact: