<?php

define("IS_ADMIN", true);
require_once(dirname(__FILE__)."/../../include/init.php");
es_include("localpage.php");
es_include("page.php");
es_include("pagelist.php");
es_include("user.php");

$output = "pageList = new Array();\r\n";

$user = new User();
if ($user->ValidateAccess(array(INTEGRATOR, ADMINISTRATOR, MODERATOR)))
{
	$pageList = new PageList();
	$items = $pageList->GetPageListForLink();

	$type = GetFromConfig("PageListType");

	$i = 0;
	if ($type == "list")
	{
		foreach ($items as $k => $v)
		{
			$v["Title"] = addcslashes($v["Title"], "\r\n'\\\"");
			if (is_null($v["PageURL"]))
			{
				$output .= "pageList[".($i)."] = new Array('".$v["Title"]."', null);\r\n";
			}
			else
			{
				$v["PageURL"] = addcslashes($v["PageURL"], "\r\n'\\\"");
				$output .= "pageList[".($i)."] = new Array('".$v["Title"]."', '".$v["PageURL"]."');\r\n";
			}
			$i++;
		}
	}
	else
	{
		foreach ($items as $k => $v)
		{
			$v["PageURL"] = addcslashes($v["PageURL"], "\r\n'\\\"");
			$v["Title"] = addcslashes($v["Title"], "\r\n'\\\"");
			$output .= "pageList[".($i)."] = new Array('".$v["Title"]."', '".$v["PageURL"]."');\r\n";
			$i++;
		}
	}
}

echo $output;

?>