BoxUri.php
905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?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;
}
}