diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php
index 210304486..160082ccf 100644
--- a/classes/context/Context.class.php
+++ b/classes/context/Context.class.php
@@ -2293,7 +2293,7 @@ class Context
$plugin_name = 'ui';
}
- if($loaded_plugins[$plugin_name])
+ if(isset($loaded_plugins[$plugin_name]))
{
return;
}
diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php
index e4024beec..9161dd8b5 100644
--- a/classes/template/TemplateHandler.class.php
+++ b/classes/template/TemplateHandler.class.php
@@ -235,6 +235,9 @@ class TemplateHandler
// replace value of src in img/input/script tag
$buff = preg_replace_callback('/<(?:img|input|script)(?:[^<>]*?)(?(?=cond=")(?:cond="[^"]+"[^<>]*)+|)[^<>]* src="(?!(?:https?|file):\/\/|[\/\{])([^"]+)"/is', array($this, '_replacePath'), $buff);
+ // replace value of srcset in img/source/link tag
+ $buff = preg_replace_callback('/<(?:img|source|link)(?:[^<>]*?)(?(?=cond=")(?:cond="[^"]+"[^<>]*)+|)[^<>]* srcset="([^"]+)"/is', array($this, '_replaceSrcsetPath'), $buff);
+
// replace loop and cond template syntax
$buff = $this->_parseInline($buff);
@@ -381,7 +384,7 @@ class TemplateHandler
}
/**
- * preg_replace_callback hanlder
+ * preg_replace_callback handler
*
* replace image path
* @param array $match
@@ -390,7 +393,19 @@ class TemplateHandler
*/
private function _replacePath($match)
{
- //return origin conde when src value started '${'.
+ $src = $this->_replaceRelativePath($match);
+ return substr($match[0], 0, -strlen($match[1]) - 6) . "src=\"{$src}\"";
+ }
+
+ /**
+ * replace relative path
+ * @param array $match
+ *
+ * @return string changed result
+ */
+ private function _replaceRelativePath($match)
+ {
+ //return origin code when src value started '${'.
if(preg_match('@^\${@', $match[1]))
{
return $match[0];
@@ -415,7 +430,33 @@ class TemplateHandler
$src = $tmp;
}
- return substr($match[0], 0, -strlen($match[1]) - 6) . "src=\"{$src}\"";
+ return $src;
+ }
+
+ /**
+ * preg_replace_callback handler
+ *
+ * replace srcset string with multiple paths
+ * @param array $match
+ *
+ * @return string changed result
+ */
+ private function _replaceSrcsetPath($match)
+ {
+ // explode urls by comma
+ $url_list = explode(",", $match[1]);
+
+ foreach ($url_list as &$url) {
+ // replace if url is not starting with the pattern
+ $url = preg_replace_callback(
+ '/^(?!(?:https?|file):\/\/|[\/\{])(\S+)/i',
+ array($this, '_replaceRelativePath'),
+ trim($url)
+ );
+ }
+ $srcset = implode(", ", $url_list);
+
+ return substr($match[0], 0, -strlen($match[1]) - 9) . "srcset=\"{$srcset}\"";
}
/**
@@ -536,7 +577,7 @@ class TemplateHandler
}
/**
- * preg_replace_callback hanlder
+ * preg_replace_callback handler
* replace php code.
* @param array $m
* @return string changed result
diff --git a/common/autoload.php b/common/autoload.php
index 04bf3c3f1..ed0257251 100644
--- a/common/autoload.php
+++ b/common/autoload.php
@@ -85,7 +85,6 @@ $GLOBALS['RX_AUTOLOAD_FILE_MAP'] = array_change_key_case(array(
'XmlLangParser' => 'classes/xml/XmlLangParser.class.php',
'XmlParser' => 'classes/xml/XmlParser.class.php',
'XeXmlParser' => 'classes/xml/XmlParser.class.php',
- 'Bmp' => 'common/libraries/bmp.php',
'Ftp' => 'common/libraries/ftp.php',
'Tar' => 'common/libraries/tar.php',
'CryptoCompat' => 'common/libraries/cryptocompat.php',
diff --git a/common/libraries/bmp.php b/common/libraries/bmp.php
deleted file mode 100644
index 64a375091..000000000
--- a/common/libraries/bmp.php
+++ /dev/null
@@ -1,257 +0,0 @@
-=0; $y--)
- {
- for ($x=0; $x<$wid; $x++)
- {
- $rgb = imagecolorat($img, $x, $y);
- fwrite($f, byte3($rgb));
- }
- fwrite($f, $wid_pad);
- }
- fclose($f);
- }
- else
- {
- foreach ($header AS $h)
- {
- echo $h;
- }
-
- //save pixels
- for ($y=$hei-1; $y>=0; $y--)
- {
- for ($x=0; $x<$wid; $x++)
- {
- $rgb = imagecolorat($img, $x, $y);
- echo self::byte3($rgb);
- }
- echo $wid_pad;
- }
- }
- }
-
- public static function getimagesize($filename)
- {
- $f = fopen($filename, "rb");
-
- //read header
- $header = fread($f, 54);
- $header = unpack( 'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' .
- 'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'.
- 'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header);
-
- if ($header['identifier1'] != 66 or $header['identifier2'] != 77)
- {
- return false;
- }
-
- if (!in_array($header['bits_per_pixel'], array(24, 32, 8, 4, 1)))
- {
- return false;
- }
-
- $bps = $header['bits_per_pixel']; //bits per pixel
- $wid2 = ceil(($bps/8 * $header['width']) / 4) * 4;
- $colors = pow(2, $bps);
-
- $wid = $header['width'];
- $hei = $header['height'];
-
- return array($wid, $hei, 'BMP');
- }
-
- public static function imagecreatefrombmp($filename)
- {
- $f = fopen($filename, "rb");
-
- //read header
- $header = fread($f, 54);
- $header = unpack( 'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' .
- 'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'.
- 'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header);
-
- if ($header['identifier1'] != 66 or $header['identifier2'] != 77)
- {
- return false;
- }
-
- if (!in_array($header['bits_per_pixel'], array(24, 32, 8, 4, 1)))
- {
- return false;
- }
-
- $bps = $header['bits_per_pixel']; //bits per pixel
- $wid2 = ceil(($bps/8 * $header['width']) / 4) * 4;
- $colors = pow(2, $bps);
-
- $wid = $header['width'];
- $hei = $header['height'];
-
- $img = imagecreatetruecolor($header['width'], $header['height']);
-
- //read palette
- if ($bps < 9)
- {
- for ($i=0; $i<$colors; $i++)
- {
- $palette[] = self::undword(fread($f, 4));
- }
- }
- else
- {
- if ($bps == 32)
- {
- imagealphablending($img, false);
- imagesavealpha($img, true);
- }
- $palette = array();
- }
-
- //read pixels
- for ($y=$hei-1; $y>=0; $y--)
- {
- $row = fread($f, $wid2);
- $pixels = self::str_split2($row, $bps, $palette);
- for ($x=0; $x<$wid; $x++)
- {
- self::makepixel($img, $x, $y, $pixels[$x], $bps);
- }
- }
- fclose($f);
-
- return $img;
- }
-
- private static function str_split2($row, $bps, $palette)
- {
- switch ($bps)
- {
- case 32:
- case 24: return str_split($row, $bps/8);
- case 8: $out = array();
- $count = strlen($row);
- for ($i=0; $i<$count; $i++)
- {
- $out[] = $palette[ ord($row[$i]) ];
- }
- return $out;
- case 4: $out = array();
- $count = strlen($row);
- for ($i=0; $i<$count; $i++)
- {
- $roww = ord($row[$i]);
- $out[] = $palette[ ($roww & 240) >> 4 ];
- $out[] = $palette[ ($roww & 15) ];
- }
- return $out;
- case 1: $out = array();
- $count = strlen($row);
- for ($i=0; $i<$count; $i++)
- {
- $roww = ord($row[$i]);
- $out[] = $palette[ ($roww & 128) >> 7 ];
- $out[] = $palette[ ($roww & 64) >> 6 ];
- $out[] = $palette[ ($roww & 32) >> 5 ];
- $out[] = $palette[ ($roww & 16) >> 4 ];
- $out[] = $palette[ ($roww & 8) >> 3 ];
- $out[] = $palette[ ($roww & 4) >> 2 ];
- $out[] = $palette[ ($roww & 2) >> 1 ];
- $out[] = $palette[ ($roww & 1) ];
- }
- return $out;
- }
- }
-
- private static function makepixel($img, $x, $y, $str, $bps)
- {
- switch ($bps)
- {
- case 32 : $a = ord($str[0]);
- $b = ord($str[1]);
- $c = ord($str[2]);
- $d = 256 - ord($str[3]); //TODO: gives imperfect results
- $pixel = $d*256*256*256 + $c*256*256 + $b*256 + $a;
- imagesetpixel($img, $x, $y, $pixel);
- break;
- case 24 : $a = ord($str[0]);
- $b = ord($str[1]);
- $c = ord($str[2]);
- $pixel = $c*256*256 + $b*256 + $a;
- imagesetpixel($img, $x, $y, $pixel);
- break;
- case 8 :
- case 4 :
- case 1 : imagesetpixel($img, $x, $y, $str);
- break;
- }
- }
-
- private static function byte3($n)
- {
- return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255);
- }
-
- private static function undword($n)
- {
- $r = unpack("V", $n);
- return $r[1];
- }
-
- private static function dword($n)
- {
- return pack("V", $n);
- }
-
- private static function word($n)
- {
- return pack("v", $n);
- }
-}
diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml
index fab3c0ceb..8a28e7b8d 100644
--- a/modules/admin/conf/module.xml
+++ b/modules/admin/conf/module.xml
@@ -21,7 +21,7 @@
{$lang->about_enable_autosave}
{$lang->about_editor_auto_dark_mode}
+{$lang->about_enable_autosave}
{$lang->about_editor_auto_dark_mode}
+