Integration with Apache

The integration with Apache and possible other servers has been described in the separate chapter.

Classes

The API provided by the HW_API extension is fully object oriented. It is very similar to the C++ interface of the Hyperwave SDK. It consist of the following classes.

  • HW_API
  • HW_API_Object
  • HW_API_Attribute
  • HW_API_Error
  • HW_API_Content
  • HW_API_Reason

Some basic classes like HW_API_String, HW_API_String_Array, etc., which exist in the Hyperwave SDK have not been implemented since PHP has powerful replacements for them.

Each class has certain method, whose names are identical to its counterparts in the Hyperwave SDK. Passing arguments to this function differs from all the other PHP extensions but is close to the C++ API of the HW SDK. Instead of passing several parameters they are all put into an associated array and passed as one parameter. The names of the keys are identical to those documented in the HW SDK. The common parameters are listed below. If other parameters are required they will be documented if needed.

  • objectIdentifier The name or id of an object, e.g. "rootcollection", "0x873A8768 0x00000002".
  • parentIdentifier The name or id of an object which is considered to be a parent.
  • object An instance of class HW_API_Object.
  • parameters An instance of class HW_API_Object.
  • version The version of an object.
  • mode An integer value determine the way an operation is executed.
  • attributeSelector Any array of strings, each containing a name of an attribute. This is used if you retrieve the object record and want to include certain attributes.
  • objectQuery A query to select certain object out of a list of objects. This is used to reduce the number of objects which was delivered by a function like hw_api::children or hw_api::find.

Note:

Methods returning boolean can return TRUE, FALSE or class="classname">HW_API_Error object.

hw_api::checkin

Checks in an object

说明

bool hw_api::checkin ( array $parameter )

This function checks in an object or a whole hierarchy of objects. The parameters array contains the required element 'objectIdentifier' and the optional element 'version', 'comment', 'mode' and 'objectQuery'. 'version' sets the version of the object. It consists of the major and minor version separated by a period. If the version is not set, the minor version is incremented. 'mode' can be one of the following values:

HW_API_CHECKIN_NORMAL
Checks in and commits the object. The object must be a document.

HW_API_CHECKIN_RECURSIVE
If the object to check in is a collection, all children will be checked in recursively if they are documents. Trying to check in a collection would result in an error.

HW_API_CHECKIN_FORCE_VERSION_CONTROL
Checks in an object even if it is not under version control.

HW_API_CHECKIN_REVERT_IF_NOT_CHANGED
Check if the new version is different from the last version. Unless this is the case the object will be checked in.

HW_API_CHECKIN_KEEP_TIME_MODIFIED
Keeps the time modified from the most recent object.

HW_API_CHECKIN_NO_AUTO_COMMIT
The object is not automatically committed on check-in.

参数

parameter

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

hw_api::checkout

Checks out an object

说明

bool hw_api::checkout ( array $parameter )

This function checks out an object or a whole hierarchy of objects.

参数

parameter
The parameters array contains the required element 'objectIdentifier' and the optional element 'version', 'mode' and 'objectQuery'. 'mode' can be one of the following values:

HW_API_CHECKIN_NORMAL
Checks out an object. The object must be a document.

HW_API_CHECKIN_RECURSIVE
If the object to check out is a collection, all children will be checked out recursively if they are documents. Trying to check out a collection would result in an error.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

hw_api::children

Returns children of an object

说明

array hw_api::children ( array $parameter )

Retrieves the children of a collection or the attributes of a document. The children can be further filtered by specifying an object query.

参数

parameter
The parameter array contains the required elements 'objectIdentifier' and the optional elements 'attributeSelector' and 'objectQuery'.

返回值

The return value is an array of objects of type HW_API_Object or HW_API_Error.

参见

hw_api::content

Returns content of an object

说明

HW_API_Content hw_api::content ( array $parameter )

This function returns the content of a document as an object of type hw_api_content.

参数

parameter
The parameter array contains the required elements 'objectidentifier' and the optional element 'mode'. The mode can be one of the constants HW_API_CONTENT_ALLLINKS, HW_API_CONTENT_REACHABLELINKS or HW_API_CONTENT_PLAIN.

HW_API_CONTENT_ALLLINKS means to insert all anchors even if the destination is not reachable.

HW_API_CONTENT_REACHABLELINKS tells this method to insert only reachable links and HW_API_CONTENT_PLAIN will lead to document without any links.

返回值

Returns an instance of hw_api_content.

hw_api::copy

Copies physically

说明

hw_api_content hw_api::copy ( array $parameter )

This function will make a physical copy including the content if it exists and returns the new object or an error object.

参数

parameter
The parameter array contains the required elements 'objectIdentifier' and 'destinationParentIdentifier'. The optional parameter is 'attributeSelector'`

返回值

Returns the copied object.

参见

hw_api::dbstat

Returns statistics about database server

说明

hw_api_object hw_api::dbstat ( array $parameter )

Returns statistics about database server.

参数

parameter

返回值

参见

hw_api::dcstat

Returns statistics about document cache server

说明

hw_api_object hw_api::dcstat ( array $parameter )

Returns statistics about document cache server.

参数

parameter

返回值

参见

hw_api::dstanchors

Returns a list of all destination anchors

说明

array hw_api::dstanchors ( array $parameter )

Retrieves all destination anchors of an object.

参数

parameter
The parameter array contains the required element 'objectIdentifier' and the optional elements 'attributeSelector' and 'objectQuery'.

返回值

参见

hw_api::dstofsrcanchor

Returns destination of a source anchor

说明

hw_api_object hw_api::dstofsrcanchor ( array $parameter )

Retrieves the destination object pointed by the specified source anchors. The destination object can either be a destination anchor or a whole document.

参数

parameter
The parameters array contains the required element 'objectIdentifier' and the optional element 'attributeSelector'.

返回值

参见

hw_api::find

Search for objects

说明

array hw_api::find ( array $parameter )

This functions searches for objects either by executing a key or/and full text query. The found objects can further be filtered by an optional object query. They are sorted by their importance. The second search operation is relatively slow and its result can be limited to a certain number of hits. This allows to perform an incremental search, each returning just a subset of all found documents, starting at a given index.

参数

parameter
The parameter array contains the 'keyquery' or/and 'fulltextquery' depending on who you would like to search. Optional parameters are 'objectquery', 'scope', 'languages' and 'attributeselector'. In case of an incremental search the optional parameters 'startIndex', 'numberOfObjectsToGet' and 'exactMatchUnit' can be passed.

返回值

hw_api::ftstat

Returns statistics about fulltext server

说明

hw_api_object hw_api::ftstat ( array $parameter )

Returns statistics about fulltext server.

参数

parameter

返回值

参见

hw_api::hwstat

Returns statistics about Hyperwave server

说明

hw_api_object hw_api::hwstat ( array $parameter )

Returns statistics about Hyperwave server.

参数

parameter

返回值

参见

hw_api::identify

Log into Hyperwave Server

说明

bool hw_api::identify ( array $parameter )

Logs into the Hyperwave Server.

参数

parameter
The parameter array must contain the elements 'username' and 'password'.

返回值

Returns an object of typeHW_API_Error if identification failed or TRUE if it was successful.

hw_api::info

Returns information about server configuration

说明

array hw_api::info ( array $parameter )

Returns information about server configuration.

参数

parameter

返回值

参见

hw_api::insert

Inserts a new object

说明

hw_api_object hw_api::insert ( array $parameter )

Insert a new object. The object type can be user, group, document or anchor. Depending on the type other object attributes has to be set.

参数

parameter
The parameter array contains the required elements 'object' and 'content' (if the object is a document) and the optional parameters 'parameters', 'mode' and 'attributeSelector'. The 'object' must contain all attributes of the object. 'parameters' is an object as well holding further attributes like the destination (attribute key is 'Parent'). 'content' is the content of the document. 'mode' can be a combination of the following flags:

HW_API_INSERT_NORMAL
The object in inserted into the server.

HW_API_INSERT_FORCE_VERSION_CONTROL

HW_API_INSERT_AUTOMATIC_CHECKOUT

HW_API_INSERT_PLAIN

HW_API_INSERT_KEEP_TIME_MODIFIED

HW_API_INSERT_DELAY_INDEXING

返回值

参见

hw_api::insertanchor

Inserts a new object of type anchor

说明

hw_api_object hw_api::insertanchor ( array $parameter )

This function is a shortcut for hwapi_insert. It inserts an object of type anchor and sets some of the attributes required for an anchor.

参数

parameter
The parameter array contains the required elements 'object' and 'documentIdentifier' and the optional elements 'destinationIdentifier', 'parameter', 'hint' and 'attributeSelector'. The 'documentIdentifier' specifies the document where the anchor shall be inserted. The target of the anchor is set in 'destinationIdentifier' if it already exists. If the target does not exists the element 'hint' has to be set to the name of object which is supposed to be inserted later. Once it is inserted the anchor target is resolved automatically.

返回值

参见

hw_api::insertcollection

Inserts a new object of type collection

说明

hw_api_object hw_api::insertcollection ( array $parameter )

This function is a shortcut for hwapi_insert. It inserts an object of type collection and sets some of the attributes required for a collection.

参数

parameter
The parameter array contains the required elements 'object' and 'parentIdentifier' and the optional elements 'parameter' and 'attributeSelector'. See hwapi_insert for the meaning of each element.

返回值

参见

hw_api::insertdocument

Inserts a new object of type document

说明

hw_api_object hw_api::insertdocument ( array $parameter )

This function is a shortcut for hwapi_insert. It inserts an object with content and sets some of the attributes required for a document.

参数

parameter
The parameter array contains the required elements 'object', 'parentIdentifier' and 'content' and the optional elements 'mode', 'parameter' and 'attributeSelector'.

See hwapi_insert for the meaning of each element.

返回值

参见

hw_api::link

Creates a link to an object

说明

bool hw_api::link ( array $parameter )

Creates a link to an object. Accessing this link is like accessing the object to links points to.

参数

parameter
The parameter array contains the required elements 'objectIdentifier' and 'destinationParentIdentifier'. 'destinationParentIdentifier' is the target collection.

返回值

The function returns TRUE on success or an error object.

参见

hw_api::lock

Locks an object

说明

bool hw_api::lock ( array $parameter )

Locks an object for exclusive editing by the user calling this function. The object can be only unlocked by this user or the system user.

参数

parameter
The parameter array contains the required element 'objectIdentifier' and the optional parameters 'mode' and 'objectquery'.

'mode' determines how an object is locked. HW_API_LOCK_NORMAL means, an object is locked until it is unlocked. HW_API_LOCK_RECURSIVE is only valid for collection and locks all objects within the collection and possible subcollections. HW_API_LOCK_SESSION means, an object is locked only as long as the session is valid.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

hw_api::move

Moves object between collections

说明

bool hw_api::move ( array $parameter )

Moves object between collections.

参数

parameter

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • hw_objrec2array

hw_api::object

Retrieve attribute information

说明

hw_api_object hw_api::object ( array $parameter )

This function retrieves the attribute information of an object of any version. It will not return the document content.

参数

parameter
The parameter array contains the required elements 'objectIdentifier' and the optional elements 'attributeSelector' and 'version'.

返回值

The returned object is an instance of class HW_API_Object on success or HW_API_Error if an error occurred.

范例

This simple example retrieves an object and checks for errors.

示例 #1 Retrieve an object

<?php
function handle_error($error)
{
  $reason = $error->reason(0);
  echo "Type: <b>";
  switch ($reason->type()) {
    case 0:
      echo "Error";
      break;
    case 1:
      echo "Warning";
      break;
    case 2:
      echo "Message";
      break;
  }
  echo "</b><br />\n";
  echo "Description: " . $reason->description("en") . "<br />\n";
}

function list_attr($obj)
{
  echo "<table>\n";
  $count = $obj->count();
  for ($i=0; $i<$count; $i++) {
    $attr = $obj->attribute($i);
    printf("<tr><td align=\"right\" bgcolor=\"#c0c0c0\"><b>%s</b></td><td bgcolor=\"#F0F0F0\">%s</td></tr>\n",
             $attr->key(), $attr->value());
  }
  echo "</table>\n";
}

$hwapi = hwapi_hgcsp($g_config[HOSTNAME]);
$parms = array("objectIdentifier"=>"rootcollection", "attributeSelector"=>array("Title", "Name", "DocumentType"));
$root = $hwapi->object($parms);
if (get_class($root) == "HW_API_Error") {
  handle_error($root);
  exit;
}
list_attr($root);
?>

参见

hw_api::objectbyanchor

Returns the object an anchor belongs to

说明

hw_api_object hw_api::objectbyanchor ( array $parameter )

This function retrieves an object the specified anchor belongs to.

参数

parameter
The parameter array contains the required element 'objectIdentifier' and the optional element 'attributeSelector'.

返回值

参见

hw_api::parents

Returns parents of an object

说明

array hw_api::parents ( array $parameter )

Retrieves the parents of an object. The parents can be further filtered by specifying an object query.

参数

parameter
The parameter array contains the required elements 'objectidentifier' and the optional elements 'attributeselector' and 'objectquery'.

返回值

The return value is an array of objects of type HW_API_Object or HW_API_Error.

参见

hw_api::remove

Delete an object

说明

bool hw_api::remove ( array $parameter )

Removes an object from the specified parent. Collections will be removed recursively.

参数

parameter
You can pass an optional object query to remove only those objects which match the query. An object will be deleted physically if it is the last instance.

The parameter array contains the required elements 'objectidentifier' and 'parentidentifier'. If you want to remove a user or group 'parentidentifier' can be skipped.

The optional parameter 'mode' determines how the deletion is performed. In normal mode the object will not be removed physically until all instances are removed. In physical mode all instances of the object will be deleted immediately. In removelinks mode all references to and from the objects will be deleted as well. In nonrecursive the deletion is not performed recursive. Removing a collection which is not empty will cause an error.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

hw_api::replace

Replaces an object

说明

hw_api_object hw_api::replace ( array $parameter )

Replaces the attributes and the content of an object.

参数

parameter
The parameter array contains the required elements 'objectIdentifier' and 'object' and the optional parameters 'content', 'parameters', 'mode' and 'attributeSelector'. 'objectIdentifier' contains the object to be replaced. 'object' contains the new object. 'content' contains the new content. 'parameters' contain extra information for HTML documents. HTML_Language is the letter abbreviation of the language of the title. HTML_Base sets the base attribute of the HTML document.

'mode' can be a combination of the following flags:

HW_API_REPLACE_NORMAL
The object on the server is replace with the object passed.

HW_API_REPLACE_FORCE_VERSION_CONTROL

HW_API_REPLACE_AUTOMATIC_CHECKOUT

HW_API_REPLACE_AUTOMATIC_CHECKIN

HW_API_REPLACE_PLAIN

HW_API_REPLACE_REVERT_IF_NOT_CHANGED

HW_API_REPLACE_KEEP_TIME_MODIFIED

返回值

参见

hw_api::setcommittedversion

Commits version other than last version

说明

hw_api_object hw_api::setcommittedversion ( array $parameter )

Commits a version of a document. The committed version is the one which is visible to users with read access. By default the last version is the committed version.

参数

parameter

返回值

参见

hw_api::srcanchors

Returns a list of all source anchors

说明

array hw_api::srcanchors ( array $parameter )

Retrieves all source anchors of an object.

参数

parameter
The parameter array contains the required element 'objectIdentifier' and the optional elements 'attributeSelector' and 'objectQuery'.

返回值

参见

hw_api::srcsofdst

Returns source of a destination object

说明

array hw_api::srcsofdst ( array $parameter )

Retrieves all the source anchors pointing to the specified destination. The destination object can either be a destination anchor or a whole document.

参数

parameter
The parameters array contains the required element 'objectIdentifier' and the optional element 'attributeSelector' and 'objectQuery'. The function returns an array of objects or an error.

返回值

参见

hw_api::unlock

Unlocks a locked object

说明

bool hw_api::unlock ( array $parameter )

Unlocks a locked object. Only the user who has locked the object and the system user may unlock an object.

参数

parameter
The parameter array contains the required element 'objectIdentifier' and the optional parameters 'mode' and 'objectquery'. The meaning of 'mode' is the same as in function hwapi_lock.

返回值

Returns TRUE on success or an object of class HW_API_Error.

参见

hw_api::user

Returns the own user object

说明

hw_api_object hw_api::user ( array $parameter )

Returns the own user object.

参数

parameter

返回值

参见

hw_api::userlist

Returns a list of all logged in users

说明

array hw_api::userlist ( array $parameter )

Returns a list of all logged in users.

参数

parameter

返回值

参见

hw_api_attribute::key

Returns key of the attribute

说明

string hw_api_attribute::key ( void )

Returns the name of the attribute.

返回值

Returns the name of the attribute as a string.

参见

hw_api_attribute::langdepvalue

Returns value for a given language

说明

string hw_api_attribute::langdepvalue ( string $language )

Returns the value in the given language of the attribute.

参数

language

返回值

Returns the value of the attribute as a string.

参见

hw_api_attribute::value

Returns value of the attribute

说明

string hw_api_attribute::value ( void )

Gets the value of the attribute.

返回值

Returns the value, as a string.

参见

hw_api_attribute::values

Returns all values of the attribute

说明

array hw_api_attribute::values ( void )

Gets all values of the attribute.

返回值

Returns an array of attribute values.

参见

hw_api_content::mimetype

Returns mimetype

说明

string hw_api_content::mimetype ( void )

Returns the mimetype of the content.

返回值

Returns the mimetype as a string.

hw_api_content::read

Read content

说明

string hw_api_content::read ( string $buffer , int $len )

Reads len bytes from the content into the given buffer.

参数

buffer

len
Number of bytes to read.

返回值

hw_api_error::count

Returns number of reasons

说明

int hw_api_error::count ( void )

Returns the number of error reasons.

返回值

Returns the number of errors, as an integer.

参见

hw_api_error::reason

Returns reason of error

说明

HW_API_Reason hw_api_error::reason ( void )

Returns the first error reason.

返回值

参见

hw_api_object::assign

Clones object

说明

bool hw_api_object::assign ( array $parameter )

Clones the attributes of an object.

参数

parameter

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

hw_api_object::attreditable

Checks whether an attribute is editable

说明

bool hw_api_object::attreditable ( array $parameter )

Checks whether an attribute is editable.

参数

parameter

返回值

Returns TRUE if the attribute is editable, FALSE otherwise.

hw_api_object::count

Returns number of attributes

说明

int hw_api_object::count ( array $parameter )

Returns the number of attributes.

参数

parameter

返回值

Returns the number as an integer.

hw_api_object::insert

Inserts new attribute

说明

bool hw_api_object::insert ( HW_API_Attribute $attribute )

Adds an attribute to the object.

参数

attribute

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

hw_api_object::remove

Removes attribute

说明

bool hw_api_object::remove ( string $name )

Removes the attribute with the given name.

参数

name
The attribute name.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

hw_api_object::title

Returns the title attribute

说明

string hw_api_object::title ( array $parameter )

Returns the title attribute.

参数

parameter

返回值

Returns the title as a string.

hw_api_object::value

Returns value of attribute

说明

string hw_api_object::value ( string $name )

Returns value of an attribute.

参数

name
The attribute name.

返回值

Returns the value of the attribute with the given name or FALSE if an error occurred.

hw_api_reason::description

Returns description of reason

说明

string hw_api_reason::description ( void )

Returns the description of a reason

返回值

Returns the description, as a string.

hw_api_reason::type

Returns type of reason

说明

HW_API_Reason hw_api_reason::type ( void )

Returns the type of a reason.

返回值

Returns an instance of HW_API_Reason.

hwapi_attribute_new

Creates instance of class hw_api_attribute

说明

HW_API_Attribute hwapi_attribute_new ([ string $name [, string $value ]] )

Creates a new instance of hw_api_attribute with the given name and value.

参数

name
The attribute name.

value
The attribute value.

返回值

Returns an instance of hw_api_attribute.

hwapi_content_new

Create new instance of class hw_api_content

说明

HW_API_Content hwapi_content_new ( string $content , string $mimetype )

Creates a new content object from the string content.

参数

content

mimetype
The mimetype for the contents.

返回值

hwapi_hgcsp

Returns object of class hw_api

说明

HW_API hwapi_hgcsp ( string $hostname [, int $port ] )

Opens a connection to the Hyperwave server on host hostname. The protocol used is HGCSP.

参数

hostname
The host name.

port
If you do not pass a port number, 418 is used.

返回值

Returns an instance of HW_API.

hwapi_object_new

Creates a new instance of class hwapi_object_new

说明

hw_api_object hwapi_object_new ( array $parameter )

Creates a new instance of the class hw_api_object.

参数

parameter

返回值

参见

目录