本文整理汇总了PHP中Horde_Url::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Url::add方法的具体用法?PHP Horde_Url::add怎么用?PHP Horde_Url::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Url
的用法示例。
在下文中一共展示了Horde_Url::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddOverwrite
public function testAddOverwrite()
{
$url = new Horde_Url('test');
$url->add('foo', 1);
$this->assertEquals('test?foo=1', (string) $url);
$url->add('foo', 2);
$this->assertEquals('test?foo=2', (string) $url);
}
示例2: _doSearch
/**
* Perform search
*
* @throws Mnemo_Exception
*/
protected function _doSearch()
{
$search_pattern = $this->_vars->get('search_pattern');
$search_type = $this->_vars->get('search_type');
$search_desc = $search_type == 'desc';
$search_body = $search_type == 'body';
if (!empty($search_pattern) && ($search_body || $search_desc)) {
$search_pattern = '/' . preg_quote($search_pattern, '/') . '/i';
$search_result = array();
foreach ($this->_notes as $memo_id => $memo) {
if ($search_desc && preg_match($search_pattern, $memo['desc']) || $search_body && preg_match($search_pattern, $memo['body'])) {
$search_result[$memo_id] = $memo;
}
}
$this->_notes = $search_result;
} elseif ($search_type == 'tags') {
// Tag search, use the browser.
$this->_browser->clearSearch();
$tags = $GLOBALS['injector']->getInstance('Mnemo_Tagger')->split($this->_vars->get('search_pattern'));
foreach ($tags as $tag) {
$this->_browser->addTag($tag);
}
$this->_notes = $this->_browser->getSlice();
$this->_handleActions(false);
return;
}
$this->_baseurl->add(array('actionID' => 'search_memos', 'search_pattern' => $search_pattern, 'search_type' => $search_type));
}
示例3: testBaseUrlWithParametersWithoutAnchor
public function testBaseUrlWithParametersWithoutAnchor()
{
$base = new Horde_Url('test');
$base->add('foo', 0);
$url = new Horde_Core_Smartmobile_Url($base);
$url->add(array('foo' => 1, 'bar' => 2));
$this->assertEquals('test?foo=1&bar=2', (string) $url);
}
示例4: testLink
public function testLink()
{
$url = new Horde_Url('test', true);
$url->add(array('foo' => 1, 'bar' => 2));
$this->assertEquals('test?foo=1&bar=2', (string) $url);
$this->assertEquals('<a href="test?foo=1&bar=2">', $url->link());
$this->assertEquals('<a href="test?foo=1&bar=2" title="foo&bar">', $url->link(array('title' => 'foo&bar')));
$this->assertEquals('<a href="test?foo=1&bar=2" title="foo&bar">', $url->link(array('title.raw' => 'foo&bar')));
}
示例5: getUrlFor
/**
* Builds URL strings for various targets
* @param string $controller The internal name of the controller or page
* @param array $details The parameters to attach either as path or as get parameters
* @param boolean $full Generate a full url or relative to dolcore, defaults to false
* @param boolean $legacy Generate an url for the legacy target page or for a dolcore controller. Ignored if one is missing
* @returns string The generated URL
*/
public function getUrlFor($controller, array $details = null, $full = false, $legacy = false)
{
switch ($controller) {
case 'discussion':
if ($legacy) {
$parameters = array('position' => 700, 'frage_id' => $details['discussion_id']);
$url = new Horde_Url($GLOBALS['conf']['path']['dol2day_front'], true);
return $url->add($parameters)->toString();
}
break;
}
}
示例6: _getSearchUrl
/**
* Construct the URL back to a supplied search
*/
function _getSearchUrl($vars)
{
$qUrl = new Horde_Url();
$queue = (int) $vars->get('queue');
$qUrl->add(array('queue' => $queue));
$summary = $vars->get('summary');
if ($summary) {
$qUrl->add('summary', $summary);
}
$states = $vars->get('states');
if (is_array($states)) {
foreach ($states as $type => $state) {
if (is_array($state)) {
foreach ($state as $s) {
$qUrl->add("states[{$type}][]", $s);
}
} else {
$qUrl->add("states[{$type}]", $state);
}
}
}
return substr($qUrl, 1);
}
示例7: _handle
/**
* @TODO: For reverse requests come up with a reasonable algorithm for
* checking if we have a lat/lng in the US since the
* findNearestAddress method is US only. If non-us, fallback to a
* findNearest or findPostalcode or similar request. Also will need
* to normalize the various response structures.
*
* 'locations' will trigger a forward geocoding request.
* 'lat' and 'lon' will trigger a reverse geocoding request.
*
* @throws Horde_Exception
*/
protected function _handle(Horde_Variables $vars)
{
if ($vars->location) {
$url = new Horde_Url('http://ws.geonames.org/searchJSON');
$url->add(array('q' => $vars->location));
} elseif ($vars->lat && $vars->lon) {
$url = new Horde_Url('http:/ws.geonames.org/findNearestJSON');
$url->add(array('lat' => $vars->lat, 'lng' => $vars->lon));
} else {
throw new Horde_Exception('Incorrect parameters');
}
$response = $GLOBALS['injector']->getInstance('Horde_Core_Factory_HttpClient')->create()->get($url);
return new Horde_Core_Ajax_Response_Prototypejs(array('results' => $response->getBody(), 'status' => 200));
}
示例8: testFromUrl
public function testFromUrl()
{
$baseurl = new Horde_Url('test', true);
$baseurl->add(array('foo' => 1, 'bar' => 2));
$url = new Horde_Url($baseurl);
$this->assertEquals('test?foo=1&bar=2', (string) $url);
$url = new Horde_Url($baseurl, true);
$this->assertEquals('test?foo=1&bar=2', (string) $url);
$url = new Horde_Url($baseurl, false);
$this->assertEquals('test?foo=1&bar=2', (string) $url);
$baseurl = new Horde_Url('test', false);
$baseurl->add(array('foo' => 1, 'bar' => 2));
$url = new Horde_Url($baseurl);
$this->assertEquals('test?foo=1&bar=2', (string) $url);
$url = new Horde_Url($baseurl, true);
$this->assertEquals('test?foo=1&bar=2', (string) $url);
$url = new Horde_Url($baseurl, false);
$this->assertEquals('test?foo=1&bar=2', (string) $url);
}
示例9: run
/**
* Run this request and return the data.
*
* @return mixed Either raw JSON, or an array of decoded values.
* @throws Horde_Service_Facebook_Exception
*/
public function run()
{
if ($this->_request != 'POST') {
$this->_endpoint->add($this->_params);
$params = array();
} else {
$params = $this->_params;
}
try {
$result = $this->_http->request($this->_request, $this->_endpoint->toString(true), $params);
} catch (Horde_Http_Exception $e) {
$this->_facebook->logger->err($e->getMessage());
throw new Horde_Service_Facebook_Exception($e);
}
if ($result->code != '200') {
$body = $result->getBody();
if (($error = json_decode($body, true)) && isset($error['error']['message'])) {
throw new Horde_Service_Facebook_Exception($error['error']['message']);
}
throw new Horde_Service_Facebook_Exception($body);
}
return json_decode($result->getBody());
}
示例10: autocompleteLocation
/**
* Return an autocomplete search response.
*
* @see Horde_Service_Weather_Base::autocompleteLocation()
*/
public function autocompleteLocation($search)
{
$url = new Horde_Url('http://autocomplete.wunderground.com/aq');
$url->add(array('query' => $search, 'format' => 'JSON'));
return $this->_parseAutocomplete($this->_makeRequest($url));
}
示例11: directoryNavLink
/**
* Produces a directory link used for navigation.
*
* @param string $currdir The current directory string.
* @param string $url The URL to link to.
*
* @return string The directory navigation string.
*/
public static function directoryNavLink($currdir, $url)
{
$label = array();
$root_dir_name = self::$backend['name'];
if ($currdir == $root_dir_name) {
$label[] = '[' . $root_dir_name . ']';
} else {
$parts = explode('/', $currdir);
$parts_count = count($parts);
$url = new Horde_Url($url);
$label[] = Horde::link($url->add('dir', self::$backend['root']), sprintf(_("Up to %s"), $root_dir_name)) . '[' . $root_dir_name . ']</a>';
for ($i = 1; $i <= $parts_count; ++$i) {
$part = array_slice($parts, 0, $i);
$dir = implode('/', $part);
if (strstr($dir, self::$backend['root']) !== false && self::$backend['root'] != $dir) {
if ($i == $parts_count) {
$label[] = $parts[$i - 1];
} else {
$label[] = Horde::link($url->add('dir', $dir), sprintf(_("Up to %s"), $dir)) . htmlspecialchars($parts[$i - 1]) . '</a>';
}
}
}
}
return implode('/', $label);
}
示例12: _createUrl
/**
* Create the URL for the keyserver.
*
* @param string $uri Action URI.
* @param array $params List of parameters to add to URL.
*
* @return Horde_Url Keyserver URL.
*/
protected function _createUrl($uri, array $params = array())
{
$url = new Horde_Url($this->_keyserver . $uri, true);
return $url->add($params);
}
示例13: _renderInline
/**
* Return the rendered inline version of the Horde_Mime_Part object.
*
* @return array See parent::render().
*/
protected function _renderInline()
{
$browser = $this->getConfigParam('browser');
$notification = $this->getConfigParam('notification');
$prefs = $this->getConfigParam('prefs');
$registry = $this->getConfigParam('registry');
$data = $this->_mimepart->getContents();
$html = '';
$title = Horde_Core_Translation::t("vCard");
$iCal = new Horde_Icalendar();
if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
$notification->push(Horde_Core_Translation::t("There was an error reading the contact data."), 'horde.error');
}
if (Horde_Util::getFormData('import') && Horde_Util::getFormData('source') && $registry->hasMethod('contacts/import')) {
$source = Horde_Util::getFormData('source');
$count = 0;
foreach ($iCal->getComponents() as $c) {
if ($c->getType() == 'vcard') {
try {
$registry->call('contacts/import', array($c, null, $source));
++$count;
} catch (Horde_Exception $e) {
$notification->push(Horde_Core_Translation::t("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
}
}
}
$notification->push(sprintf(Horde_Core_Translation::ngettext("%d contact was successfully added to your address book.", "%d contacts were successfully added to your address book.", $count), $count), 'horde.success');
}
$html .= '<table class="horde-table" style="width:100%">';
foreach ($iCal->getComponents() as $i => $vc) {
if ($i > 0) {
$html .= '<tr><td colspan="2"> </td></tr>';
}
$addresses = $vc->getAllAttributes('EMAIL');
$html .= '<tr><td colspan="2" class="header">';
if (($fullname = $vc->getAttributeDefault('FN', false)) === false) {
$fullname = count($addresses) ? $addresses[0]['value'] : Horde_Core_Translation::t("[No Label]");
}
$html .= htmlspecialchars($fullname) . '</td></tr>';
$n = $vc->printableName();
if (!empty($n)) {
$html .= $this->_row(Horde_Core_Translation::t("Name"), $n);
}
try {
$html .= $this->_row(Horde_Core_Translation::t("Alias"), implode("\n", $vc->getAttributeValues('ALIAS')));
} catch (Horde_Icalendar_Exception $e) {
}
try {
$birthdays = $vc->getAttributeValues('BDAY');
$birthday = new Horde_Date($birthdays[0]);
$html .= $this->_row(Horde_Core_Translation::t("Birthday"), $birthday->strftime($prefs->getValue('date_format')));
} catch (Horde_Icalendar_Exception $e) {
}
$photos = $vc->getAllAttributes('PHOTO');
foreach ($photos as $p => $photo) {
if (isset($photo['params']['VALUE']) && Horde_String::upper($photo['params']['VALUE']) == 'URI') {
$html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . htmlspecialchars($photo['value']) . '" />', false);
} elseif (isset($photo['params']['ENCODING']) && Horde_String::upper($photo['params']['ENCODING']) == 'B' && isset($photo['params']['TYPE'])) {
if ($browser->hasFeature('datauri') === true || $browser->hasFeature('datauri') >= strlen($photo['value'])) {
$html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . Horde_Url_Data::create($photo['params']['TYPE'], base64_decode($photo['value'])) . '" />', false);
} elseif ($this->_imageUrl) {
$html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . $this->_imageUrl->add(array('c' => $i, 'p' => $p)) . '" />', false);
}
}
}
$labels = $vc->getAllAttributes('LABEL');
foreach ($labels as $label) {
if (isset($label['params']['TYPE'])) {
if (!is_array($label['params']['TYPE'])) {
$label['params']['TYPE'] = array($label['params']['TYPE']);
}
} else {
$label['params']['TYPE'] = array_keys($label['params']);
}
$types = array();
foreach ($label['params']['TYPE'] as $type) {
switch (Horde_String::upper($type)) {
case 'HOME':
$types[] = Horde_Core_Translation::t("Home Address");
break;
case 'WORK':
$types[] = Horde_Core_Translation::t("Work Address");
break;
case 'DOM':
$types[] = Horde_Core_Translation::t("Domestic Address");
break;
case 'INTL':
$types[] = Horde_Core_Translation::t("International Address");
break;
case 'POSTAL':
$types[] = Horde_Core_Translation::t("Postal Address");
break;
case 'PARCEL':
$types[] = Horde_Core_Translation::t("Parcel Address");
break;
//.........这里部分代码省略.........
示例14: _addToken
/**
* Add the ingo action token to a URL.
*
* @param Horde_Url $url URL.
*
* @return Horde_Url URL with token added (for chainable calls).
*/
protected function _addToken(Horde_Url $url)
{
global $session;
return $url->add(self::INGO_TOKEN, $session->getToken());
}
示例15: catch
if ($valid && $form->isSubmitted()) {
// Add the item to the inventory.
try {
$ret = $sesha_driver->add(array('stock_name' => $vars->get('stock_name'), 'note' => $vars->get('note')));
} catch (Sesha_Exception $e) {
$notification->push(sprintf(_("There was a problem adding the item: %s"), $ret->getMessage()), 'horde.error');
header('Location: ' . $url);
exit;
}
$stock_id = $ret;
$notification->push(_("The item was added succcessfully."), 'horde.success');
// Add categories to the item.
$sesha_driver->updateCategoriesForStock($stock_id, $vars->get('category_id'));
// Add properties to the item as well.
$sesha_driver->updatePropertiesForStock($stock_id, $vars->get('property'));
$url->add(array('actionId' => 'view_stock', 'stock_id' => $stock_id->stock_id));
header('Location: ' . $url->toString(true, true));
exit;
}
break;
case 'remove_stock':
if (Sesha::isAdmin(Horde_Perms::DELETE)) {
try {
$ret = $sesha_driver->delete($stock_id);
} catch (Sesha_Exception $e) {
$notification->push(sprintf(_("There was a problem with the driver while deleting: %s"), $e->getMessage()), 'horde.error');
header('Location: ' . Horde::url($baseUrl . '/list.php', true));
exit;
}
$notification->push(sprintf(_("Item number %d was successfully deleted"), $stock_id), 'horde.success');
} else {