BoxDefault.php 861 Bytes
<?php

/**
 *
 * @author liuziyang
 * @version
 */

/**
 * BoxDefault helper
 *
 * @uses viewHelper Zend_View_Helper
 */
class Web_View_Helper_BoxDefault extends Zend_View_Helper_Abstract {

    /**
     * @var Zend_View_Interface
     */
    public $view;

    /**
     *
     */
    public function boxDefault(array $goodsImg, $defaultColor=0) {
        $defaultGoods = array();
        if($defaultColor != 0)
        {
	        foreach ($goodsImg as $key => $val) {
	            if ($val['color_id'] == $defaultColor) {
	                $defaultGoods = $val;
	            }
	        }
        }
        return empty($defaultGoods) ? array_shift($goodsImg) : $defaultGoods;
    }

    /**
     * Sets the view field
     * @param $view Zend_View_Interface
     */
    public function setView(Zend_View_Interface $view) {
        $this->view = $view;
    }

}