function NextendSliderCache($slider) { nextendimportsmartslider2('nextend.smartslider.check'); nextendimport('nextend.css.css'); nextendimport('nextend.javascript.javascript'); nextendimport('nextend.fonts.google'); $this->slider = $slider; $sliderid = $slider->_sliderid; $recache = false; $cached = json_decode(NextendSmartSliderStorage::get('slidercache' . $sliderid), true); if (nextendIsWordpress()) { $time = current_time('timestamp'); } else { $time = time(); } nextendimportsmartslider2('nextend.smartslider.admin.models.slides'); $slidesModel = new NextendSmartsliderAdminModelSlides(null); $slides = $slidesModel->getSlides($sliderid, ''); $slideexpire = null; foreach ($slides as $s) { $publish_up = strtotime($s['publish_up']); if ($publish_up && $publish_up > $time && ($slideexpire == null || $publish_up < $slideexpire)) { $slideexpire = $publish_up; } $publish_down = strtotime($s['publish_down']); if ($publish_down && $publish_down > $time && ($slideexpire == null || $publish_down < $slideexpire)) { $slideexpire = $publish_down; } } if (is_array($cached)) { if (NextendSmartSliderStorage::get('sliderchanged' . $sliderid) == 1) { $recache = true; } else { if (isset($cached['time']) && isset($cached['expire']) && $cached['time'] < time() - $cached['expire'] * 60 * 60) { $recache = true; } else { if (isset($cached['slideexpire']) && $cached['slideexpire'] < $time) { $recache = true; } } } } else { $recache = true; } if (!$recache) { $data = $cached['data']; if (isset($data['css'])) { if (!NextendFilesystem::fileexists(NextendFilesystem::absoluteURLToPath($data['css']))) { $recache = true; } } else { $recache = true; } if (!isset($data['libraries']) || !isset($data['libraries']['jquery']) || !isset($data['libraries']['jquery']['jsfiles']) || count($data['libraries']['jquery']['jsfiles']) == 0) { $recache = true; } } //$recache = true; if ($recache) { $data = $this->render(); $cached = array('time' => time(), 'data' => $data); if ($this->slider->_generatorParams->get('enabled', 0)) { $generatorcached = json_decode(NextendSmartSliderStorage::get('generator' . $sliderid), true); if (is_array($generatorcached)) { $cached['time'] = $generatorcached['time']; $cached['expire'] = $this->slider->_generatorParams->get('cachetime', '24'); } } if ($slideexpire) { $cached['slideexpire'] = $slideexpire; } NextendSmartSliderStorage::set('slidercache' . $sliderid, json_encode($cached)); NextendSmartSliderStorage::set('sliderchanged' . $sliderid, '0'); } $this->cssurl = $data['css']; if (nextendIsWordPress()) { add_action('nextend_css', array($this, 'addCSS')); } elseif (nextendIsMagento()) { Nextend_SmartSlider2_Model_Observer::$sliders[] = array($this, 'addCSS'); } else { $this->addCSS(); } $js = NextendJavascript::getInstance(); foreach ($data['js']['core'] as $j) { $js->addJsFile($j); } if (isset($data['libraries']) && count($data['libraries'])) { foreach ($data['libraries'] as $library => $jss) { $js->loadLibrary($library); if (!empty($jss['js'])) { $js->addLibraryJs($library, $jss['js']); } if (count($jss['jsfiles'])) { foreach ($jss['jsfiles'] as $j) { $js->addLibraryJsFile($library, $j); } } } } if (isset($data['fonts']) && count($data['fonts'])) { $google = NextendFontsGoogle::getInstance(); foreach ($data['fonts'] as $k => $v) { $style = explode(',', $v[0]); $subset = explode(',', $v[1]); for ($i = 0; $i < count($style); $i++) { $google->addFont($k, $style[$i], $subset[$i]); } } } $slider = $data['html']; if (nextendIsJoomla()) { if (version_compare(JVERSION, '1.6.0', 'ge')) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $article = new stdClass(); $article->text = $slider; $_p = array(); $dispatcher->trigger('onContentPrepare', array('com_smartslider2', &$article, &$_p, 0)); if (!empty($article->text)) { $slider = $article->text; } } } elseif (nextendIsWordPress()) { if (!function_exists('ss2_attr_shortcode')) { function ss2_attr_shortcode($matches) { return 'data-' . $matches[1] . '="' . str_replace('"', '"', do_shortcode(str_replace('"', '"', $matches[2]))) . '"'; } } $slider = preg_replace_callback("/data-(click|enter|leave)=\"(.*?)\"/", "ss2_attr_shortcode", $slider); $slider = do_shortcode($slider); } echo $slider; }
function loadSlides() { $slides = array(); $generateslides = NextendParse::parse($this->_generatorParams->get('generateslides', '0|*|0|*|0')); $createslides = intval($generateslides[1]); $staticslides = intval($generateslides[2]); $publishbetween = (array) NextendParse::parse($this->_generatorSlideParams->get('publishdates', '|*|')); if (!isset($publishbetween[1])) { $publishbetween[1] = ''; } if (!$this->_backend && $this->_generatorParams->get('enabled', 0) && $createslides == 0 && ($publishbetween[0] == '' || strtotime($publishbetween[0]) < time()) && ($publishbetween[1] == '' || strtotime($publishbetween[1]) > time())) { nextendimportsmartslider2('nextend.smartslider.generator'); $this->generator = new NextendSmartsliderGenerator($this->_generatorParams, $this->_generatorSlideParams, $this->_sliderid); $slides = $this->generator->generateSlides($this->_sliderid); } else { nextendimportsmartslider2('nextend.smartslider.admin.models.slides'); $slidesModel = new NextendSmartsliderAdminModelSlides(null); $where = ''; $date = ''; if (nextendIsWordpress()) { $date = current_time('mysql'); } else { $date = date('Y-m-d H:i:s'); } if ($this->_backend) { $where = " AND ((published = 1 AND (publish_up = '0000-00-00 00:00:00' OR publish_up < '" . $date . "') AND (publish_down = '0000-00-00 00:00:00' OR publish_down > '" . $date . "')) OR id = " . NextendRequest::getInt('slideid') . ") "; } else { $where = " AND published = 1 AND (publish_up = '0000-00-00 00:00:00' OR publish_up < '" . $date . "') AND (publish_down = '0000-00-00 00:00:00' OR publish_down > '" . $date . "') "; } $slides = $slidesModel->getSlides($this->_sliderid, $where); if (!$this->_backend && $createslides && !$staticslides) { nextendimportsmartslider2('nextend.smartslider.generator'); $this->generator = new NextendSmartsliderGenerator($this->_generatorParams, $this->_generatorSlideParams, $this->_sliderid); $source = $this->_generatorParams->get('source', ''); if ($source) { $this->generator->initDatasource($source); for ($i = 0; $i < count($slides); $i++) { if ($slides[$i]['generator'] > 0) { $slides[$i] = $this->generator->makeSlide($slides[$i]); } } } } } $this->_activeSlide = 0; return $slides; }