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; }
/** * 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'); }
function display() { $mainframe = JFactory::getApplication(); // Initialize variables $db = JFactory::getDBO(); $nullDate = $db->getNullDate(); $document = JFactory::getDocument(); $document->setTitle('Product Selection'); JHTML::_('behavior.modal'); $template = $mainframe->getTemplate(); $document->addStyleSheet("templates/{$template}/css/general.css"); $document->addScript('media/com_tienda/js/tienda.js'); $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); $lists = $this->_getLists(); //Ordering allowed ? // $ordering = ($lists['order'] == 'section_name' && $lists['order_Dir'] == 'ASC'); $rows =& $this->get('List'); $page =& $this->get('Pagination'); JHTML::_('behavior.tooltip'); $object = JRequest::getVar('object'); $link = 'index.php?option=com_tienda&task=elementproductmultiple&tmpl=component&object=' . $object; Tienda::load('TiendaGrid', 'library.grid'); ?> <?php JHTML::_('script', 'tienda.js', 'media/com_tienda/js/'); ?> <form action="<?php echo $link; ?> " method="post" name="adminForm"> <table> <tr> <td width="100%"><?php echo JText::_('COM_TIENDA_FILTER'); ?> : <input type="text" name="search" id="search" value="<?php echo $lists['search']; ?> " class="text_area" onchange="document.adminForm.submit();" /> <button onclick="this.form.submit();"><?php echo JText::_('COM_TIENDA_GO'); ?> </button> <button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo JText::_('COM_TIENDA_RESET'); ?> </button> </td> <td nowrap="nowrap"> <button onclick="tiendaSetItemsToOrder(<?php echo count($rows); ?> , '<?php echo JText::_('COM_TIENDA_UNABLE_TO_RETRIEVE_PRODUCT_SELECTION'); ?> ');return false;"><?php echo JText::_('COM_TIENDA_ADD_SELECTED_PRODUCTS_TO_ORDER'); ?> </button> </td> </tr> </table> <table class="adminlist" cellspacing="1"> <thead> <tr> <th width="5"><?php echo JText::_('COM_TIENDA_NUM'); ?> </th> <th style="width: 20px;"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?> );" /></th> <th width="2%" class="title"><?php echo JHTML::_('grid.sort', 'ID', 'tbl.product_id', @$lists['order_Dir'], @$lists['order']); ?> </th> <th style="width:50px;"><?php echo JText::_('COM_TIENDA_IMAGE'); ?> </th> <th class="title"><?php echo JHTML::_('grid.sort', 'Name', 'tbl.product_name', @$lists['order_Dir'], @$lists['order']); ?> </th> <th class="title"><?php echo JHTML::_('grid.sort', 'Price', 'pp.product_price', @$lists['order_Dir'], @$lists['order']); ?> </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 }
/** * 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; }
/** * 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; }
private function _migrateImages($prefix = 'jos_', $vm_prefix = 'vm_', &$results, $internal = true) { $p = $prefix . $vm_prefix; // Fetch the VM full image if ($internal) { $db = JFactory::getDBO(); } else { $db = $this->_verifyDB(); } $query = "SELECT product_id as id, product_full_image as image FROM {$p}product"; $db->setQuery($query); $products = $db->loadAssocList(); Tienda::load('TiendaImage', 'library.image'); if ($internal) { $vm_image_path = JPATH_SITE . "/components/com_virtuemart/shop_image/product/"; } else { $state = $this->_getState(); $url = $state->external_site_url; $vm_image_path = $url . "/components/com_virtuemart/shop_image/product/"; } $n = count($results); $results[$n]->title = 'Product Images'; $results[$n]->query = 'Copy Product 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']); } 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++; } } }
<?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");
<?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>
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]; $folders[] = $tmp; } } $list = array('folders' => $folders, 'docs' => $docs, 'images' => $images); return $list; }
/** * 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); } $view->product_comments = $this->getComments($view, $row->product_id); $view->files = $this->getFiles($view, $row->product_id); $view->product_relations = $this->getRelationshipsHtml($view, $row->product_id, 'relates'); $view->product_children = $this->getRelationshipsHtml($view, $row->product_id, 'parent'); $view->product_requirements = $this->getRelationshipsHtml($view, $row->product_id, 'requires'); $view->product_description = $product_description; $view->setModel($model, true); // we know the product, set the meta info $doc = JFactory::getDocument(); $doc->setTitle(str_replace(array("'", "&"), array("'", "&"), htmlspecialchars_decode($row->product_name))); $doc->setDescription(htmlspecialchars_decode($product_description)); // add the media/templates folder as a valid path for templates $view->addTemplatePath(Tienda::getPath('products_templates')); // but add back the template overrides folder to give it priority $template_overrides = JPATH_BASE . '/templates/' . $app->getTemplate() . '/html/com_tienda/' . $view->getName(); $view->addTemplatePath($template_overrides); // using a helper file, we determine the product's layout $layout = Tienda::getClass('TiendaHelperProduct', 'helpers.product')->getLayout($row->product_id, array('category_id' => $cat->category_id)); $view->setLayout($layout); $dispatcher = JDispatcher::getInstance(); ob_start(); $dispatcher->trigger('onBeforeDisplayProduct', array($row->product_id)); $view->assign('onBeforeDisplayProduct', ob_get_contents()); ob_end_clean(); ob_start(); $dispatcher->trigger('onAfterDisplayProduct', array($row->product_id)); $view->assign('onAfterDisplayProduct', ob_get_contents()); ob_end_clean(); $view->display(); $this->footer(); return; }
?> </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');
<?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'); ?>
/** * 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]; }
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 = JModel::getInstance('ElementImage', 'TiendaModel'); $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_tienda&task=elementImage&tmpl=component&object=' . $object; ?> <script type='text/javascript'> var image_base_path = '<?php echo Tienda::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_TIENDA_DIRECTORY'); ?> </label> <?php echo $this->folderList; ?> <button type="button" id="upbutton" title="<?php echo JText::_('COM_TIENDA_DIRECTORY_UP'); ?> "><?php echo JText::_('COM_TIENDA_UP'); ?> </button> </div> <div style="float: right"> <button type="button" onclick="ImageManager.onok();window.parent.document.getElementById('sbox-window').close();"><?php echo JText::_('COM_TIENDA_INSERT'); ?> </button> <button type="button" onclick="window.parent.document.getElementById('sbox-window').close();"><?php echo JText::_('COM_TIENDA_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_TIENDA_IMAGE_URL'); ?> </label></td> <td><input type="text" id="f_url" value="" /></td> <td><label for="f_align"><?php echo JText::_('COM_TIENDA_ALIGN'); ?> </label></td> <td> <select size="1" id="f_align" title="Positioning of this image"> <option value="" selected="selected"><?php echo JText::_('COM_TIENDA_NOT_SET'); ?> </option> <option value="left"><?php echo JText::_('COM_TIENDA_LEFT'); ?> </option> <option value="right"><?php echo JText::_('COM_TIENDA_RIGHT'); ?> </option> </select> </td> </tr> <tr> <td><label for="f_alt"><?php echo JText::_('COM_TIENDA_IMAGE_DESCRIPTION'); ?> </label></td> <td><input type="text" id="f_alt" value="" /></td> </tr> <tr> <td><label for="f_title"><?php echo JText::_('COM_TIENDA_TITLE'); ?> </label></td> <td><input type="text" id="f_title" value="" /></td> <td><label for="f_caption"><?php echo JText::_('COM_TIENDA_CAPTION'); ?> </label></td> <td><input type="checkbox" id="f_caption" /></td> </tr> </table> </fieldset> <input type="hidden" id="dirPath" name="dirPath" /> <input type="hidden" id="f_file" name="f_file" /> <input type="hidden" id="tmpl" name="component" /> </form> <form action="<?php echo JURI::base(); ?> index.php?option=com_media&task=file.upload&tmpl=component&<?php echo $this->session->getName() . '=' . $this->session->getId(); ?> &pop_up=1&<?php echo JUtility::getToken(); ?> =1" id="uploadForm" method="post" enctype="multipart/form-data"> <fieldset> <legend><?php echo JText::_('COM_TIENDA_UPLOAD'); ?> </legend> <fieldset class="actions"> <input type="file" id="file-upload" name="Filedata" /> <input type="submit" id="file-upload-submit" value="<?php echo JText::_('COM_TIENDA_START_UPLOAD'); ?> "/> <span id="upload-clear"></span> </fieldset> <ul class="upload-queue" id="upload-queue"> <li style="display: none" /> </ul> </fieldset> <input type="hidden" name="return-url" value="<?php echo base64_encode('index.php?option=com_media&view=images&tmpl=component&e_name=' . JRequest::getCmd('e_name')); ?> " /> </form> <?php }
$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++; } ?>
/** * 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_') { if (empty($value)) { $attributes[$key] = 0; } else { $attributes[$key] = $value; } } } if (!count($attributes)) { // no attributes are selected -> use default if (!isset($row->default_attributes)) { $attributes = $helper_product->getDefaultAttributes($product_id); } else { $attributes = $row->default_attributes; } } $attr_orig = $attributes; sort($attributes); // Add 0 to attributes to include all the root attributes //$attributes[] = 0;//remove this one. its causing the getAvailableQuantity to not get quantity because of wrong csv // For getting child opts $view->selected_opts = json_encode(array_merge($attributes, array('0'))); $attributes_csv = implode(',', $attributes); // Integrity checks on quantity being added if ($product_qty < 0) { $product_qty = '1'; } // using a helper file to determine the product's information related to inventory $availableQuantity = $helper_product->getAvailableQuantity($product_id, $attributes_csv); if ($availableQuantity->product_check_inventory && $product_qty > $availableQuantity->quantity) { $invalidQuantity = '1'; } } // adjust the displayed price based on the selected or default attributes TiendaHelperProduct::calculateProductAttributeProperty($row, $attr_orig, 'price', 'product_weight'); $show_tax = $config->get('display_prices_with_tax'); $show_product = $config->get('display_category_cartbuttons'); $view->show_tax = $show_tax; $row->tax = '0'; $row->taxtotal = '0'; if ($show_tax) { // finish TiendaHelperUser::getGeoZone -- that's why this isn't working Tienda::load('TiendaHelperUser', 'helpers.user'); $geozones_user = TiendaHelperUser::getGeoZones($user_id); if (empty($geozones_user)) { $geozones = array(Tienda::getInstance()->get('default_tax_geozone')); } else { $geozones = array(); foreach ($geozones_user as $value) { $geozones[] = $value->geozone_id; } } Tienda::load('TiendaHelperTax', 'helpers.tax'); $product = new stdClass(); $product->product_price = $row->price; $product->product_id = $product_id; $tax = TiendaHelperTax::calculateGeozonesTax(array($product), 2, $geozones); $row->taxtotal = $tax->tax_total; $row->tax = $tax->tax_total; } $row->_product_quantity = $product_qty; if ($page == 'product' || $isPOS) { $display_cartbutton = Tienda::getInstance()->get('display_product_cartbuttons', '1'); } else { $display_cartbutton = Tienda::getInstance()->get('display_category_cartbuttons', '1'); } $view->page = $page; $view->display_cartbutton = $display_cartbutton; $view->availableQuantity = $availableQuantity; $view->invalidQuantity = $invalidQuantity; if ($isPOS) { $view->product = $row; } else { $view->item = $row; } $dispatcher = JDispatcher::getInstance(); ob_start(); $dispatcher->trigger('onDisplayProductAttributeOptions', array($row->product_id)); $view->onDisplayProductAttributeOptions = ob_get_contents(); ob_end_clean(); $html = $view->loadTemplate(); if (isset($view->callback_js) && !empty($view->callback_js)) { $callback_js = $view->callback_js; } return $html; }
function downloadLabel() { $order_id = JRequest::getInt('order_id'); $file = JRequest::getVar('label'); $path = Tienda::getPath('order_files') . DS . $order_id; $this->download($file, $path); }
function onAfterCreateItemForAddToCart($item, $values, $files) { if (empty($values["hasCustomFields"])) { return array(); } //generate a new custom fields id $newCustomFieldsID = $this->getNewCustomFieldsID(); if ($newCustomFieldsID == false) { JError::raiseNotice('onAfterCreateItemForAddToCart', JText::_('TIENDA_PRODUCT_CUSTOMFIELDS_AFTER_CREATE_ITEM_FAILED') . '(No max custom_fields_id retrieved)'); } //get custom field values $params = new DSCParameter(''); foreach ($values as $key => $value) { if (substr($key, 0, 13) == 'custom_field_') { $params->set($key, $value); } } //custom fields of type 'file': files being uploaded if (!empty($files)) { $user_id = JFactory::getUser()->id; jimport('joomla.filesystem.file'); foreach ($files as $key => $file) { if (substr($key, 0, 13) == 'custom_field_') { $destination_webfolder = Tienda::getUrl('cartitems_files') . $user_id . '/' . $newCustomFieldsID . '/'; $destination_folder = Tienda::getPath('cartitems_files') . DS . $user_id . DS . $newCustomFieldsID . DS; if (!JFolder::exists($destination_folder)) { JFolder::create($destination_folder); } $dest_file = $file['name']; if (!JFile::upload($file['tmp_name'], $destination_folder . $dest_file)) { JError::raiseNotice('onAfterCreateItemForAddToCart', JText::_('TIENDA_PRODUCT_CUSTOMFIELDS_AFTER_CREATE_ITEM_FAILED') . '(unable to upload)'); } $params->set($key, $destination_webfolder . $dest_file); } } } return array('cartitem_customfields_id' => $newCustomFieldsID, 'cartitem_customfields' => trim($params->toString())); }
<?php defined('_JEXEC') or die('Restricted access'); $min_length = Tienda::getInstance()->get('password_min_length', 5); $req_num = Tienda::getInstance()->get('password_req_num', 1); $req_alpha = Tienda::getInstance()->get('password_req_alpha', 1); $req_spec = Tienda::getInstance()->get('password_req_spec', 1); Tienda::load('TiendaHelperImage', 'helpers.image'); $image = TiendaHelperImage::getLocalizedName("help_tooltip.png", Tienda::getPath('images')); $js_strings = array('COM_TIENDA_PASSWORD_VALID', 'COM_TIENDA_PASSWORD_INVALID', 'COM_TIENDA_PASSWORD_DO_NOT_MATCH', 'COM_TIENDA_PASSWORD_MATCH', 'COM_TIENDA_SUCCESS', 'COM_TIENDA_ERROR', 'COM_TIENDA_PASSWORD_MIN_LENGTH', 'COM_TIENDA_PASSWORD_REQ_ALPHA', 'COM_TIENDA_PASSWORD_REQ_NUMBER', 'COM_TIENDA_PASSWORD_REQ_SPEC'); TiendaHelperImage::addJsTranslationStrings($js_strings); $enable_tooltips = Tienda::getInstance()->get('one_page_checkout_tooltips_enabled', 0); ?> <div style="clear: both;width:100%;"> <div class="form_item"> <div class="form_key"> <?php echo JText::_('COM_TIENDA_PASSWORD') . ': ' . TiendaGrid::required(); if ($enable_tooltips) { ?> <a class="img_tooltip" href="" > <img src="<?php echo Tienda::getUrl('images') . $image; ?> " alt='<?php echo JText::_('COM_TIENDA_HELP'); ?> ' /> <span> <?php
function sendShipment($ordershipping_id) { try { $this->response = $this->getClient()->ProcessShipment($this->getRequest()); if ($this->response->Response->ResponseStatus->Code != '0') { $results = $this->processResponse($this->response); // Save Tracking Numbers & Images if ($results) { $row = JTable::getInstance('OrderShippings', 'TiendaTable'); $row->load($ordershipping_id); // Structure: Shipment_id\nTracking_id_1\nTracking_id_2\n.... $row->ordershipping_tracking_id = $row->ordershipping_tracking_id . $results['shipment_id'] . "\n"; foreach ($results['tracking_numbers'] as $t => $image) { $row->ordershipping_tracking_id = $row->ordershipping_tracking_id . $t . "\n"; $row->save(); JFile::write(Tienda::getPath('order_files') . DS . $row->order_id . DS . $t . '.gif', $image); } } else { $this->setError(JText::_('COM_TIENDA_UPS_ERRORCODE2')); return false; } return true; } else { $this->setError('E1', JText::_('COM_TIENDA_UPS_ERRORCODE1')); return false; } } catch (SoapFault $exception) { $this->response = array(); $this->setError((string) $exception . $this->getClient()->__getLastRequest()); return false; } return true; }
/** * Batch resize of thumbs * @author Skullbock */ function recreateThumbs() { $per_step = 100; $from_id = JRequest::getInt('from_id', 0); $to = $from_id + $per_step; Tienda::load('TiendaHelperCategory', 'helpers.category'); Tienda::load('TiendaImage', 'library.image'); $width = Tienda::getInstance()->get('category_img_width', '0'); $height = Tienda::getInstance()->get('category_img_height', '0'); $model = $this->getModel('Categories', 'TiendaModel'); $model->setState('limistart', $from_id); $model->setState('limit', $to); $row = $model->getTable(); $count = $model->getTotal(); $categories = $model->getList(); $i = 0; $last_id = $from_id; foreach ($categories as $p) { $i++; $image = $p->category_full_image; $path = Tienda::getPath('categories_images'); if ($image != '') { $img = new TiendaImage($path . '/' . $image); $img->setDirectory(Tienda::getPath('categories_images')); // Thumb Tienda::load('TiendaHelperImage', 'helpers.image'); $imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper'); $imgHelper->resizeImage($img, 'category'); } $last_id = $p->category_id; } if ($i < $count) { $redirect = "index.php?option=com_tienda&controller=categories&task=recreateThumbs&from_id=" . ($last_id + 1); } else { $redirect = "index.php?option=com_tienda&view=config"; } $redirect = JRoute::_($redirect, false); $this->setRedirect($redirect, JText::_('COM_TIENDA_DONE'), 'notice'); return; }
/** * Uploads a file to associate to an item * * @return unknown_type */ function addfile($fieldname = 'createproductfile_file', $path = 'products_files') { Tienda::load('TiendaFile', 'library.file'); $upload = new TiendaFile(); // handle upload creates upload object properties $upload->handleUpload($fieldname); // then save image to appropriate folder if ($path == 'products_files') { $path = Tienda::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_TIENDA_MOVE_FAILED_FROM'), $upload->file_path, $dest)); return false; } $upload->full_path = $dest; return $upload; }