2 /* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3 and is published under the AGPL license. */
5 class Syj_View_Helper_AddParamToUrl extends Zend_View_Helper_Abstract
7 public function addParamToUrl($url, $param, $value, $replace = false) {
8 if (strpos ($url, '?') === false) {
9 return $url . '?' . $param . '=' . $this->view->escape($value);
12 $parts = explode('&', substr(strstr($url, '?'), 1));
14 foreach (explode('&', substr(strstr($url, '?'), 1)) as $key => $part) {
15 if (substr($part, 0, strlen($param . '=')) === ($param . '=')) {
24 $parts[] = $param . '=' . $this->view->escape($value);
26 return strstr($url, '?', true) . '?' . implode('&', $parts);