Example #1
0
function vam_childs_in_topic_count($topics_id)
{
    $topics_count = 0;
    $topics_query = vam_db_query("select topics_id from " . TABLE_TOPICS . " where parent_id = '" . (int) $topics_id . "'");
    while ($topics = vam_db_fetch_array($topics_query)) {
        $topics_count++;
        $topics_count += vam_childs_in_topic_count($topics['topics_id']);
    }
    return $topics_count;
}
Example #2
0
    $rows = 0;
    if (isset($_GET['search'])) {
        $search = vam_db_prepare_input($_GET['search']);
        $topics_query = vam_db_query("select t.topics_id, td.topics_name, t.parent_id, t.sort_order, t.date_added, t.last_modified from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.topics_id = td.topics_id and td.language_id = '" . (int) $_SESSION['languages_id'] . "' and td.topics_name like '%" . vam_db_input($search) . "%' order by t.sort_order, td.topics_name");
    } else {
        $topics_query = vam_db_query("select t.topics_id, td.topics_name, t.parent_id, t.sort_order, t.date_added, t.last_modified from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.parent_id = '" . (int) $current_topic_id . "' and t.topics_id = td.topics_id and td.language_id = '" . (int) $_SESSION['languages_id'] . "' order by t.sort_order, td.topics_name");
    }
    while ($topics = vam_db_fetch_array($topics_query)) {
        $topics_count++;
        $rows++;
        // Get parent_id for subtopics if search
        if (isset($_GET['search'])) {
            $tPath = $topics['parent_id'];
        }
        if ((!isset($_GET['tID']) && !isset($_GET['aID']) || isset($_GET['tID']) && $_GET['tID'] == $topics['topics_id']) && !isset($tInfo) && substr($action, 0, 3) != 'new') {
            $topic_childs = array('childs_count' => vam_childs_in_topic_count($topics['topics_id']));
            $topic_articles = array('articles_count' => vam_articles_in_topic_count($topics['topics_id']));
            $tInfo_array = array_merge($topics, $topic_childs, $topic_articles);
            $tInfo = new objectInfo($tInfo_array);
        }
        if (isset($tInfo) && is_object($tInfo) && $topics['topics_id'] == $tInfo->topics_id) {
            echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . vam_href_link(FILENAME_ARTICLES, vam_get_topic_path($topics['topics_id'])) . '\'">' . "\n";
        } else {
            echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . vam_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $topics['topics_id']) . '\'">' . "\n";
        }
        ?>
                <td class="dataTableContent"><?php 
        echo '<a href="' . vam_href_link(FILENAME_ARTICLES, vam_get_topic_path($topics['topics_id'])) . '">' . vam_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a>&nbsp;<b>' . $topics['topics_name'] . '</b>';
        ?>
</td>
                <td class="dataTableContent" align="center">&nbsp;</td>