]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
URL shortening can now be disabled for the 'maxurllength'
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 6 Oct 2013 20:35:26 +0000 (22:35 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 6 Oct 2013 20:35:49 +0000 (22:35 +0200)
Also, URL shortening now consistently uses 'maxurllength'...

CONFIGURE
actions/apistatusnetconfig.php
actions/urlsettings.php
classes/User_urlshortener_prefs.php
lib/default.php
lib/util.php

index c5fac78730c88358833c5b9ccb9a1b0efe3e795c..d41f64b44f5ab2e895cf87274cc70bcb352ce171 100644 (file)
--- a/CONFIGURE
+++ b/CONFIGURE
@@ -794,14 +794,14 @@ external: external links in notices. One of three values: 'sometimes',
 url
 ---
 
-Everybody loves URL shorteners. These are some options for fine-tuning
-how and when the server shortens URLs.
+These are some options for fine-tuning how and when the server will 
+shorten URLs.
 
 shortener: URL shortening service to use by default. Users can override
-           individually. 'ur1.ca' by default.
-maxlength: If an URL is strictly longer than this limit, it will be
+           individually. 'internal' by default.
+maxurllength: If an URL is strictly longer than this limit, it will be
            shortened. Note that the URL shortener service may return an
-           URL longer than this limit. Defaults to 25. Users can
+           URL longer than this limit. Defaults to 100. Users can
            override. If set to 0, all URLs will be shortened.
 maxnoticelength: If a notice is strictly longer than this limit, all
            URLs in the notice will be shortened. Users can override.
index a58c5d3dfaa67831694789494fd3ac8c9ae1fe96..33ac32a7da43b8857d92b8ad273e75c280ffaef0 100644 (file)
@@ -61,7 +61,7 @@ class ApiStatusnetConfigAction extends ApiAction
         'xmpp' => array('enabled', 'server', 'port', 'user'),
         'integration' => array('source'),
         'attachments' => array('uploads', 'file_quota'),
-        'url' => array('maxlength', 'maxnoticelength'),
+        'url' => array('maxurllength', 'maxnoticelength'),
     );
 
     /**
index 837d4df1d0cbc513a2d2d83031dbbac5b08301b4..dd1218bc14f986ffbc8cd60acb5561969963db0e 100644 (file)
@@ -136,7 +136,7 @@ class UrlsettingsAction extends SettingsAction
                      (!is_null($this->arg('maxurllength'))) ?
                      $this->arg('maxurllength') : User_urlshortener_prefs::maxUrlLength($user),
                      // TRANS: Field title in URL settings in profile.
-                     _('URLs longer than this will be shortened, 0 means always shorten.'));
+                     _('URLs longer than this will be shortened, -1 means never shorten because a URL is long.'));
         $this->elementEnd('li');
         $this->elementStart('li');
         $this->input('maxnoticelength',
@@ -145,7 +145,7 @@ class UrlsettingsAction extends SettingsAction
                      (!is_null($this->arg('maxnoticelength'))) ?
                      $this->arg('maxnoticelength') : User_urlshortener_prefs::maxNoticeLength($user),
                      // TRANS: Field title in URL settings in profile.
-                     _('URLs in notices longer than this will always be shortened, -1 means shorten only if notice text exceeds maximum length.'));
+                     _('URLs in notices longer than this will always be shortened, -1 means only shorten if the full post exceeds maximum length.'));
         $this->elementEnd('li');
         $this->elementEnd('ul');
         // TRANS: Button text for saving "Other settings" in profile.
@@ -183,7 +183,7 @@ class UrlsettingsAction extends SettingsAction
 
         $maxurllength = $this->trimmed('maxurllength');
 
-        if (!Validate::number($maxurllength, array('min' => 0))) {
+        if (!Validate::number($maxurllength, array('min' => -1))) {
             // TRANS: Client exception thrown when the maximum URL settings value is invalid in profile URL settings.
             throw new ClientException(_('Invalid number for maximum URL length.'));
         }
index 146c8b80878c17ccacc050194b964de4f2aa2b98..a9a70112c7b15e9428c81f9376a920b3cb9a37d5 100755 (executable)
@@ -58,7 +58,7 @@ class User_urlshortener_prefs extends Managed_DataObject
 
     static function maxUrlLength($user)
     {
-        $def = common_config('url', 'maxlength');
+        $def = common_config('url', 'maxurllength');
 
         $prefs = self::getPrefs($user);
 
index 16f384e1c20c957f2375f2043fd4cc7111c90786..68b4518bfaa73d2c1b28bfe6332447cfdb50e78f 100644 (file)
@@ -343,7 +343,7 @@ $default =
               'external' => 'sometimes'), // Options: 'sometimes', 'never', default = 'sometimes'
         'url' =>
         array('shortener' => 'internal',
-              'maxlength' => 100,
+              'maxurllength' => 100,
               'maxnoticelength' => -1),
         'http' => // HTTP client settings when contacting other sites
         array('ssl_cafile' => false, // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt')
index c9500d72227504da93c818fa41d79186009eed8d..fdd678abdb1406c859acba5092faf1933274deac 100644 (file)
@@ -2155,7 +2155,7 @@ function common_shorten_url($long_url, User $user=null, $force = false)
     // $force forces shortening even if it's not strictly needed
     // I doubt URL shortening is ever 'strictly' needed. - ESP
 
-    if (mb_strlen($long_url) < $maxUrlLength && !$force) {
+    if (($maxUrlLength == -1 || mb_strlen($long_url) < $maxUrlLength) && !$force) {
         return $long_url;
     }