<?php
defined('_JEXEC') or die('Restricted access');

if (!class_exists('modVMLocationHelper')) {
    class modVMLocationHelper
    {
        public static function getLink(&$params)
        {
            $document = JFactory::getDocument();

            foreach ($document->_links as $link => $value)
            {
                $value = JArrayHelper::toString($value);
                if (strpos($value, 'application/'.$params->get('format').'+xml'))
                {
                    return $link;
                }
            }
        }

        public static function sefRelToAbs($value) {

            // Replace all &amp; with & as the router doesn't understand &amp;
            $url = str_replace('&amp;', '&', $value);//replace chars &amp; on & in
            if(substr(strtolower($url),0,9) != "index.php") return $url;//cheking correct url

            $uri    = JURI::getInstance();
            $prefix = $uri->toString(array('scheme', 'host', 'port'));

            return $prefix.JRoute::_($url);
        }

    }
}
