00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Catalog 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 00028 /** 00029 * Product options text type block 00030 * 00031 * @category Mage 00032 * @package Mage_Catalog 00033 * @author Magento Core Team <core@magentocommerce.com> 00034 */ 00035 class Mage_Catalog_Block_Product_View_Options_Type_Select 00036 extends Mage_Catalog_Block_Product_View_Options_Abstract 00037 { 00038 00039 public function getValuesHtml() 00040 { 00041 $_option = $this->getOption(); 00042 00043 if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN 00044 || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) { 00045 $require = ($_option->getIsRequire()) ? ' required-entry' : ''; 00046 $extraParams = ''; 00047 $select = $this->getLayout()->createBlock('core/html_select') 00048 ->setData(array( 00049 'id' => 'select_'.$_option->getId(), 00050 'class' => $require.' product-custom-option' 00051 )); 00052 if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN) { 00053 $select->setName('options['.$_option->getid().']') 00054 ->addOption('', $this->__('-- Please Select --')); 00055 } else { 00056 $select->setName('options['.$_option->getid().'][]'); 00057 $select->setClass('multiselect'.$require.' product-custom-option'); 00058 } 00059 foreach ($_option->getValues() as $_value) { 00060 $priceStr = $this->_formatPrice(array( 00061 'is_percent' => ($_value->getPriceType() == 'percent') ? true : false, 00062 'pricing_value' => $_value->getPrice(true) 00063 ), false); 00064 $select->addOption( 00065 $_value->getOptionTypeId(), 00066 $_value->getTitle() . ' ' . $priceStr . '' 00067 ); 00068 } 00069 if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) { 00070 $extraParams = ' multiple="multiple"'; 00071 } 00072 $select->setExtraParams('onchange="opConfig.reloadPrice()"'.$extraParams); 00073 00074 return $select->getHtml(); 00075 } 00076 00077 if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO 00078 || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX 00079 ) { 00080 $selectHtml = '<ul id="options-'.$_option->getId().'-list" class="options-list">'; 00081 $require = ($_option->getIsRequire()) ? ' validate-one-required-by-name' : ''; 00082 $arraySign = ''; 00083 switch ($_option->getType()) { 00084 case Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO: 00085 $type = 'radio'; 00086 $class = 'radio'; 00087 if (!$_option->getIsRequire()) { 00088 $selectHtml .= '<li><input type="radio" id="options_'.$_option->getId().'" class="'.$class.' product-custom-option" name="options['.$_option->getId().']" onclick="opConfig.reloadPrice()" value="" checked="checked" /><span class="label"><label for="options_'.$_option->getId().'">' . $this->__('None') . '</label></span></li>'; 00089 } 00090 break; 00091 case Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX: 00092 $type = 'checkbox'; 00093 $class = 'checkbox'; 00094 $arraySign = '[]'; 00095 break; 00096 } 00097 $count = 1; 00098 foreach ($_option->getValues() as $_value) { 00099 $count++; 00100 $priceStr = $this->_formatPrice(array( 00101 'is_percent' => ($_value->getPriceType() == 'percent') ? true : false, 00102 'pricing_value' => $_value->getPrice(true) 00103 )); 00104 $selectHtml .= '<li>' . 00105 '<input type="'.$type.'" class="'.$class.' '.$require.' product-custom-option" onclick="opConfig.reloadPrice()" name="options['.$_option->getId().']'.$arraySign.'" id="options_'.$_option->getId().'_'.$count.'" value="'.$_value->getOptionTypeId().'" />' . 00106 '<span class="label"><label for="options_'.$_option->getId().'_'.$count.'">'.$_value->getTitle().' '.$priceStr.'</label></span>'; 00107 if ($_option->getIsRequire()) { 00108 $selectHtml .= '<script type="text/javascript">' . 00109 '$(\'options_'.$_option->getId().'_'.$count.'\').advaiceContainer = \'options-'.$_option->getId().'-container\';' . 00110 '$(\'options_'.$_option->getId().'_'.$count.'\').callbackFunction = \'validateOptionsCallback\';' . 00111 '</script>'; 00112 } 00113 $selectHtml .= '</li>'; 00114 } 00115 $selectHtml .= '</ul>'; 00116 return $selectHtml; 00117 } 00118 } 00119 00120 }