本文整理汇总了PHP中Citruscart::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Citruscart::getPath方法的具体用法?PHP Citruscart::getPath怎么用?PHP Citruscart::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Citruscart
的用法示例。
在下文中一共展示了Citruscart::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getImage
public static function getImage($id, $by = 'id', $alt = '', $type = 'thumb', $url = false)
{
switch ($type) {
case "full":
$path = 'manufacturers_images';
break;
case "thumb":
default:
$path = 'manufacturers_thumbs';
break;
}
$tmpl = "";
if (strpos($id, '.')) {
// then this is a filename, return the full img tag if file exists, otherwise use a default image
$src = JFile::exists(Citruscart::getPath($path) . '/' . $id) ? Citruscart::getUrl($path) . $id : 'media/citruscart/images/noimage.png';
// if url is true, just return the url of the file and not the whole img tag
$tmpl = $url ? $src : "<img src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' name='" . JText::_($alt) . "' align='center' border='0' >";
} else {
if (!empty($id)) {
// load the item, get the filename, create tmpl
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
$row = JTable::getInstance('Manufacturers', 'CitruscartTable');
$row->load((int) $id);
$id = $row->manufacturer_image;
$src = JFile::exists(Citruscart::getPath($path) . '/' . $row->manufacturer_image) ? Citruscart::getUrl($path) . $id : 'media/citruscart/images/noimage.png';
// if url is true, just return the url of the file and not the whole img tag
$tmpl = $url ? $src : "<img src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' name='" . JText::_($alt) . "' align='center' border='0' >";
}
}
return $tmpl;
}
示例2: CitruscartHelperImage
/**
* Protected! Use the getInstance
*/
protected function CitruscartHelperImage()
{
// Parent Helper Construction
parent::__construct();
$config = Citruscart::getInstance();
// Load default Parameters
$this->product_img_height = $config->get('product_img_height');
$this->product_img_width = $config->get('product_img_width');
$this->category_img_height = $config->get('category_img_height');
$this->category_img_width = $config->get('category_img_width');
$this->manufacturer_img_width = $config->get('manufacturer_img_width');
$this->manufacturer_img_height = $config->get('manufacturer_img_height');
$this->product_img_path = Citruscart::getPath('products_images');
$this->category_img_path = Citruscart::getPath('categories_images');
$this->manufacturer_img_path = Citruscart::getPath('manufacturers_images');
$this->product_thumb_path = Citruscart::getPath('products_thumbs');
$this->category_thumb_path = Citruscart::getPath('categories_thumbs');
$this->manufacturer_thumb_path = Citruscart::getPath('manufacturers_thumbs');
}
示例3: getList
function getList()
{
static $list;
// Only process the list once per request
if (is_array($list)) {
return $list;
}
// Get current path from request
$current = $this->getState('folder');
// If undefined, set to empty
if ($current == 'undefined') {
$current = '';
}
// Initialize variables
if (strlen($current) > 0) {
$basePath = Citruscart::getPath('images') . DS . $current;
} else {
$basePath = Citruscart::getPath('images');
}
$mediaBase = str_replace(DS, '/', Citruscart::getPath('images') . '/');
$images = array();
$folders = array();
$docs = array();
// Get the list of files and folders from the given folder
$fileList = JFolder::files($basePath);
$folderList = JFolder::folders($basePath);
// Iterate over the files if they exist
if ($fileList !== false) {
foreach ($fileList as $file) {
if (is_file($basePath . DS . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
$tmp = new JObject();
$tmp->name = $file;
$tmp->path = str_replace(DS, '/', JPath::clean($basePath . DS . $file));
$tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
$tmp->size = filesize($tmp->path);
$ext = strtolower(JFile::getExt($file));
switch ($ext) {
// Image
case 'jpg':
case 'png':
case 'gif':
case 'xcf':
case 'odg':
case 'bmp':
case 'jpeg':
$info = getimagesize($tmp->path);
$tmp->width = $info[0];
$tmp->height = $info[1];
$tmp->type = $info[2];
$tmp->mime = $info['mime'];
$filesize = MediaHelper::parseSize($tmp->size);
if ($info[0] > 60 || $info[1] > 60) {
$dimensions = MediaHelper::imageResize($info[0], $info[1], 60);
$tmp->width_60 = $dimensions[0];
$tmp->height_60 = $dimensions[1];
} else {
$tmp->width_60 = $tmp->width;
$tmp->height_60 = $tmp->height;
}
if ($info[0] > 16 || $info[1] > 16) {
$dimensions = MediaHelper::imageResize($info[0], $info[1], 16);
$tmp->width_16 = $dimensions[0];
$tmp->height_16 = $dimensions[1];
} else {
$tmp->width_16 = $tmp->width;
$tmp->height_16 = $tmp->height;
}
$images[] = $tmp;
break;
// Non-image document
// Non-image document
default:
$iconfile_32 = JPATH_ADMINISTRATOR . "/components/com_media/images/mime-icon-32/" . $ext . ".png";
if (file_exists($iconfile_32)) {
$tmp->icon_32 = "components/com_media/images/mime-icon-32/" . $ext . ".png";
} else {
$tmp->icon_32 = "components/com_media/images/con_info.png";
}
$iconfile_16 = JPATH_ADMINISTRATOR . "/components/com_media/images/mime-icon-16/" . $ext . ".png";
if (file_exists($iconfile_16)) {
$tmp->icon_16 = "components/com_media/images/mime-icon-16/" . $ext . ".png";
} else {
$tmp->icon_16 = "components/com_media/images/con_info.png";
}
$docs[] = $tmp;
break;
}
}
}
}
// Iterate over the folders if they exist
if ($folderList !== false) {
foreach ($folderList as $folder) {
$tmp = new JObject();
$tmp->name = basename($folder);
$tmp->path = str_replace(DS, '/', JPath::clean($basePath . DS . $folder));
$tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
$count = MediaHelper::countFiles($tmp->path);
$tmp->files = $count[0];
$tmp->folders = $count[1];
//.........这里部分代码省略.........
示例4: Copyright
# com_citruscart - citruscart
# ------------------------------------------------------------------------
# author Citruscart Team - Citruscart http://www.citruscart.com
# copyright Copyright (C) 2014 - 2019 Citruscart.com All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://citruscart.com
# Technical Support: Forum - http://citruscart.com/forum/index.html
-------------------------------------------------------------------------*/
defined('_JEXEC') or die('Restricted access');
$user = JFactory::getUser();
JHtml::_('script', 'media/citruscart/js/citruscart.js', false, false);
JHtml::_('script', 'media/citruscart/js/citruscart_checkout.js', false, false);
JHtml::_('script', 'media/citruscart/js/citruscart_checkout_onepage.js', false, false);
JHtml::_('stylesheet', 'media/citruscart/css/citruscart_checkout_onepage.css');
Citruscart::load('CitruscartHelperImage', 'helpers.image');
$image = CitruscartHelperImage::getLocalizedName("help_tooltip.png", Citruscart::getPath('images'));
$enable_tooltips = Citruscart::getInstance()->get('one_page_checkout_tooltips_enabled', 0);
$display_credits = Citruscart::getInstance()->get('display_credits', '0');
$guest_enabled = Citruscart::getInstance()->get('guest_checkout_enabled', 0);
$this->section = 1;
$js_strings = array('COM_CITRUSCART_UPDATING_PAYMENT_METHODS', 'COM_CITRUSCART_CHECKING_COUPON', 'COM_CITRUSCART_UPDATING_BILLING', 'COM_CITRUSCART_UPDATING_SHIPPING_RATES', 'COM_CITRUSCART_UPDATING_CART', 'COM_CITRUSCART_UPDATING_ADDRESS', 'COM_CITRUSCART_VALIDATING');
CitruscartHelperImage::addJsTranslationStrings($js_strings);
?>
<a name="citruscart-method"></a>
<div id="citruscart_checkout_pane">
<a name="citruscartRegistration" id="citruscartRegistration"></a>
<?php
// login link
if (!$this->user->id) {
示例5: jimport
<?php
echo CitruscartSelect::btbooleanlist('manufacturer_enabled', '', $row->manufacturer_enabled);
?>
</td>
</tr>
<tr>
<td style="width: 100px; text-align: right;" class="key">
<?php
echo JText::_('COM_CITRUSCART_CURRENT_IMAGE');
?>
:
</td>
<td>
<?php
jimport('joomla.filesystem.file');
if (!empty($row->manufacturer_image) && JFile::exists(Citruscart::getPath('manufacturers_images') . DS . $row->manufacturer_image)) {
echo CitruscartUrl::popup(CitruscartHelperManufacturer::getImage($row->manufacturer_id, '', '', 'full', true), CitruscartHelperManufacturer::getImage($row->manufacturer_id), array('update' => false, 'img' => true));
}
?>
<br />
<input type="text" name="manufacturer_image" id="manufacturer_image" value="<?php
echo $row->manufacturer_image;
?>
" size="48" maxlength="250" />
</td>
</tr>
<tr>
<td style="width: 100px; text-align: right;" class="key">
<?php
echo JText::_('COM_CITRUSCART_UPLOAD_NEW_IMAGE');
?>
示例6: jimport
?>
</td>
</tr>
<tr>
<td style="width: 100px; text-align: right;" class="key">
<label for="category_full_image">
<?php
echo JText::_('COM_CITRUSCART_CURRENT_IMAGE');
?>
:
</label>
</td>
<td>
<?php
jimport('joomla.filesystem.file');
if (!empty($row->category_full_image) && JFile::exists(Citruscart::getPath('categories_images') . DS . $row->category_full_image)) {
echo CitruscartUrl::popup(Citruscart::getClass('CitruscartHelperCategory', 'helpers.category')->getImage($row->category_id, '', '', 'full', true), CitruscartHelperCategory::getImage($row->category_id), array('update' => false, 'img' => true));
}
?>
<br />
<input type="text" name="category_full_image" id="category_full_image" size="48" maxlength="250" value="<?php
echo $row->category_full_image;
?>
" />
</td>
</tr>
<tr>
<td style="width: 100px; text-align: right;" class="key">
<label for="category_full_image_new">
<?php
echo JText::_('COM_CITRUSCART_UPLOAD_NEW_IMAGE');
示例7: Copyright
/*------------------------------------------------------------------------
# com_citruscart
# ------------------------------------------------------------------------
# author Citruscart Team - Citruscart http://www.citruscart.com
# copyright Copyright (C) 2014 Citruscart.com All Rights Reserved.
# license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://citruscart.com
# Technical Support: Forum - http://citruscart.com/forum/index.html
-------------------------------------------------------------------------*/
/** ensure this file is being included by a parent file */
defined('_JEXEC') or die('Restricted access');
JHtml::_('script', 'media/citruscart/js/citruscart.js', false, false);
$items = $this->product_relations_data->items;
$form = $this->form;
Citruscart::load('CitruscartHelperImage', 'helpers.image');
$image_addtocart = CitruscartHelperImage::getLocalizedName("addcart.png", Citruscart::getPath('images'));
?>
<form action="<?php
echo JRoute::_($form['action']);
?>
" method="post" class="adminform" name="adminFormChildren" enctype="multipart/form-data" >
<div class="reset"></div>
<div id="product_children">
<div id="product_children_header" class="citruscart_header">
<span><?php
echo JText::_('COM_CITRUSCART_SELECT_THE_ITEMS_TO_ADD_TO_YOUR_CART');
?>
</span>
示例8: view
/**
* Displays a single product
* (non-PHPdoc)
* @see Citruscart/site/CitruscartController#view()
*/
function view()
{
$session = JFactory::getSession();
$app = JFactory::getApplication();
$input = JFactory::getApplication()->input;
$this->display_cartbutton = true;
$input->set('view', $this->get('suffix'));
$model = $this->getModel($this->get('suffix'));
$model->getId();
Citruscart::load('CitruscartHelperUser', 'helpers.user');
$user_id = JFactory::getUser()->id;
$filter_group = CitruscartHelperUser::getUserGroup($user_id, $model->getId());
$model->setState('filter_group', $filter_group);
$model->setState('product.qty', 1);
$model->setState('user.id', $user_id);
$row = $model->getItem(false, false, false);
// use the state
$filter_category = $model->getState('filter_category', $input->getString('filter_category'));
if (empty($filter_category)) {
$categories = Citruscart::getClass('CitruscartHelperProduct', 'helpers.product')->getCategories($row->product_id);
if (!empty($categories)) {
$filter_category = $categories[0];
}
}
$unpublished = false;
if ($row->unpublish_date != JFactory::getDbo()->getNullDate()) {
$unpublished = strtotime($row->unpublish_date) < time();
}
if (!$unpublished && $row->publish_date != JFactory::getDbo()->getNullDate()) {
$unpublished = strtotime($row->publish_date) > time();
}
if (empty($row->product_enabled) || $unpublished) {
$redirect = "index.php?option=com_citruscart&view=products&task=display&filter_category=" . $filter_category;
$redirect = JRoute::_($redirect, false);
$this->message = JText::_('COM_CITRUSCART_CANNOT_VIEW_DISABLED_PRODUCT');
$this->messagetype = 'notice';
$this->setRedirect($redirect, $this->message, $this->messagetype);
return;
}
Citruscart::load('CitruscartArticle', 'library.article');
$product_description = CitruscartArticle::fromString($row->product_description);
$product_description_short = CitruscartArticle::fromString($row->product_description_short);
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
$cmodel = JModelLegacy::getInstance('Categories', 'CitruscartModel');
$cat = $cmodel->getTable();
$cat->load($filter_category);
// if product browsing enabled on detail pages, get surrounding items based on browsing state
$ns = $app->getName() . '::' . 'com.citruscart.products.state';
$session_state = $session->get($ns);
$surrounding = array();
// Only do this if product browsing is enabled on product detail pages
if ($this->defines->get('enable_product_detail_nav') && $session_state) {
$products_model = $this->getModel($this->get('suffix'));
$products_model->emptyState();
foreach ((array) $session_state as $key => $value) {
$products_model->setState($key, $value);
}
$surrounding = $products_model->getSurrounding($model->getId());
}
$view = $this->getView($this->get('suffix'), JFactory::getDocument()->getType());
$view->set('_doTask', true);
$view->assign('row', $row);
$view->assign('surrounding', $surrounding);
// breadcrumb support
$pathway = $app->getPathway();
// does this item have its own itemid? if so, let joomla handle the breadcrumb,
// otherwise, help it out a little bit
$category_itemid = $input->getInt('Itemid', Citruscart::getClass("CitruscartHelperRoute", 'helpers.route')->category($filter_category, true));
if (!($product_itemid = $this->router->findItemid(array('view' => 'products', 'task' => 'view', 'id' => $row->product_id)))) {
$items = Citruscart::getClass("CitruscartHelperCategory", 'helpers.category')->getPathName($filter_category, 'array');
if (!empty($items)) {
// add the categories to the pathway
Citruscart::getClass("CitruscartHelperPathway", 'helpers.pathway')->insertCategories($items, $category_itemid);
}
// add the item being viewed to the pathway
$pathway->addItem($row->product_name);
}
$cat->itemid = $category_itemid;
$view->assign('cat', $cat);
// Check If the inventroy is set then it will go for the inventory product quantities
if ($row->product_check_inventory) {
$inventoryList = Citruscart::getClass('CitruscartHelperProduct', 'helpers.product')->getProductQuantities($row->product_id);
if (!Citruscart::getInstance()->get('display_out_of_stock') && empty($inventoryList)) {
// redirect
$redirect = "index.php?option=com_citruscart&view=products&task=display&filter_category=" . $filter_category;
$redirect = JRoute::_($redirect, false);
$this->message = JText::_('COM_CITRUSCART_CANNOT_VIEW_PRODUCT');
$this->messagetype = 'notice';
$this->setRedirect($redirect, $this->message, $this->messagetype);
return;
}
// if there is no entry of product in the productquantities
if (count($inventoryList) == 0) {
$inventoryList[''] = '0';
}
//.........这里部分代码省略.........
示例9: getImageUrl
/**
* Get the URL to the path to images
* @return unknown_type
*/
function getImageUrl()
{
// Check where we should upload the file
// This is the default one
$dir = Citruscart::getPath('products_images');
$url = Citruscart::getUrl('products_images');
$helper = CitruscartHelperBase::getInstance();
// is the image path overridden?
if (!empty($this->product_images_path) && $helper->checkDirectory($this->product_images_path, false)) {
$url = str_replace(JPATH_SITE . DIRECTORY_SEPARATOR, JURI::root(), $this->product_images_path);
} else {
// try with the SKU
if (Citruscart::getInstance()->get('sha1_images', '0')) {
if (!empty($this->product_sku)) {
$subdirs = $this->getSha1Subfolders($this->product_sku, '/');
$image_dir = $url . $subdirs . $this->product_sku . '/';
}
} else {
$image_dir = $url . $this->product_sku . '/';
}
// try with the SKU
if (!empty($this->product_sku)) {
$url = $image_dir;
} else {
if (Citruscart::getInstance()->get('sha1_images', '0')) {
$subdirs = $this->getSha1Subfolders($this->product_id, '/');
$image_dir = $url . $subdirs . $this->product_id . '/';
} else {
$image_dir = $url . $this->product_id . '/';
}
$url = $image_dir;
}
}
return $url;
}
示例10: display
function display()
{
$mainframe = JFactory::getApplication();
// Initialize variables
$db = JFactory::getDBO();
$nullDate = $db->getNullDate();
$document = JFactory::getDocument();
$document->setTitle('Image Selection');
JHTML::_('behavior.modal');
$template = $mainframe->getTemplate();
$document->addStyleSheet("templates/{$template}/css/general.css");
$app = JFactory::getApplication();
$append = '';
if ($app->getClientId() == 1) {
$append = 'administrator/';
}
JHTML::_('script', 'popup-imagemanager.js', $append . 'components/com_media/assets/');
JHTML::_('stylesheet', 'popup-imagemanager.css', $append . 'components/com_media/assets/');
$limitstart = JRequest::getVar('limitstart', '0', '', 'int');
$lists = $this->_getLists();
$rows = $this->get('List');
$page = $this->get('Pagination');
JHTML::_('behavior.tooltip');
$config = JComponentHelper::getParams('com_media');
/*
* Display form for FTP credentials?
* Don't set them here, as there are other functions called before this one if there is any file write operation
*/
jimport('joomla.client.helper');
$ftp = !JClientHelper::hasCredentials('ftp');
//$model = JModelLegacy::getInstance('ElementImage', 'CitruscartModel');
$this->assign('session', JFactory::getSession());
$this->assign('config', $config);
$this->assign('state', $this->get('state'));
$this->assign('folderList', $this->get('folderList'));
$this->assign('require_ftp', $ftp);
$object = JRequest::getVar('object');
$link = 'index.php?option=com_citruscart&task=elementImage&tmpl=component&object=' . $object;
?>
<script type='text/javascript'>
var image_base_path = '<?php
echo Citruscart::getPath('images');
?>
/';
</script>
<form action="<?php
echo $link;
?>
" id="imageForm" method="post" enctype="multipart/form-data">
<div id="messages" style="display: none;">
<span id="message"></span><img src="<?php
echo JURI::base();
?>
components/com_media/images/dots.gif" width="22" height="12" alt="..." />
</div>
<fieldset>
<div style="float: left">
<label for="folder"><?php
echo JText::_('COM_CITRUSCART_DIRECTORY');
?>
</label>
<?php
echo $this->folderList;
?>
<button type="button" id="upbutton" title="<?php
echo JText::_('COM_CITRUSCART_DIRECTORY_UP');
?>
"><?php
echo JText::_('COM_CITRUSCART_UP');
?>
</button>
</div>
<div style="float: right">
<button type="button" onclick="ImageManager.onok();window.parent.document.getElementById('sbox-window').close();"><?php
echo JText::_('COM_CITRUSCART_INSERT');
?>
</button>
<button type="button" onclick="window.parent.document.getElementById('sbox-window').close();"><?php
echo JText::_('COM_CITRUSCART_CANCEL');
?>
</button>
</div>
</fieldset>
<iframe id="imageframe" name="imageframe" src="index.php?option=com_media&view=imagesList&tmpl=component&folder=<?php
echo $this->state->folder;
?>
"></iframe>
<fieldset>
<table class="properties">
<tr>
<td><label for="f_url"><?php
echo JText::_('COM_CITRUSCART_IMAGE_URL');
?>
</label></td>
<td><input type="text" id="f_url" value="" /></td>
<td><label for="f_align"><?php
echo JText::_('COM_CITRUSCART_ALIGN');
?>
</label></td>
//.........这里部分代码省略.........
示例11: addfile
/**
* Uploads a file to associate to an item
*
* @return unknown_type
*/
function addfile($fieldname = 'createproductfile_file', $path = 'products_files')
{
Citruscart::load('CitruscartFile', 'library.file');
$upload = new CitruscartFile();
// handle upload creates upload object properties
$upload->handleUpload($fieldname);
// then save image to appropriate folder
if ($path == 'products_files') {
$path = Citruscart::getPath('products_files');
}
$upload->setDirectory($path);
$dest = $upload->getDirectory() . DS . $upload->getPhysicalName();
// delete the file if dest exists
if ($fileexists = JFile::exists($dest)) {
JFile::delete($dest);
}
// save path and filename or just filename
if (!JFile::upload($upload->file_path, $dest)) {
$this->setError(sprintf(JText::_('COM_CITRUSCART_MOVE_FAILED_FROM'), $upload->file_path, $dest));
return false;
}
$upload->full_path = $dest;
return $upload;
}
示例12: _migrateImages
//.........这里部分代码省略.........
}
if ($check) {
if ($internal) {
$img = new CitruscartImage($vm_image_path . $result['image']);
} else {
$tmp_path = JFactory::getApplication()->getCfg('tmp_path');
$file = fopen($vm_image_path . $result['image'], 'r');
$file_content = stream_get_contents($file);
fclose($file);
$file = fopen($tmp_path . DIRECTORY_SEPARATOR . $result['image'], 'w');
fwrite($file, $file_content);
fclose($file);
$img = new CitruscartImage($tmp_path . DS . $result['image']);
}
Citruscart::load('CitruscartTableProducts', 'tables.products');
$product = JTable::getInstance('Products', 'CitruscartTable');
$product->load($result['id']);
$path = $product->getImagePath();
$type = $img->getExtension();
$img->load();
$name = $img->getPhysicalName();
// Save full Image
if (!$img->save($path . $name)) {
$results[$n]->error .= '::Could not Save Product Image- From: ' . $vm_image_path . $result['image'] . ' To: ' . $path . $result['image'];
}
$img->setDirectory($path);
// Save Thumb
Citruscart::load('CitruscartHelperImage', 'helpers.image');
$imgHelper = CitruscartHelperBase::getInstance('Image', 'CitruscartHelper');
if (!$imgHelper->resizeImage($img, 'product')) {
$results[$n]->error .= '::Could not Save Product Thumb';
}
// Save correct image naming
$product->product_full_image = $name;
$product->save();
$results[$n]->affectedRows++;
}
}
$n++;
// CATEGORIES
// Fetch the VM full image
$query = "SELECT category_id as id, category_full_image as image FROM {$p}category";
$db->setQuery($query);
$products = $db->loadAssocList();
Citruscart::load('CitruscartImage', 'library.image');
if ($internal) {
$vm_image_path = JPATH_SITE . "/components/com_virtuemart/shop_image/category/";
} else {
$state = $this->_getState();
$url = $state->external_site_url;
$vm_image_path = $url . "/components/com_virtuemart/shop_image/category/";
}
$results[$n]->title = 'Category Images';
$results[$n]->query = 'Copy Category Images & Resize';
$results[$n]->error = '';
$results[$n]->affectedRows = 0;
foreach ($products as $result) {
$check = false;
if ($internal) {
$check = JFile::exists($vm_image_path . $result['image']);
} else {
$check = $this->url_exists($vm_image_path) && $result['image'];
}
if ($check) {
if ($internal) {
$img = new CitruscartImage($vm_image_path . $result['image']);
} else {
$tmp_path = JFactory::getApplication()->getCfg('tmp_path');
$file = fopen($vm_image_path . $result['image'], 'r');
$file_content = stream_get_contents($file);
fclose($file);
$file = fopen($tmp_path . DS . $result['image'], 'w');
fwrite($file, $file_content);
fclose($file);
$img = new CitruscartImage($tmp_path . DS . $result['image']);
}
$img->load();
$path = Citruscart::getPath('categories_images') . DS;
$name = $img->getPhysicalName();
// Save full Image
if (!$img->save($path . $name)) {
$results[$n]->error .= '::Could not Save Category Image - From: ' . $vm_image_path . $result['image'] . ' To: ' . $path . $result['image'];
}
$img->setDirectory($path);
// Save Thumb
Citruscart::load('CitruscartHelperImage', 'helpers.image');
$imgHelper = CitruscartHelperBase::getInstance('Image', 'CitruscartHelper');
if (!$imgHelper->resizeImage($img, 'category')) {
$results[$n]->error .= '::Could not Save Category Thumb';
}
// Save correct image name
Citruscart::load('CitruscartTableCategories', 'tables.categories');
$category = JTable::getInstance('Categories', 'CitruscartTable');
$category->load($result['id']);
$category->category_full_image = $name;
$category->save();
$results[$n]->affectedRows++;
}
}
}
示例13: getImage
/**
* Gets a category's image
*
* @param $id
* @param $by
* @param $alt
* @param $type
* @param $url
* @return unknown_type
*/
public static function getImage($id, $by = 'id', $alt = '', $type = 'thumb', $url = false)
{
$app = JFactory::getApplication();
switch ($type) {
case "full":
$path = 'categories_images';
break;
case "thumb":
default:
if ($app->isSite()) {
$path = "categories_images";
} else {
$path = 'categories_thumbs';
}
break;
}
$tmpl = "";
if (!empty($id) && is_numeric($id) && strpos($id, '.') === false) {
$model = Citruscart::getClass('CitruscartModelCategories', 'models.categories');
$item = $model->getItem((int) $id);
$full_image = !empty($item->category_full_image) ? $item->category_full_image : null;
if (filter_var($full_image, FILTER_VALIDATE_URL) !== false) {
// $full_image contains a valid URL
$src = $full_image;
} elseif (JFile::exists(Citruscart::getPath($path) . "/" . $full_image)) {
$src = Citruscart::getUrl($path) . $full_image;
} else {
$src = JURI::root(true) . '/media/citruscart/images/placeholder_239.gif';
}
if ($url) {
return $src;
} elseif (!empty($src)) {
$tmpl = "<img src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "'/>";
}
return $tmpl;
}
if (strpos($id, '.')) {
// then this is a filename, return the full img tag if file exists, otherwise use a default image
$src = JFile::exists(Citruscart::getPath($path) . '/' . $id) ? Citruscart::getUrl($path) . $id : JURI::root(true) . '/media/citruscart/images/placeholder_239.gif';
// if url is true, just return the url of the file and not the whole img tag
$tmpl = $url ? $src : "<img src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' />";
}
return $tmpl;
}
示例14: recreateThumbs
/**
* Batch resize of thumbs
* @author Skullbock
*/
function recreateThumbs()
{
$app = JFactory::getApplication();
$per_step = 100;
$from_id = $app->input->getInt('from_id', 0);
$to = $from_id + $per_step;
Citruscart::load('CitruscartHelperManufacturer', 'helpers.manufacturer');
Citruscart::load('CitruscartImage', 'library.image');
$width = Citruscart::getInstance()->get('manufacturer_img_width', '0');
$height = Citruscart::getInstance()->get('manufacturer_img_height', '0');
$model = $this->getModel('Manufacturers', 'CitruscartModel');
$model->setState('limistart', $from_id);
$model->setState('limit', $to);
$row = $model->getTable();
$count = $model->getTotal();
$manufacturers = $model->getList();
$i = 0;
$last_id = $from_id;
foreach ($manufacturers as $p) {
$i++;
$image = $p->manufacturer_full_image;
if ($image != '') {
$img = new CitruscartImage($image, 'manufacturer');
$img->setDirectory(Citruscart::getPath('manufacturers_images'));
// Thumb
Citruscart::load('CitruscartHelperImage', 'helpers.image');
$imgHelper = CitruscartHelperBase::getInstance('Image', 'CitruscartHelper');
$imgHelper->resizeImage($img, 'manufacturer');
}
$last_id = $p->manufacturer_id;
}
if ($i < $count) {
$redirect = "index.php?option=com_citruscart&controller=manufacturers&task=recreateThumbs&from_id=" . ($last_id + 1);
} else {
$redirect = "index.php?option=com_citruscart&view=config";
}
$redirect = JRoute::_($redirect, false);
$this->setRedirect($redirect, JText::_('COM_CITRUSCART_DONE'), 'notice');
return;
}
示例15: foreach
?>
</span>
</div> -->
<?php
$i = 1;
?>
<ul class="citruscart_product_gallery_thumb" id="citruscart-product-gallery-list<?php
$product_id;
?>
">
<?php
foreach ($gallery_data->images as $image) {
?>
<?php
$src = $gallery_data->uri . $image;
if (JFile::exists(Citruscart::getPath('products_thumbs') . DS . $image)) {
$src = $gallery_data->uri . "thumbs/" . $image;
}
$product_image = $gallery_data->uri . "/" . $image;
$id = "citruscart_alt_image" . $product_id . "_" . $i;
$alt_id = "citruscart_product_image_alt" . $product_id . "_" . $i;
$onclick = "changeAltImage('/ {$i} /')";
?>
<li class="zoom_gallery">
<a href="#" data-image="<?php
echo JRoute::_($src);
?>
" >
<!-- id="citruscart_alt_image<?php
echo $i;
?>