Add site url to XslLinks

19/07/2012 22:59


#input parameters
function GetSiteFromUrl(
$site=$short.substring($index+1, $short.length-$index-1)
return $site
function FixXslLink
$file=[xml](get-content ($srcPath+"\"+$fileName))
#Get nodes with Xsl Link settings (not error if node doesn't exist)
$main=$|where {$ -match "MainXslLink"}
$header=$|where {$ -match "HeaderXslLink"}
$item=$|where {$ -match "ItemXslLink"}
$links=@($main, $header, $item)
$prefix=GetSiteFromUrl -url $siteUrl
$prefix="/"+ $prefix
foreach($link in $links)
#write-host "Vynatok z linku:" $text.substring(0, $prefix.length)
if($text -ne $null) #if link is defined
    #Check if site url is already added to links, if not, add it
    if($text.substring(0, $prefix.length) -ne $prefix)
        $text=$prefix + $text
        write-host "Changing XslLink..."
        write-host "XslLink is already changed."
write-host "Saving file..."
write-host "File saved to: " $srcPath
FixXslLink -srcPath $srcPath -fileName $fileName -siteUrl $siteUrl