/**
  * visit 
  * 
  * @param KVDthes_Term $node 
  * @return void
  */
 public function visit(KVDthes_Term $node)
 {
     $this->result .= $this->pad() . "<li>\n";
     $this->depth++;
     $this->result .= $this->pad() . '<p><a href="' . $this->ro->gen($this->termRoute, array($this->termIdParameter => $node->getId())) . '">' . $node->getTerm() . "</a></p>\n";
     $this->depth--;
     return true;
 }
Пример #2
0
 /**
  * toHtml 
  * 
  * @param int $range 
  * @return string
  */
 public function toHtml($range = 5, $showtotals = false)
 {
     $html = '';
     if ($showtotals) {
         $html .= '<p><strong>Je zoekopdracht leverde ' . $this->pager->getTotalRecordCount() . ' resultaten.</strong></p>';
     }
     if ($this->pager->getPage() > $this->pager->getFirstPage()) {
         $this->parameters[$this->paginaNaam] = $this->pager->getPrev();
         $html .= $this->lh->genHtmlLink($this->ro->gen($this->route, $this->parameters), 'Vorige');
         $html .= ' [ ';
         $this->parameters[$this->paginaNaam] = $this->pager->getFirstPage();
         $html .= $this->lh->genHtmlLink($this->ro->gen($this->route, $this->parameters), $this->pager->getFirstPage()) . ' ';
     } else {
         $html .= 'Vorige [ ';
     }
     $html .= $this->pager->getPage() > $this->pager->getFirstPage() + $range ? '.. ' : '';
     foreach ($this->pager->getPrevLinks($range) as $page) {
         if ($page != $this->pager->getFirstPage()) {
             $this->parameters[$this->paginaNaam] = $page;
             $html .= $this->lh->genHtmlLink($this->ro->gen($this->route, $this->parameters), $page) . ' ';
         }
     }
     $html .= '<strong>' . $this->pager->getPage() . '</strong> ';
     foreach ($this->pager->getNextLinks($range) as $page) {
         if ($page != $this->pager->getLastPage()) {
             $this->parameters[$this->paginaNaam] = $page;
             $html .= $this->lh->genHtmlLink($this->ro->gen($this->route, $this->parameters), $page) . ' ';
         }
     }
     $html .= $this->pager->getPage() < $this->pager->getLastPage() - $range ? '.. ' : '';
     if ($this->pager->getPage() < $this->pager->getLastPage()) {
         $this->parameters[$this->paginaNaam] = $this->pager->getLastPage();
         $html .= $this->lh->genHtmlLink($this->ro->gen($this->route, $this->parameters), $this->pager->getLastPage());
         $html .= ' ] ';
         $this->parameters[$this->paginaNaam] = $this->pager->getNext();
         $html .= $this->lh->genHtmlLink($this->ro->gen($this->route, $this->parameters), 'Volgende');
     } else {
         $html .= ' ] Volgende';
     }
     return $html;
 }
 /**
  * Generate a formatted Agavi URL.
  *
  * @param      string A route name.
  * @param      array  An associative array of parameters.
  * @param      mixed  An array of options, or the name of an options preset.
  *
  * @return     string The generated URL.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public function gen($route, array $params = array(), $options = array())
 {
     $req = $this->context->getRequest();
     if (substr($route, -1) == '*') {
         $options['refill_all_parameters'] = true;
         $route = substr($route, 0, -1);
     }
     $options = $this->resolveGenOptions($options);
     $aso = $this->argSeparatorOutput;
     if ($options['separator'] != $aso) {
         $aso = $options['separator'];
     }
     if ($options['use_trans_sid'] === true && defined('SID') && SID !== '') {
         $params = array_merge($params, array(session_name() => session_id()));
     }
     if ($route === null && empty($params)) {
         $retval = $req->getRequestUri();
         $retval = str_replace(array('[', ']', '\''), array('%5B', '%5D', '%27'), $retval);
         // much quicker than str_replace($this->argSeparatorInput, array_fill(0, count($this->argSeparatorInput), $aso), $retval)
         foreach ($this->argSeparatorInput as $char) {
             $retval = str_replace($char, $aso, $retval);
         }
     } else {
         if ($this->isEnabled()) {
             // the route exists and routing is enabled, the parent method handles it
             $append = '';
             list($path, $usedParams, $options, $extraParams, $isNullRoute) = parent::gen($route, $params, $options);
             if ($isNullRoute) {
                 // add the incoming parameters from the request uri for gen(null) and friends
                 $extraParams = array_merge($this->inputParameters, $extraParams);
             }
             if (count($extraParams) > 0) {
                 $append = http_build_query($extraParams, '', $aso);
                 if ($append !== '') {
                     $append = '?' . $append;
                 }
             }
         } else {
             // the route exists, but we must create a normal index.php?foo=bar URL.
             $isNullRoute = false;
             $routes = $this->getAffectedRoutes($route, $isNullRoute);
             if ($isNullRoute) {
                 $params = array_merge($this->inputParameters, $params);
             }
             if (count($routes) == 0) {
                 $path = $route;
             }
             // we collect the default parameters from the route and make sure
             // new parameters don't overwrite already defined parameters
             $defaults = array();
             $ma = $req->getParameter('module_accessor');
             $aa = $req->getParameter('action_accessor');
             foreach ($routes as $route) {
                 if (isset($this->routes[$route])) {
                     $r = $this->routes[$route];
                     $myDefaults = array();
                     foreach ($r['opt']['defaults'] as $key => $default) {
                         $myDefaults[$key] = $default->getValue();
                     }
                     if ($r['opt']['module']) {
                         $myDefaults[$ma] = $r['opt']['module'];
                     }
                     if ($r['opt']['action']) {
                         $myDefaults[$aa] = $r['opt']['action'];
                     }
                     $defaults = array_merge($myDefaults, $defaults);
                 }
             }
             $params = array_merge($defaults, $params);
         }
         if (!isset($path)) {
             // the route does not exist. we generate a normal index.php?foo=bar URL.
             $path = $_SERVER['SCRIPT_NAME'];
         }
         if (!isset($path)) {
             // routing was off; the name of the route is the input
         }
         if (!isset($append)) {
             $append = '?' . http_build_query($params, '', $aso);
         }
         $retval = $path . $append;
     }
     if (!$options['relative'] || $options['relative'] && ($options['scheme'] !== null || $options['authority'] !== null || $options['host'] !== null || $options['port'] !== null)) {
         $scheme = false;
         if ($options['scheme'] !== false) {
             $scheme = $options['scheme'] === null ? $req->getUrlScheme() : $options['scheme'];
         }
         $authority = '';
         if ($options['authority'] === null) {
             if ($options['host'] !== null && $options['host'] !== false) {
                 $authority = $options['host'];
             } elseif ($options['host'] === false) {
                 $authority = '';
             } else {
                 $authority = $req->getUrlHost();
             }
             $port = null;
             if ($options['port'] !== null && $options['port'] !== false) {
                 if (AgaviToolkit::isPortNecessary($options['scheme'] !== null && $options['scheme'] !== false ? $options['scheme'] : $req->getUrlScheme(), $options['port'])) {
                     $port = $options['port'];
                 } else {
                     $port = null;
                 }
             } elseif ($options['port'] === false) {
                 $port = null;
             } elseif ($options['scheme'] === null) {
                 if (!AgaviToolkit::isPortNecessary($req->getUrlScheme(), $port = $req->getUrlPort())) {
                     $port = null;
                 }
             }
             if ($port !== null) {
                 $authority .= ':' . $port;
             }
         } elseif ($options['authority'] !== false) {
             $authority = $options['authority'];
         }
         if ($scheme === false) {
             // nothing at all, e.g. when displaying a URL without the "http://" prefix
             $scheme = '';
         } elseif (trim($scheme) === '') {
             // a protocol-relative URL (see #1224)
             $scheme = '//';
         } else {
             // given scheme plus "://"
             $scheme = $scheme . '://';
         }
         $retval = $scheme . $authority . $retval;
     }
     if ($options['fragment'] !== null) {
         $retval .= '#' . $options['fragment'];
     }
     return $retval;
 }