1
0
Эх сурвалжийг харах

Merge branch 'master' of https://github.com/unaio/una

AntonLV 9 жил өмнө
parent
commit
d4089e8b15

+ 26 - 4
inc/classes/BxDolImageResize.php

@@ -29,6 +29,8 @@ class BxDolImageResize extends BxDolFactory implements iBxDolSingleton
     protected $_isUseGD; ///< use GD library or command line ImagMagic utilites
     protected $_oManager; ///< Intervention Image Manager
     protected $_sError; ///< Intervention Image Manager error string
+    protected $_bRemoveTransparency = false; ///< remove transparency from images during resizing
+    protected $_sRemoveTransparencyFillColor = '#ffffff'; ///< when removing transparency - fill with this color
 
     protected function __construct()
     {
@@ -239,25 +241,45 @@ class BxDolImageResize extends BxDolFactory implements iBxDolSingleton
         return IMAGE_ERROR_SUCCESS;
     }
 
+    function _removeTransparency ($oImg)
+    {
+        $oImgBack = $this->_oManager->canvas($oImg->width(), $oImg->height(), $this->_sRemoveTransparencyFillColor);
+        return $oImgBack->insert($oImg);
+    }
+
     function _resize ($sSrcImage, $sDstImage = '')
     {       
         $this->_sError = '';
         try {
             if ($this->_isAutoCrop || $this->_isSquareResize) {
-                $this->_oManager
+
+                $oImg = $this->_oManager
                     ->make($sSrcImage)
-                    ->orientate()
+                    ->orientate();
+
+                if ($this->_bRemoveTransparency)
+                    $oImg = $this->_removeTransparency($oImg);
+
+                $oImg
                     ->fit($this->w, $this->_isSquareResize ? $this->w : $this->h)
                     ->save($sDstImage ? $sDstImage : $sSrcImage, $this->_iJpegQuality);
+
             } 
             else {
-                $this->_oManager
+
+                $oImg = $this->_oManager
                     ->make($sSrcImage)
-                    ->orientate()
+                    ->orientate();
+
+                if ($this->_bRemoveTransparency)
+                    $oImg = $this->_removeTransparency($oImg);
+
+                $oImg
                     ->resize($this->w, $this->h, function ($constraint) {
                         $constraint->aspectRatio();
                         $constraint->upsize();
                     })
+                    ->trim()
                     ->save($sDstImage ? $sDstImage : $sSrcImage, $this->_iJpegQuality);
             }
             chmod($sDstImage ? $sDstImage : $sSrcImage, BX_DOL_FILE_RIGHTS);

+ 11 - 7
inc/classes/BxDolMetatags.php

@@ -460,17 +460,21 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
         if(!$aLocation || !$aLocation['country'] || !isset($aCountries[$aLocation['country']]))
             return '';
 
+        $s = '';
+        
         $sCountryUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country&keyword=' . $aLocation['country'] . '">' . $aCountries[$aLocation['country']] . '</a>';
         if(empty($aLocation['state']) || empty($aLocation['city']))
-            return _t('_sys_location_country', $sCountryUrl);
+            $s = _t('_sys_location_country', $sCountryUrl);
 
-        $sCityUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country_city&keyword=' . $aLocation['country'] . '&state=' . rawurlencode($aLocation['state']) . '&city=' . rawurlencode($aLocation['city']) . '">' . $aLocation['city'] . '</a>';
-        $sStateUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country_state&keyword=' . $aLocation['country'] . '&state=' . rawurlencode($aLocation['state']) . '">' . $aLocation['state'] . '</a>';
+        if (!$s) {
+            $sCityUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country_city&keyword=' . $aLocation['country'] . '&state=' . rawurlencode($aLocation['state']) . '&city=' . rawurlencode($aLocation['city']) . '">' . $aLocation['city'] . '</a>';
+            $sStateUrl = '<a href="' . BX_DOL_URL_ROOT . 'searchKeyword.php?type=location_country_state&keyword=' . $aLocation['country'] . '&state=' . rawurlencode($aLocation['state']) . '">' . $aLocation['state'] . '</a>';
 
-        if(empty($aLocation['street']) || empty($aLocation['street_number']))
-        	$s = _t('_sys_location_country_city', $sCountryUrl, $sStateUrl, $sCityUrl);
-        else
-            $s = _t('_sys_location_country_city_street', $sCountryUrl, $sStateUrl, $sCityUrl, $aLocation['street'], $aLocation['street_number']);
+            if(empty($aLocation['street']) || empty($aLocation['street_number']))
+        	    $s = _t('_sys_location_country_city', $sCountryUrl, $sStateUrl, $sCityUrl);
+            else
+                $s = _t('_sys_location_country_city_street', $sCountryUrl, $sStateUrl, $sCityUrl, $aLocation['street'], $aLocation['street_number']);
+        }
 
         return $bHTML ? $s : trim(strip_tags($s));
     }

+ 12 - 2
template/form_field_location.html

@@ -35,10 +35,20 @@
 
     var bx_location_process_address = function (o) {
         var i, sKey, sCountry, sCity;
+
         for (i in o) {
             for (sKey in oBxLocationHashMap) {
-                if (o[i].types.indexOf(oBxLocationHashMap[sKey]) > -1) {
-                    var sIndex = 'route' == oBxLocationHashMap[sKey] || 'locality' == oBxLocationHashMap[sKey] ? 'long_name' : 'short_name';
+
+                var sName = oBxLocationHashMap[sKey];
+                
+                if ('locality' == sName && -1 == o[i].types.indexOf(sName))
+                    sName = 'postal_town';
+                
+                if ('administrative_area_level_1' == sName && -1 == o[i].types.indexOf(sName))
+                    sName = 'administrative_area_level_2';
+
+                if (o[i].types.indexOf(sName) > -1) {
+                    var sIndex = 'route' == sName || 'locality' == sName ? 'long_name' : 'short_name';
                     $('[name="' + sKey + '"]').val(o[i][sIndex]);
                 }