Пример #1
0
 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
0
            ?>
                        <input onclick="<?php 
            echo $onclick;
            ?>
" value="<?php 
            echo JText::_('COM_TIENDA_ADD_TO_CART');
            ?>
" type="button" class="btn btn-primary btn-addtocart" />
                        <?php 
            break;
        case "image":
        default:
            ?>
 
                        <img class='addcart' src='<?php 
            echo Tienda::getUrl('images') . $image_addtocart;
            ?>
' alt='<?php 
            echo JText::_('COM_TIENDA_ADD_TO_CART');
            ?>
' onclick="<?php 
            echo $onclick;
            ?>
" />
                        <?php 
            break;
    }
}
?>
        </div>
        
Пример #3
0
 /**
  * Generates a validation message
  *
  * @param unknown_type $text
  * @param unknown_type $type
  * @return unknown_type
  */
 public static function validationMessage($text, $type = 'fail')
 {
     switch (strtolower($type)) {
         case "success":
             $src = Tienda::getUrl('images') . 'accept_16.png';
             $html = "<div class='tienda_validation'><img src='{$src}' alt='" . JText::_('COM_TIENDA_SUCCESS') . "'><span class='validation-success'>" . JText::_($text) . "</span></div>";
             break;
         default:
             $src = Tienda::getUrl('images') . 'remove_16.png';
             $html = "<div class='tienda_validation'><img src='{$src}' alt='" . JText::_('COM_TIENDA_ERROR') . "'><span class='validation-fail'>" . JText::_($text) . "</span></div>";
             break;
     }
     return $html;
 }
Пример #4
0
$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 
    echo JText::_('COM_TIENDA_PASSWORD_REQUIREMENTS');
    ?>
: <br />
						<?php 
    echo '- ' . JText::sprintf("COM_TIENDA_PASSWORD_MIN_LENGTH", $min_length) . '<br />';
    if ($req_num) {
        echo '- ' . JText::_('COM_TIENDA_PASSWORD_REQ_NUMBER') . '<br />';
    }
Пример #5
0
 /**
  * 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;
 }
Пример #6
0
 /**
  * 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;
 }
Пример #7
0
:</span>
				<input type="text" name="product_qty" value="1" size="5" />
			</div>

			<input type="hidden" name="product_id" value="<?php 
echo $product->product_id;
?>
" size="5" />
			<?php 
$url = "index.php?option=com_tienda&format=raw&controller=carts&task=addToCart&productid=" . $product->product_id;
?>
			<?php 
$onclick = 'tiendaDoTask(\'' . $url . '\', \'tiendaUserShoppingCart\', document.adminForm);';
?>
			<?php 
$text = "<img class='addcart' src='" . Tienda::getUrl('images') . "addcart.png' alt='" . JText::_('COM_TIENDA_ADD_TO_CART') . "' onclick=\"{$onclick}\" />";
?>
			<?php 
$lightbox_attribs = array();
$lightbox['update'] = false;
if ($lightbox_width = Tienda::getInstance()->get('lightbox_width')) {
    $lightbox_attribs['width'] = $lightbox_width;
}
?>
			<?php 
echo TiendaUrl::popup("index.php?option=com_tienda&view=carts&task=confirmAdd&tmpl=component", $text, $lightbox_attribs);
?>
		</form>
	</div>
</div>
Пример #8
0
 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()));
 }
Пример #9
0
 /**
  *
  * @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, $resize = false, $options = array(), $main_product = false)
 {
     $style = "";
     $height_style = "";
     $width_style = "";
     $dimensions = "";
     if (!empty($options['width'])) {
         $dimensions .= "width=\"" . $options['width'] . "\" ";
     }
     if (!empty($options['height'])) {
         $dimensions .= "height=\"" . $options['height'] . "\" ";
     }
     if (!empty($options['height'])) {
         $height_style = "max-height: " . $options['height'] . "px;";
     }
     if (!empty($options['width'])) {
         $width_style = "max-width: " . $options['width'] . "px;";
     }
     if (!empty($height_style) || !empty($width_style)) {
         $style = "style='{$height_style} {$width_style}'";
     }
     switch ($type) {
         case "full":
             $path = 'products_images';
             break;
         case "thumb":
         default:
             $path = 'products_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) . '/' . $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 " . $dimensions . " src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' align='middle' border='0' " . $style . " />";
     } else {
         if (!empty($id)) {
             if (isset($this) && is_a($this, 'TiendaHelperProduct')) {
                 $helper =& $this;
             } else {
                 $helper = TiendaHelperBase::getInstance('Product');
             }
             $model = Tienda::getClass('TiendaModelProducts', 'models.products');
             $model->setId((int) $id);
             $item = $model->getItem();
             $full_image = !empty($item->product_full_image) ? $item->product_full_image : null;
             $thumb_image = !empty($item->product_thumb_image) ? $item->product_thumb_image : $full_image;
             switch ($type) {
                 case "full":
                     $image_ref = $full_image;
                     break;
                 case "thumb":
                 default:
                     $image_ref = $thumb_image;
                     break;
             }
             if (filter_var($image_ref, FILTER_VALIDATE_URL) !== false) {
                 // $full_image contains a valid URL
                 $src = $image_ref;
                 if ($url) {
                     return $src;
                 } elseif (!empty($src)) {
                     $tmpl = "<img src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' />";
                     return $tmpl;
                 }
             }
             $row = $helper->load((int) $id, true, false);
             // load the item, get the filename, create tmpl
             $urli = $row->getImageUrl();
             $dir = $row->getImagePath();
             if ($path == 'products_thumbs') {
                 $dir .= 'thumbs';
                 $urli .= 'thumbs/';
             }
             if ($main_product) {
                 $dispatcher = JDispatcher::getInstance();
                 $dispatcher->trigger('onGetProductMainImage', array($row->product_id, &$full_image, $options));
             }
             $dirname = dirname($image_ref);
             if (!empty($dirname) && $dirname !== ".") {
                 $dir = JPath::clean(JPATH_SITE . "/" . dirname($image_ref));
                 $urli = JURI::root(true) . '/' . dirname($image_ref) . '/';
                 $file = JPath::clean(JPATH_SITE . "/" . $image_ref);
                 $id = JURI::root(true) . '/' . $image_ref;
             } else {
                 $file = $dir . '/' . $image_ref;
                 $id = $urli . $image_ref;
             }
             // Gotta do some resizing first?
             if ($resize) {
                 // Add a suffix to the thumb to avoid conflicts with user settings
                 $suffix = '';
                 if (isset($options['width']) && isset($options['height'])) {
                     $suffix = '_' . $options['width'] . 'x' . $options['height'];
                 } elseif (isset($options['width'])) {
                     $suffix = '_w' . $options['width'];
                 } elseif (isset($options['height'])) {
                     $suffix = '_h' . $options['height'];
                 }
                 // Add suffix to file path
                 $dot = strrpos($file, '.');
                 $resize = substr($file, 0, $dot) . $suffix . substr($file, $dot);
                 if (!JFile::exists($resize)) {
                     Tienda::load('TiendaImage', 'library.image');
                     $image = new TiendaImage($file);
                     $image->load();
                     // If both width and height set, gotta figure hwo to resize
                     if (isset($options['width']) && isset($options['height'])) {
                         // If width is larger, proportionally
                         if ($options['width'] / $image->getWidth() < $options['height'] / $image->getHeight()) {
                             $image->resizeToWidth($options['width']);
                             $image->save($resize);
                         } else {
                             $image->resizeToHeight($options['height']);
                             $image->save($resize);
                         }
                     } elseif (isset($options['width'])) {
                         $image->resizeToWidth($options['width']);
                         $image->save($resize);
                     } elseif (isset($options['height'])) {
                         $image->resizeToHeight($options['height']);
                         $image->save($resize);
                     }
                 }
                 // Add suffix to url path
                 $dot = strrpos($id, '.');
                 $id = substr($id, 0, $dot) . $suffix . substr($id, $dot);
             }
             $src = JFile::exists($file) ? $id : JURI::root(true) . '/media/com_tienda/images/placeholder_239.gif';
             $tmpl = $url ? $src : "<img " . $dimensions . " src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' align='middle' border='0' " . $style . " />";
         }
     }
     return $tmpl;
 }
Пример #10
0
                ?>
                        <input onclick="<?php 
                echo $onclick;
                ?>
" value="<?php 
                echo JText::_('COM_TIENDA_ADD_TO_CART');
                ?>
" type="button" class="btn" />
                        <?php 
                break;
            case "image":
            default:
                ?>
 
                        <img class='addcart' src='<?php 
                echo Tienda::getUrl('images') . "addcart.png";
                ?>
' alt='<?php 
                echo JText::_('COM_TIENDA_ADD_TO_CART');
                ?>
' onclick="<?php 
                echo $onclick;
                ?>
" />
                        <?php 
                break;
        }
    }
    ?>
        </div>