I think you just need to add the timestamp to the start of the story before
you save it,
i.e.
$content = date("d/m/Y H:i:s - ") . $content;

or am I missing something?


        Tim
        www.chessish.com

> -----Original Message-----
> From: Tim Bogart [SMTP:[EMAIL PROTECTED]]
> Sent: 24 January 2002 15:01
> To:   Tim Ward; [EMAIL PROTECTED]
> Subject:      Re: phpwiki save button
> 
> On Thursday 24 January 2002 06:36 am, Tim Ward wrote:
> > What is it you actually want to do? Add the current date/time or a
> > timestamp entered on the submitting form? 
> 
> yes.  That is exactly what I wish to do.
> 
> See date() for the former. Once
> > you've got your stamp in a format you want just add it to the front of
> the
> > story before saving. Give us a bit more detail about what it is that
> isn't
> > working, or the code that you want to modify.
> 
> The following is the savepage.php script.  It (in as much as I can figure)
> is 
>  what is executed when one pushes or clicks on the "save" button when
> phpwiki 
> is serving up the"editpage.html" file to a user on his or her browser, and
> 
> the individual is finished editing, and wishes to save their entry.  The 
> "save" button is at the bottom of the edit page.  What I wish to have
> happen 
> is, to have the save button do what it does now, save the changes, but in 
> addition to that, if I had my perfect world, I would like this
> savepage.php 
> script prefix the edited text with a date and time stamp on the left side
> of 
> the page, appearing as a (redundancy here) prefix to the typed material.  
> That way each entry would have a date and time stamp.  I hope I am
> describing 
> this in a fashon you can understand.  Let me give you an example.  One
> types 
> ...
> 
> This is a good day.
> 
> Then the individual pushes the save button.  The save is executed, and the
> 
> user is bounced back to the preview page (the preview page part happens as
> a 
> result simply of how the thing just works).  When the preview page is 
> displayed, the newly added text appears, but looks like this...
> 
> 2002 01/24 09:33:45  This is a good day.
> 
> The format of the date and time are really fluff to me, as long as it
> appears.
> 
> I hope my description is understandable.  I eagerly await your response.
> 
> Tim B.
> 
> Here's the script...
> 
> ---------------------------------------------------------
> 
> s_id('$Id: savepage.php,v 1.17 2001/11/14 21:05:38 dairiki Exp $'); 
> require_once('lib/Template.php'); 
> require_once('lib/transform.php'); 
> require_once('lib/ArchiveCleaner.php'); 
>  
> /* All page saving events take place here. All page info is also taken
> care 
> of here. This is klugey. But it works. There's probably a slicker way of 
> coding it. 
> */ 
>  
> // FIXME: some links so that it's easy to get back to someplace useful
> from 
> these // error pages. 
>  
> function ConcurrentUpdates($pagename) { /* xgettext only knows about c/c++
> 
> line-continuation strings is does not know about php's dot operator. We
> want 
> to translate this entire paragraph as one string, of course. 
> */ 
> $html = "<p>"; $html .= gettext ("PhpWiki is unable to save your changes, 
> because another user edited and saved the page while you were editing the 
> page too. If saving proceeded now changes from the previous author would
> be 
> lost."); 
> $html .= "</p>\n<p>"; $html .= gettext ("In order to recover from this 
> situation follow these steps:"); 
> $html .= "\n<ol><li>"; $html .= gettext ("Use your browser's <b>Back</b> 
> button to go back to the edit page."); 
> $html .= "</li>\n<li>"; $html .= gettext ("Copy your changes to the
> clipboard 
> or to another temporary place (e.g. text editor)."); 
> $html .= "</li>\n<li>"; $html .= gettext ("<b>Reload</b> the page. You
> should 
> now see the most current version of the page. Your changes are no longer 
> there."); 
> $html .= "</li>\n<li>"; $html .= gettext ("Make changes to the file again.
> 
> Paste your additions from the clipboard (or text editor)."); 
> $html .= "</li>\n<li>"; $html .= gettext ("Press <b>Save</b> again."); 
> $html .= "</li></ol></p>\n"; $html .= QElement('p', gettext ("Sorry for
> the 
> inconvenience.")); 
>  
> echo GeneratePage('MESSAGE', $html, sprintf (gettext ("Problem while
> updating 
> %s"), $pagename)); 
> ExitWiki(); 
> } 
>  
> function PageIsLocked($pagename) { 
> $html = QElement('p', gettext("This page has been locked by the
> administrator 
> and cannot be edited.")); 
> $html .= QElement('p', gettext ("Sorry for the inconvenience.")); 
>  
> echo GeneratePage('MESSAGE', $html, sprintf (gettext ("Problem while
> editing 
> %s"), $pagename)); 
> ExitWiki (""); 
> } 
>  
> function NoChangesMade($pagename) { $html = QElement('p', gettext ("You
> have 
> not made any changes.")); $html .= QElement('p', gettext ("New version not
> 
> saved.")); 
> echo GeneratePage('MESSAGE', $html, sprintf(gettext("Edit aborted: %s"), 
> $pagename)); 
> ExitWiki (""); 
> } 
>  
> function BadFormVars($pagename)
> {     $html = QElement('p', gettext ("Bad form submission"));
>       $html .= QElement('p', gettext ("Required form variables are
> missing.")); 
>       echo GeneratePage('MESSAGE', $html, sprintf(gettext("Edit aborted:
> %s"), $pagename)); 
>       ExitWiki (""); 
> } 
>  
> function savePreview($dbi, $request)
> {     $pagename = $request->getArg('pagename');
>       $version = $request->getArg('version'); 
>       $page = $dbi->getPage($pagename);
>       $selected = $page->getRevision($version); 
>  
>       // FIXME: sanity checking about posted variables // FIXME: check for
> simultaneous edits.
>       foreach (array('minor_edit', 'convert') as $key) 
>               $formvars[$key] = $request->getArg($key) ? 'checked' : '';
>       foreach (array('content', 'editversion', 'summary', 'pagename',
> 'version') as $key) 
>               @$formvars[$key] = htmlspecialchars($request->getArg($key));
> 
>  
>       $template = new WikiTemplate('EDITPAGE'); 
>       $template->setPageRevisionTokens($selected);
>       $template->replace('FORMVARS', $formvars);
>       $template->replace('PREVIEW_CONTENT',
> do_transform($request->getArg('content'))); 
>       echo $template->getExpansion(); 
> } 
>  
> function savePage ($dbi, $request)
> {     global $user; 
>  
>       // FIXME: fail if this check fails?
> assert($request->get('REQUEST_METHOD') == 'POST'); 
>  
>       if ($request->getArg('preview')) return savePreview($dbi, $request);
> 
>       $pagename = $request->getArg('pagename');
>       $version = $request->getArg('version'); 
>  
>       $page = $dbi->getPage($pagename);
>       $current = $page->getCurrentRevision(); 
>  
>       $content = $request->getArg('content');
>       $editversion = $request->getArg('editversion'); 
>       if ( $content === false || $editversion === false )
> BadFormVars($pagename); 
>       // noreturn 
>  
>       if ($page->get('locked') && !$user->is_admin()) 
>               PageIsLocked($args->pagename); // noreturn. 
>  
>       $meta['author'] = $user->id();
>       $meta['author_id'] = $user->authenticated_id();
>       $meta['is_minor_edit'] = (bool) $request->getArg('minor_edit');
>       $meta['summary'] = trim($request->getArg('summary')); 
>  
>       $content = preg_replace('/[ \t\r]+\n/', "\n", chop($content)); 
>       if ($request->getArg('convert')) $content = CookSpaces($content); 
>  
>       if ($content == $current->getPackedContent())
>       {       NoChangesMade($pagename);
>               // noreturn
>       } 
>  
>       //////////////////////////////////////////////////////////////// 
>       // // From here on, we're actually saving. 
>       // $newrevision = $page->createRevision($editversion + 1, $content,
> $meta, ExtractWikiPageLinks($content)); 
>       if (!is_object($newrevision))
>       {       // Save failed. 
>               ConcurrentUpdates($pagename); 
>       } 
>  
>       // Clean out archived versions of this page. $cleaner = new
> ArchiveCleaner($GLOBALS['ExpireParams']); 
>       $cleaner->cleanPageRevisions($page); 
>       $warnings = $dbi->GenericWarnings(); 
>       if (empty($warnings))
>       {       // Do redirect to browse page.
>               // In this case, the user will most likely not see the rest
> of
>               // the HTML we generate (below). 
>               $request->redirect(WikiURL($pagename, false,
> 'absolute_url')); } 
>  
>               $html = sprintf(gettext("Thank you for editing %s."),
> LinkExistingWikiWord($pagename)); 
>               $html .= "<br>\n"; $html .= gettext ("Your careful attention
> to detail is much appreciated.");
>               $html .= "\n"; 
>  
>               if ($warnings)
>               {       $html .= Element('p', "<b>Warning!</b> " .
> htmlspecialchars($warnings) . "<br>\n");
>               } 
>  
>               global $SignatureImg; 
>               if (!empty($SignatureImg)) $html .= sprintf("<P><img
> src=\"%s\"></P>\n", DataURL($SignatureImg)); 
>  
>               $html .= "<hr noshade>\n"; $html .=
> do_transform($newrevision->getContent()); 
>               echo GeneratePage('BROWSE', $html, $pagename, $newrevision);
>       } 
>  
>  
>       // Local Variables: 
>       // mode: php 
>       // tab-width: 8 
>       // c-basic-offset: 4 
>       // c-hanging-comment-ender-p: nil 
>       // indent-tabs-mode: nil 
>       // End: 
> ?> 
> 
> --------------------------------------------------------------
> 
> 
> >
> > (also) Tim
> > www.chessish.com <http://www.chessish.com>
> >
> >     ----------
> >     From:  Tim Bogart [SMTP:[EMAIL PROTECTED]]
> >     Sent:  23 January 2002 17:47
> >     To:  [EMAIL PROTECTED]
> >     Subject:  phpwiki save button
> >
> >     Hello everybody.  My name is Tim and I am new to this list.  I am
> > not a
> >     programmer and don't even play one on tv.
> >
> >     I've recently installed and have started to attempt to customize
> > phpwiki.  I
> >     need to modify the way the "save" button works.  I not only need it
> > to do the
> >     save, but I would like it to append a date and time stamp to the
> > text being
> >     posted to the wiki.  My first choice would that the line of text
> > being typed
> >     would be prefixed with the stamp rather than slapping it on the end.
> > This I
> >     believe would be the most ergonomically convienient for those
> > reading that
> >     which has been posted.
> >
> >     Is there anybody out there willing to give me a hand.
> >
> >     TIA,
> >
> >     Tim B.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to