/** * Render HTML structure * @param int $sliderID * * @return (string) */ public function render($sliderID, $status = false) { $content = ''; if (is_numeric((int) $sliderID)) { $objJSNEasySliderSlider = new JSNEasySliderSlider(); $data = $objJSNEasySliderSlider->getSliderInfoByID((int) $sliderID); if (count($data)) { if ($status) { if (!(int) $data->published) { return $content; } } $randID = $objJSNEasySliderSlider->randomString(10); $this->_loadAssets(); $content .= $this->renderArrow((int) $sliderID, $randID); $content .= $this->renderBody((int) $sliderID, $randID); $content .= $this->renderScriptTag((int) $sliderID, $randID, $data); } } return $content; }
/** * Render HTML structure * @param int $sliderID * * @return (string) */ public function render($sliderID, $status = false) { if (is_numeric((int) $sliderID)) { $objJSNEasySliderSlider = new JSNEasySliderSlider(); // Load the results as a list of stdClass objects (see later for more options on retrieving data). $results = $objJSNEasySliderSlider->getSliderInfoByID((int) $sliderID); if (count($results)) { if ($status) { if (!(int) $results->published) { return ''; } } $this->_loadAssets(); $data = json_decode($results->slider_data); if ($data) { $settings = isset($data->settings) ? $data->settings : new stdClass(); $startAt = isset($settings->startAt) ? $settings->startAt : 1; $loop = isset($settings->loopSlider) && $settings->loopSlider ? 'loop' : ''; $fonts = isset($data->fonts) ? array_unique($data->fonts) : array(); $html = ''; foreach ($fonts as $key => $font) { $font = preg_replace('/\\s/is', '+', $font); $html .= '<link href="//fonts.googleapis.com/css?family=' . $font . '" rel="stylesheet" type="text/css" data-noprefix />'; } $html .= '<div uribase="' . $this->_uriBase . '" class="jsn-es-slider" id="slider' . $sliderID . '" data-full-width="' . (isset($data->fullWidth) ? $data->fullWidth : 'false') . '" data-full-height="' . (isset($data->fullHeight) ? $data->fullHeight : 'false') . '" data-width="' . (isset($data->width) ? $data->width : '') . '" data-height="' . (isset($data->height) ? $data->height : '') . '" data-max-width="' . (isset($data->maxWidth) ? $data->maxWidth : '') . '" data-min-width="' . (isset($data->minWidth) ? $data->minWidth : '') . '" data-max-height="' . (isset($data->maxHeight) ? $data->maxHeight : '') . '" data-min-height="' . (isset($data->minHeight) ? $data->minHeight : '') . '" data-container-width="' . (isset($data->canvasWidth) ? $data->canvasWidth : '') . '" data-container-height="' . (isset($data->canvasHeight) ? $data->canvasHeight : '') . '" data-tablet-mode="' . (isset($data->tabletMode) ? $data->tabletMode : 'false') . '" data-tablet-under="' . (isset($data->tabletUnder) ? $data->tabletUnder : '') . '" data-tablet-width="' . (isset($data->tabletWidth) ? $data->tabletWidth : '') . '" data-tablet-height="' . (isset($data->tabletHeight) ? $data->tabletHeight : '') . '" data-mobile-mode="' . (isset($data->mobileMode) ? $data->mobileMode : 'false') . '" data-mobile-under="' . (isset($data->mobileUnder) ? $data->mobileUnder : '') . '" data-mobile-width="' . (isset($data->mobileWidth) ? $data->mobileWidth : '') . '" data-mobile-height="' . (isset($data->mobileHeight) ? $data->mobileHeight : '') . '" data-start-at="' . $startAt . '" data-loop="' . $loop . '" >'; //get html string for slides if (isset($data->slides) && !empty($data->slides)) { foreach ($data->slides as $slide) { $html .= $this->renderSlide($slide, $settings); } } if (isset($settings->showPagination) && $settings->showPagination) { $html .= '<div class="buttons-container"><div class="buttons"></div></div>'; } else { $html .= '<div class="buttons-container hidden" style="visibility: hidden;"><div class="buttons"></div></div>'; } if (isset($settings->showProgress) && $settings->showProgress) { $html .= '<div class="jsn-es-progress"><div class="jsn-es-progress-bar"></div></div>'; } $html .= '<span class="loading-text">...</span>'; $nextLabel = isset($settings->nextBtnLabel) && $settings->nextBtnLabel ? $settings->nextBtnLabel : ''; $prevLabel = isset($settings->prevBtnLabel) && $settings->prevBtnLabel ? $settings->prevBtnLabel : ''; if (isset($settings->showBtnPrev) && $settings->showBtnPrev) { if (is_bool($settings->showBtnPrev)) { $html .= '<a class="nav-button prev ' . (isset($settings->prevBtnLabel) && $settings->prevBtnLabel ? 'button-has-text' : '') . '">' . $prevLabel . '</a>'; } else { if ($settings->showBtnPrev == 'true') { $html .= '<a class="nav-button prev ' . (isset($settings->prevBtnLabel) && $settings->prevBtnLabel ? 'button-has-text' : '') . '">' . $prevLabel . '</a>'; } } } if (isset($settings->showBtnNext) && $settings->showBtnNext) { if (is_bool($settings->showBtnNext)) { $html .= '<a class="nav-button next ' . (isset($settings->nextBtnLabel) && $settings->nextBtnLabel ? 'button-has-text' : '') . '">' . $nextLabel . '</a>'; } else { if ($settings->showBtnNext == 'true') { $html .= '<a class="nav-button next ' . (isset($settings->nextBtnLabel) && $settings->nextBtnLabel ? 'button-has-text' : '') . '">' . $nextLabel . '</a>'; } } } $html .= '</div>'; return $html; } else { return '<p>error</p>'; } } } return ''; }