: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace Nextend\SmartSlider3\Application\Model;
use Nextend\Framework\Data\Data;
use Nextend\Framework\Database\Database;
use Nextend\Framework\Misc\Base64;
use Nextend\Framework\Misc\Str;
use Nextend\Framework\Model\AbstractModelTable;
use Nextend\Framework\Request\Request;
use Nextend\SmartSlider3\Application\Helper\HelperSliderChanged;
use Nextend\SmartSlider3\Renderable\Component\AbstractComponent;
use Nextend\SmartSlider3\Renderable\Component\ComponentCol;
use Nextend\SmartSlider3\Renderable\Component\ComponentContent;
use Nextend\SmartSlider3\Renderable\Component\ComponentLayer;
use Nextend\SmartSlider3\Renderable\Component\ComponentRow;
use Nextend\SmartSlider3\SlideBuilder\BuilderComponentLayer;
use Nextend\SmartSlider3\SlideBuilder\BuilderComponentSlide;
use Nextend\SmartSlider3\Slider\Slide;
use Nextend\SmartSlider3\Slider\Slider;
use Nextend\SmartSlider3\SmartSlider3Info;
use Nextend\SmartSlider3Pro\Renderable\Component\ComponentGroup;
class ModelSlides extends AbstractModelTable {
protected function createConnectorTable() {
return Database::getTable('nextend2_smartslider3_slides');
public function get($id) {
return $this->table->findByPk($id);
public function getAll($sliderid = 0, $where = '') {
return Database::queryAll('SELECT * FROM ' . $this->getTableName() . ' WHERE slider = ' . $sliderid . ' ' . $where . ' ORDER BY ordering', false, "assoc", null);
public function createQuickImage($image, $sliderId) {
'background-type' => 'image',
'backgroundImage' => $image['image']
if (!empty($image['alt'])) {
$parameters['backgroundAlt'] = $image['alt'];
$slideID = $this->create($sliderId, $image['title'], array(), $image['image'], $parameters, array(
'description' => $image['description']
$this->markChanged($sliderId);
public function createQuickEmptySlide($sliderId) {
'background-type' => 'color'
$slideID = $this->create($sliderId, 'Slide', array(), '', $parameters);
$this->markChanged($sliderId);
public function createQuickStaticOverlay($sliderId) {
$slideID = $this->create($sliderId, n2_('Static overlay'), array(), '', $parameters);
$this->markChanged($sliderId);
public function createQuickPost($post, $sliderId) {
$title = $this->removeFourByteChars($data->get('title'));
$description = $this->removeFourByteChars($data->get('description'));
$slideBuilder = new BuilderComponentSlide(array(
'description' => $description,
'thumbnail' => $data->get('image'),
'background-type' => 'image',
'backgroundImage' => $data->get('image'),
'backgroundImageOpacity' => 20,
'backgroundColor' => '000000FF'
$slideBuilder->content->set(array(
'desktopportraitpadding' => '10|*|100|*|10|*|100|*|px',
'mobileportraitpadding' => '10|*|10|*|10|*|10|*|px'
$heading = new BuilderComponentLayer($slideBuilder->content, 'heading');
$heading->item->set(array(
'heading' => '{name/slide}',
'font' => Base64::encode('{"data":[{"extra":"","color":"ffffffff","size":"48||px","tshadow":"0|*|0|*|0|*|000000ff","afont":"Roboto,Arial","lineheight":"1.5","bold":0,"italic":0,"underline":0,"align":"inherit","letterspacing":"normal","wordspacing":"normal","texttransform":"none"},{"extra":""}]}'),
$text = new BuilderComponentLayer($slideBuilder->content, 'text');
'desktopportraitmargin' => '0|*|0|*|20|*|0|*|px',
'content' => '{description/slide}',
'font' => Base64::encode('{"data":[{"extra":"","color":"ffffffff","size":"18||px","tshadow":"0|*|0|*|0|*|000000ff","afont":"Roboto,Arial","lineheight":"1.5","bold":0,"italic":0,"underline":0,"align":"inherit","letterspacing":"normal","wordspacing":"normal","texttransform":"none"},{"extra":""}]}'),
$link = $data->get('link');
$buttonLayer = new BuilderComponentLayer($slideBuilder->content, 'button');
$buttonLayer->item->set(array(
'content' => n2_('Read more'),
'link' => $link . '|*|_self'
$row = $this->convertSlideDataToDatabaseRow($slideBuilder->getData(), $sliderId);
$slideID = $this->create($row['slider'], $row['title'], $row['slide'], $row['thumbnail'], $row['params'], array(
'description' => $row['description'],
'published' => $row['published'],
'publish_up' => $row['publish_up'],
'publish_down' => $row['publish_down']
$this->markChanged($sliderId);
public function createSimpleEditAdd($postData, $sliderId) {
$data = new Data($postData);
$title = $data->get('title', '');
$description = $data->get('description', '');
$slideBuilder = new BuilderComponentSlide(array(
'description' => $description,
'thumbnailType' => $data->get('thumbnailType', ''),
'thumbnail' => $data->get('backgroundImage', ''),
'background-type' => 'image',
'backgroundImage' => $data->get('backgroundImage', ''),
'backgroundImageOpacity' => 100,
'backgroundColor' => '000000FF',
'href' => $data->get('href', ''),
'href-target' => $data->get('href-target', '')
$slideBuilder->content->set(array(
'desktopportraitpadding' => '10|*|100|*|10|*|100|*|px',
'mobileportraitpadding' => '10|*|10|*|10|*|10|*|px'
$videoUrl = $data->get('video', '');
preg_match('/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/', $videoUrl, $matches);
$thumbnail = 'https://i.ytimg.com/vi/' . $matches[2] . '/hqdefault.jpg';
$slideBuilder->set('thumbnail', $thumbnail);
$youtubeLayer = new BuilderComponentLayer($slideBuilder->content, 'youtube');
$youtubeLayer->item->set(array(
'youtubeurl' => $videoUrl,
preg_match('/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/', $videoUrl, $matches);
$vimeoLayer = new BuilderComponentLayer($slideBuilder->content, 'vimeo');
$vimeoLayer->item->set(array(
$mp4Layer = new BuilderComponentLayer($slideBuilder->content, 'video');
$mp4Layer->item->set(array(
$heading = new BuilderComponentLayer($slideBuilder->content, 'heading');
$heading->item->set(array(
'heading' => '{name/slide}'
$row = $this->convertSlideDataToDatabaseRow($slideBuilder->getData(), $sliderId);
$slideID = $this->create($row['slider'], $row['title'], $row['slide'], $row['thumbnail'], $row['params'], array(
'description' => $row['description'],
'published' => $row['published'],
'publish_up' => $row['publish_up'],
'publish_down' => $row['publish_down']
$this->markChanged($sliderId);
public function import($row, $sliderId) {
if (!$row['params']->has('version')) {
* We must set the missing empty version to allow upgrade of the old slides
$row['params']->set('version', '');
return $this->create($sliderId, $row['title'], $row['slide'], $row['thumbnail'], $row['params']->toArray(), array(
'description' => $row['description'],
'published' => $row['published'],
'publish_up' => $row['publish_up'],
'publish_down' => $row['publish_down'],
'first' => $row['first'],
'ordering' => $row['ordering'],
'generator_id' => $row['generator_id']
private function create($sliderID, $title, $layers, $thumbnail, $params = array(), $optional = array()) {
if (!isset($optional['ordering'])) {
$optional['ordering'] = $this->getNextOrdering($sliderID);
if (!isset($params['version'])) {
$params['version'] = SmartSlider3Info::$version;
$data = array_merge(array(
'publish_up' => '1970-01-01 00:00:00',
'publish_down' => '1970-01-01 00:00:00',
'slide' => json_encode($layers, JSON_UNESCAPED_SLASHES),
'thumbnail' => $thumbnail,
'params' => json_encode($params, JSON_UNESCAPED_SLASHES),
$this->table->insert($data);
return $this->table->insertId();
* @param int $generatorID
public function createSlideWithGenerator($sliderId, $generatorID, $slide) {
$row = $this->convertSlideDataToDatabaseRow($slide, $sliderId);
$slideId = $this->create($row['slider'], $row['title'], $row['slide'], $row['thumbnail'], $row['params'], array(
'description' => $row['description'],
'published' => $row['published'],
'publish_up' => $row['publish_up'],
'publish_down' => $row['publish_down'],
'generator_id' => $generatorID
$this->markChanged($sliderId);
public function save($slideID, $slide, $guides) {
$slideData = json_decode(Base64::decode($slide), true);
$slideData['guides'] = $guides;
$row = $this->convertSlideDataToDatabaseRow($slideData);
$this->table->update(array(
'title' => $row['title'],
'slide' => json_encode($row['slide'], JSON_UNESCAPED_SLASHES),
'description' => $row['description'],
'thumbnail' => $row['thumbnail'],
'published' => $row['published'],
'publish_up' => $row['publish_up'],
'publish_down' => $row['publish_down'],
'params' => json_encode($row['params'], JSON_UNESCAPED_SLASHES)
), array('id' => $slideID));
$this->markChanged(Request::$REQUEST->getInt('sliderid'));
public function saveSimple($slideID, $title, $description, $params) {
$this->table->update(array(
'description' => $description,
'params' => json_encode($params, JSON_UNESCAPED_SLASHES)
), array('id' => $slideID));
* Updates the params field of the slide;
public function updateSlideParams($id, $params) {
$this->table->update(array(
'params' => json_encode($params)
public function delete($id) {
$slide = $this->get($id);
if ($slide['generator_id'] > 0) {
$slidesWithSameGenerator = $this->getAll($slide['slider'], 'AND generator_id = ' . intval($slide['generator_id']));
if (count($slidesWithSameGenerator) == 1) {
$generatorModel = new ModelGenerator($this);
$generatorModel->delete($slide['generator_id']);
$this->table->deleteByAttributes(array(
$this->markChanged($slide['slider']);
* @param bool $maintainOrdering
* @param bool|int $targetSliderId
* @return int The new slide ID;
public function copyTo($id, $maintainOrdering = false, $targetSliderId = false) {
if ($targetSliderId === false || $row['slider'] == $targetSliderId) {
* Copy the slide to the same slider
$this->shiftSlideOrdering($row['slider'], $row['ordering']);
* Copy the slide to another slider
$row['slider'] = $targetSliderId;
if (!$maintainOrdering) {
if (!empty($row['generator_id'])) {
$generatorModel = new ModelGenerator($this);
$row['generator_id'] = $generatorModel->duplicate($row['generator_id']);
$row['slide'] = json_encode(AbstractComponent::translateUniqueIdentifier(json_decode($row['slide'], true)), JSON_UNESCAPED_SLASHES);
$this->table->insert($row);
$id = $this->table->insertId();
$this->markChanged($row['slider']);
public function setTitle($id, $title) {
$slide = $this->get($id);
$this->table->update(array(
$this->markChanged($slide['slider']);
public function first($id) {
$slide = $this->get($id);
$this->table->update(array(
"slider" => $slide['slider']
$this->table->update(array(
$this->markChanged($slide['slider']);
public function publish($id) {
$this->markChanged(Request::$REQUEST->getInt('sliderid'));
return $this->table->update(array(
), array("id" => intval($id)));
public function unPublish($id) {
$this->table->update(array(
$this->markChanged(Request::$REQUEST->getInt('sliderid'));
public function convertToSlide($id) {
$slide = $this->get($id);
$data = new Data($slide['params'], true);
$data->set('static-slide', 0);
$this->table->update(array(
"params" => $data->toJSON()
$this->markChanged($slide['slider']);
public function deleteBySlider($sliderid) {