<?php
/**
* Draw the Main Indexsite with all Toplevel Categories.
*
* The Main Indexsite shows all toplevel categories.
* @global string $neModuleName
* @global array $neConfig
* @global handle $neDb
*/
function drawCategory($intCatId) {
global $neModuleName, $neConfig, $neDb, $neTheme, $neSession;
/*Load the Template*/
$tpl = $neTheme->getTemplate('webdir','category.tpl');
$strQuery = 'SELECT * ';
$strQuery .= 'FROM '.$neConfig['db']['prefix'].'_webdir_categories ';
$strQuery .= 'WHERE cat_id = '.$intCatId;
$cat = $neDb->getRow($strQuery,DB_FETCHMODE_ASSOC);
neGetDbError($cat,__LINE__,__FILE__,$strQuery);
/* Common Content for the Template */
$tpl->setVariable(array(
'LABEL_SEARCH' => neTranslate('search'),
'LABEL_GO' => neTranslate('go'),
'LABEL_TOP_HITS' => neTranslate('top_hits'),
'LABEL_LATEST_LINKS' => neTranslate('latest_links'),
'ACTION' => NE_MODULE_LOADER,
'MOD' => $neModuleName,
'OP' => 'search',
'CAT_NAME' => neFormatText($cat['cat_name'],'plain'),
'CAT_DESCR' => neFormatText($cat['cat_descr'],'ubb'),
'LINK_TOP_HITS' => NE_MODULE_LOADER.'?mod='.$neModuleName.'&op=top_hits',
'LINK_LATEST_LINKS' => NE_MODULE_LOADER.'?mod='.$neModuleName.'&op=latest_links'
));
if ($neSession->isAllowed($neConfig['webdir']['allow_suggest'])) {
$tpl->setVariable(array(
'LABEL_SUGGEST_URL' => neTranslate('suggest_url'),
'LINK_SUGGEST_URL' => NE_MODULE_LOADER.'?mod='.$neModuleName.'&op=suggest&cat='.$cat['cat_id'],
));
}
/* Show the Subcategories of this Category*/
$strQuery = 'SELECT cat_id, cat_name ';
$strQuery.= 'FROM '.$neConfig['db']['prefix'].'_webdir_categories ';
$strQuery.= 'WHERE cat_parent = '.$cat['cat_id'];
$strQuery.= ' ORDER BY cat_name ASC';
$result = $neDb->query($strQuery);
neGetDbError($result,__LINE__,__FILE__);
$tpl->setCurrentBlock('subcategories');
while ($subCat = $result->fetchRow(DB_FETCHMODE_ASSOC) ) {
$tpl->setVariable(array(
'LABEL_SUBCATEGORIES' => neTranslate('subcategories'),
'SUBCAT_NAME' => neFormatText($subCat['cat_name'],'plain'),
'SUBCAT_LINK' => 'index.php?mod='.$neModuleName.'&cat='.$subCat['cat_id'],
'SUBCAT_DESCRIPTION' => neFormatText($subCat['cat_descr'],'plain')
));
$tpl->parse('subcat');
}
$result->free();
/* Show the Links in this Category*/
$strQuery = 'SELECT * ';
$strQuery.= 'FROM '.$neConfig['db']['prefix'].'_webdir_links ';
$strQuery.= 'WHERE link_cat = '.$cat['cat_id'].' AND link_approved=1 AND link_valid=1 ';
$strQuery.= 'ORDER BY link_name ASC';
$result = $neDb->query($strQuery);
neGetDbError($result,__LINE__,__FILE__);
$tpl->setCurrentBlock('links');
while($link = $result->fetchRow(DB_FETCHMODE_ASSOC)){
$tpl->setVariable(array(
'LABEL_WEBSITES' => neTranslate('websites'),
'LINK_ID' => (int) $link['link_id'],
'LINK_REDIRECT' => NE_MODULE_LOADER."?mod=webdir&op=redirect&id=".$link['link_id'],
'LINK_URL' => neFormatText($link['link_url'],'plain'),
'LINK_NAME' => neFormatText($link['link_name'],'plain'),
'LINK_DESCR' => neFormatText($link['link_descr'],'ubb'),
'LINK_SUBMITTER' => neGetUserName($link['link_submitter']),
'LINK_ADDED' => neFormatTimeStamp($link['link_added'],'datetime'),
'LINK_HITS' => (int) $link['link_hits'],
'LINK_PAGERANK' => getPageRank($link),
));
if ($neSession->isAdmin($neModuleName) ) {
$tpl->setVariable('EDIT_URL_LINK',getEditUrlLink($link['link_id']));
}
$tpl->parse('link');
}
$result->free();
if ($neSession->isAdmin($neModuleName) ) {
$tpl->setCurrentBlock('admin');
$tpl->setVariable(array(
'LABEL_NEW_LINKS' => neTranslate('new_links'),
'NEWS_LINKS' => '2',
'EDIT_CAT_LINK' => getEditCatLink($cat['cat_id']),
'ADD_CAT_LINK' => getAddCatLink($cat['cat_id']),
'ADD_URL_LINK' => getAddUrlLink($cat['cat_id']),
));
}
$tpl->show();
setBreadcrumbs($cat['cat_id']);
$neTheme->drawTitle(neFormatText($cat['cat_name']));
$neTheme->drawSite(neFormatText($cat['cat_name']));
}
?>