當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Horde_Url::setAnchor方法代碼示例

本文整理匯總了PHP中Horde_Url::setAnchor方法的典型用法代碼示例。如果您正苦於以下問題:PHP Horde_Url::setAnchor方法的具體用法?PHP Horde_Url::setAnchor怎麽用?PHP Horde_Url::setAnchor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Horde_Url的用法示例。


在下文中一共展示了Horde_Url::setAnchor方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRemoveEncoded

 public function testRemoveEncoded()
 {
     $url = new Horde_Url('test?foo=1&bar=2');
     $this->assertEquals('test?bar=2', (string) $url->remove('foo'));
     $url = new Horde_Url('test?foo=1&bar=2');
     $this->assertEquals('test?foo=1', (string) $url->remove('bar'));
     $url = new Horde_Url('test?foo=1&bar=2');
     $this->assertEquals('test', (string) $url->remove(array('foo', 'bar')));
     $url = new Horde_Url('test?foo=1&bar=2&baz=3');
     $this->assertEquals('test?bar=2&baz=3', (string) $url->remove('foo'));
     $url = new Horde_Url('test?foo=1&bar=2#baz');
     $url->setAnchor('');
     $this->assertEquals('test?foo=1&bar=2', (string) $url);
 }
開發者ID:jubinpatel,項目名稱:horde,代碼行數:14,代碼來源:RemoveTest.php

示例2: getUrlFor

 /**
  * Return a properly formatted link depending on the global pretty url
  * configuration
  *
  * @param string $controller       The controller to generate a URL for.
  * @param array $data              The data needed to generate the URL.
  * @param boolean $full            Generate a full URL.
  * @param integer $append_session  0 = only if needed, 1 = always, -1 = never.
  *
  * @return Horde_Url The generated URL
  */
 public static function getUrlFor($controller, $data, $full = false, $append_session = 0)
 {
     global $prefs;
     $rewrite = isset($GLOBALS['conf']['urls']['pretty']) && $GLOBALS['conf']['urls']['pretty'] == 'rewrite';
     switch ($controller) {
         case 'view':
             if ($rewrite && empty($data['special'])) {
                 $url = '';
                 // Viewing a List
                 if ($data['view'] == 'List') {
                     $groupby = isset($data['groupby']) ? $data['groupby'] : $prefs->getValue('groupby');
                     if ($groupby == 'owner' && !empty($data['owner'])) {
                         $url = 'user/' . urlencode($data['owner']) . '/';
                     } elseif ($groupby == 'owner') {
                         $url = 'user/';
                     } elseif ($groupby == 'none') {
                         $url = 'all/';
                     }
                     $url = Horde::url($url, $full, $append_session);
                     //  don't append the page number if it's zero
                     if (!empty($data['page'])) {
                         $url->add('page', $data['page']);
                     }
                     return $url;
                 }
                 // Viewing a Gallery or Image
                 if ($data['view'] == 'Gallery' || $data['view'] == 'Image') {
                     // @TODO: This is needed to correctly generate URLs in
                     // places that are not specifically requested by the user,
                     // for instance, in a gallery block. Otherwise, the proper
                     // date variables would not be attached to the url, since we
                     // don't know them ahead of time.  This is a slight hack and
                     // needs to be corrected, probably by delegating at least
                     // some of the URL generation to the gallery/image/view
                     // object...most likely when we move to PHP5.
                     if (empty($data['year']) && $data['view'] == 'Image') {
                         // Getting these objects is not ideal, but at this point
                         // they should already be locally cached so the cost
                         // is minimized.
                         $i = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($data['image']);
                         $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($data['gallery']);
                         if ($g->get('view_mode') == 'Date') {
                             $imgDate = new Horde_Date($i->originalDate);
                             $data['year'] = $imgDate->year;
                             $data['month'] = $imgDate->month;
                             $data['day'] = $imgDate->mday;
                         }
                     }
                     $url = 'gallery/' . (!empty($data['slug']) ? $data['slug'] : 'id/' . (int) $data['gallery']) . '/';
                     // See comments below about lightbox
                     if ($data['view'] == 'Image' && (empty($data['gallery_view']) || !empty($data['gallery_view']) && $data['gallery_view'] != 'GalleryLightbox')) {
                         $url .= (int) $data['image'] . '/';
                     }
                     $extras = array();
                     // We may have a value of zero here, but it's the default,
                     // so ignore it if it's empty.
                     if (!empty($data['havesearch'])) {
                         $extras['havesearch'] = $data['havesearch'];
                     }
                     // Block any auto navigation (for date views)
                     if (!empty($data['force_grouping'])) {
                         $extras['force_grouping'] = $data['force_grouping'];
                     }
                     $url = new Horde_Url($url);
                     if (count($extras)) {
                         $url->add($extras);
                     }
                     //Slight hack until we delegate at least some of the url
                     // generation to the gallery/image/view object.
                     if ($data['view'] == 'Image' && !empty($data['gallery_view']) && $data['gallery_view'] == 'GalleryLightbox') {
                         $url->setAnchor($data['image']);
                     }
                 } elseif ($data['view'] == 'Results') {
                     $url = new Horde_Url('tag/' . (!empty($data['tag']) ? urlencode($data['tag']) . '/' : ''));
                     if (!empty($data['actionID'])) {
                         $url->add(array('actionID' => $data['actionID']));
                     }
                     if (!empty($data['owner'])) {
                         $url->add('owner', $data['owner']);
                     }
                 }
                 // Keep the URL as clean as possible - don't append the page
                 // number if it's zero, which would be the default.
                 if (!empty($data['page'])) {
                     $url->add('page', $data['page']);
                 }
                 if (!empty($data['year'])) {
                     $url->add(array('year' => $data['year'], 'month' => empty($data['month']) ? 0 : $data['month'], 'day' => empty($data['day']) ? 0 : $data['day']));
                 }
//.........這裏部分代碼省略.........
開發者ID:jubinpatel,項目名稱:horde,代碼行數:101,代碼來源:Ansel.php

示例3: testEncodeAnchor

 public function testEncodeAnchor()
 {
     $url = new Horde_Url('test');
     $url->setAnchor('a@b.com');
     $this->assertEquals('test#a%40b.com', (string) $url);
 }
開發者ID:jubinpatel,項目名稱:horde,代碼行數:6,代碼來源:AddTest.php


注:本文中的Horde_Url::setAnchor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。