예제 #1
0
 /**
 * Context is an array with these keys:
 *   entryNumber     (optional) the index for the entry to edit
 * OUTPUTS (via Post):
 *   labbookEditCmd  one of "Save" or "Don't save"
 *   entryNumber     (same as was provided as input)
 *   labbookEntry    the new entry (an array)
 */
 function display($context)
 {
     $labbook = openLabbook();
     // Either retrieve the old entry or create a new one
     if (isset($context['entryNumber'])) {
         $entry = $labbook[$context['entryNumber']];
         $entry['modtime'] = time();
     } else {
         $entry = newLabbookEntry();
     }
     // Start the page
     echo $this->pageHeader("Edit notebook entry");
     // Make the form
     echo makeEventForm("onSaveEntry");
     echo "<p>" . formEditLabbook($entry);
     if (isset($context['entryNumber'])) {
         echo "<input type='hidden' name='entryNumber' value='" . $context['entryNumber'] . "'>\n";
     }
     echo "<p><input type='submit' name='labbookEditCmd' value='Save'>\n";
     echo "<input type='submit' name='labbookEditCmd' value=\"Don't save\">\n";
     echo "</form>\n";
     echo "<p><i>Hint: you can use HTML tags in your lab notebook entries.</i></p>\n";
     // End the page
     echo $this->pageFooter();
 }
예제 #2
0
/**
* Returns the entry number of the new entry.
*/
function addLabbookEntry($title, $text, $model = "", $keywords = "", $thumbnail = null)
{
    $labbook = openLabbook();
    $entry = newLabbookEntry($model, $keywords);
    $entry['title'] = $title;
    $entry['entry'] = $text;
    if ($thumbnail) {
        $entry['thumbnail'] = $thumbnail;
    }
    // else it stays the default
    $entryNum = count($labbook);
    $labbook[$entryNum] = $entry;
    saveLabbook($labbook);
    return $entryNum;
}