TranslationString Class Reference

List of all members.

Detailed Description

Handles one string's data: original string, translation, locale, store new, load stored, etc.

Definition at line 28 of file TranslationString.php.

Public Member Functions

 __construct ($stringID=0, $projectID=0, $original="", $localeID=1, $translation="", $sentenceID=0, $lastSeen=0, $rowOrder=0)
 GetStringID ()
 GetProjectID ()
 GetOriginal ()
 GetLocaleID ()
 GetTranslation ()
 GetSentenceID ()
 GetLastSeen ()
 SetTranslation ($translation)
 SetRowOrder ($index)
 Save ()
 DestroyData ()
 FindSimilar ($FindText="", $localeID=0, $FilterPercent=60)
 FindText ($findText="", $localeID=0, $findOriginal, $start=0, $limit=100)

Static Public Member Functions

static InitSentenceLengthCache ()
static InitWordSentencesCache ()

Static Public Attributes

static $SentenceLengthCache
static $WordSentencesCache

Private Member Functions

 FindSentenceIndex ($findSimilarToo)
 StoreSentenceIndex ()

Private Attributes

 $StringID
 $ProjectID
 $Original
 $LocaleID
 $Translation
 $SentenceID
 $LastSeen
 $RowOrder
 $Matches
 $Words


Constructor & Destructor Documentation

TranslationString::__construct ( stringID = 0,
projectID = 0,
original = "",
localeID = 1,
translation = "",
sentenceID = 0,
lastSeen = 0,
rowOrder = 0 
)

Fetch a string from the database or create a new one from passed data.

TranslationString object can be constructed three ways:

$original = "", $stringID > 0: the specified string will be loaded from the database.

$original != "", $stringID > 0: the object instance is initailized with that data as if it was loaded from the database.

$original != "", $stringID = 0: in the way to create a new string with ->Save();

Parameters:
$stringID Specifies which string to load from the database, 0 if passing all other data!
$projectID To which project this string belongs.
$original The original language string.
$localeID The locale ID of the specified translation.
$translation The translation of the $original string to $loccaleID locale.
$sentenceID ID of the ($origingal) string in the SentenceIndex table.
$lastSeen Unix timestamp of this string's last insert or update.
$rowOrder The row order index of this string in its project, see SetRowOrder().
Exceptions:
'Exception' thrown if not existing $StringID is passed for loading from db

Definition at line 67 of file TranslationString.php.

References $DB, GetDbConn(), and GetTables().


Member Function Documentation

TranslationString::DestroyData (  ) 

Destroy the currently loaded string in the database, irreversible.

This object will hold the old string's data as if it was a new, not Save()-d one.

Definition at line 367 of file TranslationString.php.

References $DB, GetDbConn(), and GetTables().

TranslationString::FindSentenceIndex ( findSimilarToo  )  [private]

Find similar sentences in the sentence index database

If $findSimilarToo is true the similar sentences will be stored in the internal $this->Matches array. The key is the sentence ID, the value is the match percentage. If $findSimilarToo is false, only one result will be returned, the exact match. $this->Matches remains empty! (Exact match = same words same times, not exactly the same string!)

Parameters:
$findSimilarToo If false, the search will end with the first exact match.

Definition at line 586 of file TranslationString.php.

References $DB, $SentenceLengthCache, GetDbConn(), and GetTables().

Referenced by FindSimilar(), and Save().

TranslationString::FindSimilar ( FindText = "",
localeID = 0,
FilterPercent = 60 
)

Public function to find existing sentences in the string database

Finds similar sentences and returns them in an array ordered by match percentage descending. Return format: array[stringID]["string"][] = array, TranslationString objects with all matches array[stringID]["percent"] = integer, match percentage If parameters are omitted, the current string object's text and localeID will be used. If parameters are specified, the current string is changed to those.

Parameters:
$FindText The sentence or text to find, if emtpy, uses this object's Original string.
$localeID Find strings only in this locale.
$FilterPercent Drop results below this match percentage, defaults to 60.
Returns:
Array of matches of ID,Percent subarrays of TranslationStrings, ordered descending by Percent.

Definition at line 398 of file TranslationString.php.

References $DB, FindSentenceIndex(), GetDbConn(), and GetTables().

TranslationString::FindText ( findText = "",
localeID = 0,
findOriginal,
start = 0,
limit = 100 
)

Find strings based on part of the string.

Can find in both Original string and Translation, uses LIKE string% match for the select. There is no percentage data returned from this function, otherwise the array is the same like in FindSimilar().

Parameters:
$findText The sentence or text to find, if emtpy, uses this object's Original o Translation.
$localeID Find strings only in this locale.
$findOriginal bool: true finds in Original strings, false finds in Translations.
$start int: Start at this result entry (for paging).
$limit int: Limit search results to this number.
Returns:
Array of matches of ID subarrays of TranslationStrings.

Definition at line 505 of file TranslationString.php.

References $DB, fixstr(), GetDbConn(), and GetTables().

TranslationString::GetLastSeen (  ) 

Get the current string's last update timestamp.

Returns:
string When the string was last changed or inserted.

Definition at line 233 of file TranslationString.php.

TranslationString::GetLocaleID (  ) 

Get the current string's locale id.

Returns:
int The current string's locale id.

Definition at line 200 of file TranslationString.php.

TranslationString::GetOriginal (  ) 

Get the current string's original (English) text.

Returns:
string The current string's original text.

Definition at line 189 of file TranslationString.php.

TranslationString::GetProjectID (  ) 

Get the current string's string project id.

Returns:
int The project's id in which this string resides.

Definition at line 178 of file TranslationString.php.

TranslationString::GetSentenceID (  ) 

Get the current string's sentence index ID, based on what words this string contains.

Returns:
string The current string's ID in the sentence index.

Definition at line 222 of file TranslationString.php.

TranslationString::GetStringID (  ) 

Get the current string's string id.

Returns:
int The current string's string id.

Definition at line 167 of file TranslationString.php.

TranslationString::GetTranslation (  ) 

Get the current string's translation.

Returns:
string The current string's translated text.

Definition at line 211 of file TranslationString.php.

static TranslationString::InitSentenceLengthCache (  )  [static]

Initialize the static sentence cache which contains word counts of each sentence.

The pre-cached wordcounts are used for searching similar things, match percent comparison is based on these numbers, becasue not all words of the SIMILAR strings will be loaded from the database on FindSimilar(), only those words what this searched string also has. Thus complete word-word percent comparsion needs this length data.

Sets TranslationString::$SentenceLengthCache

Definition at line 126 of file TranslationString.php.

References $DB, $SentenceLengthCache, GetDbConn(), and GetTables().

Referenced by CacheIndexes().

static TranslationString::InitWordSentencesCache (  )  [static]

LATER Initialize the static words sentence cache which contains in which sentences the given word occures.

Definition at line 145 of file TranslationString.php.

References $DB, $WordSentencesCache, GetDbConn(), and GetTables().

TranslationString::Save (  ) 

Store the string in the database and create indexes for it.

Checks if the same Original exists in the same Project. In this case no new string created, just updated.

Returns:
The found existing or newly created String ID.
Exceptions:
'Exception' thrown if Original srtring is not set.

Definition at line 274 of file TranslationString.php.

References $DB, $SentenceLengthCache, FindSentenceIndex(), GetDbConn(), GetTables(), and StoreSentenceIndex().

TranslationString::SetRowOrder ( index  ) 

Set the current string's row order index, this will be used for ordering by StringIterators.

Using this value you can make sure, that strings are in good order, even if newer strings in the same project will get much higher StringID in later imports.

Parameters:
$index The index of this string in its project, for better GUI displays.

Definition at line 257 of file TranslationString.php.

TranslationString::SetTranslation ( translation  ) 

Set the current string's translation, call Save() to apply to the database.

Parameters:
$translation The current string's new translated text.

Definition at line 244 of file TranslationString.php.

TranslationString::StoreSentenceIndex (  )  [private]

Insert the current sentence into the sentence index database

Called by this class after trying FindSentenceIndex for already existing match. If the find did not found a 100% match in the sentence index, this function can be called to add the current sentence.

Definition at line 668 of file TranslationString.php.

References $DB, GetDbConn(), and GetTables().

Referenced by Save().


Member Data Documentation

TranslationString::$LastSeen [private]

The date and time when this string was last updated.

Definition at line 36 of file TranslationString.php.

TranslationString::$LocaleID [private]

Language, encoding of this string. Default: HU_hu.utf-8.

Definition at line 33 of file TranslationString.php.

TranslationString::$Matches [private]

Other strings found to be similar, after calling a find!.

Definition at line 39 of file TranslationString.php.

TranslationString::$Original [private]

The original English string.

Definition at line 32 of file TranslationString.php.

TranslationString::$ProjectID [private]

The ID of the project to which this string belogns.

Definition at line 31 of file TranslationString.php.

TranslationString::$RowOrder [private]

The row order index of this string in its project, see SetRowOrder().

Definition at line 37 of file TranslationString.php.

TranslationString::$SentenceID [private]

The ID of this sentence in TranslaitonSentences table.

Definition at line 35 of file TranslationString.php.

TranslationString::$SentenceLengthCache [static]

Cache for strings' lengths: InitSentenceLengtCache()

Definition at line 42 of file TranslationString.php.

Referenced by FindSentenceIndex(), InitSentenceLengthCache(), and Save().

TranslationString::$StringID [private]

ID of this string in TranslationStrings table.

Definition at line 30 of file TranslationString.php.

TranslationString::$Translation [private]

The tranlsation of $Original to $LocaleID.

Definition at line 34 of file TranslationString.php.

TranslationString::$Words [private]

Contains the ($Original) words of this string

Definition at line 40 of file TranslationString.php.

TranslationString::$WordSentencesCache [static]

LATER Cache for "word in which sentences": InitWordSentencesCache()

Definition at line 43 of file TranslationString.php.

Referenced by InitWordSentencesCache().


The documentation for this class was generated from the following file:
Generated on Tue Mar 20 00:42:40 2007 for XarayaTranslationMemory by  doxygen 1.4.7