Hyperwave functions
Introduction
Hyperwave has been developed at IICM in Graz. It started with the name Hyper-G and changed to Hyperwave when it was commercialised (If I remember properly it was in 1996).
Hyperwave is not free software. The current version, 4.0, is available at www.hyperwave.com. A time limited version can be downloaded for free (30 days).
Hyperwave is an information system similar to a database (HIS, Hyperwave Information Server). Its focus is the storage and management of documents. A document can be any possible piece of data that may as well be stored in file. Each document is accompanied by its object record. The object record contains meta data for the document. The meta data is a list of attributes which can be extended by the user. Certain attributes are always set by the Hyperwave server, other may be modified by the user.
Besides the documents, all hyper links contained in a document are stored as object records as well. Hyper links which are in a document will be removed from it and stored as individual objects, when the document is inserted into the database. The object record of the link contains information about where it starts and where it ends. In order to gain the original document you will have to retrieve the plain document without the links and the list of links and reinsert them (The functions hw_pipedocument and hw_gettext do this for you. The advantage of separating links from the document is obvious.
Once a document to which a link is pointing to changes its name, the link can easily be modified accordingly. The document containing the link is not affected at all. You may even add a link to a document without modifying the document itself.
Saying that hw_pipedocument and hw_gettext do the link insertion automatically is not as simple as it sounds. Inserting links implies a certain hierachy of the documents. On a web server this is given by the file system, but Hyperwave has its own hierachy and names do not reflect the position of an object in that hierachy. Therefore creation of links first of all requires a mapping from the Hyperwave hierachy and namespace into a web hierachy respective web namespace. The fundamental difference between Hyperwave and the web is the clear distingtion between names and hierachy in Hyperwave. The name does not contain any information about the objects position in the hierachy. In the web the name also contains the information on where the object is located in the hierachy. This leads to two possibles ways of mapping. Either the Hyperwave hierachy and name of the Hyperwave object is reflected in the URL or the name only. To make things simple the second approach is used. Hyperwave object with name 'my_object' is mapped to 'http://host/my_object' diregarding where it resides in the Hyperwave hierachy. An object with name 'parent/my_object' could be the child of 'my_object' in the Hyperwave hierachy, though in a web namespace it appears to be just the opposite and the user might get confused. This can only be prevented by selecting reasonable obect names.
Having made this decission a second problem arises. How do you involve php3? The URL http://host/my_object will not call any php3 script unless you tell your web server to rewrite it to e.g. 'http://host/php3_script/my_object' and the script 'php3_script' evaluates the $PATH_INFO variable and retrieves the object with name 'my_object' from the Hyperwave server. Their is just one little drawback which can be fixed easily. Rewriting any URL would not allow any access to other document on the web server. A php3 script for searching in the Hyperwave server would be impossible. Therefore you
will need at least a second rewriting rule to exclude certain URLS like all e.g. starting with http://host/Hyperwave. This is basically sharing of a namespace by the web and Hyperwave server.
Based on the above mechanism links are insert into documents.
It gets more complicated if php3 is not run as a module/CGI script but as a standalone application e.g. to dump the content of the Hyperwave server on a CD-ROM. In such a case it makes sense to retain the Hyperwave hierachy and map in onto the filesystem. This conflicts with the object names if they reflect its own hierachy (e.g. by chosing names including '/'). Therefore '/' has to be replaced by another character, e.g. '_'. to be continued.
The network protocol to communicate with the Hyperwave server is called HG-CSP (Hyper-G Client/Server Protocol). It is based on messages to initiate certain actions, e.g. get object record. In early versions of the Hyperwave Server two native clients (Harmony, Amadeus) were provided for communication with the server. Those two disappeared when Hyperwave was commercialized. As a replacement a so called wavemaster was provided. The wavemaster is like a protocol converter from HTTP to HG-CSP. The idea is to do all the administration of the database and visualisation of documents by a web interface. The wavemaster implements a set of placeholders for certain actions to customise the interface. This set of placeholders is called the PLACE Language. PLACE lacks a lot of features of a real programming language and any extension to it only enlarges the list of placeholders.
This has led to the use of JavaScript which IMO does not make life easier.
Adding Hyperwave support to PHP3 should fill in the gap of a missing programming language for interface customisation. It implements all the messages as defined by the HG-CSP but also provides more powerful commands to e.g. retrieve complete documents.
Hyperwave has its own terminology to name certain pieces of information. This has widely been taken over and extended. Almost all functions operate on one of the following data types.
-
object ID: An unique integer value for each object in the Hyperwave server. It is also one of the attributes of the object record (ObjectID). Object ids are often used as an input parameter to specify an object.
-
object record: A string with attribute-value pairs of the form attribute=value. The pairs are separated by a carriage return from each other. An object record can easily be converted into an object array with hw_object2array. Several functions return object records. The names of those functions end with obj.
-
object array: An associated array with all attributes of an object. The key is the attribute name. If an attribute occurs more than once in an object record it will result in another indexed or associated array. Attributes which are language depended (like the title, keyword, description) will form an associated array with the key set to the language abbreviation. All other multiple attributes will form an indexed array. php3 functions never return object arrays.
-
hw_document: This is a complete new data type which holds the actual document, e.g. HTML, PDF etc. It is somewhat optimised for HTML documents but may be used for any format.
Several functions which return an array of object records do also return an associated array with statistical information about them. The array is the last element of the object record array. The statistical array contains the following entries:
Hidden
Number of object records with attribute PresentationHints set to Hidden.
CollectionHead
Number of object records with attribute PresentationHints set to CollectionHead.
FullCollectionHead
Number of object records with attribute PresentationHints set to FullCollectionHead.
CollectionHeadNr
Index in array of object records with attribute PresentationHints set to CollectionHead.
FullCollectionHeadNr
Index in array of object records with attribute PresentationHints set to FullCollectionHead.
Total
Total: Number of object records.
Integration with Apache
The Hyperwave module is best used when PHP3 is compiled as an apache module. In such a case the underlying Hyperwave server can be hidden from users almost completely if apache uses its rewriting engine. The following instructions will explain this.
Since PHP3 with Hyperwave support build into apache is intended to replace the native Hyperwave solution based on wavemaster I will assume that the apache server will only serve as a Hyperwave web interface. This is not necessary but it simplifies the configuration. The concept is quite simple. First of all you need a PHP3 script which evaluates the PATH_INFO variable and treats its value as the name of a Hyperwave object. Let's call this script 'Hyperwave'. The URL http://your.hostname/Hyperwave/name_of_object would than return the Hyperwave object with the name 'name_of_object'. Depending on the type of the object the script has to react accordingly. If it is a collection, it will probably return a list of children. If it is a document it will return the mime type and the content. A slight improvement can be achieved if the apache rewriting engine is used. From the users point of view it would be more straight forward if the URL http://your.hostname/name_of_object would return the object. The rewriting rule is quite easy:
RewriteRule ^/(.*) /usr/local/apache/htdocs/HyperWave/$1 [L]
Now every URL relates to an object in the Hyperwave server. This causes a simple to solve problem. There is no way to execute a different script, e.g. for searching, than the 'Hyperwave' script. This can be fixed with another rewriting rule like the following:
RewriteRule ^/hw/(.*) /usr/local/apache/htdocs/hw/$1 [L]
This will reserve the directory /usr/local/apache/htdocs/hw for additional scripts and other files. Just make sure this rule is evaluated before the one above. There is just a little drawback: all Hyperwave objects whose name starts with 'hw/' will be shadowed. So, make sure you don't use such names. If you need more directories, e.g. for images just add more rules or place them all in one directory. Finally, don't forget to turn on the rewriting engine with
RewriteEngine on
My experiences have shown that you will need the following scripts:
- to return the object itself
Todo
-
to allow searching
-
to identify yourself
-
to set your profile
-
one for each additional function like to show the object attributes, to show information about users, to show the status of the server, etc.
There are still some things todo:
-
The hw_InsertDocument has to be split into hw_InsertObject and hw_PutDocument.
-
The names of several functions are not fixed, yet.
-
Most functions require the current connection as its first parameter. This leads to a lot of typing, which is quite often not necessary if there is just one open connection. A default connection will improve this.
Hyperwave functions
hw_Changeobject
Name
hw_Changeobject — changes object
Description
int hw_changeobject(int connection, int object_to_change, string commands);
This command allows to remove, add, or modify individual attributes of an object record. The object is specified by the Object ID object_to_change; commands adhere to the following syntax:
<command> ::= <remcmd> |
<addcmd> |
<remcmd> "\" <addcmd>
<remcmd> ::= "rem " <attribute> "=" <value>
<addcmd> ::= "add " <attribute> "=" <value>
Note that in order to delete or remove an attribute its old value has to be supplied (some attributes are allowed more than once). A command like rem attr=value\add attr=value allows to modify attributes in one operation.
Returns TRUE if no error occurs otherwise FALSE.
hw_Children
Name
hw_Children — object ids of children
Description
array hw_children(int connection, int objectID);
Returns an array of object ids. Each id belongs to a child of the collection with ID objectID. The array contains all children both documents and collections.
hw_ChildrenObj
Name
hw_ChildrenObj — object records of children
Description
array hw_childrenobj(int connection, int objectID);
Returns an array of object records. Each object record belongs to a child of the collection with ID
objectID. The array contains all children both documents and collections.
hw_Close
Name
hw_Close — closes the Hyperwave connection
Description
int hw_close(int connection);
Returns false if connection is not a valid connection index, otherwise true. Closes down the connection to a Hyperwave server with the given connection index.
hw_Connect
Name
hw_Connect — opens a connection
Description
int hw_connect(string host, int port, string username, string password);
Opens a connection to a Hyperwave server and returns a connection index on success, or false if the connection could not be made. Each of the arguments should be a quoted string, except for the port number. The username and password arguments are optional and can be left out. In such a case no identification with the server will be done. It is similar to identify as user anonymous. This function returns a connection index that is needed by other Hyperwave functions. You can have multiple connections open at once. Keep in mind, that the password is not encrypted.
See also hw_pConnect.
hw_Cp
Name
hw_Cp — copies objects
Description
int hw_cp(int connection, array object_id_array, int destination id);
Copies the objects with object ids as specified in the second parameter to the collection with the id
destination id.
The value return is the number of copied objects. See also hw_mv.
hw_Deleteobject
Name
hw_Deleteobject — deletes object
Description
int hw_deleteobject(int connection, int object_to_delete);
Deletes the the object with the given object id in the second parameter. It will delete all instances of the object.
Returns TRUE if no error occurs otherwise FALSE. See also hw_mv.
hw_DocByAnchor
Name
hw_DocByAnchor — object id object belonging to anchor
Description
int hw_docbyanchor(int connection, int anchorID);
Returns an th object id of the document to which anchorID belongs.
hw_DocByAnchorObj
Name
hw_DocByAnchorObj — object record object belonging to anchor
Description
string hw_docbyanchorobj(int connection, int anchorID);
Returns an th object record of the document to which anchorID belongs.
hw_DocumentAttributes
Name
hw_DocumentAttributes — object record of hw_document
Description
string hw_documentattributes(int hw_document);
Returns the object record of the document.
See also hw_DocumentBodyTag, hw_DocumentSize.
hw_DocumentBodyTag
Name
hw_DocumentBodyTag — body tag of hw_document
Description
string hw_documentbodytag(int hw_document);
Returns the BODY tag of the document. If the document is an HTML document the BODY tag should be printed before the document.
See also hw_DocumentAttributes, hw_DocumentSize.
hw_DocumentSize
Name
hw_DocumentSize — size of hw_document
Description
int hw_documentsize(int hw_document);
Returns the size in bytes of the document.
See also hw_DocumentBodyTag, hw_DocumentAttributes.
hw_ErrorMsg
Name
hw_ErrorMsg — returns error message
Description
string hw_errormsg(int connection);
Returns a string containing the last error message or 'No Error'. If false is returned, this function failed. The message relates to the last command.
hw_EditText
Name
hw_EditText — retrieve text document
Description
int hw_edittext(int connection, int hw_document);
Uploads the text document to the server. The object record of the document may not be modified while the document is edited. This function will only works for pure text documents. It will not open a special data connection and therefore blocks the control connection during the transfer.
See also hw_PipeDocument, hw_FreeDocument, hw_DocumentBodyTag, hw_DocumentSize, hw_OutputDocument, hw_GetText.
hw_Error
Name
hw_Error — error number
Description
int hw_error(int connection);
Returns the last error number. If the return value is 0 no error has occurred. The error relates to the last command.
hw_Free_Document
Name
hw_Free_Document — frees hw_document
Description
int hw_free_document(int hw_document);
Frees the memory occupied by the Hyperwave document.
hw_GetParents
Name
hw_GetParents — object ids of parents
Description
array hw_getparentsobj(int connection, int objectID);
Returns an indexed array of object ids. Each object id belongs to a parent of the object with ID
objectID.
hw_GetParentsObj
Name
hw_GetParentsObj — object records of parents
Description
array hw_getparentsobj(int connection, int objectID);
Returns an indexed array of object records plus an associated array with statistical information about the object records. The associated array is the last entry of the returned array. Each object record belongs to a parent of the object with ID objectID.
hw_GetChildColl
Name
hw_GetChildColl — object ids of child collections
Description
array hw_getchildcoll(int connection, int objectID);
Returns an array of object ids. Each object ID belongs to a child collection of the collection with ID
objectID. The function will not return child documents. See also hw_GetChildren, hw_GetChildDocColl.
hw_GetChildCollObj
Name
hw_GetChildCollObj — object records of child collections
Description
array hw_getchildcollobj(int connection, int objectID);
Returns an array of object records. Each object records belongs to a child collection of the collection with ID objectID. The function will not return child documents.
See also hw_ChildrenObj, hw_GetChildDocCollObj.
hw_GetSrcByDestObj
Name
hw_GetSrcByDestObj — Returns anchors pointing at object
Description
array hw_getsrcbydestobj(int connection, int objectID);
Returns the object records of all anchors pointing to the object with ID objectID. The object can either be a document or an anchor of type destination.
See also hw_GetAnchors.
hw_GetObject
Name
hw_GetObject — object record
Description
array hw_getobject(int connection, int objectID);
Returns the object record for the object with ID objectID. See also hw_GetAndLock.
hw_GetAndLock
Name
hw_GetAndLock — return bject record and lock object
Description
string hw_getandlock(int connection, int objectID);
Returns the object record for the object with ID objectID. It will also lock the object, so other users cannot access it until it is unlocked.
See also hw_Unlock, hw_GetObject.
hw_GetText
Name
hw_GetText — retrieve text document
Description
int hw_gettext(int connection, int objectID, int rootID);
Returns the document with object ID objectID. If the document has anchors which can be inserted, they will be inserted already. The optional parameter rootID determines how links are inserted into the document. The default is 0 and will result in links that are constructed from the name of the link's destination object. This is useful for web applications. If a link points to an object with name 'internet_movie' the HTML link will be <A HREF="/internet_movie">. The actual location of the source and destination object in the document hierachy is disregarded. You will have to set up your web browser, to rewrite that URL to for example '/my_script.php3/internet_movie'. 'my_script.php3' will have to evaluate $PATH_INFO and retrieve the document.
If rootID is unequal to 0 the link is constructed from all the names starting at the object with the id rootID separated by a slash relative to the current object. If for example the above document 'internet_movie' is located at 'a-b-c-internet_movie' with '-' being the seperator between hierachy levels and the source document is located at 'a-b-d-source' the resulting HTML link would be: <A HREF="../c/internet_movie">. This is useful if you want to download the whole server content onto disk and map the document hierachy onto the file system.
This function will only work for pure text documents. It will not open a special data connection and therefore blocks the control connection during the transfer.
See also hw_PipeDocument, hw_FreeDocument, hw_DocumentBodyTag, hw_DocumentSize, hw_OutputDocument.
hw_GetObjectByQuery
Name
hw_GetObjectByQuery — search object
Description
array hw_getobjectbyquery(int connection, string query, int max_hits);
Searches for objects on the whole server and returns an array of object ids. The maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum number of matches is unlimited.
See also hw_GetObjectByQueryObj.
hw_GetObjectByQueryObj
Name
hw_GetObjectByQueryObj — search object
Description
array hw_getobjectbyqueryobj(int connection, string query, int max_hits);
Searches for objects on the whole server and returns an array of object records. The maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum number of matches is unlimited.
See also hw_GetObjectByQuery.
hw_GetObjectByQueryColl
Name
hw_GetObjectByQueryColl — search object in collection
Description
array hw_getobjectbyquerycoll(int connection, int objectID, string query, int
max_hits);
Searches for objects in collection with ID objectID and returns an array of object ids. The maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum number of matches is unlimited.
See also hw_GetObjectByQueryCollObj.
hw_GetObjectByQueryCollObj
Name
hw_GetObjectByQueryCollObj — search object in collection
Description
array hw_getobjectbyquerycollobj(int connection, int objectID, string query, int max_hits);
Searches for objects in collection with ID objectID and returns an array of object records. The maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum number of matches is unlimited.
See also hw_GetObjectByQueryColl.
hw_GetChildDocColl
Name
hw_GetChildDocColl — object ids of child documents of collection
Description
array hw_getchilddoccoll(int connection, int objectID);
Returns array of object ids for child documents of a collection. See also hw_GetChildren, hw_GetChildColl.
hw_GetChildDocCollObj
Name
hw_GetChildDocCollObj — object records of child documents of collection
Description
array hw_getchilddoccollobj(int connection, int objectID);
Returns an array of object records for child documents of a collection. See also hw_ChildrenObj, hw_GetChildCollObj.
hw_GetAnchors
Name
hw_GetAnchors — object ids of anchors of document
Description
array hw_getanchors(int connection, int objectID);
Returns an array of object ids with anchors of the document with object ID objectID.
hw_GetAnchorsObj
Name
hw_GetAnchorsObj — object records of anchors of document
Description
array hw_getanchorsobj(int connection, int objectID);
Returns an array of object records with anchors of the document with object ID objectID.
hw_Mv
Name
hw_Mv — moves objects
Description
int hw_mv(int connection, array object id array, int source id, int
destination id);
Moves the objects with object ids as specified in the second parameter from the collection with id source id to the collection with the id destination id. If the source id is 0 the objects will be unlinked from the source collection. If this is the last instance of that object it will be deleted.
The value return is the number of moved objects. See also hw_cp, hw_deleteobject.
hw_Identify
Name
hw_Identify — identifies as user
Description
int hw_identify(string username, string password);
Identifies as user with username and password. Identification is only valid for the current session. I do not thing this function will be needed very often. In most cases it will be easier to identify with the opening of the connection.
See also hw_Connect.
hw_InCollections
Name
hw_InCollections — check if object ids in collections
Description
array hw_incollections(int connection, array object_id_array, array
collection_id array, int return_collections);
Checks whether a set of objects (documents or collections) specified by the object_id_array is part of the collections defined by collection id_array. When the fourth parameter return_collectionsis 0, the subset of object ids that is part of the collections (i.e., the documents or collections that are children of one or more collections of collection ids or their subcollections, recursively) is returned as an array. When the fourth parameter is 1, however, the set of collections that have one or more objects of this subset as children are returned as an array. This option allows a client to, e.g., highlight the part of the collection hierarchy that contains the matches of a previous query, in a graphical overview.
hw_Info
Name
hw_Info — info about connection
Description
string hw_info(int connection);
Returns information about the current connection. The returned string has the following format:
<Serverstring>, <Host>, <Port>, <Username>, <Port of Client>, <Byte swapping>
hw_InsColl
Name
hw_InsColl — insert collection
Description
int hw_inscoll(int connection, int objectID, array object_array);
Inserts a new collection with attributes as in object_array into collection with object ID
objectID.
hw_InsDoc
Name
hw_InsDoc — insert document
Description
int hw_insdoc(int connection, int parentID, string object_record, string
text);
Inserts a new document with attributes as in object_record into collection with object ID parentID. This function inserts either an object record only or an object record and a pure ascii text in text if text is given. If you want to insert a general document of any kind use hw_insertdocument instead.
See also hw_InsertDocument, hw_InsColl.
hw_InsertDocument
Name
hw_InsertDocument — upload any document
Description
int hw_putdocument(int connection, int parent_id, int hw_document);
Uploads a document into the collection with parent_id. The document has to be created before with hw_NewDocument. Make sure that the object record of the new document contains at least the attributes: Type, DocumentType, Title and Name. Possibly you also want to set the MimeType.
See also hw_PipeDocument.
hw_New_Document
Name
hw_New_Document — create new document
Description
int hw_new_document(string document_data, string object_record, int
document_size);
Returns a new Hyperwave document with document data set to document_data and object record set to object_record. The length of the document_data has to passed in document_sizeThis function does not insert the document into the Hyperwave server.
See also hw_FreeDocument, hw_DocumentSize, hw_DocumentBodyTag, hw_OutputDocument, hw_InsertDocument.
hw_Objrec2Array
Name
hw_Objrec2Array — convert attributes from object record to object array
Description
array hw_objrec2array(string object_record);
Converts an object_record into an object array.
hw_OutputDocument
Name
hw_OutputDocument — prints hw_document
Description
int hw_outputdocument(int hw_document);
Prints the document without the BODY tag.
hw_pConnect
Name
hw_pConnect — make a persistent database connection
Description
int hw_pconnect(string host, int port, string username, string password);
Returns a connection index on success, or false if the connection could not be made. Opens a persistent connection to a Hyperwave server. Each of the arguments should be a quoted string, except for the port number. The username and password arguments are optional and can be left out. In such a case no identification with the server will be done. It is similar to identify as user anonymous. This function returns a connection index that is needed by other Hyperwave functions. You can have multiple persistent connections open at once.
See also hw_Connect.
hw_PipeDocument
Name
hw_PipeDocument — retrieve any document
Description
int hw_pipedocument(int connection, int objectID);
Returns the Hyperwave document with object ID objectID. If the document has anchors which can be inserted, they will have been inserted already. The document will be transfered via a special data connection which does not block the control connection.
See also hw_GetText for more on link insertion, hw_FreeDocument, hw_DocumentSize, hw_DocumentBodyTag, hw_OutputDocument.
hw_Root
Name
hw_Root — root object id
Description
int hw_root();
Returns the object ID of the hyperroot collection. Currently this is always 0. The child collection of the hyperroot is the root collection of the connected server.
hw_Unlock
Name
hw_Unlock — unlock object
Description
int hw_unlock(int connection, int objectID);
Unlocks a document, so other users regain access. See also hw_GetAndLock.
hw_Username
Name
hw_Username — name of currently logged in user
Description
string hw_getusername(int connection);
Returns the username of the connection.