: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
public function fill($value) {
if (!empty($this->variables) && !empty($value)) {
return preg_replace_callback('/{((([a-z]+)\(([^}]+)\))|([a-zA-Z0-9][a-zA-Z0-9_\/]*))}/', array(
private function parseFunction($match) {
$args = self::splitTokens($match[4]);
for ($i = 0; $i < count($args); $i++) {
$args[$i] = $this->parseVariable($args[$i]);
if (method_exists($this, '_' . $match[3])) {
return call_user_func_array(array(
return $this->parseVariable($match[5]);
private function parseVariable($variable) {
preg_match('/^("|\')(.*)("|\')$/', $variable, $match);
preg_match('/((([a-z]+)\(([^}]+)\)))/', $variable, $match);
return call_user_func(array(
preg_match('/([a-zA-Z][0-9a-zA-Z_]*)(\/([0-9a-z]+))?/', $variable, $match);
$index = empty($match[3]) ? 0 : $match[3];
if (is_numeric($index)) {
$index = max(1, intval($index)) - 1;
if (isset($this->variables[$index]) && isset($this->variables[$index][$match[1]])) {
return $this->variables[$index][$match[1]];
private function _fallback($s, $def) {
private function _cleanhtml($s) {
return strip_tags($s, '<p><a><b><br><i>');
private function _removehtml($s) {
private function _splitbychars($s, $start = 0, $length = null) {
return Str::substr($s, $start, $length);
private function _splitbywords($s, $start, $length) {
$len = intval(Str::strlen($s));
$posStart = max(0, $start == 0 ? 0 : Str::strpos($s, ' ', $start));
$posEnd = max(0, $length > $len ? $len : Str::strpos($s, ' ', $length));
if ($posEnd == 0 && $length <= $len) $posEnd = $len;
return Str::substr($s, $posStart, $posEnd);
private function _findimage($s, $index) {
$index = isset($index) ? intval($index) - 1 : 0;
preg_match_all('/(<img.*?src=[\'"](.*?)[\'"][^>]*>)|(background(-image)??\s*?:.*?url\((["|\']?)?(.+?)(["|\']?)?\))/i', $s, $r);
if (isset($r[2]) && !empty($r[2][$index])) {
} else if (isset($r[6]) && !empty($r[6][$index])) {
$s = trim($r[6][$index], "'\" \t\n\r\0\x0B");
private function _findlink($s, $index) {
$index = isset($index) ? intval($index) - 1 : 0;
preg_match_all('/href=["\']?([^"\'>]+)["\']?/i', $s, $r);
if (isset($r[1]) && !empty($r[1][$index])) {
private function _removevarlink($s) {
return preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', '', $s);
private function _removelinebreaks($s) {
return preg_replace('/\r?\n|\r/', '', $s);
public function getTitle($isAdmin = false) {
return $this->fill($this->title);
public function getDescription() {
return $this->fill($this->description);
public function getRawTitle() {
public function getRawDescription() {
return $this->description;
public function getBackgroundImage() {
return $this->fill($this->parameters->get('backgroundImage'));
public function getThumbnail() {
return ResourceTranslator::toUrl($this->getThumbnailRaw());
public function getThumbnailRaw() {
$image = $this->thumbnail;
return $this->getBackgroundImage();
return $this->fill($image);
public function getThumbnailDynamic() {
$image = $this->thumbnail;
$image = $this->parameters->get('backgroundImage');
return $this->fill($image);
public function getThumbnailAltDynamic() {
$alt = $this->fill($this->parameters->get('thumbnailAlt'));
$alt = $this->getTitle();
public function getLightboxImage() {
$image = $this->fill($this->parameters->get('ligthboxImage'));
$image = $this->getBackgroundImage();
return ResourceTranslator::toUrl($image);
public function getRow() {
'title' => $this->getTitle(),
'slide' => $this->getFilledLayers(),
'description' => $this->getDescription(),
'thumbnail' => ResourceTranslator::urlToResource($this->getThumbnail()),
'published' => $this->published,
'publish_up' => $this->publish_up,
'publish_down' => $this->publish_down,
'params' => $this->parameters->toJSON(),
'slider' => $this->slider,
'ordering' => $this->ordering,
public function fillParameters() {
$this->parameters->set('backgroundImage', $this->fill($this->parameters->get('backgroundImage')));
$this->parameters->set('backgroundAlt', $this->fill($this->parameters->get('backgroundAlt')));
$this->parameters->set('backgroundTitle', $this->fill($this->parameters->get('backgroundTitle')));
$this->parameters->set('backgroundVideoMp4', $this->fill($this->parameters->get('backgroundVideoMp4')));
$this->parameters->set('backgroundColor', $this->fill($this->parameters->get('backgroundColor')));
$this->parameters->set('href', $this->fill($this->parameters->get('href')));
private function getFilledLayers() {
$layers = $this->slide['layers'];
$layers = AbstractComponent::translateUniqueIdentifier($layers);
$this->fillLayers($layers);
return json_encode($layers);
public function setNextCacheRefresh($time) {
$this->nextCacheRefresh = min($this->nextCacheRefresh, $time);
public function setVisibility($visibility) {
$this->visible = $visibility;
public function isVisible() {
if ($this->publish_down != '1970-01-01 00:00:00') {
$publish_down = strtotime($this->publish_down);
if ($publish_down > Platform::getTimestamp()) {
$this->setNextCacheRefresh($publish_down);
if ($this->publish_up != '1970-01-01 00:00:00') {
$publish_up = strtotime($this->publish_up);
if ($publish_up > Platform::getTimestamp()) {
$this->setNextCacheRefresh($publish_up);
public function getSlideStat() {
if ($this->hasGenerator()) {
return $this->generator->getSlideStat();
public function getGeneratorLabel() {
$source = $this->generator->getSource();
return $source->getLabel();
public function getElementID() {
return $this->getSlider()->elementId;
public function addScript($script, $name = false) {
$this->sliderObject->addScript($script, $name);
public function isScriptAdded($name) {
return $this->sliderObject->isScriptAdded($name);
public function addLess($file, $context) {
$this->sliderObject->addLess($file, $context);
public function addCSS($css) {
$this->sliderObject->addCSS($css);
public function addDeviceCSS($device, $css) {
$this->sliderObject->addDeviceCSS($device, $css);
public function addFont($font, $mode, $pre = null) {
return $this->sliderObject->addFont($font, $mode, $pre);
public function addStyle($style, $mode, $pre = null) {
return $this->sliderObject->addStyle($style, $mode, $pre);
public function addImage($imageUrl) {
$this->sliderObject->addImage($imageUrl);
public function isAdmin() {
return $this->sliderObject->isAdmin;
public function isLazyLoadingEnabled() {
return $this->sliderObject->features->lazyLoad->isEnabled;
public function optimizeImageWebP($src) {
public function renderImage($item, $src, $attributes = array(), $pictureAttributes = array()) {
* @see https://bugs.chromium.org/p/chromium/issues/detail?id=1181291
if (!$this->frontendFirst) {
$attributes['loading'] = 'lazy';
$imageUrl = ResourceTranslator::toUrl($src);
FastImageSize::initAttributes($src, $attributes);
$attributes = Html::addExcludeLazyLoadAttributes($attributes);
$attributes['src'] = $imageUrl;
$this->addImage($imageUrl);
return Html::tag('img', $attributes, false);
public function getThumbnailType() {
return $this->parameters->get('thumbnailType', 'default');
public function renderThumbnailImage($width, $height, $attributes = array()) {
$src = $this->getThumbnailRaw();
return '<img src="data:," alt style="visibility:hidden;">';
$attributes['src'] = ResourceTranslator::toUrl($src);
$originalThumbnailSize = FastImageSize::getSize($src);
if ($originalThumbnailSize) {
$attributes['width'] = $originalThumbnailSize['width'];
$attributes['height'] = $originalThumbnailSize['height'];
$attributes['loading'] = 'lazy';
$attributes = Html::addExcludeLazyLoadAttributes($attributes);
$imagePath = ResourceTranslator::toPath($src);
if (isset($imagePath[0])) {
$optimizeThumbnail = $this->sliderObject->params->get('optimize-thumbnail-scale', 0);
if ($optimizeThumbnail) {
$optimizedThumbnailUrl = $this->sliderObject->features->optimize->optimizeThumbnail($attributes['src']);
$attributes['src'] = $optimizedThumbnailUrl;
$optimizedThumbnailSize = FastImageSize::getSize(ResourceTranslator::urlToResource($optimizedThumbnailUrl));
if ($optimizedThumbnailSize) {
$attributes['width'] = $optimizedThumbnailSize['width'];
$attributes['height'] = $optimizedThumbnailSize['height'];
$sources[] = Html::tag('img', $attributes, false);
return HTML::tag('picture', Html::addExcludeLazyLoadAttributes(), implode('', $sources));