本文整理汇总了PHP中Tienda::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Tienda::getPath方法的具体用法?PHP Tienda::getPath怎么用?PHP Tienda::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tienda
的用法示例。
在下文中一共展示了Tienda::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(Tienda::getPath($path) . DS . $id) ? Tienda::getUrl($path) . $id : 'media/com_tienda/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_tienda/tables');
$row = JTable::getInstance('Manufacturers', 'TiendaTable');
$row->load((int) $id);
$id = $row->manufacturer_image;
$src = JFile::exists(Tienda::getPath($path) . DS . $row->manufacturer_image) ? Tienda::getUrl($path) . $id : 'media/com_tienda/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: TiendaHelperImage
/**
* Protected! Use the getInstance
*/
protected function TiendaHelperImage()
{
// Parent Helper Construction
parent::__construct();
$config = Tienda::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 = Tienda::getPath('products_images');
$this->category_img_path = Tienda::getPath('categories_images');
$this->manufacturer_img_path = Tienda::getPath('manufacturers_images');
$this->product_thumb_path = Tienda::getPath('products_thumbs');
$this->category_thumb_path = Tienda::getPath('categories_thumbs');
$this->manufacturer_thumb_path = Tienda::getPath('manufacturers_thumbs');
}
示例3: display
//.........这里部分代码省略.........
</th>
<th class="title"><?php
echo JText::_('COM_TIENDA_QTY');
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15"><?php
echo $page->getListFooter();
?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$k = 0;
for ($i = 0, $n = count($rows); $i < $n; $i++) {
$row =& $rows[$i];
$onclick = "\r\n\t\t\t\t\twindow.parent.jSelectProducts(\r\n\t\t\t\t\t'{$row->product_id}', '" . str_replace(array("'", "\""), array("\\'", ""), $row->product_name) . "', '" . JRequest::getVar('object') . "'\r\n\t\t\t\t\t);";
?>
<tr class="<?php
echo "row{$k}";
?>
">
<td><?php
echo $page->getRowOffset($i);
?>
</td>
<td style="text-align: center;"><?php
echo TiendaGrid::checkedout($row, $i, 'product_id');
?>
</td>
<td style="text-align: center;"><a style="cursor: pointer;"
onclick="<?php
echo $onclick;
?>
"> <?php
echo $row->product_id;
?>
</a>
</td>
<td>
<?php
jimport('joomla.filesystem.file');
if (!empty($row->product_thumb_image) && JFile::exists(Tienda::getPath('products_thumbs') . DS . $row->product_thumb_image)) {
?>
<img src="<?php
echo Tienda::getURL('products_thumbs') . $row->product_thumb_image;
?>
" style="display: block;" />
<?php
}
?>
</td>
<td><a style="cursor: pointer;"
onclick="<?php
echo $onclick;
?>
"> <?php
echo htmlspecialchars($row->product_name, ENT_QUOTES, 'UTF-8');
?>
</a></td>
<td style="text-align: center;"><a style="cursor: pointer;"
onclick="<?php
echo $onclick;
?>
"> <?php
echo $row->product_price;
?>
</a></td>
<td style="text-align: center;"><input id="<?php
echo "qty{$i}";
?>
" name="<?php
echo "qty{$i}";
?>
" type="text" value="1" style="width: 30px;" /></td>
</tr>
<?php
$k = 1 - $k;
}
?>
</tbody>
</table>
<input type="hidden" name="boxchecked" value="0" /> <input type="hidden"
name="filter_order" value="<?php
echo $lists['order'];
?>
" /> <input
type="hidden" name="filter_order_Dir"
value="<?php
echo $lists['order_Dir'];
?>
" /></form>
<?php
}
示例4: 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)
{
switch ($type) {
case "full":
$path = 'categories_images';
break;
case "thumb":
default:
$path = 'categories_thumbs';
break;
}
$tmpl = "";
if (!empty($id) && is_numeric($id) && strpos($id, '.') === false) {
$model = Tienda::getClass('TiendaModelCategories', '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(Tienda::getPath($path) . "/" . $full_image)) {
$src = Tienda::getUrl($path) . $full_image;
} else {
$src = JURI::root(true) . '/media/com_tienda/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(Tienda::getPath($path) . DS . $id) ? Tienda::getUrl($path) . $id : JURI::root(true) . '/media/com_tienda/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;
}
示例5: 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 = Tienda::getPath('products_images');
$url = Tienda::getUrl('products_images');
$helper = TiendaHelperBase::getInstance();
// is the image path overridden?
if (!empty($this->product_images_path) && $helper->checkDirectory($this->product_images_path, false)) {
$url = str_replace(JPATH_SITE . DS, JURI::root(), $this->product_images_path);
} else {
// try with the SKU
if (Tienda::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 (Tienda::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;
}
示例6: _migrateImages
//.........这里部分代码省略.........
}
if ($check) {
if ($internal) {
$img = new TiendaImage($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 TiendaImage($tmp_path . DS . $result['image']);
}
Tienda::load('TiendaTableProducts', 'tables.products');
$product = JTable::getInstance('Products', 'TiendaTable');
$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
Tienda::load('TiendaHelperImage', 'helpers.image');
$imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper');
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();
Tienda::load('TiendaImage', '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 TiendaImage($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 TiendaImage($tmp_path . DS . $result['image']);
}
$img->load();
$path = Tienda::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
Tienda::load('TiendaHelperImage', 'helpers.image');
$imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper');
if (!$imgHelper->resizeImage($img, 'category')) {
$results[$n]->error .= '::Could not Save Category Thumb';
}
// Save correct image name
Tienda::load('TiendaTableCategories', 'tables.categories');
$category = JTable::getInstance('Categories', 'TiendaTable');
$category->load($result['id']);
$category->category_full_image = $name;
$category->save();
$results[$n]->affectedRows++;
}
}
}
示例7: jimport
<?php
echo TiendaGrid::boolean($row->product_enabled);
?>
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<?php
echo JText::_('COM_TIENDA_CURRENT_IMAGE');
?>
:
</td>
<td>
<?php
jimport('joomla.filesystem.file');
if (!empty($row->product_full_image) && JFile::exists(Tienda::getPath('products_images') . DS . $row->product_full_image)) {
?>
<img src="<?php
echo Tienda::getURL('products_images') . $row->product_full_image;
?>
" style="display: block;" />
<?php
}
?>
</td>
</tr>
</table>
</fieldset>
<?php
$modules = JModuleHelper::getModules("tienda_product_dashboard_main");
示例8: defined
<?php
defined('_JEXEC') or die('Restricted access');
JHTML::_('script', 'tienda.js', 'media/com_tienda/js/');
$items = @$this->product_relations_data->items;
$form = @$this->form;
Tienda::load('TiendaHelperImage', 'helpers.image');
$image_addtocart = TiendaHelperImage::getLocalizedName("addcart.png", Tienda::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="tienda_header">
<span><?php
echo JText::_('COM_TIENDA_SELECT_THE_ITEMS_TO_ADD_TO_YOUR_CART');
?>
</span>
</div>
<table class="adminlist">
<thead>
<tr>
<th>
</th>
示例9: 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 = Tienda::getPath('images') . DS . $current;
} else {
$basePath = Tienda::getPath('images');
}
$mediaBase = str_replace(DS, '/', Tienda::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];
//.........这里部分代码省略.........
示例10: view
/**
* Displays a single product
* (non-PHPdoc)
* @see tienda/site/TiendaController#view()
*/
function view()
{
$this->display_cartbutton = true;
JRequest::setVar('view', $this->get('suffix'));
$model = $this->getModel($this->get('suffix'));
$model->getId();
Tienda::load('TiendaHelperUser', 'helpers.user');
$user_id = JFactory::getUser()->id;
$filter_group = TiendaHelperUser::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', JRequest::getVar('filter_category'));
if (empty($filter_category)) {
$categories = Tienda::getClass('TiendaHelperProduct', '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_tienda&view=products&task=display&filter_category=" . $filter_category;
$redirect = JRoute::_($redirect, false);
$this->message = JText::_('COM_TIENDA_CANNOT_VIEW_DISABLED_PRODUCT');
$this->messagetype = 'notice';
$this->setRedirect($redirect, $this->message, $this->messagetype);
return;
}
Tienda::load('TiendaArticle', 'library.article');
$product_description = TiendaArticle::fromString($row->product_description);
JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
$cmodel = JModel::getInstance('Categories', 'TiendaModel');
$cat = $cmodel->getTable();
$cat->load($filter_category);
// if product browsing enabled on detail pages, get surrounding items based on browsing state
$session = JFactory::getSession();
$app = JFactory::getApplication();
$ns = $app->getName() . '::' . 'com.tienda.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
$app = JFactory::getApplication();
$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 = JRequest::getInt('Itemid', Tienda::getClass("TiendaHelperRoute", 'helpers.route')->category($filter_category, true));
if (!($product_itemid = $this->router->findItemid(array('view' => 'products', 'task' => 'view', 'id' => $row->product_id)))) {
$items = Tienda::getClass("TiendaHelperCategory", 'helpers.category')->getPathName($filter_category, 'array');
if (!empty($items)) {
// add the categories to the pathway
Tienda::getClass("TiendaHelperPathway", '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 = Tienda::getClass('TiendaHelperProduct', 'helpers.product')->getProductQuantities($row->product_id);
if (!Tienda::getInstance()->get('display_out_of_stock') && empty($inventoryList)) {
// redirect
$redirect = "index.php?option=com_tienda&view=products&task=display&filter_category=" . $filter_category;
$redirect = JRoute::_($redirect, false);
$this->message = JText::_('COM_TIENDA_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';
}
$view->assign('inventoryList', $inventoryList);
//.........这里部分代码省略.........
示例11: jimport
?>
</td>
</tr>
<tr>
<td style="width: 100px; text-align: right;" class="key">
<label for="category_full_image">
<?php
echo JText::_('COM_TIENDA_CURRENT_IMAGE');
?>
:
</label>
</td>
<td>
<?php
jimport('joomla.filesystem.file');
if (!empty($row->category_full_image) && JFile::exists(Tienda::getPath('categories_images') . DS . $row->category_full_image)) {
echo TiendaUrl::popup(Tienda::getClass('TiendaHelperCategory', 'helpers.category')->getImage($row->category_id, '', '', 'full', true), TiendaHelperCategory::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_TIENDA_UPLOAD_NEW_IMAGE');
示例12: jimport
<?php
echo TiendaSelect::btbooleanlist('manufacturer_enabled', '', @$row->manufacturer_enabled);
?>
</td>
</tr>
<tr>
<td style="width: 100px; text-align: right;" class="key">
<?php
echo JText::_('COM_TIENDA_CURRENT_IMAGE');
?>
:
</td>
<td>
<?php
jimport('joomla.filesystem.file');
if (!empty($row->manufacturer_image) && JFile::exists(Tienda::getPath('manufacturers_images') . DS . $row->manufacturer_image)) {
echo TiendaUrl::popup(TiendaHelperManufacturer::getImage($row->manufacturer_id, '', '', 'full', true), TiendaHelperManufacturer::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_TIENDA_UPLOAD_NEW_IMAGE');
?>
示例13: getStickerPath
/**
* Returns the full path to the order sticker file
*
* @param int $id
* @return string
*/
function getStickerPath($id, $check)
{
static $paths;
$id = (int) $id;
if (!is_array($paths)) {
$paths = array();
}
if (empty($paths[$id])) {
// Check where we should upload the file
// This is the default one
$dir = Tienda::getPath('order_files');
$helper = TiendaHelperBase::getInstance();
// try with the product id
if ($helper->checkDirectory($dir . DS . $id, $check)) {
$dir = $dir . DS . $id . DS;
}
return $dir;
}
return $paths[$id];
}
示例14: foreach
$gallery_data = $this->gallery_data;
if ($gallery_data->show_gallery) {
?>
<div class="dsc-wrap product_gallery" id="product_gallery">
<div id="product_gallery_header" class="tienda_header dsc-wrap">
<span><?php
echo JText::_('COM_TIENDA_IMAGES');
?>
</span>
</div>
<?php
$i = 1;
foreach ($gallery_data->images as $image) {
$src = $gallery_data->uri . $image;
if (JFile::exists(Tienda::getPath('products_thumbs') . "/" . $image)) {
$src = $gallery_data->uri . "thumbs/" . $image;
}
?>
<div class="dsc-wrap product_gallery_thumb" id="product_gallery_thumb_<?php
echo $i;
?>
">
<?php
echo TiendaUrl::popup($gallery_data->uri . $image, '<img src="' . $src . '" alt="' . $gallery_data->product_name . '" />', array('update' => false, 'img' => true));
?>
</div>
<?php
$i++;
}
?>
示例15: getCartButton
/**
* Get the cart button form for a specific product
*
* @param int $product_id The id of the product
* @return html The add to cart form
*/
public static function getCartButton($product_id, $layout = 'product_buy', $values = array(), &$callback_js = '')
{
if (is_array($values) && !count($values)) {
$values = JRequest::get('request');
}
$html = '';
$page = JRequest::getVar('page', 'product');
$isPOS = $page == 'pos';
if ($isPOS) {
JLoader::register("TiendaViewPOS", JPATH_ADMINISTRATOR . "/components/com_tienda/views/pos/view.html.php");
$view = new TiendaViewPOS();
} else {
JLoader::register("TiendaViewProducts", JPATH_SITE . "/components/com_tienda/views/products/view.html.php");
$view = new TiendaViewProducts();
}
$model = JModel::getInstance('Products', 'TiendaModel');
$model->setId($product_id);
$model->setState('task', 'product_buy');
Tienda::load('TiendaHelperBase', 'helpers._base');
$helper_product = TiendaHelperBase::getInstance('Product');
Tienda::load('TiendaHelperUser', 'helpers.user');
$user_id = JFactory::getUser()->id;
if ($isPOS) {
$user_id = JRequest::getInt('user_id', $user_id);
}
$filter_group = TiendaHelperUser::getUserGroup($user_id, $product_id);
$qty = isset($values['product_qty']) && !empty($values['product_qty']) ? $values['product_qty'] : 1;
$model->setState('filter_group', $filter_group);
$model->setState('product.qty', $qty);
$model->setState('user.id', $user_id);
$row = $model->getItem(false, true, false);
if ($row->product_notforsale || Tienda::getInstance()->get('shop_enabled') == '0') {
return $html;
}
// This enable this helper method to be used outside of tienda
if ($isPOS) {
$view->set('_controller', 'pos');
$view->set('_view', 'pos');
} else {
$view->addTemplatePath(JPATH_SITE . '/components/com_tienda/views/products/tmpl');
$view->addTemplatePath(JPATH_SITE . '/templates/' . JFactory::getApplication('site')->getTemplate() . '/html/com_tienda/products/');
// add extra templates
$view->addTemplatePath(Tienda::getPath('product_buy_templates'));
$view->set('_controller', 'products');
$view->set('_view', 'products');
}
$view->set('_doTask', true);
$view->set('hidemenu', true);
$view->setModel($model, true);
$view->setLayout($layout);
$view->product_id = $product_id;
$view->values = $values;
$filter_category = $model->getState('filter_category', JRequest::getInt('filter_category', (int) @$values['filter_category']));
$view->filter_category = $filter_category;
if ($isPOS) {
$view->validation = "index.php?option=com_tienda&view=pos&task=validate&format=raw";
} else {
$view->validation = "index.php?option=com_tienda&view=products&task=validate&format=raw";
}
$config = Tienda::getInstance();
// TODO What about this??
$show_shipping = $config->get('display_prices_with_shipping');
if ($show_shipping) {
$article_link = $config->get('article_shipping', '');
$shipping_cost_link = JRoute::_('index.php?option=com_content&view=article&id=' . $article_link);
$view->shipping_cost_link = $shipping_cost_link;
}
$quantity_min = 1;
if ($row->quantity_restriction) {
$quantity_min = $row->quantity_min;
}
$invalidQuantity = '0';
$attributes = array();
$attr_orig = array();
if (empty($values)) {
$product_qty = $quantity_min;
// get the default set of attribute_csv
if (!isset($row->default_attributes)) {
$default_attributes = $helper_product->getDefaultAttributes($product_id);
} else {
$default_attributes = $row->default_attributes;
}
sort($default_attributes);
$attributes_csv = implode(',', $default_attributes);
$availableQuantity = $helper_product->getAvailableQuantity($product_id, $attributes_csv);
if ($availableQuantity->product_check_inventory && $product_qty > $availableQuantity->quantity) {
$invalidQuantity = '1';
}
$attr_orig = $attributes = $default_attributes;
} else {
$product_qty = !empty($values['product_qty']) ? (int) $values['product_qty'] : $quantity_min;
// TODO only display attributes available based on the first selected attribute?
foreach ($values as $key => $value) {
if (substr($key, 0, 10) == 'attribute_') {
//.........这里部分代码省略.........