Short desc char limit import set to option
authorLaury GvR <laury@gaslightmedia.com>
Thu, 20 Jul 2017 17:55:19 +0000 (13:55 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 20 Jul 2017 17:55:19 +0000 (13:55 -0400)
Short desc character limits for import were set to 120, but now
are set only to 120 if the setting short_desc_char_limit is unset.
This is done for both csv import and the member import.

models/admin/import/index.php
models/admin/management/import/members.php

index 1e3f10b..beb1941 100644 (file)
@@ -1114,10 +1114,18 @@ class GlmMembersAdmin_import_index
                     '',
                     preg_replace( '/\t+/', '', preg_replace( "/&#?[a-z0-9]{2,8};/i", "", strip_tags( $data['descr'] ) ) )
                 );
-                $short_descr = substr(implode(' ', array_slice(explode(' ', $stripped), 0, 30)), 0, 116);
+
+                if ( isset( $this->config['settings']['short_desc_char_limit'] ) ) {
+                    $short_desc_char_limit = $this->config['settings']['short_desc_char_limit'];
+                } else {
+                    $short_desc_char_limit = 120;
+                }
+                $ellipsis = ' ...';
+
+                $short_descr = substr(implode(' ', array_slice(explode(' ', $stripped), 0, 30)), 0, $short_desc_char_limit - strlen($ellipsis));
 
                 if (strlen($short_descr) < strlen($stripped)) {
-                    $short_descr .= ' ...';
+                    $short_descr .= $ellipsis;
                 }
 
                 // Setup the Member Profile Status
index 0d27fe7..a98c0e2 100644 (file)
@@ -796,12 +796,19 @@ if (!$failure) {
         // Add this member to the names inserted so we can check for duplicates
         $namesInserted[$membName] = true;
 
+        if ( isset( $this->config['settings']['short_desc_char_limit'] ) ) {
+            $short_desc_char_limit = $this->config['settings']['short_desc_char_limit'];
+        } else {
+            $short_desc_char_limit = 120;
+        }
+        $ellipsis = ' ...';
+
         // Create truncated short_descr from descriptions - Less tags, html encoded characters, newlines, tabs, etc.
         $stripped = str_replace(PHP_EOL, '', preg_replace('/\t+/', '', preg_replace("/&#?[a-z0-9]{2,8};/i", "", strip_tags($val['description']))));
-        $short_descr = substr(implode(' ', array_slice(explode(' ', $stripped), 0, 30)), 0, 116);
+        $short_descr = substr(implode(' ', array_slice(explode(' ', $stripped), 0, 30)), 0, $short_desc_char_limit - strlen($ellipsis));
 
         if (strlen($short_descr) < strlen($stripped)) {
-            $short_descr .= ' ...';
+            $short_descr .= $ellipsis;
         }
 
         // Build Credit Card bitmap