function printEntry($num, $entry) { echo "<hr>\n"; echo "<a name='entry{$num}'</a>"; echo formatLabbookEntry($entry); echo "</hr>\n"; echo "<p><a href='#top'>Top</a>"; // | <a href='".makeEventURL("onNotebookEdit", $num)."'>Edit</a>\n"; //onNotebookEdit removed for security reasons (probably nobody was using it }
/** * Make sure you say what $context is here. For example: * * Context is an array containing: * labbookEntry the labbook entry number for adding this new model */ function display($context) { echo $this->pageHeader("NAME OF YOUR PAGE GOES HERE"); // Here's a sample page that displays a notebook entry. // The notebook entry number was specified in $context['labbookEntry'] // This is a common way to display results of a background job. // Load and format the notebook entry: $labbook = openLabbook(); $num = $context['labbookEntry']; echo formatLabbookEntry($labbook[$num]); // This line makes a URL that, when clicked, will cause the onEditNotebook() // function to be called. It's declared below... echo "<p><a href='" . makeEventURL('onEditNotebook', $num) . "'>Edit notebook entry</a></p>\n"; // These lines create an HTML form that will call onReturn() to be called // when the user clicks the Continue > button. onReturn() is declared below. echo "<p>" . makeEventForm("onReturn"); echo "<input type='submit' name='cmd' value='Continue >'>\n</form></p>\n"; // Note the explicit </form> to end the form! echo $this->pageFooter(); }
/** * This function is called automatically by saveLabbook(). * The output won't be ideal, because paths to linked items will be broken. */ function saveLabbookHTML($bookData) { $file = $_SESSION['dataDir'] . "/" . MP_DIR_SYSTEM . "/labbook.html"; // Write the notebook data if ($fp = @fopen($file, "wb")) { fwrite($fp, mpPageHeader("Lab notebook")); fwrite($fp, "<a name='top'>\n<ul>\n"); foreach ($bookData as $num => $entry) { $title = $entry['title']; if ($title == "") { $title = "(no title)"; } fwrite($fp, "<li><a href='#entry{$num}'</a>{$title} [" . formatDayTime($entry['modtime']) . "]</li>\n"); } fwrite($fp, "</ul>\n<br clear='all' />\n"); foreach ($bookData as $num => $entry) { fwrite($fp, "<hr>\n"); fwrite($fp, "<a name='entry{$num}'>\n"); fwrite($fp, formatLabbookEntry($entry)); fwrite($fp, "</a>\n"); fwrite($fp, "<p><a href='#top'>Top</a>\n"); } fwrite($fp, mpPageFooter()); @fclose($fp); return true; } else { return false; } }
// 2. Include core functionality - defines constants, etc. require_once MP_BASE_DIR . '/lib/core.php'; require_once MP_BASE_DIR . '/lib/labbook.php'; // 3. Restore session data. If you don't want to access the session // data for some reason, you must call mpInitEnvirons() instead. mpStartSession(); // 4. For pages that want to see the session but not change it, such as // pages that are refreshing periodically to monitor a background job. mpSessReadOnly(); # MAIN - the beginning of execution for this page ############################################################################ $labbook = openLabbook(); $entry = $labbook[$_REQUEST['entry_num']]; // Start the page: produces <HTML>, <HEAD>, <BODY> tags echo mpPageHeader("{$entry['title']}"); ?> <form> <table border='0' width='100%'><tr> <td align='left'><small> When finished, you should <input type="button" value="close this window" language="JavaScript" onclick="self.close();">. </small></td><td align='right'><small><i> Hint: Use File | Save As... to save a copy of this page. </i></small></td> </tr></table> </form> <hr> <?php echo formatLabbookEntry($entry); echo mpPageFooter();