add($HTTP_POST_VARS['title'], $HTTP_POST_VARS['content'], $HTTP_SESSION_VARS['member']->id, $HTTP_SESSION_VARS['project']->id, $HUB['sys']['file'] . '/' . $HTTP_POST_VARS['dir']); /* display result */ $tpl = new Template($HUB['sys']['tpl']); $tpl->set_file('result', 'project_add_result.dwt'); switch ($res) { case 1: $tpl->set_var('ADD_RESULT', 'The documentation has been added yet!'); break; default: $tpl->set_var('ADD_RESULT', 'Fail in adding new documentation!'); break; } $tpl->pparse('out', 'result'); } elseif ($HTTP_POST_VARS['from'] == 'attach') { /* handle data work */ $ml = new Material_List(); $ml->find_by_attachment($HUB['sys']['file'] . '/' . $HTTP_POST_VARS['dir']); /* refresh */ $tpl = new Template($HUB['sys']['tpl']); $tpl->set_file('add', 'project_add.dwt'); $tpl->set_var(array('DOC_TITLE' => $HTTP_POST_VARS['title'], 'DOC_CONTENT' => $HTTP_POST_VARS['content'])); $tpl->set_var('MTR_DIR', $HTTP_POST_VARS['dir']); $tpl->set_block('add', 'row', 'rows'); for ($i = 0; $i < count($ml->materials); $i++) { $tpl->set_var(array('MTR_NAME' => $ml->materials[$i]->name, 'MTR_TYPE' => $ml->materials[$i]->type, 'MTR_DESCR' => $ml->materials[$i]->descr )); $tpl->parse('rows', 'row', true); } $tpl->parse('out', 'add'); $tpl->p('out'); } } else { /* display user interface */ $tpl = new Template($HUB['sys']['tpl']); $tpl->set_file('add', 'project_add.dwt'); $tpl->parse('out', 'add'); $tpl->p('out'); } ?>