示例#1
0
文件: treemenu.php 项目: oki34/eztags
$children = eZTagsObject::fetchList(array('parent_id' => $tagID, 'main_tag_id' => 0), $limitArray);
$response = array();
$response['error_code'] = 0;
$response['id'] = $tagID;
$response['parent_id'] = $tag instanceof eZTagsObject ? (int) $tag->attribute('parent_id') : -1;
$response['children_count'] = count($children);
$response['children'] = array();
foreach ($children as $child) {
    $childResponse = array();
    $childResponse['id'] = (int) $child->attribute('id');
    $childResponse['parent_id'] = (int) $child->attribute('parent_id');
    $childResponse['has_children'] = $child->getChildrenCount() > 0 ? 1 : 0;
    $childResponse['synonyms_count'] = $child->getSynonymsCount();
    $childResponse['subtree_limitations_count'] = $child->getSubTreeLimitationsCount();
    $childResponse['language_name_array'] = $child->languageNameArray();
    $childResponse['keyword'] = $child->attribute('keyword');
    $childResponse['url'] = 'tags/id/' . $child->attribute('id');
    $childResponse['icon'] = eZTagsTemplateFunctions::getTagIcon($child->getIcon());
    eZURI::transformURI($childResponse['url']);
    $childResponse['modified'] = (int) $child->attribute('modified');
    $response['children'][] = $childResponse;
}
$jsonText = json_encode($response);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + MAX_AGE) . ' GMT');
header('Cache-Control: cache, max-age=' . MAX_AGE . ', post-check=' . MAX_AGE . ', pre-check=' . MAX_AGE);
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $tag instanceof eZTagsObject ? (int) $tag->attribute('modified') : time()) . ' GMT');
header('Pragma: cache');
header('Content-Type: application/json');
header('Content-Length: ' . strlen($jsonText));
echo $jsonText;
eZExecution::cleanExit();