<?php

$cms_root_path = "../../../";
require_once($cms_root_path."includes/compatibility_includer.php");

$term = "";
if ( !empty($_GET['term']) ) {
	$term = $_GET['term'];
}

$existing_pagedata_names = Pagedata::GetExistingPagedataNames($term);

$json = array();

foreach($existing_pagedata_names as $existing_pagedata_name) {

	if ( empty($existing_pagedata_name['name']) ) {
		continue;
	}

	$json[] = array(
		'id' => $existing_pagedata_name['name'],
		'label' => $existing_pagedata_name['name'],
		'value' => $existing_pagedata_name['name'],
	);
}

echo json_encode($json);