Ejemplo n.º 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(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;
 }
Ejemplo n.º 2
0
				<?php 
}
?>
				<div class="reset marginbot"></div>

				<div class="citruscart-expanded" id="comments-pane">
				<div class="contentheading">
					<?php 
echo JText::_('COM_CITRUSCART_ORDER_COMMENTS');
?>
					<?php 
if ($enable_tooltips) {
    ?>
					<a class="img_tooltip" href="" >
						<img src="<?php 
    echo Citruscart::getUrl('images') . $image;
    ?>
" alt='<?php 
    echo JText::_('COM_CITRUSCART_HELP');
    ?>
' />
						<span>
							<?php 
    echo JText::_('COM_CITRUSCART_USE_THIS_AREA_FOR_SPECIAL_INSTRUCTIONS_OR_QUESTIONS_REGARDING_YOUR_ORDER');
    ?>
						</span>
					</a>
					<?php 
}
?>
				</div>
Ejemplo n.º 3
0
            case "button":
                ?>
                        <input onclick="<?php 
                echo $onclick;
                ?>
" value="<?php 
                echo JText::_('COM_CITRUSCART_ADD_TO_CART');
                ?>
" type="button" class="btn" />
                        <?php 
                break;
            case "image":
            default:
                ?>
                        <img class='addcart' src='<?php 
                echo Citruscart::getUrl('images') . "addcart.png";
                ?>
' alt='<?php 
                echo JText::_('COM_CITRUSCART_ADD_TO_CART');
                ?>
' onclick="<?php 
                echo $onclick;
                ?>
" />
                        <?php 
                break;
        }
    }
    ?>
        </div>
Ejemplo n.º 4
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 = Citruscart::getUrl('images') . 'accept_16.png';
             $html = "<div class='citruscart_validation'><img src='{$src}' alt='" . JText::_('COM_CITRUSCART_SUCCESS') . "'><span class='validation-success'>" . JText::_($text) . "</span></div>";
             break;
         default:
             $src = Citruscart::getUrl('images') . 'remove_16.png';
             $html = "<div class='citruscart_validation'><img src='{$src}' alt='" . JText::_('COM_CITRUSCART_ERROR') . "'><span class='validation-fail'>" . JText::_($text) . "</span></div>";
             break;
     }
     return $html;
 }
Ejemplo n.º 5
0
        case "button":
            ?>
                        <input onclick="<?php 
            echo $onclick;
            ?>
" value="<?php 
            echo JText::_('COM_CITRUSCART_ADD_TO_CART');
            ?>
" type="button" class="btn btn-primary btn-addtocart" />
                        <?php 
            break;
        case "image":
        default:
            ?>
                        <img class='addcart' src='<?php 
            echo Citruscart::getUrl('images') . $image_addtocart;
            ?>
' alt='<?php 
            echo JText::_('COM_CITRUSCART_ADD_TO_CART');
            ?>
' onclick="<?php 
            echo $onclick;
            ?>
" />
                        <?php 
            break;
    }
}
?>
        </div>
Ejemplo n.º 6
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)
 {
     $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;
 }
Ejemplo n.º 7
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 = 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;
 }
Ejemplo n.º 8
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)
 {
     $app = JFactory::getApplication();
     $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';
             $p_id = "citruscart_main_image" . $id;
             break;
         case "thumb":
         default:
             $path = 'products_images';
             $p_id = "citruscart_thumb_image" . $id;
             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 : 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 " . $dimensions . " src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' align='middle' border='0' " . $style . " />";
     } else {
         if (!empty($id)) {
             if (isset($this) && is_a($this, 'CitruscartHelperProduct')) {
                 $helper = $this;
             } else {
                 $helper = CitruscartHelperBase::getInstance('Product');
             }
             $model = Citruscart::getClass('CitruscartModelProducts', '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;
                     $p_id = "citruscart_main_image" . $id;
                     break;
                 case "thumb":
                 default:
                     $image_ref = $thumb_image;
                     $p_id = "citruscart_thumb_image" . $id;
                     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) {
                 $app->triggerEvent('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)) {
                     Citruscart::load('CitruscartImage', 'library.image');
                     $image = new CitruscartImage($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/citruscart/images/placeholder_239.gif';
             if (JFactory::getApplication()->isSite()) {
                 $tmpl = $url ? $src : "<img class='citruscart-product-main-images'  id=" . $p_id . " " . $dimensions . " src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' align='middle' border='0' />";
             } else {
                 $tmpl = $url ? $src : "<img " . $dimensions . " src='" . $src . "' alt='" . JText::_($alt) . "' title='" . JText::_($alt) . "' align='middle' border='0'/>";
             }
         }
     }
     return $tmpl;
 }