/** * printNotes Recursive function to display the notes for a record in a threaded manner. * @param array $parent Array of notes with the same parent thread. */ function printNotes($parent) { // Need the main $tasks array: global $notes; global $details; // Start an ordered list: echo '<ul>'; // Loop through each subarray: foreach ($parent as $threadID => $noteText) { // Display the item: //echo "<li>$noteText\n"; //echo "(written by %s on %s)"; printf('<li> <input type="submit" value="Reply" id="%s" name="addChild[]" onclick="%s" /> <!--<input type="image" src="includes/images/minus-8.png" name="pmtRemove[]" onclick="%s" />--> <span %s id="%s">%s</span> <small>(written by %s on %s at %s)</small> <br /><p id="%u" style="display:none"> <input type="submit" value="Add Reply" name="addNote[]" onclick="%s" /> <input type="text" name="note[%u]" size="50" maxlength="100" /> </p>', 'button' . $threadID, 'showRow(' . $threadID . '); return false;', 'updateRemoveID(' . $threadID . ');', $details[$threadID]['userID'] == $_SESSION['userID'] || $_SESSION['level'] >= 4 ? 'class="editNote"' : '', 'note-' . $threadID, $noteText . "\n", $details[$threadID]['author'], date('m/d/Y', strtotime($details[$threadID]['date'])), $details[$threadID]['time'], $threadID, 'addChild(' . $threadID . ');', $threadID); // Check for subtasks: if (isset($notes[$threadID])) { // Call this function: printNotes($notes[$threadID]); } // Complete the list item: echo '</li>'; } // End of FOREACH loop. // Close the ordered list: echo '</ul>'; }
echo '<h3 class="center">Notes</h3><br /> <input type="hidden" id="newMain" name="newMain" value="false" /> <input type="hidden" id="noteID" name="noteID" value="false" />'; if (!$notesR) { printf('Query: %s, Error: %s', $notesQ, mysqli_error($DBS['comet'])); } if (mysqli_num_rows($notesR) > 0) { while (list($note, $tID, $pID, $modified, $time, $uID, $name) = mysqli_fetch_row($notesR)) { // Build a multidimensional array. // Then... $notes[$pID][$tID] = $note; $details[$tID]['date'] = $modified; $details[$tID]['author'] = $name; $details[$tID]['time'] = $time; $details[$tID]['userID'] = $uID; } printNotes($notes[0]); } echo '<table cellpadding="2" cellspacing="2" width="100%">'; printf('<tr class="center"> <td> <input type="submit" value="Add Note" name="addMainNote" onclick="%s"/> </td> <td colspan="3"> <input type="text" name="mainNote" size="50" maxlength="100" /> </td> </tr> </table><br />', 'newNote();'); } else { header('Location: ../index.php'); }
function parseRequest($request, $category) { global $categoriesRegexp, $dateRegexp, $specialPages, $title; //getFileFromRequest($request); $html = ""; if ($request == '') { $title = "Home"; $html = printSpecialPage($specialPages['home'], BASE_URI); return $html; } foreach ($specialPages as $page => $file) { if ($request == $page || $request == $page . "/") { // last case is for colophon page $title = ucfirst($page); $html = printSpecialPage($file, $request . "/"); return $html; } } if ($category == "notes/") { $html .= printNotes($request); return $html; } if ($category == "projects/") { $html .= printProjects(BASE_PATH . $request, $request, "projects/"); return $html; } if ($category == "blog/") { $html .= printBlogPosts($request); return $html; } //error 404 $html .= printErrorText(); return $html; }