Wicked::url PHP Method

url() public static method

Puts together the URL to a Wicked page. Uses mod_rewrite or GET style URLs depending on configuration.
public static url ( string $page, boolean $full = false, integer $append_session ) : Horde_Url
$page string The name of the page to target.
$full boolean @see Horde::url()
$append_session integer @see Horde::url()
return Horde_Url The URL of $page.
    public static function url($page, $full = false, $append_session = 0)
    {
        if ($GLOBALS['conf']['urls']['pretty'] == 'rewrite') {
            $script = str_replace('%2F', '/', urlencode($page));
        } else {
            $script = Horde::url('display.php')->add('page', $page);
        }
        $url = Horde::url($script, $full, array('append_session' => $append_session));
        if (!$full) {
            $url->url = preg_replace('|^([a-zA-Z][a-zA-Z0-9+.-]{0,19})://[^/]*|', '', $url->url);
        }
        return $url;
    }

Usage Example

Esempio n. 1
0
 /**
  * Renders this page in display mode.
  *
  * @param string $searchtext  The title to search for.
  *
  * @return string  The content.
  * @throws Wicked_Exception
  */
 public function display($searchtext)
 {
     global $injector, $notification, $page_output, $wicked;
     $view = $injector->createInstance('Horde_View');
     if (!$searchtext) {
         return $view->render('pagelist/search') . $view->render('pagelist/footer');
     }
     /* Prepare exact match section */
     $exact = array();
     $page = new Wicked_Page_StandardPage($searchtext);
     if ($wicked->pageExists($searchtext)) {
         $exact[] = $page->toView();
     } else {
         $exact[] = (object) array('author' => '', 'context' => Wicked::url($searchtext, false)->link(array('title' => sprintf(_("Create %s"), $searchtext))) . sprintf(_("%s does not exist. You can create it now."), '<strong>' . htmlspecialchars($searchtext) . '</strong>') . '</a>', 'date' => '', 'name' => htmlspecialchars($searchtext), 'timestamp' => 0, 'version' => '', 'url' => Wicked::url($searchtext, false));
     }
     /* Prepare page title matches */
     $titles = array();
     foreach ($this->_results['titles'] as $page) {
         if (!empty($page['page_history'])) {
             $page = new Wicked_Page_StandardHistoryPage($page);
         } else {
             $page = new Wicked_Page_StandardPage($page);
         }
         $titles[] = $page->toView();
     }
     /* Prepare page text matches */
     $pages = array();
     foreach ($this->_results['pages'] as $page) {
         if (!empty($page['page_history'])) {
             $page = new Wicked_Page_StandardHistoryPage($page);
         } else {
             $page = new Wicked_Page_StandardPage($page);
         }
         $object = $page->toView();
         $object->context = $this->getContext($page, $searchtext);
         $pages[] = $object;
     }
     $page_output->addScriptFile('tables.js', 'horde');
     $header = $injector->createInstance('Horde_View');
     $header->th_page = _("Page");
     $header->th_version = _("Current Version");
     $header->th_author = _("Last Author");
     $header->th_updated = _("Last Update");
     $view = $injector->createInstance('Horde_View');
     // Show search form and page header.
     $content = $view->render('pagelist/search');
     // Show exact match.
     $header->title = _("Exact Match");
     $content .= $header->render('pagelist/results_header') . $view->renderPartial('pagelist/page', array('collection' => $exact)) . $view->render('pagelist/results_footer');
     // Show page title matches.
     $header->title = _("Page Title Matches");
     $content .= $header->render('pagelist/results_header') . $view->renderPartial('pagelist/page', array('collection' => $titles)) . $view->render('pagelist/results_footer');
     // Show page text matches.
     $header->title = _("Page Text Matches");
     $content .= $header->render('pagelist/results_header') . $view->renderPartial('pagelist/page', array('collection' => $pages)) . $view->render('pagelist/results_footer');
     return $content;
 }
All Usage Examples Of Wicked::url