BoxUri.php 905 Bytes
<?php

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

/**
 * boxUri helper
 *
 * @uses viewHelper Zend_View_Helper
 */
class Web_View_Helper_BoxUri extends Zend_View_Helper_Abstract {
	
	/**
	 * @var Zend_View_Interface 
	 */
	public $view;
	
	/**
	 * 
	 */
	public function boxUri(array $query_opt, $q, array $moveOpt, $url = '/search?', array $defaultMove = array()) {
		$result = array();
		$moveOpt = array_merge($defaultMove, $moveOpt);
		foreach ($moveOpt as $value) {
			unset($query_opt[$value]);
		}
		$uri = (!empty($query_opt) ? http_build_query($query_opt) : '');
		if(!empty($this->view->curQuery)) {
			$uri .= '&query=' . $this->view->curQuery;
		}
		return !empty($uri) ? $url . $uri . '&' . $q : (!empty($q) ? $url . $q : $url);
	}
	
	/**
	 * Sets the view field 
	 * @param $view Zend_View_Interface
	 */
	public function setView(Zend_View_Interface $view) {
		$this->view = $view;
	}

}