function rev_get_token() { $token = Context::getcontext()->controller->token; if (isset($token)) { return $token; } return false; }
public function register_fonts() { $fonts = $this->get_all_fonts(); if (!empty($fonts)) { $http = is_ssl() ? 'https' : 'http'; foreach ($fonts as $font) { if ($font !== '') { $font_url = $http . '://fonts.googleapis.com/css?family=' . $font['url']; Context::getcontext()->controller->addCSS($font_url); } } } }
public function hookdisplayBackOfficeHeader() { if (Tools::getvalue('configure') == 'revsliderprestashop') { $this->context->controller->addCSS($this->_path . 'css/jui/new/jquery-ui-1.10.3.custom.min.css'); $this->context->controller->addCSS($this->_path . 'css/admin.css'); $this->context->controller->addCSS($this->_path . 'css/tipsy.css'); $this->context->controller->addCSS($this->_path . 'css/load-styles.css'); $this->context->controller->addCSS($this->_path . 'js/farbtastic/farbtastic.css'); $this->context->controller->addCSS($this->_path . 'js/codemirror/codemirror.css'); $this->context->controller->addCSS($this->_path . 'css/edit_layers.css'); $this->context->controller->addCSS($this->_path . 'css/thickbox.css'); $this->context->controller->addCSS($this->_path . 'rs-plugin/css/settings.css'); $this->context->controller->addCSS($this->_path . 'rs-plugin/css/static-captions.css'); $g_urlContent = UniteFunctionsWPRev::getUrlContent(); $dynamicadmincss = 'index.php?controller=Revolutionslider_ajax&token=' . Context::getcontext()->controller->token . '&revControllerAction=captions'; $this->smarty->assign('dynamicadmincss', $dynamicadmincss); $this->smarty->assign('g_urlContent', $g_urlContent); $this->smarty->assign('this_path', $this->_path); return $this->display(__FILE__, 'views/templates/admin/revolution_admin.tpl'); } }
<th width='70px'><?php echo RevsliderPrestashop::$lang['N_Slides']; ?> </th> <?php } ?> <th width='50%'><?php echo RevsliderPrestashop::$lang['Actions']; ?> </th> </tr> </thead> <tbody> <?php if ($outputTemplates) { $useSliders = $arrSlidersTemplates; $pagenum = isset($_GET['pagenumt']) ? absint($_GET['pagenumt']) : 1; $offset = ($pagenum - 1) * $limit; } else { $useSliders = $arrSliders; $pagenum = isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1; $offset = ($pagenum - 1) * $limit; } $cur_offset = 0; $current_id_shop_group = Context::getcontext()->shop->id_shop_group; $current_shop_id = Context::getcontext()->shop->id; $shop_context = Context::getcontext()->cookie->shopContext; if (!empty($shop_context) && isset($shop_context)) { $shop_contexttype = substr($shop_context, 0, 1); } else {
public static function get_uploaded_files_markup($results = array()) { $lan_iso = Context::getcontext()->language->iso_code; include_once _PS_ROOT_DIR_ . '/modules/revsliderprestashop/views/config/config.php'; // include_once(_PS_ROOT_DIR_.'/modules/revsliderprestashop/views/lang/'.$lan_iso.'.php'); include_once _PS_ROOT_DIR_ . '/modules/revsliderprestashop/views/include/utils.php'; $upload_dir = __PS_BASE_URI__ . 'modules/revsliderprestashop/uploads/'; $current_path = _PS_ROOT_DIR_ . '/modules/revsliderprestashop/uploads/'; $url = uploads_url(); ob_start(); if (!empty($results)) { ?> <div id="divImageList" > <ul id="selectable" class=""> <?php $num = 0; foreach ($results as $id => $filename) { //$img = $results[$num]; $thumbsize = GlobalsRevSlider::IMAGE_SIZE_THUMBNAIL; $mediumsize = GlobalsRevSlider::IMAGE_SIZE_MEDIUM; $largesize = GlobalsRevSlider::IMAGE_SIZE_LARGE; $filerealname = substr($filename, 0, strrpos($filename, '.')); $fileext = substr($filename, strrpos($filename, '.'), strlen($filename) - strlen($filerealname)); $thumbimg = $img = "{$filerealname}-{$thumbsize}x{$thumbsize}{$fileext}"; $mediumimg = "{$filerealname}-{$mediumsize}x{$mediumsize}{$fileext}"; $largeimg = "{$filerealname}-{$largesize}x{$largesize}{$fileext}"; $file_path = $file_path = $current_path . $largeimg; $date = filemtime($file_path); $size = filesize($file_path); // $file_ext = substr(strrchr($file, '.'), 1); $file_infos = pathinfo($file_path); $file_ext = $file_infos['extension']; // $sorted[$k] = array('file' => $file, 'date' => $date, 'size' => $size, 'extension' => $file_ext); $extension_lower = fix_strtolower($file_ext); $is_img = true; list($img_width, $img_height, $img_type, $attr) = getimagesize($file_path); // if (++$num % 4 === 1): ?> <li data-image="<?php echo $filename; ?> " data-large="<?php echo $upload_dir . $img; ?> " data-medium="<?php echo $upload_dir . $img; ?> " data-thumb="<?php echo $upload_dir . $img; ?> " class="ff-item-type-2 file"> <figure data-type="img" data-name="1117858_1577750_graph-1024x1024.png"> <a data-function="apply" data-field_id="" data-file="<?php echo $upload_dir . $img; ?> " class="link" href="javascript:void('')"> <div class="img-precontainer"> <div class="img-container"> <span></span> <img alt="<?php echo $img; ?> " src="<?php echo $upload_dir . $img; ?> " class="original " > </div> </div> <div class="img-precontainer-mini original-thumb"> <div class="filetype png hide">png</div> <div class="img-container-mini"> <span></span> <img src="<?php echo $upload_dir . $img; ?> " class=" " alt="<?php echo $img; ?> thumbnails"> </div> </div> </a> <div class="box"> <h4 class="ellipsis"> <a data-function="apply" data-field_id="" data-file="<?php echo $img; ?> " class="link" href="javascript:void('')"> <?php echo $img; ?> </a></h4> </div> <?php $date = filemtime($current_path . $img); ?> <input type="hidden" class="date" value="<?php echo $date; ?> "/> <input type="hidden" class="size" value="<?php echo $size; ?> "/> <input type="hidden" class="extension" value="<?php echo $extension_lower; ?> "/> <input type="hidden" class="name" value=""/> <div class="file-date"><?php echo date(lang_Date_type, $date); ?> </div> <div class="file-size"><?php echo makeSize($size); ?> </div> <div class='img-dimension'><?php if ($is_img) { echo $img_width . "x" . $img_height; } ?> </div> <div class='file-extension'><?php echo Tools::safeOutput($extension_lower); ?> </div>
/** * @param $iIdProduct * @return mixed */ private static function getIdeasOrTipsByproductId($iIdProduct) { if (!array_key_exists($iIdProduct, self::$aNowIdeasOrTips)) { self::$aNowIdeasOrTips[$iIdProduct] = NowIdeasOrTips::getItems($iIdProduct, Context::getcontext()->language->id); } return self::$aNowIdeasOrTips[$iIdProduct]; }
public function importSliderFromPost($updateAnim = true, $updateStatic = true) { try { $sliderID = UniteFunctionsRev::getPostVariable("sliderid"); $sliderExists = !empty($sliderID); if ($sliderExists) { $this->initByID($sliderID); } $filepath = $_FILES["import_file"]["tmp_name"]; if (file_exists($filepath) == false) { UniteFunctionsRev::throwError("Import file not found!!!"); } //check if zip file or fallback to old, if zip, check if all files exist if (!class_exists("ZipArchive")) { $importZip = false; } else { $zip = new ZipArchive(); $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE); } if ($importZip === true) { //true or integer. If integer, its not a correct zip file //check if files all exist in zip $slider_export = $zip->getStream('slider_export.txt'); $custom_animations = $zip->getStream('custom_animations.txt'); $dynamic_captions = $zip->getStream('dynamic-captions.css'); $static_captions = $zip->getStream('static-captions.css'); if (!$slider_export) { UniteFunctionsRev::throwError("slider_export.txt does not exist!"); } //if(!$custom_animations) UniteFunctionsRev::throwError("custom_animations.txt does not exist!"); //if(!$dynamic_captions) UniteFunctionsRev::throwError("dynamic-captions.css does not exist!"); //if(!$static_captions) UniteFunctionsRev::throwError("static-captions.css does not exist!"); $content = ''; $animations = ''; $dynamic = ''; $static = ''; while (!feof($slider_export)) { $content .= fread($slider_export, 1024); } if ($custom_animations) { while (!feof($custom_animations)) { $animations .= fread($custom_animations, 1024); } } if ($dynamic_captions) { while (!feof($dynamic_captions)) { $dynamic .= fread($dynamic_captions, 1024); } } if ($static_captions) { while (!feof($static_captions)) { $static .= fread($static_captions, 1024); } } fclose($slider_export); if ($custom_animations) { fclose($custom_animations); } if ($dynamic_captions) { fclose($dynamic_captions); } if ($static_captions) { fclose($static_captions); } //check for images! } else { //check if fallback //get content array $content = @file_get_contents($filepath); } if ($importZip === true) { //we have a zip $db = new UniteDBRev(); //update/insert custom animations $animations = @unserialize($animations); if (!empty($animations)) { foreach ($animations as $key => $animation) { //$animation['id'], $animation['handle'], $animation['params'] $exist = $db->fetch(GlobalsRevSlider::$table_layer_anims, "handle = '" . $animation['handle'] . "'"); if (!empty($exist)) { //update the animation, get the ID if ($updateAnim == "true") { //overwrite animation if exists $arrUpdate = array(); $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $db->update(GlobalsRevSlider::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle'])); $id = $exist['0']['id']; } else { //insert with new handle $arrInsert = array(); $arrInsert["handle"] = 'copy_' . $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } } else { //insert the animation, get the ID $arrInsert = array(); $arrInsert["handle"] = $animation['handle']; $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params']))); $id = $db->insert(GlobalsRevSlider::$table_layer_anims, $arrInsert); } //and set the current customin-oldID and customout-oldID in slider params to new ID from $id $content = str_replace(array('customin-' . $animation['id'], 'customout-' . $animation['id']), array('customin-' . $id, 'customout-' . $id), $content); } dmp(__("animations imported!", REVSLIDER_TEXTDOMAIN)); } else { dmp(__("no custom animations found, if slider uses custom animations, the provided export may be broken...", REVSLIDER_TEXTDOMAIN)); } //overwrite/append static-captions.css if (!empty($static)) { if ($updateStatic == "true") { //overwrite file RevOperations::updateStaticCss($static); } else { //append $static_cur = RevOperations::getStaticCss(); $static = $static_cur . "\n" . $static; RevOperations::updateStaticCss($static); } } //overwrite/create dynamic-captions.css //parse css to classes $dynamicCss = UniteCssParserRev::parseCssToArray($dynamic); if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) { foreach ($dynamicCss as $class => $styles) { //check if static style or dynamic style $class = trim($class); if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) { //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img continue; } //is a dynamic style if (strpos($class, ':hover') !== false) { $class = trim(str_replace(':hover', '', $class)); $arrInsert = array(); $arrInsert["hover"] = json_encode($styles); $arrInsert["settings"] = json_encode(array('hover' => 'true')); } else { $arrInsert = array(); $arrInsert["params"] = json_encode($styles); } //check if class exists $result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'"); if (!empty($result)) { //update $db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class)); } else { //insert $arrInsert["handle"] = $class; $db->insert(GlobalsRevSlider::$table_css, $arrInsert); } } dmp(__("dynamic styles imported!", REVSLIDER_TEXTDOMAIN)); } else { dmp(__("no dynamic styles found, if slider uses dynamic styles, the provided export may be broken...", REVSLIDER_TEXTDOMAIN)); } } // $content = preg_replace('!s:(\d+):"(.*?)";!', "'s:'.strlen('$2').':\"$2\";'", $content); //clear errors in string $content = preg_replace_callback('!s:(\\d+):"(.*?)";!', create_function('$match', 'return "s:".strlen($match[2]).":\\"{$match[2]}\\";";'), $content); //clear errors in string $arrSlider = @unserialize($content); if (empty($arrSlider)) { UniteFunctionsRev::throwError("Wrong export slider file format! This could be caused because the ZipArchive extension is not enabled."); } //update slider params $sliderParams = $arrSlider["params"]; $sliderParams["displayhook"] = ''; $sliderParams["id_shop"] = Context::getcontext()->shop->id; if ($sliderExists) { $sliderParams["title"] = $this->arrParams["title"]; $sliderParams["alias"] = $this->arrParams["alias"]; $sliderParams["id_shop"] = Context::getcontext()->shop->id; //$sliderParams["shortcode"] = $this->arrParams["shortcode"]; } if (isset($sliderParams["background_image"])) { $sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]); } $json_params = json_encode($sliderParams); //update slider or craete new if ($sliderExists) { $arrUpdate = array("params" => $json_params); $this->db->update(GlobalsRevSlider::$table_sliders, $arrUpdate, array("id" => $sliderID)); } else { //new slider $arrInsert = array(); $arrInsert["params"] = $json_params; $arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1"); $arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1"); //$arrInsert["id_shop"] = Context::getcontext()->shop->id; $sliderID = $this->db->insert(GlobalsRevSlider::$table_sliders, $arrInsert); } //-------- Slides Handle ----------- //delete current slides if ($sliderExists) { $this->deleteAllSlides(); } //create all slides $arrSlides = $arrSlider["slides"]; $alreadyImported = array(); foreach ($arrSlides as $slide) { $params = $slide["params"]; $layers = $slide["layers"]; //convert params images: if (isset($params["image"])) { //import if exists in zip folder if (trim($params["image"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image = $zip->getStream('images/' . $params["image"]); if (!$image) { echo $params["image"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) { //$importImage = UniteFunctionsWPRev::import_media('zip://'.$filepath."#".ABSPATH.'/'.$params["image"], $sliderParams["alias"].'/'); $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"]); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path']; $params["image"] = $importImage['path']; } } else { $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]]; } } } } $params["image"] = UniteFunctionsWPRev::getImageUrlFromPath($params["image"]); if ($rev_image_id = get_image_id_by_url($params["image"])) { $params["image_id"] = $rev_image_id; } } //convert layers images: foreach ($layers as $key => $layer) { if (isset($layer["image_url"])) { //import if exists in zip folder if (trim($layer["image_url"]) !== '') { if ($importZip === true) { //we have a zip, check if exists $image_url = $zip->getStream('images/' . $layer["image_url"]); if (!$image_url) { echo $layer["image_url"] . ' not found!<br>'; } else { if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) { $importImage = UniteFunctionsWPRev::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"]); if ($importImage !== false) { $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path']; $layer["image_url"] = $importImage['path']; } } else { $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]]; } } } } $layer["image_url"] = UniteFunctionsWPRev::getImageUrlFromPath($layer["image_url"]); $layers[$key] = $layer; } } //create new slide $arrCreate = array(); $arrCreate["slider_id"] = $sliderID; $arrCreate["slide_order"] = $slide["slide_order"]; $arrCreate["layers"] = json_encode($layers); $arrCreate["params"] = json_encode($params); $this->db->insert(GlobalsRevSlider::$table_slides, $arrCreate); } } catch (Exception $e) { $errorMessage = $e->getMessage(); return array("success" => false, "error" => $errorMessage, "sliderID" => $sliderID); } //update dynamic-captions.css RevOperations::updateDynamicCaptions(); return array("success" => true, "sliderID" => $sliderID); }
} } return $results; } public static function GetAllBlogPost() { $id_lang = (int) Context::getContext()->language->id; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM `' . _DB_PREFIX_ . 'smart_blog_category` sbc INNER JOIN `' . _DB_PREFIX_ . 'smart_blog_category_lang` sbcl ON(sbc.`id_smart_blog_category` = sbcl.`id_smart_blog_category` AND sbcl.`id_lang` = ' . (int) $id_lang . ') INNER JOIN `' . _DB_PREFIX_ . 'smart_blog_category_shop` sbs ON sbs.id_smart_blog_category = sbc.id_smart_blog_category and sbs.id_shop = ' . (int) Context::getContext()->shop->id . ' WHERE sbc.`active`= 1'); return $result; } public static function GetCategoryNameById($id_category = '') { if (isset($id_category) && !empty($id_category) && $id_category != 0) { $id_lang = (int) Context::getContext()->language->id; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT sbcl.`name` FROM `' . _DB_PREFIX_ . 'category` sbc INNER JOIN `' . _DB_PREFIX_ . 'category_lang` sbcl ON(sbc.`id_category` = sbcl.`id_category` AND sbcl.`id_lang` = ' . (int) $id_lang . ') INNER JOIN `' . _DB_PREFIX_ . 'category_shop` sbs ON sbs.id_category = sbc.id_category and sbs.id_shop = ' . (int) Context::getContext()->shop->id . ' WHERE sbc.`active`= 1 and sbc.`id_category` = ' . $id_category); return $result[0]['name']; } else { return false; } } public static function GetAllProducts($id_category, $order_by = null, $order_way = null, $limit = null) { // start set prestashop value $random = false; if ($order_by == 'ID') { $order_by = 'id_product'; } elseif ($order_by == 'date') { $order_by = 'date_add'; } elseif ($order_by == 'title') { $order_by = 'name'; } elseif ($order_by == 'price') { $order_by = 'price'; } else { $order_by = 'position'; } if ($order_by == 'rand') { $random = true; } // end set prestashop value $random_number_products = 1; $check_access = true; $id_lang = Context::getcontext()->language->id; $context = Context::getContext(); // if ($check_access && !$this->checkAccess($context->customer->id)) // return false; $active = true; $front = true; if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) { $front = false; } if (empty($order_by)) { $order_by = 'position'; } else { $order_by = strtolower($order_by); } if (empty($order_way)) { $order_way = 'ASC'; } $order_by_prefix = false; if ($order_by == 'id_product' || $order_by == 'date_add' || $order_by == 'date_upd') { $order_by_prefix = 'p'; } elseif ($order_by == 'name') { $order_by_prefix = 'pl'; } elseif ($order_by == 'manufacturer') { $order_by_prefix = 'm'; $order_by = 'name'; } elseif ($order_by == 'position') { $order_by_prefix = 'cp'; }
$countdown_js = __PS_BASE_URI__ . 'modules/revsliderprestashop/js/countdown/jquery.countdown.js'; $countdown_css = __PS_BASE_URI__ . 'modules/revsliderprestashop/css/countdown/countdown.css'; Context::getcontext()->controller->addJs($countdown_js); Context::getcontext()->controller->addCSS($countdown_css); // end start countdown JS } } return $html; } private function setLayersByPostData($postData, $sliderID) { $priceDisplay = Product::getTaxCalculationMethod((int) Context::getcontext()->cookie->id_customer); if (!$priceDisplay) { $productprice = Tools::displayPrice($postData["price"], Context::getContext()->currency); } else { $productprice = Tools::displayPrice($postData["price_tax_exc"], Context::getContext()->currency); } $postID = $postData["id_product"]; $countdown = $this->SetCountDown($postData); // $imgsrc = $this->SetImageSrc($postData); $title = UniteFunctionsRev::getVal($postData, "name"); $excerpt_limit = $this->getSliderParam($sliderID, "excerpt_limit", 55, RevSlider::VALIDATE_NUMERIC); $excerpt_limit = (int) $excerpt_limit; $description = substr($postData["description"], $excerpt_limit); $description_short = $postData["description_short"]; // $alias = UniteFunctionsRev::getVal($postData, "post_name"); // $content = UniteFunctionsRev::getVal($postData, "post_content"); //$link = get_permalink($postID); $link = $postData["link"]; $date_add = $postData["date_add"]; //$date_add = UniteFunctionsWPRev::convertPostDate($date_add); $date_upd = $postData["date_upd"]; //$date_upd = UniteFunctionsWPRev::convertPostDate($date_upd); $category_default = $postData["category_default"]; $linkobj = new Link(); $addtocart = $linkobj->getPageLink('cart', false, NULL, "add=1&id_product=" . $postID, false); foreach ($this->arrLayers as $key => $layer) { $text = UniteFunctionsRev::getVal($layer, "text"); $text = str_replace("%title%", $title, $text); $text = str_replace("%description_short%", $description_short, $text); $text = str_replace("%description%", $description, $text); $text = str_replace("%link%", $link, $text); $text = str_replace("%addtocart%", $addtocart, $text); $text = str_replace("%countdown%", $countdown, $text); // $text = str_replace("%imgsrc%", $imgsrc, $text); $text = str_replace("%date%", $date_add, $text); $text = str_replace("%date_modified%", $date_upd, $text); $text = str_replace("%product_price%", $productprice, $text); $text = str_replace("%category_default%", $category_default, $text); $arrMatches = array(); $text = str_replace('-', '_REVSLIDER_', $text); preg_match_all('/%product:\\w+%/', $text, $arrMatches); foreach ($arrMatches as $matched) { foreach ($matched as $match) { $meta = str_replace("%product:", "", $match); $meta = str_replace("%", "", $meta); $meta = str_replace('_REVSLIDER_', '-', $meta); if (isset($postData[$meta]) && !empty($postData[$meta])) { $metaValue = $postData[$meta]; $text = str_replace($match, $metaValue, $text); } } } $text = str_replace('_REVSLIDER_', '-', $text); // start hook exec $extra_hook_meta_exec = array(); Hook::exec('actionsdsrevinsertmetaexec', array('extra_hook_meta_exec' => &$extra_hook_meta_exec, 'id_product' => &$postID)); if (isset($extra_hook_meta_exec) && !empty($extra_hook_meta_exec)) { foreach ($extra_hook_meta_exec as $svalue) { $hook_title = "%" . $svalue['title'] . "%";
<input type="hidden" name="id_shop" id="sds_rev_id_shop" value="<?php echo Context::getcontext()->shop->id; ?> ">