function getCache() { if (count($this->_files) == 0 && $this->_text == '') { return false; } if ($this->_cacheTime == 'static' || $this->_cacheTime == 0) { $folder = $this->_path . 'static' . DIRECTORY_SEPARATOR; $currentcachetime = 0; } else { $time = time(); $currentcachetime = $time - $time % $this->_cacheTime; $folder = $this->_path . $this->_prename . $currentcachetime . DIRECTORY_SEPARATOR; } $this->createCacheSubFolder($folder, $currentcachetime); $hash = $this->createHash(); $cachefile = $folder . $hash . '.' . $this->_filetype; $cachefilegzip = $folder . $hash . '.php'; if (!NextendFilesystem::existsFile($cachefile)) { $cached = "/* " . date('l jS \\of F Y h:i:s A') . "*/\n\n"; for ($i = 0; $i < count($this->_files); $i++) { $cached .= $this->parseFile(NextendFilesystem::readFile($this->_files[$i]), $this->_files[$i], $i); } $cached .= $this->_text; NextendFilesystem::createFile($cachefile, $this->parseCached($cached)); if ($this->_gzip) { $php = '<?php ' . $this->getgzipHeader($currentcachetime) . 'if (extension_loaded("zlib") && (ini_get("output_handler") != "ob_gzhandler")) {' . 'ini_set("zlib.output_compression", 1);' . '}' . 'readfile("' . str_replace('\\', '/', $cachefile) . '");'; NextendFilesystem::createFile($cachefilegzip, $php); } } if ($this->_gzip) { return NextendFilesystem::pathToAbsoluteURL($cachefilegzip); } return NextendFilesystem::pathToAbsoluteURL($cachefile); }
function makeUrl($matches) { if (substr($matches[1], 0, 5) == 'data:') { return $matches[0]; } if (substr($matches[1], 0, 4) == 'http') { return $matches[0]; } if (substr($matches[1], 0, 2) == '//') { return $matches[0]; } return 'url(' . str_replace(array('http://', 'https://'), '//', NextendFilesystem::pathToAbsoluteURL(dirname($this->path))) . '/' . $matches[1] . ')'; }
function getData($number) { nextendimport('nextend.database.database'); $db = NextendDatabase::getInstance(); $data = array(); require_once JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php'; $config = MijoShop::get('opencart')->get('config'); $currency = MijoShop::get('opencart')->get('currency'); if (MijoShop::get('base')->isAdmin('joomla')) { global $vqmod; if (empty($vqmod)) { require_once JPATH_MIJOSHOP_OC . '/vqmod/vqmod.php'; $vqmod = new VQMod(); } require_once $vqmod->modCheck(DIR_SYSTEM . 'library/tax.php'); MijoShopOpencart::$tax = new Tax(MijoShopOpencart::$registry); MijoShopOpencart::$registry->set('tax', MijoShopOpencart::$tax); } $tax = MijoShop::get('opencart')->get('tax'); $router = MijoShop::get('router'); $language_id = intval($this->_data->get('mijoshopproductssourcelanguage')); if (!$language_id) { $language_id = intval($config->get('config_language_id')); } $tmpLng = $config->get('config_language_id'); $config->set('config_language_id', $language_id); MijoShopOpencart::$loader->model('catalog/product'); $p = new ModelCatalogProduct(MijoShopOpencart::$registry); $query = 'SELECT '; $query .= 'p.product_id '; $query .= 'FROM #__mijoshop_product AS p '; $query .= 'LEFT JOIN #__mijoshop_product_description AS pc USING(product_id) '; $query .= 'LEFT JOIN #__mijoshop_product_to_category AS ptc USING(product_id) '; $query .= 'LEFT JOIN #__mijoshop_product_special AS ps USING(product_id) '; $where = array(); $category = array_map('intval', explode('||', $this->_data->get('mijoshopproductssourcecategory', ''))); if (!in_array(0, $category) && count($category) > 0) { $where[] = 'ptc.category_id IN (' . implode(',', $category) . ') '; } if ($this->_data->get('mijoshopproductssourcepublished', 1)) { $where[] = ' p.status = 1 '; } if ($this->_data->get('mijoshopproductssourcespecial', 0)) { $where[] = ' ps.price IS NOT NULL'; $jnow = JFactory::getDate(); $now = version_compare(JVERSION, '1.6.0', '<') ? $jnow->toMySQL() : $jnow->toSql(); $where[] = ' (ps.date_start = "0000-00-00" OR ps.date_start < \'' . $now . '\')'; $where[] = ' (ps.date_end = "0000-00-00" OR ps.date_end > \'' . $now . '\')'; } if ($this->_data->get('mijoshopproductssourceinstock', 0)) { $where[] = ' p.quantity > 0 '; } $where[] = ' pc.language_id = ' . $language_id; if (count($where) > 0) { $query .= 'WHERE ' . implode(' AND ', $where) . ' '; } $query .= 'GROUP BY p.product_id '; $order = NextendParse::parse($this->_data->get('mijoshopproductsorder1', 'pc.name|*|asc')); if ($order[0]) { $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' '; $order = NextendParse::parse($this->_data->get('mijoshopproductsorder2', '|*|asc')); if ($order[0]) { $query .= ', ' . $order[0] . ' ' . $order[1] . ' '; } } $query .= 'LIMIT 0, ' . $number; $db->setQuery($query); $result = $db->loadAssocList(); for ($i = 0; $i < count($result); $i++) { $pi = $p->getProduct($result[$i]['product_id']); $data[$i] = array(); $data[$i]['title'] = $data[$i]['name'] = $pi['name']; $data[$i]['short_description'] = $pi['description']; $data[$i]['model'] = $pi['model']; $data[$i]['sku'] = $pi['sku']; $data[$i]['quantity'] = $pi['quantity']; $data[$i]['manufacturer'] = $pi['manufacturer']; $data[$i]['rating'] = $pi['rating']; $data[$i]['price'] = $currency->format($tax->calculate($pi['price'], $pi['tax_class_id'], $config->get('config_tax'))); if ((double) $product_info['special']) { $data[$i]['special_price'] = $currency->format($tax->calculate($pi['special'], $pi['tax_class_id'], $config->get('config_tax'))); } else { $data[$i]['special_price'] = ''; } if ($config->get('config_tax')) { $data[$i]['price_ex_tax'] = $currency->format((double) $pi['special'] ? $pi['special'] : $pi['price']); } $data[$i]['thumbnail'] = $data[$i]['image'] = NextendFilesystem::pathToAbsoluteURL(DIR_IMAGE) . $pi['image']; $data[$i]['addtocart'] = $data[$i]['url'] = $router->route('index.php?option=com_mijoshop&route=product/product&product_id=' . $pi['product_id']); $data[$i]['addtocart_label'] = 'View product'; $data[$i]['category_name'] = 'Not available'; $data[$i]['category_url'] = '#'; } $config->set('config_language_id', $tmpLng); return $data; }
function resizeImage($imageurl, $width, $height, $mode = 'cover', $resizeremote = false) { $originalimageurl = $imageurl; if ($width > 0 && $height > 0 && function_exists('exif_imagetype') && function_exists('imagecreatefrompng')) { $extra = array(); if (substr($imageurl, 0, 2) == '//') { $imageurl = parse_url(NextendUri::getBaseuri(), PHP_URL_SCHEME) . ':' . $imageurl; } $imageurl = NextendUri::relativetoabsolute($imageurl); $imagepath = NextendFilesystem::absoluteURLToPath($imageurl); if ($imagepath == $imageurl) { if (!$resizeremote) { return $originalimageurl; } $imagepath = parse_url($imageurl, PHP_URL_PATH); } else { $extra[] = @filemtime($imagepath); $imageurl = $imagepath; } $extension = strtolower(pathinfo($imagepath, PATHINFO_EXTENSION)); $filetype = ''; if ($extension == 'png') { $filetype = 'png'; } else { if ($extension == 'jpg' || $extension == 'jpeg') { $filetype = 'jpg'; } } if ($filetype != '') { $hash = $this->createHashFromArray(array_merge(func_get_args(), $this->backgrouncolor, $extra)); $cachefile = $this->_folder . $hash . '.' . $filetype; if (!NextendFilesystem::existsFile($cachefile)) { $imagetype = @exif_imagetype($imageurl); if ($imagetype) { if ($imagetype == IMAGETYPE_PNG) { $filetype = 'png'; } else { if ($imagetype == IMAGETYPE_JPEG) { $filetype = 'jpg'; } else { $filetype = ''; } } if ($filetype) { $img = null; $rotated = null; if ($filetype == 'png') { $img = @imagecreatefrompng($imageurl); } else { if ($filetype == 'jpg') { $img = @imagecreatefromjpeg($imageurl); if (function_exists("exif_read_data")) { $exif = exif_read_data($imageurl); if ($exif && !empty($exif['Orientation'])) { switch ($exif['Orientation']) { case 3: $rotated = imagerotate($img, 180, 0); break; case 6: $rotated = imagerotate($img, -90, 0); break; case 8: $rotated = imagerotate($img, 90, 0); break; } } if ($rotated) { imagedestroy($img); $img = $rotated; } } } } if ($img) { $owidth = imagesx($img); $oheight = imagesy($img); if ($rotated || $owidth != $width || $oheight != $height) { $image = imagecreatetruecolor($width, $height); if ($filetype == 'png') { imagesavealpha($image, true); imagealphablending($image, false); $white = imagecolorallocatealpha($image, 255, 255, 255, 127); imagefilledrectangle($image, 0, 0, $width, $height, $white); } else { if ($filetype == 'jpg') { $bg = imagecolorallocate($image, $this->backgrouncolor[0], $this->backgrouncolor[1], $this->backgrouncolor[2]); imagefilledrectangle($image, 0, 0, $width, $height, $bg); } } $dst_x = 0; $dst_y = 0; $src_x = 0; $src_y = 0; $dst_w = $width; $dst_h = $height; $src_w = $owidth; $src_h = $oheight; $horizontalRatio = $width / $owidth; $verticalRatio = $height / $oheight; if ($mode == 'cover') { if ($horizontalRatio > $verticalRatio) { $new_h = $horizontalRatio * $oheight; $dst_y = ($height - $new_h) / 2; $dst_h = $new_h; } else { $new_w = $verticalRatio * $owidth; $dst_x = ($width - $new_w) / 2; $dst_w = $new_w; } } else { if ($mode == 'contain') { if ($horizontalRatio < $verticalRatio) { $new_h = $horizontalRatio * $oheight; $dst_y = ($height - $new_h) / 2; $dst_h = $new_h; } else { $new_w = $verticalRatio * $owidth; $dst_x = ($width - $new_w) / 2; $dst_w = $new_w; } } } imagecopyresampled($image, $img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); imagedestroy($img); if ($filetype == 'png') { imagepng($image, $cachefile); } else { if ($filetype == 'jpg') { imagejpeg($image, $cachefile, 100); } } imagedestroy($image); return NextendFilesystem::pathToAbsoluteURL($cachefile); } else { imagedestroy($img); } } } } } else { return NextendFilesystem::pathToAbsoluteURL($cachefile); } } } return $originalimageurl; }
function resizeImage($image, $w, $h) { $w = intval($w); $h = intval($h); $cachefile = $this->_folder . 'resize' . md5($image) . $w . '_' . $h . '.' . $this->_filetype; if (!NextendFilesystem::existsFile($cachefile)) { if ($image && $w >= 1 && $h >= 1) { if (strpos($image, 'http') === 0) { //url } else { if (!NextendFilesystem::existsFile($image)) { $image = NextendFilesystem::getBasePath() . $image; } } if (is_readable($image)) { $orig = null; switch (exif_imagetype($image)) { case IMAGETYPE_JPEG: $orig = imagecreatefromjpeg($image); break; case IMAGETYPE_PNG: $orig = imagecreatefrompng($image); break; } if ($orig) { $this->createIm($w, $h); $ow = imagesx($orig); $oh = imagesy($orig); $ratioX = $ow / $w; $ratioY = $oh / $h; if ($ratioX > $ratioY) { $ow = $ratioY * $w; } else { $oh = $ratioX * $h; } imagecopyresampled($this->_im, $orig, 0, 0, 0, 0, $w, $h, $ow, $oh); $this->saveIm($cachefile); imagedestroy($orig); return NextendFilesystem::pathToAbsoluteURL($cachefile); } } else { return $image; } } else { return $image; } } return NextendFilesystem::pathToAbsoluteURL($cachefile); }
function parseFile($content, $path, $i) { return preg_replace('#url\\([\'"]([^"\'\\)]+)[\'"]\\)#', 'url(' . NextendFilesystem::pathToAbsoluteURL(dirname($path)) . '/$1)', $content); }
function generateAjaxCSS($loadedCSS) { $css = ''; if (count($this->_cssFiles)) { $lesscache = $this->_lesscache; foreach ($this->_cssFiles as $k => $file) { if (!in_array($k, $loadedCSS)) { if (is_array($file)) { $lesscache->addContext($file[1], $file[2]); } else { $css .= preg_replace('#url\\([\'"]([^"\'\\)]+)[\'"]\\)#', 'url(' . NextendFilesystem::pathToAbsoluteURL(dirname($k)) . '/$1)', NextendFilesystem::readFile($k)); } } } if ($lesscache) { $filename = $lesscache->getCache(); if ($filename) { $lessfile = NextendFilesystem::absoluteURLToPath($lesscache->getCache()); $css .= preg_replace('#url\\([\'"]([^"\'\\)]+)[\'"]\\)#', 'url(' . NextendFilesystem::pathToAbsoluteURL(dirname($lessfile)) . '/$1)', NextendFilesystem::readFile($lessfile)); } } } $css .= $this->_css; return $css; }
function generateCSS() { if (class_exists('NextendFontsGoogle')) { $fonts = NextendFontsGoogle::getInstance(); $fonts->generateFonts(); } if (count($this->_cssFiles)) { foreach ($this->_cssFiles as $file) { if (is_array($file)) { // LESS $this->_lesscache->addContext($file[1], $file[2]); } else { if (substr($file, 0, 4) == 'http') { $this->serveCSSFile($file); } else { if ($this->_cacheenabled) { $this->_cache->addFile($file); } else { $url = NextendFilesystem::pathToAbsoluteURL($file); $this->serveCSSFile($url); } } } } } if ($this->_cacheenabled) { if ($this->_lesscache) { $this->_cache->addFile(NextendFilesystem::absoluteURLToPath($this->_lesscache->getCache())); } $this->serveCSSFile($this->_cache->getCache()); } else { if ($this->_lesscache) { $this->serveCSSFile($this->_lesscache->getCache()); } } $this->serveCSS(); }
function lessColorizeimage(&$arg) { if (isset($arg[2])) { $arg =& $arg[2]; if (isset($arg[0])) { $colorize = $this->getFromEscapedArgs($arg[0]); } if (isset($arg[1])) { $image = $this->getFromEscapedArgs($arg[1]); if ($image == '-1') { return 'none'; } } if (isset($arg[2])) { $color = $this->getFromEscapedArgs($arg[2]); } $url = ''; if ($colorize == 0) { $url = NextendFilesystem::pathToAbsoluteURL(NextendFilesystem::getBasePath() . $image); } else { if (realpath($image) !== false) { $image = realpath($image); } else { $image = NextendFilesystem::getBasePath() . $image; } $url = $this->colorizeImage($image, $color, '548722'); } return $this->url($url); } }