Get Pages index URLs.

@param int  $nb       Number of pages to be shown in the index
@param bool $absolute Indicate if the URI should be absolute

@return array
160120
public function getPagesIndex($nb = 11, $absolute = false)
    {
        $space = ($nb - 1) / 2;
        $start = $this->getCurPage() - $space;
        $end = $this->getCurPage() + $space;
        if ($start < 1 && $end > $this->getNbPages()) {
            $start = 1;
            $end = $this->getNbPages();
        } elseif ($start < 1) {
            $start = 1;
            $end = $nb - 1;
        } elseif ($end > $this->getNbPages()) {
            $end = $this->getNbPages();
            $start = $end - $nb + 1;
        }

        if ($start < 1) {
            $start = 1;
        }
        if ($end > $this->getNbPages()) {
            $end = $this->getNbPages();
        }

        $ret = array();
        for ($i = $start; $i <= $end; ++$i) {
            $ret[$i] = array(
                $this->getUrl($i, $absolute),
                $i == $this->getCurPage(),
            );
        }

        return $ret;
    }
603827
public function getAllLinks($pageNumber)
    {

        $iTotalLinks = $this->GetLinksCount($pageNumber);
        $listLinks = array();
        for ($index = 1; $index <= $iTotalLinks; $index++) {
            array_push($listLinks, $this->GetLink($pageNumber, $index));
        }
        return $listLinks;
    }
849346
public function getUrl($page, $absolute = false, $routePrm = null)
    {
        $prm = !is_null($routePrm) ? $routePrm : $this->routePrm;
        $prm['page'] = $page;

        return $this->service->generateUrl($this->route, $prm, $absolute);
    }
239020
private static function InternetCombineUrl( $absolute, $relative )
	{
		if ( $relative == "" ) return $absolute;

		$p = parse_url( $relative );

		if( isset( $p["scheme"] ) ) return $relative;

		extract( parse_url( $absolute ) );

		$path = dirname( $path );
		if ( $path = "\\" ) $path = "/";

		if ( $relative[0] == '/' )
		{
			$cparts = array_filter( explode( "/", $relative ) );
		}
		else
		{
			$aparts = array_filter(explode( "/", $path ) );
			$rparts = array_filter(explode( "/", $relative ) );
			$cparts = array_merge( $aparts, $rparts );
			foreach( $cparts as $i => $part )
			{
				if( $part == '.')
				{
					$cparts[$i] = null;
				}

				if($part == '..')
				{
					$cparts[$i - 1] = null;
					$cparts[$i] = null;
				}
			}
			$cparts = array_filter( $cparts );
		}

		$path = implode( "/", $cparts );
		$url = "";
		if ( $scheme )
		{
			$url = "$scheme://";
		}
		if ( isset( $user ) )
		{
			$url .= "$user";
			if( $pass )
			{
				$url .= ":$pass";
			}
			$url .= "@";
		}

		if( $host )
		{
			$url .= "$host/";
		}

		$url .= $path;

		return $url;
	}
1354676
public function generateUrl(NewsCategoryModel $category, PageModel $page, $absolute = false)
    {
        $page->loadDetails();

        $params = '/'.$this->getParameterName($page->rootId).'/'.$this->getCategoryAlias($category, $page);

        return $absolute ? $page->getAbsoluteUrl($params) : $page->getFrontendUrl($params);
    }
226693
public static function getRouteByName($name, $parameters = [], $absolute = true) {
		foreach ( self::$routes as $routePath => $routeDetails ) {
			if (self::checkRouteName ( $routeDetails, $name )) {
				if (\sizeof ( $parameters ) > 0)
					$routePath = self::_getURL ( $routePath, $parameters );
				if (! $absolute)
					return \ltrim ( $routePath, '/' );
				else
					return $routePath;
			}
		}
		return false;
	}
641401
public function getNextPageParams()
    {
        $limit = $this->limit <= 0 ? $this->count : $this->limit;
        $next_url = $this->offset_key
            . $this->offset
            . $this->limit_key
            . $limit;

        if ($this->count <= ($this->offset + $limit)) {
           return false;
        }

        if ($this->count >= $limit) {
            $next_url = $this->offset_key
                . ($this->offset + $limit)
                . $this->limit_key
                . $limit;
        }

        return $next_url;
    }
524896
public function getIndex($index)
    {
        if (is_string($index) &&
            is_array($this->secondary_indexes) &&
            array_key_exists($index, $this->secondary_indexes)
        ) {
            return $this->secondary_indexes[$index];
        } else {
            throw new ENabuCoreException(ENabuCoreException::ERROR_INVALID_INDEX, array(print_r($index, true)));
        }
    }
63069
protected function getRootPagesWithIndexingOff()
    {
        $rootPages = $this->getRootPages();
        $rootPagesWithIndexingOff = [];

        foreach ($rootPages as $rootPage) {
            try {
                $this->initializeTSFE($rootPage);
                $solrIsEnabledAndIndexingDisabled = $this->getIsSolrEnabled() && !$this->getIsIndexingEnabled();
                if ($solrIsEnabledAndIndexingDisabled) {
                    $rootPagesWithIndexingOff[] = $rootPage;
                }
            } catch (\RuntimeException $rte) {
                $rootPagesWithIndexingOff[] = $rootPage;
            } catch (ServiceUnavailableException $sue) {
                if ($sue->getCode() == 1294587218) {
                    //  No TypoScript template found, continue with next site
                    $rootPagesWithIndexingOff[] = $rootPage;
                    continue;
                }
            }
        }

        return $rootPagesWithIndexingOff;
    }
981017
protected function calculateLinks($currentPage, $numberOfPages)
    {
        $baseUrl = $this->getBaseUrl();
        $prev = ($currentPage > 1) ? $currentPage - 1 : null;
        $next = ($currentPage < $numberOfPages) ? $currentPage + 1 : null;

        $separator = ($this->paginationLink) ? '/' : '?page=';

        return [
            'current' => $baseUrl.$separator.$currentPage,
            'prev' => ($prev) ? $baseUrl.$separator.$prev : null,
            'next' => ($next) ? $baseUrl.$separator.$next : null,
            'last' => ($numberOfPages > 0) ? $baseUrl.$separator.$numberOfPages : null,
        ];
    }
483269
public function getCurrentUri($absolute = true)
    {
        if ($absolute) {
            return $this->get('scheme') . $this->get('name') . $this->get('uri');
        } else {
            return $this->get('uri');
        }
    }
1063477
public function getPageLink($idPage, $absolute = false)
	{
	    if (empty($idPage))
	        return null;
        
        // Retrieve cache version if front mode to avoid multiple calls
        $cacheKey = 'getPageLink_' . $idPage . '_' . $absolute;
        $cacheConfig = 'engine_page_services';
        $melisEngineCacheSystem = $this->serviceLocator->get('MelisEngineCacheSystem');
        $results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig);
        if (!empty($results)) return $results;
	        
        // Get the already generated link from the DB if possible    
        $link = '';
        $tablePageDefaultUrls = $this->getServiceLocator()->get('MelisEngineTablePageDefaultUrls');
        if ($this->getRenderMode() == 'front')
        {
            $defaultUrls = $tablePageDefaultUrls->getEntryById($idPage);
            if (!empty($defaultUrls))
            {
                $defaultUrls = $defaultUrls->toArray();
                if (count($defaultUrls) > 0)
                {
                    $link = $defaultUrls[0]['purl_page_url'];
                }
            }
        }
        
        // if nothing found in DB, then let's generate
        if ($link == '')
        {
            // Generate real one
            
            // Check for SEO URL first
            $seoUrl = '';
            $melisPage = $this->getServiceLocator()->get('MelisEnginePage');
            $datasPageRes = $melisPage->getDatasPage($idPage);
            $datasPageTreeRes = $datasPageRes->getMelisPageTree();
            
            if ($datasPageTreeRes && !empty($datasPageTreeRes->pseo_url))
            {
                $seoUrl = $datasPageTreeRes->pseo_url;
                if (substr($seoUrl, 0, 1) != '/')
                    $seoUrl = '/' . $seoUrl;
            }
            
            if ($seoUrl == '')
            {
                // First let's see if page is the homepage one ( / no id following for url)
                $datasSite = $this->getSiteByPageId($idPage);
                if (!empty($datasSite) && $datasSite->site_main_page_id == $idPage)
                {
                    $seoUrl = '/';
                }
                else
                {
                    // if not, construct a classic Melis URL /..../..../id/xx
                    $datasPage = $this->getPageBreadcrumb($idPage);
            
                    $seoUrl = '/';
                    foreach ($datasPage as $page)
                    {
                        if (!empty($datasSite) && $datasSite->site_main_page_id == $page->page_id)
                            continue;

                            $namePage = $page->page_name;
    
                        $seoUrl .= $namePage . '/';
                    }
                    $seoUrl .= 'id/' . $idPage;
                }
            }

            $link = $this->cleanLink($seoUrl);
            
            $tablePageDefaultUrls->save(
                array(
                    'purl_page_id' => $idPage,
                    'purl_page_url' => $link
                ),
                $idPage
            );
        }
            
		$router = $this->getServiceLocator()->get('router');
        $request = $this->getServiceLocator()->get('request');
        $routeMatch = $router->match($request);
        
        $idversion = null;
        if (!empty($routeMatch)){
            $idversion = $routeMatch->getParam('idversion');
        }
            
		if ($absolute || !empty($idversion))
		{
			$host = $this->getDomainByPageId($idPage);
			$link = $host . $link;
		}

		// Save cache key
		$melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $link);
	
		return $link;
	}
948048
public function getMyAliasNbPages()
    {
        if ($this->_myLastPageGroupNb == 0) {
            return $this->getAliasNbPages();
        } else {
            $old = $this->currpagegroup;
            $this->currpagegroup = '{nb'.$this->_myLastPageGroupNb.'}';
            $new = $this->getPageGroupAlias();
            $this->currpagegroup = $old;

            return $new;
        }
    }
813897
public function getNewsShowPermalink(News $articles, $absolute = 1)
    {
        return $this->getContainer()->get('router')->generate($this->getNewsShowRoute(), $this->getNewsShowRouteParameters($articles), $absolute);
    }
1305540
public function getData($pageSize = 10, $pageNo = null)
    {
        if (empty($pageNo) && isset($_GET[$this->getPageVar()])) {
            $pageNo = intval($_GET[$this->getPageVar()]);
        }
        $pageNo = empty($pageNo) ? 1 : $pageNo;
        return [
            'pageSize' => $pageSize,
            'pageNo' => $pageNo,
            'totalCount' => $this->_dbInstance->getTotalCount(),
            'result' => $this->_dbInstance->getData($pageSize, $pageNo),
        ];
    }
449644
public function getPreviousUrl($absolute = false)
    {
        return $this->hasPrevious() ? $this->getUrl($this->getPrevious(), $absolute) : null;
    }
776631
static public function getMapRolesForSite($nb_site)
    {
        $nb_site_id = nb_getMixedValue($nb_site, NABU_SITE_FIELD_ID);
        if (is_numeric($nb_site_id)) {
            $retval = CNabuEngine::getEngine()
                    ->getMainDB()
                    ->getQueryAsObjectArray(
                        '\nabu\data\site\CNabuSiteMapRole', null,
                        'select smr.* '
                        . 'from nb_site_map sm, nb_site_map_role smr '
                       . 'where sm.nb_site_map_id=smr.nb_site_map_id '
                         . 'and sm.nb_site_id=%site_id$d '
                       . 'order by sm.nb_site_map_order, smr.nb_role_id',
                        array(
                            'site_id' => $nb_site_id
                        ), null, true
                    )
            ;
        } else {
            $retval = null;
        }

        return $retval;
    }