示例#1
0
function buildToggleList($id, $toggle_list = '')
{
    global $db;
    $result = $db->Execute("select parent_id from " . TABLE_PHREEFORM . " where id = '" . $id . "'");
    if ($result->fields['parent_id'] != '0') {
        $toggle_list = buildToggleList($result->fields['parent_id'], $toggle_list);
    }
    $toggle_list .= "  Toggle('dc_" . $result->fields['parent_id'] . "_" . $id . "');" . chr(10);
    return $toggle_list;
}
$result = $db->Execute('select id, parent_id, doc_type, doc_title, doc_group, security from ' . TABLE_PHREEFORM . ' 
	order by doc_title, id, parent_id');
$toc_array = array();
$toc_array[-1][] = array('id' => 0, 'doc_type' => '0', 'doc_title' => TEXT_HOME);
// home dir
while (!$result->EOF) {
    if (security_check($result->fields['security'])) {
        $toc_array[$result->fields['parent_id']][] = array('id' => $result->fields['id'], 'doc_type' => $result->fields['doc_type'], 'doc_title' => $result->fields['doc_title'], 'show' => $result->fields['doc_group'] == $tab ? true : false);
    }
    $result->MoveNext();
}
$toggle_list = false;
if ($group) {
    $result = $db->Execute("select id from " . TABLE_PHREEFORM . " where doc_group = '" . $group . "'");
    if ($result->RecordCount() > 0) {
        $toggle_list = buildToggleList($result->fields['id']);
    }
}
switch ($_REQUEST['action']) {
    // figure which detail page to load
    case 'search':
    case 'view':
        $result = html_heading_bar(array(), array(' ', TEXT_DOCUMENT_TITLE, TEXT_ACTION));
        $list_header = $result['html_code'];
        // build the list for the page selected
        if (isset($_REQUEST['search_text']) && $_REQUEST['search_text'] != '') {
            $search_fields = array('doc_title');
            $search = ' where ' . implode(' like \'%' . $_REQUEST['search_text'] . '%\' or ', $search_fields) . ' like \'%' . $_REQUEST['search_text'] . '%\'';
        } else {
            $search = '';
        }