$in_str = substr($in_str, 0, $len);
$in_str = '(' . $in_str . ')';
$sql = "SELECT\n                b.location AS location,\n                a.name AS name\n            FROM\n                " . $cfg["tab"]["area"] . " AS a,\n                " . $cfg["tab"]["nav_sub"] . " AS b\n            WHERE\n                b.idarea IN " . Contenido_Security::escapeDB($in_str, $db) . " AND\n                b.idarea = a.idarea AND\n                b.level = 1\n            ORDER BY\n                b.idnavs";
$db->query($sql);
while ($db->next_record()) {
    # Extract caption from
    # the xml language file
    $caption = $nav->getName($db->f("location"));
    $tmp_area = $db->f("name");
    # Set template data
    $tpl->set("d", "ID", 'c_' . $tpl->dyn_cnt[0]);
    $tpl->set("d", "CLASS", '');
    $tpl->set("d", "OPTIONS", '');
    $tpl->set("d", "CAPTION", '<a class="white" onclick="sub.clicked(this)" target="right_bottom" href="' . $sess->url("main.php?area={$tmp_area}&frame=4&idworkflow={$idworkflow}") . '">' . $caption . '</a>');
    if ($area == $tmp_area) {
        $tpl->set('s', 'DEFAULT', markSubMenuItem($tpl->dyn_cnt[0], true));
    }
    $tpl->next();
}
$tpl->set('s', 'COLSPAN', $tpl->dyn_cnt[0] * 2 + 2);
$tpl->set('s', 'IDCAT', $idcat);
$tpl->set('s', 'SESSID', $sess->id);
$tpl->set('s', 'CLIENT', $client);
$tpl->set('s', 'LANG', $lang);
# Generate the third
# navigation layer
if ($idworkflow <= 0) {
    $tpl->generate($cfg["path"]["templates"] . $cfg["templates"]["subnav_blank"]);
} else {
    $tpl->generate($cfg["path"]["templates"] . $cfg["templates"]["subnav"]);
}
    $result = $notification->returnNotification("warning", i18n('There is no Content Allocation tree.', 'content_allocation'));
} else {
    if (!is_object($tpl)) {
        $tpl = new Template();
    }
    $hiddenfields = '<input type="hidden" name="action" value="storeallocation">
		<input type="hidden" name="idart" value="' . $idart . '">
		<input type="hidden" name="contenido" value="' . $sess->id . '">
		<input type="hidden" name="area" value="' . $area . '">
		<input type="hidden" name="frame" value="' . $frame . '">
		<input type="hidden" name="idcat" value="' . $idcat . '">';
    $tpl->set('s', 'HIDDENFIELDS', $hiddenfields);
    if (sizeof($loadedAllocations) > 0) {
        $tpl->set('s', 'ARRAY_CHECKED_BOXES', 'var checkedBoxes = [' . implode(',', $loadedAllocations) . '];');
    } else {
        $tpl->set('s', 'ARRAY_CHECKED_BOXES', 'var checkedBoxes = [];');
    }
    $oDiv = new cHTMLDiv();
    $oDiv->updateAttributes(array('style' => 'text-align: right; padding: 5px; width: 730px; border: 1px #B3B3B3 solid; background-color: #FFFFFF;'));
    $oDiv->setContent('<input type="image" src="images/but_ok.gif" />');
    $tpl->set('s', 'DIV', '<br>' . $oDiv->render());
    $tpl->set('s', 'TREE', $result);
    $tpl->set('s', 'REMOVE_ALL', i18n("Remove all", 'content_allocation'));
    $tpl->set('s', 'REMOVE', i18n("Remove", 'content_allocation'));
    $result = $tpl->generate($cfg['pica']['treetemplate_complexlist'], true);
    $script = '<link rel="stylesheet" type="text/css" href="' . $cfg['pica']['style_complexlist'] . '"/>
	<script language="javascript" src="' . $cfg['pica']['script_complexlist'] . '"></script>';
    $oPage->addScript('style', $script);
}
$oPage->setContent($sLocationString . $result . markSubMenuItem(5, true));
$oPage->render();