00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Wishlist_Block_Share_Wishlist extends Mage_Catalog_Block_Product_Abstract
00036 {
00037
00038 protected $_collection = null;
00039 protected $_customer = null;
00040
00041 protected function _prepareLayout()
00042 {
00043 if ($headBlock = $this->getLayout()->getBlock('head')) {
00044 $headBlock->setTitle($this->getHeader());
00045 }
00046 }
00047
00048 public function getWishlist()
00049 {
00050 if(is_null($this->_collection)) {
00051 $this->_collection = Mage::registry('shared_wishlist')->getProductCollection()
00052 ->addAttributeToSelect('name')
00053 ->addAttributeToSelect('price')
00054 ->addAttributeToSelect('special_price')
00055 ->addAttributeToSelect('special_from_date')
00056 ->addAttributeToSelect('special_to_date')
00057 ->addAttributeToSelect('image')
00058 ->addAttributeToSelect('small_image')
00059 ->addAttributeToSelect('thumbnail')
00060
00061 ->addStoreFilter();
00062
00063 Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($this->_collection);
00064 Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($this->_collection);
00065 }
00066 return $this->_collection;
00067 }
00068
00069 public function getWishlistCustomer()
00070 {
00071 if(is_null($this->_customer)) {
00072 $this->_customer = Mage::getModel('customer/customer')
00073 ->load(Mage::registry('shared_wishlist')->getCustomerId());
00074
00075 }
00076
00077 return $this->_customer;
00078 }
00079
00080
00081 public function getEscapedDescription($item)
00082 {
00083 if ($item->getWishlistItemDescription()) {
00084 return $this->htmlEscape($item->getWishlistItemDescription());
00085 }
00086 return ' ';
00087 }
00088
00089 public function getHeader()
00090 {
00091 return Mage::helper('wishlist')->__("%s's Wishlist", $this->htmlEscape($this->getWishlistCustomer()->getFirstname()));
00092 }
00093
00094 public function getFormatedDate($date)
00095 {
00096 return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
00097 }
00098
00099 public function isSaleable()
00100 {
00101 foreach ($this->getWishlist() as $item) {
00102 if ($item->isSaleable()) {
00103 return true;
00104 }
00105 }
00106
00107 return false;
00108 }
00109 }