本文整理汇总了PHP中Horde_Url类的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Url类的具体用法?PHP Horde_Url怎么用?PHP Horde_Url使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Horde_Url类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTab
/**
* Adds a tab to the interface.
*
* @param string $title The text which appears on the tab.
* @param Horde_Url $link The target page.
* @param mixed $params Either a string value to set the tab variable to,
* or a hash of parameters. If an array, the tab
* variable can be set by the 'tabname' key.
*/
public function addTab($title, $link, $params = array())
{
if (!is_array($params)) {
$params = array('tabname' => $params);
}
$this->_tabs[] = array_merge(array('title' => $title, 'link' => $link->copy(), 'tabname' => null, 'img' => null, 'class' => null), $params);
}
示例2: testUrlMissingScheme
public function testUrlMissingScheme()
{
$url = new Horde_Url('example.com/test?foo=1&bar=2');
$url->setScheme();
$this->assertEquals('/test?foo=1&bar=2', $url->toString(true, false));
$this->assertEquals('http://example.com/test?foo=1&bar=2', $url->toString(true, true));
}
示例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: testEmptyRedirect
public function testEmptyRedirect()
{
$url = new Horde_Url('');
try {
$url->redirect();
$this->fail();
} catch (Horde_Url_Exception $e) {
}
}
示例6: token
/**
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*/
public function token($options)
{
try {
$link = new Horde_Url($GLOBALS['registry']->link($options['method'], $options['args']));
} catch (Horde_Exception $e) {
return $e->getMessage();
}
return $link->link() . $options['title'] . '</a>';
}
示例7: _init
/**
*/
protected function _init()
{
global $browser, $injector, $page_output, $registry;
$page_output->addScriptFile('base.js');
$page_output->addScriptFile('passphrase.js');
$page_output->addScriptFile('viewport.js');
$page_output->addScriptFile('external/CustomElements.js');
$page_output->addScriptFile('external/time-elements.js');
$page_output->addScriptFile('external/tinycon.js');
$page_output->addScriptFile('dragdrop2.js', 'horde');
$page_output->addScriptFile('form_ghost.js', 'horde');
$page_output->addScriptFile('jstorage.js', 'horde');
$page_output->addScriptFile('slider2.js', 'horde');
$page_output->addScriptFile('toggle_quotes.js', 'horde');
$page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
$page_output->addScriptPackage('IMP_Script_Package_Imp');
$page_output->addThemeStylesheet('mailbox.css');
$page_output->addThemeStylesheet('message_view.css');
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if ($imp_imap->access(IMP_Imap::ACCESS_FLAGS)) {
$page_output->addScriptFile('colorpicker.js', 'horde');
$this->view->picker_img = Horde_Themes_Image::tag('colorpicker.png', array('alt' => _("Color Picker")));
}
if ($imp_imap->access(IMP_Imap::ACCESS_REMOTE)) {
$page_output->addScriptFile('external/base64.js');
}
$this->_addMailboxVars();
$this->view->show_innocent = !empty($imp_imap->config->innocent_params);
$this->view->show_search = $imp_imap->access(IMP_Imap::ACCESS_SEARCH);
$this->view->show_spam = !empty($imp_imap->config->spam_params);
$impSubinfo = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/dynamic'));
$impSubinfo->addHelper('Text');
$impSubinfo->quota = (bool) $imp_imap->config->quota;
$topbar = $injector->getInstance('Horde_View_Topbar');
$topbar->search = $this->view->show_search;
$topbar->searchMenu = true;
$topbar->subinfo = $impSubinfo->render('mailbox_subinfo');
$page_output->topbar = true;
$blank = new Horde_Url();
$impSidebar = new Horde_View(array('templatePath' => array($registry->get('templates', 'horde') . '/sidebar', IMP_TEMPLATES . '/dynamic')));
$impSidebar->addHelper('Text');
$impSidebar->containers = array(array('id' => 'imp-specialmboxes'));
if ($imp_imap->isImap()) {
$impSidebar->containers[] = array('rows' => array(array('id' => 'folderopts_link', 'cssClass' => 'folderoptsImg', 'link' => $blank->link() . _("Folder Actions") . '</a>'), array('id' => 'dropbase', 'style' => 'display:none', 'cssClass' => 'folderImg', 'link' => $blank->link() . _("Move to Base Level") . '</a>')));
$impSidebar->containers[] = array('id' => 'imp-normalmboxes');
}
$sidebar = $injector->getInstance('Horde_View_Sidebar');
$sidebar->newLink = $blank->link(array('id' => 'composelink', 'class' => 'icon'));
$sidebar->newText = _("New Message");
$sidebar->content = $impSidebar->render('sidebar');
$this->view->sidebar = $sidebar->render();
$this->view->max_fsize = intval($browser->allowFileUploads());
$page_output->noDnsPrefetch();
$this->_pages[] = 'mailbox';
}
示例8: _postRequest
/**
* Send a POST request
*
* @param string $method The method to call.
* @param array $params The method parameters.
*
* @return string The request results
* @throws Horde_Service_Facebook_Exception
*/
protected function _postRequest($method, &$params)
{
$this->_finalizeParams($params);
try {
$url = new Horde_Url(Horde_Service_Facebook::REST_SERVER_ADDR . $method);
$result = $this->_http->request('POST', $url->toString(), $this->_createPostString($params));
} catch (Exception $e) {
$this->_facebook->logger->err($e->getMessage());
throw new Horde_Service_Facebook_Exception(Horde_Service_Facebook_Translation::t("Facebook service is unavailable. Please try again later."));
}
return $result->getBody();
}
示例9: 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;
}
}
示例10: _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));
}
示例11: 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);
}
示例12: __construct
public function __construct(array $config)
{
if (!empty($config['what']) && !empty($config['loc'])) {
$this->title = $this->header = _("Search Results");
$url = new Horde_Url('list.php');
$this->backToList = $url->link() . _('Back to stock list') . '</a>';
} else {
$this->title = $this->header = _("Available Inventory");
}
$this->selectedCategories = is_array($config['selectedCategories']) ? $config['selectedCategories'] : array($config['selectedCategories']);
if (empty($this->selectedCategories[0])) {
array_shift($this->selectedCategories);
}
$this->shownProperties = $this->properties($config['propertyIds']);
$this->columnHeaders = $this->columnHeaders($config['sortDir'], $config['sortBy']);
$filters = array();
if (!empty($this->selectedCategories)) {
$filters[] = array('type' => 'categories', 'value' => $this->selectedCategories, 'exact' => $config['exact']);
}
if (!empty($config['loc'])) {
if (in_array(Sesha::SEARCH_ID, $config['loc'])) {
$filters[] = array('type' => 'stock_id', 'exact' => $config['exact'], 'value' => $config['what']);
}
if (in_array(Sesha::SEARCH_NAME, $config['loc'])) {
$filters[] = array('type' => 'stock_name', 'exact' => $config['exact'], 'value' => $config['what']);
}
if (in_array(Sesha::SEARCH_NOTE, $config['loc'])) {
$filters[] = array('type' => 'note', 'exact' => $config['exact'], 'value' => $config['what']);
}
if (in_array(Sesha::SEARCH_PROPERTY, $config['loc'])) {
$filters[] = array('type' => 'values', 'exact' => $config['exact'], 'value' => array(array('values' => array($config['what']))));
}
}
$this->shownStock = $this->stock($filters);
parent::__construct($config);
}
示例13: _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);
}
示例14: _idDeconstruct
/**
* Deconstruct the ID elements from the ID string
*
* @param string $id The ID to be deconstructed.
*
* @return array A tuple of (owner, folder subpath).
*/
private function _idDeconstruct($id)
{
if (!($decoded_id = Horde_Url::uriB64Decode($id))) {
$msg = sprintf('Share id %s is invalid.', $id);
$this->_logger->err($msg);
throw new Horde_Exception_NotFound($msg);
}
if (!($sid = @unserialize($decoded_id))) {
$msg = sprintf('Share id %s is invalid.', $decoded_id);
$this->_logger->err($msg);
throw new Horde_Exception_NotFound($msg);
}
return $sid;
}
示例15: _makeRequest
/**
* Make the remote API call.
*
* @param Horde_Url $url The endpoint.
*
* @return mixed The unserialized results form the remote API call.
* @throws Horde_Service_Weather_Exception
*/
protected function _makeRequest(Horde_Url $url)
{
// Owm returns temperature data in Kelvin by default!
if ($this->units == Horde_Service_Weather::UNITS_METRIC) {
$url->add('units', 'metric');
} else {
$url->add('units', 'imperial');
}
$url->add(array('key' => $this->_key))->setRaw(true);
$cachekey = md5('hordeweather' . $url);
if (!empty($this->_cache) && !($results = $this->_cache->get($cachekey, $this->_cache_lifetime)) || empty($this->_cache)) {
$response = $this->_http->get((string) $url);
if (!$response->code == '200') {
throw new Horde_Service_Weather_Exception($response->code);
}
$results = $response->getBody();
if (!empty($this->_cache)) {
$this->_cache->set($cachekey, $results);
}
}
$results = Horde_Serialize::unserialize($results, Horde_Serialize::JSON);
if (!$results instanceof StdClass) {
throw new Horde_Service_Weather_Exception(sprintf('Error, unable to decode response: %s', $results));
}
return $results;
}