Overview   Package   Tree   Index 
Tv2 documentation
PREV  NEXT FRAMES  NO FRAME 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

tv2-engine
Class tv2Xdb


class tv2Xdb

Tv2 X database (tv2Xdb) -- a simple but powerful flat-file XML database

Authors:
Emilis Dambauskas (emilis@gildija.lt)
Version:
$Id: tv2Xdb.class.php,v 1.8 2003/10/13 03:35:13 lunaticlt Exp $
Copyright:
2002–2003 Emilis Dambauskas under Artistic license

Field Summary
string$dir
Directory in which xdb document files are stored
private array$fat
Array with document properties
private string$fat_table
Db table name for fat
private object$fh
tv2FileHelper object
private array$fident
Array (ident => id)
string$file_dir
Directory in which files from document fields are stored
private array$ver
Experimental.
private array$ver_filter
Experimental.
private array$ver_index
Experimental.
private string$ver_table
Experimental.

Constructor Summary
void tv2Xdb()
Constructor

Method Summary
private boolean cDir(string $path)
Recursively creates directories
boolean changeDocPermissions(object& $doc)
Updates document permissions
boolean changeDocType(object& $doc, [string $type])
Changes document type
string checkNfix([boolean $fix])
Checks FAT,version info and indices for errors and fixes them if needed
void connect()
Fills fat and ver_info arrays
private mixed decodeCdata(string $string)
Decode string from CDATA
boolean documentExists(mixed $id)
Checks if a document exists
private string encodeCdata(string $string)
Encode string as CDATA (removes < > &)
private boolean error(string $msg)
Error reporting
array getAllDocs([string $mode])
Returns FAT array for all documents in Xdb
array getFat([mixed $ids], [array $o])
Get FAT entries for a specified list of document IDs
array getList(string $path)
Get FAT entries for documents in some path
private boolean isPermitted(integer $doc_id, string $access)
Permission checking
private void loadFileHelper()
Loads tv2FileHelper into $this->fh.
private boolean loadXIndex()
Loads ctlIndexer object into parameter $xi
private boolean loadXQuery()
Loads tv2XQuery object into parameter $xq
boolean moveDocument(object& $doc, string $ident, [boolean $overwrite])
Moves document from one path to another
array query(string $q, [array $o], [integer $s], [integer $l])
Queries Xdb using SQL-like synthax
object& readDocument(mixed $id, [mixed $vinfo])
Creates tv2Document object reference
boolean removeDocument(object& $doc, [mixed $vinfo])
Removes document
void setVersionFilter(array $filter)
Experimental.
void setVersionPreference(array $filter)
Experimental.
boolean updateIndex(object& $doc)
Updates indexes for the specified document
boolean writeDocument(object& $doc)
Writes tv2 document information into database and disk.


Field Detail

dir

string $dir

Directory in which xdb document files are stored


fat

private array $fat

Array with document properties


fat_table

private string $fat_table

Db table name for fat


fh

private object $fh

tv2FileHelper object


fident

private array $fident

Array (ident => id)


file_dir

string $file_dir

Directory in which files from document fields are stored


ver

private array $ver

Experimental. Default version (serves as versioning indicator)


ver_filter

private array $ver_filter

Experimental. Run-time version filter


ver_index

private array $ver_index

Experimental. Srray with document version info


ver_table

private string $ver_table

Experimental. Version information db table


Constructor Detail

tv2Xdb()

void tv2Xdb()

Constructor

Uses the global variables:
protocol, db, security, $var_cache

Method Detail

cDir()

private boolean cDir(string $path)

Recursively creates directories

Parameters:
path - - path to a document
Returns:
TRUE if action succeeded

changeDocPermissions()

boolean changeDocPermissions(object& $doc)

Updates document permissions

Parameters:
doc - - tv2Document object
Returns:
TRUE on success, FALSE otherwise

changeDocType()

boolean changeDocType(object& $doc, [string $type])

Changes document type

Parameters:
doc - - tv2Document reference
type - - type to change to
Returns:
TRUE on success, FALSE otherwise

checkNfix()

string checkNfix([boolean $fix])

Checks FAT,version info and indices for errors and fixes them if needed

Parameters:
fix - (default TRUE) tells if the function should fix errors
Returns:
String with error messages or warnings, empty string on complete success
To Do:
  • this method still needs to be finished and upgraded

connect()

void connect()

Fills fat and ver_info arrays


decodeCdata()

private mixed decodeCdata(string $string)

Decode string from CDATA

Parameters:
string - - string to be decoded
Returns:
decoded string

documentExists()

boolean documentExists(mixed $id)

Checks if a document exists

Parameters:
id - - document ID or ident
Returns:
TRUE if exists, FALSE otherwise

encodeCdata()

private string encodeCdata(string $string)

Encode string as CDATA (removes < > &)

Parameters:
string - - string to be encoded
Returns:
encoded string

error()

private boolean error(string $msg)

Error reporting

Parameters:
msg - - error message
Returns:
always returns FALSE
Uses the global variables:
errors

getAllDocs()

array getAllDocs([string $mode])

Returns FAT array for all documents in Xdb

Parameters:
mode - index by id ('id') or ident('ident').
Returns:
array containing FAT entries
Deprecated:
This function is subject to removal when it will not be used in xadmin module

getFat()

array getFat([mixed $ids], [array $o])

Get FAT entries for a specified list of document IDs

Parameters:
ids - ID array or single ID/ident
o - Order: array('field', 'ASC'/'DESC')
Returns:
array containing FAT records

getList()

array getList(string $path)

Get FAT entries for documents in some path

Parameters:
path - - path
Returns:
array containing FAT records
Deprecated:
You should use tv2Xdb::query and tv2Xdb::getFat methods instead

isPermitted()

private boolean isPermitted(integer $doc_id, string $access)

Permission checking

Parameters:
doc_id - - tv2 Xdb document id
access - - access type (one of: r/w/x/o/d)
Returns:
TRUE if permission granted, FALSE otherwise

loadFileHelper()

private void loadFileHelper()

Loads tv2FileHelper into $this->fh. ATTENTION: method copied from tv2Client::loadFileHelper.

Uses the global variables:
ENGINE_DIR

loadXIndex()

private boolean loadXIndex()

Loads ctlIndexer object into parameter $xi

Returns:
TRUE on success, FALSE on failure
Uses the global variables:
$config

loadXQuery()

private boolean loadXQuery()

Loads tv2XQuery object into parameter $xq

Returns:
TRUE on success, FALSE on failure

moveDocument()

boolean moveDocument(object& $doc, string $ident, [boolean $overwrite])

Moves document from one path to another

Parameters:
doc - - tv2Document object
ident - - new document ident
overwrite - - overwrite confirmation flag (default FALSE)
Returns:
TRUE on success, FALSE on failure

query()

array query(string $q, [array $o], [integer $s], [integer $l])

Queries Xdb using SQL-like synthax

Parameters:
q - SQL like query
o - order by: array('field', 'ASC'/'DESC')
s - start from (default 0)
l - limit result number to
Returns:
document ID array

readDocument()

object& readDocument(mixed $id, [mixed $vinfo])

Creates tv2Document object reference

Parameters:
id - - document ID or ident
vinfo - Experimental. Specifies with version of the document to open.
Returns:
object tv2Document object

removeDocument()

boolean removeDocument(object& $doc, [mixed $vinfo])

Removes document

Parameters:
doc - - tv2Document object
vinfo - Experimental. If specified only the version of the document will be removed
Returns:
TRUE on success, FALSE on failure

setVersionFilter()

void setVersionFilter(array $filter)

Experimental. Sets strict version filter (Xdb will see only documents with this version)

Parameters:
filter - array of version arrays

setVersionPreference()

void setVersionPreference(array $filter)

Experimental. Set a version preference: Xdb will try opening specified versions over default version

Parameters:
filter - array of version arrays

updateIndex()

boolean updateIndex(object& $doc)

Updates indexes for the specified document

Parameters:
doc - - tv2Document object
Returns:
TRUE on success, FALSE on failure

writeDocument()

boolean writeDocument(object& $doc)

Writes tv2 document information into database and disk. Used both for updating and creating new documents

Parameters:
doc - - tv2Document object
Returns:
TRUE on success, FALSE on failure

 Overview   Package   Tree   Index 
Tv2 documentation
PREV  NEXT FRAMES  NO FRAME 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Submit a bug

This document was generated by phpdocgen 0.17-rc3.
Copyright © 2002-03 Stéphane GALLAND (under the GNU General Public License)