Date: 24 September 2004
Testing with additions to Mozile 0.6.14, using Mozilla 1.6 on a Windows/Apache/PHP platform.
...Defined elsewhere in Mozile docs...
The whole document is saved.
Filename and path details are not sent.
The id's of editable areas are not sent.
Only a single block in a document is saved.
Filename and path details are not sent.
The ID of the editable area, if one is present, is added to the save URL.
The ID comes from the "id" attribute in the XHTML file being edited.
e.g. in a div tag such as:
<div id="file1_edit"> ... </div>
With a save URL such as:
http://www.mywebsite.com/scripts/saveit.php
the target URL becomes:
http://www.mywebsite.com/scripts/saveit.php?MozileID=file1_edit
With a save URL such as:
http://www.mywebsite.com/scripts/saveit.php?name=Max
the target URL becomes:
http://www.mywebsite.com/scripts/saveit.php?name=Max&MozileID=file1_edit
Possible extensions
Should the filename and path be saved? It would make sense. In PHP you would be more likely to have a main save script that would save all the files, so you would need the filename and possibly the path as well. These could possibly be put into a POST header before calling XMLHttpRequest.
With the POST method it would also be possible to do a "save as file...". This would require an additional text box for the Save dialogue window.
The XMLHttpRequest has the facility for user authentication via a username and password although I have not tested it to see if it works. This might be useful for implementing a simple CMS.
The request was successful. In reply to the POST method the message-body contains the result of the server action.
If the result of the save is successful Mozile displays a success message in the status bar. If there is an error Mozile pops up the Save Message window giving further details.
This contains header fields only but no message-body. This response is used to indicate that the save operation was completely successful.
A new page is not loaded in the current browser window. Mozile displays a success message in the status bar.
This is to indicate that a new resource has been created. Further information should be returned in the headers and message-body. (This return information doesn't appear to be used by Mozile. I don't know if there is any planned use for this.)
A new page is not loaded in the current browser window. Mozile displays a success message in the status bar.
Variety of error messages that should be displayed to the user.
Mozile pops up the Save Message window giving further details.
There are other error codes that Mozile might need to process.
A dedicated window is opened that handles the POST transfer using the XMLHttpRequest method. An asynchronous request is used.
A status window is opened showing a progress bar and an Abort button. A short status message is displayed showing the current state of the XMLHttpRequest. It is not possible to get an idea of how long the save process will take so the progress bar takes the form of a continually spinning barber pole. Normally there should not be a reason for activating the "Abort" function, but this can be used if the save process hangs.
Note: The Post Progress Window does not have the window close icon (X in top right corner). This is to prevent non-tec users from closing the window midway through a request and potentially making a mess of the save process. If the abort button is pressed the request should be stopped in a tidy way. The Abort button then changes to a Close button allowing the user to close the window. If the code controlling this does not execute correctly the Post Progress Window could be left open with no way to close it other than by shutting down the whole browser. I'm not sure if this is likely to happen, but if it does, please report what you did to cause the error. One fix to this potential problem would be to have a background timeout to abort the request and close the window after a certain interval. (People could maybe tweak this value to suit their own setup.)
Some of these occur too quickly and may not display.
The result of the server action is returned in the body of the response. This makes use of a Mozile specific namespace and tags. The response must be in XML or XHTML. Any other response (e.g. HTML) will generate an error.
http://www.mozile.mozdev.org/ns/save/
Note: The XHTML 1.0 spec says this:
The XHTML namespace may be used with other XML namespaces as per [XMLNS [p.32] ], although such documents are not strictly conforming XHTML 1.0 documents as defined above. Work by W3C is addressing ways to specify conformance for documents involving multiple namespaces.
So, your XHTML pages might not validate. I don't think this causes any problems when browsers try to display the pages.
element | use |
---|---|
post | container for result of server action. |
status | status code |
statustext | short unformatted description |
status | meaning |
---|---|
0 | reserved |
1 | ok |
user defined | error |
<mozile xmlns="http://www.mozile.mozdev.org/ns/save/"> <post> <status>1</status> <statustext>Saved OK</statustext> </post> </mozile>
The POST Progress Window closes, the Save Message Window is not shown.
<mozile xmlns="http://www.mozile.mozdev.org/ns/save/"> <post> <status>2</status> <statustext>Database connect error</statustext> </post> </mozile>
This is displayed in the Save Message Window as:
Save Method: HTTP POST
An error occurred during the save.
[2] Database connect error
Server response:
200 OK
It is important to take into account the display limitations when deciding upon the values for status and statustext. Both must be present. An error is produced if one or both are empty.
These are the main error messages you are likely to come across in the Save Message Window.
Unexpected server response | Server response other than 200, 201, 204 |
XML response not received from server. | 200 OK received, but server response is not in XHTML. E.g. a plain HTML file has been sent instead. |
Something is wrong with the XML response. <post> tag is missing or namespace is incorrect. Namespace should be; http://www.mozile.mozdev.org/ns/save/ |
|
<status> tag is missing. | |
Empty <status></status> tags. | |
<statustext> tag is missing. | |
Empty <statustext></statustext> tags. |
In addition to these, if the XHTML is not well formed a parse error is generated. This will give an indication of what the (first) parse error is.
Additional errors that shouldn't occur during normal use are logged to the Mozile Debugger. If you find one of these, and can reproduce it, please report it.
This handles the display of error messages to the user for all save methods.
The following are used with the POST method.
.isAbort | boolean | true means the save was aborted. |
.isError | boolean | false means saved ok. |
.status | string | server status (a number, e.g. 200) |
.statusText | string | server status in words |
.msgText | string | short unformatted message |
.document | XML document | XML server response (not used) |
.documentText | string | Text server response |
The WEBDAV save method also uses orignalStatus and orignalStatusText. The values of these, together with status and statusText, are always logged to the Mozile debugger.
The POST Progress and Save Dialog Windows both close.
"Save Successful" is displayed in the browser status bar.
The Save Error window always opens if there is an error.
This has two sections, as in the example above, for the error message and server status. Additionally, if there is a server document (e.g. a 404 Not Found web page) then an additional button is present below the server response. When this is activated the document opens in a new browser window.
"Save Error" is displayed in the browser status bar.
"Save Aborted" is displayed in the browser status bar. The save may or may not have completed, it all depends on when the abort was executed.
I haven't fully integrated the display of messages for WEBDAV. At the moment they should display as before. (Let me know if they don't!)
The idea at the moment (I don't know how WEBDAV works) is that the same Save Message Window
could be used as above to report errors with the first line changed to;
Save Method: WEBDAV
Obviously, more work needs to be done on displaying error messages if anyone implements the save of multiple editing areas in one go.
The POST data may be extracted from the global variable $HTTP_RAW_POST_DATA.
The ID of the editable area is found in the global variable $_GET["MozileID"].
Use the test file save_dump.php to test that the info is received correctly by the server.
There are various test files for checking that the save via POST works correctly. Just set the php file as the save to file in the Mozile Save dialogue window.
save_ok.php | 200 OK, file saved. |
save_error.php | 200 OK, with error message. |
save_201.php | 201 header only (file created) |
save_204.php | 204 header only (file saved ok) |
save_dump.php | Dumps the POSTed info back into the (faulty) response. |
save_parse_error.php | Example of a parse error. |
save_html.php | Example of an invalid response in HTML. (Must be XHTML.) |