XarayaTranslationMemory  1.6
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
TranslationProject Class Reference

Public Member Functions

 __construct ($loadByID=0, $brief=false)
 
 CreateRootProject ($name, $localeID)
 
 CreateProject ($rootID, $parentID, $name, $isFolder, $localeID, $document='', $skeleton='')
 
 Save ()
 
 LoadRoot ($name, $localeID)
 
 Load ($parentID, $name, $localeID, $brief)
 
 LoadFromRecordSet ($recordSet, $brief)
 
 LoadByID ($projectID, $brief)
 
 DestroyData ()
 
 SetName ($name)
 
 SetSkeleton ($skeleton)
 
 SetDocument ($document)
 
 GetName ()
 
 GetID ()
 
 GetRootID ()
 
 GetParentID ()
 
 GetIsFolder ()
 
 GetLocaleID ()
 
 GetSkeleton ()
 
 GetDocument ()
 
 GetLastSeen ()
 

Static Public Member Functions

static InitLocaleIDCache ()
 
static GetRoots ($localeID)
 

Static Public Attributes

static $LocaleIDCache
 

Private Member Functions

 Clear ()
 
 CheckNameCollision ()
 
 LoadRecordSetEntry ($rs)
 

Private Attributes

 $ProjectID
 
 $ParentID
 
 $RootID
 
 $Name
 
 $IsFolder
 
 $LocaleID
 
 $Skeleton
 
 $Document
 
 $LastSeen
 
 $Brief
 

Detailed Description

This class can handle projects. A project is either a file which contains some translatable strings, or an empty project which does not have actual strings, just subprojects only.

A project(file) has an original document, a skeleton which contains ###33### type references to TranslationString objects. The translated document can be created from the Project's Skeleton and the Strings referenced by the ## IDs. ***** A 'PROJECT' IS ONE FILE IN XARAYA TERMS *****

Definition at line 31 of file TranslationProject.php.

Constructor & Destructor Documentation

◆ __construct()

TranslationProject::__construct (   $loadByID = 0,
  $brief = false 
)

Initialize a new project handler.

Parameters
$loadByIDInteger, a project ID to be loaded. If not specified, empty project handler is made.
$briefIf true, the faster project won't handle Document and Skeleton and Save won't work.

Definition at line 53 of file TranslationProject.php.

References LoadByID().

Member Function Documentation

◆ CheckNameCollision()

TranslationProject::CheckNameCollision ( )
private

Check if there is another Project in the database with the same name, in the same tree branch and the in the same locale (as the current Project properties).

Returns
Bool true if names collide, false if name is free

Definition at line 116 of file TranslationProject.php.

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

Referenced by CreateProject(), and Save().

◆ Clear()

TranslationProject::Clear ( )
private

Reinitalize - clear all internal data of - this Project.

Definition at line 105 of file TranslationProject.php.

Referenced by CreateProject().

◆ CreateProject()

TranslationProject::CreateProject (   $rootID,
  $parentID,
  $name,
  $isFolder,
  $localeID,
  $document = '',
  $skeleton = '' 
)

Initialize this object as a new (sub)project in a root or any other project.

These projects may or may not store the real textural content for the project's translation. If you want to store the project in the database, you must call ->Save() too. Until saving, the project won't have a Project ID!

Parameters
$parentIDIn which project to create this project as child.
$nameName of the project to be created.
$isFolderTrue if the project is a folder (no document, container for more projects)
$localeIDLocale ID of this project.
$documentThe original content of the document to be translated.
$skeletonThe document which contains IDs in place of each translation string from origdoc.
Exceptions:
'Exception' thrown if a project with same name exists in the same location.

Definition at line 165 of file TranslationProject.php.

References CheckNameCollision(), and Clear().

Referenced by CreateRootProject().

◆ CreateRootProject()

TranslationProject::CreateRootProject (   $name,
  $localeID 
)

Create a new Project into the current object instance, which has 0 as parent ID.

Root projects cannot have actual strings content, just a placeholder for all its subprojects

Parameters
$nameName of the project to be created.
$localeIDLocale ID of this project.
Returns
The ID of the newly created project, false if a root project wiht $name already exists.

Definition at line 144 of file TranslationProject.php.

References CreateProject().

◆ DestroyData()

TranslationProject::DestroyData ( )

Removes the current project from the database.

Throws exception if the project has child projects or contains strings.

Definition at line 403 of file TranslationProject.php.

References $DB, ProjectIterator\ClearCache(), GetDbConn(), and GetTables().

◆ GetDocument()

TranslationProject::GetDocument ( )

Get the original document of this project

Returns
string Original document of this project.

Definition at line 571 of file TranslationProject.php.

References $Document.

◆ GetID()

TranslationProject::GetID ( )

Get the ID of this project. 0 if project is not yet in the database.

Returns
int ID of this project.

Definition at line 487 of file TranslationProject.php.

References $ProjectID.

Referenced by TranslationExportXaraya\CheckCodeFiles(), TranslationExportXaraya\ExportProject(), TranslationImportXaraya\ImportFile(), and TranslationImportXaraya\ProcessDir().

◆ GetIsFolder()

TranslationProject::GetIsFolder ( )

Cheks if the project is a folder (container for projects, has no translation document).

Returns
string Returns true if this project is a folder.

Definition at line 529 of file TranslationProject.php.

References $IsFolder.

◆ GetLastSeen()

TranslationProject::GetLastSeen ( )

Get the last seen (last update) timestamp of this project

Usually projects older than the root project of a tree can be considered as dead projects (removed from the project, becuase they were not updated by the last import).

Returns
timestamp The last update time of this project.

Definition at line 587 of file TranslationProject.php.

References $LastSeen.

◆ GetLocaleID()

TranslationProject::GetLocaleID ( )

Get the locale ID of this project. 0 if project is not yet in the database.

Returns
int ID of this project.

Definition at line 543 of file TranslationProject.php.

References $LocaleID.

Referenced by TranslationExportXaraya\CheckCodeFiles(), TranslationImportXaraya\ImportFile(), and TranslationImportXaraya\ProcessDir().

◆ GetName()

TranslationProject::GetName ( )

Get the name of this Project

Returns
string Name of this project.

Definition at line 473 of file TranslationProject.php.

References $Name.

Referenced by TranslationExportXaraya\CheckCodeFiles().

◆ GetParentID()

TranslationProject::GetParentID ( )

Get the Parent ID of this project.

Returns
int Parent ID of this project.

Definition at line 515 of file TranslationProject.php.

References $ParentID.

◆ GetRootID()

TranslationProject::GetRootID ( )

Get the Root project's ID containing this project.

Returns
int Root ID of this project.

Definition at line 501 of file TranslationProject.php.

References $RootID.

Referenced by TranslationImportXaraya\ProcessDir().

◆ GetRoots()

static TranslationProject::GetRoots (   $localeID)
static

Load array of all root projects of the given locale.

Returns
Array Hastable with Project ID as index and TranslationProject objects as data.

Definition at line 85 of file TranslationProject.php.

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

Referenced by TranslationBackend\__construct().

◆ GetSkeleton()

TranslationProject::GetSkeleton ( )

Get the skeleton of this project

Returns
string Skeleton of this project.

Definition at line 557 of file TranslationProject.php.

References $Skeleton.

Referenced by TranslationExportXaraya\ExportProject().

◆ InitLocaleIDCache()

static TranslationProject::InitLocaleIDCache ( )
static

Initialize the static locale ID cache, by loading locales from the database.

You can access the locale IDs in TraslationProject::$LocaleIDCache[localename] = id format.

Definition at line 67 of file TranslationProject.php.

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

Referenced by CacheIndexes().

◆ Load()

TranslationProject::Load (   $parentID,
  $name,
  $localeID,
  $brief 
)

Load a Project by name.

Parameters
$parentIDIn which parent project.
$nameWhich project to look for.
$localeIDWhich locale version to find.
Returns
True on success, false otherwise.

Definition at line 262 of file TranslationProject.php.

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

Referenced by LoadRoot().

◆ LoadByID()

TranslationProject::LoadByID (   $projectID,
  $brief 
)

Load a project by ID.

Parameters
$projectIDWhich project to load.
Returns
True on success, false otherwise.

Definition at line 315 of file TranslationProject.php.

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

Referenced by __construct().

◆ LoadFromRecordSet()

TranslationProject::LoadFromRecordSet (   $recordSet,
  $brief 
)

Load the next Project from an existing ADODB recordset.

The query running in the recordset must return the same columns as the query in this class' ->Load() method. Useful for loading a lot of project at once.

Parameters
$recordSetExisting ADODB recordset running a project list query.
Returns
True on success, false otherwise.

Definition at line 302 of file TranslationProject.php.

References LoadRecordSetEntry().

◆ LoadRecordSetEntry()

TranslationProject::LoadRecordSetEntry (   $rs)
private

Load a Project's details using an exisitng record set.

Called by public Load() methods.

Parameters
$rsThe recordset running the specified query and providing data for the project.
Returns
True on success, false otherwise (no more rows).

Definition at line 351 of file TranslationProject.php.

Referenced by Load(), LoadByID(), and LoadFromRecordSet().

◆ LoadRoot()

TranslationProject::LoadRoot (   $name,
  $localeID 
)

Load a root Project with the given name (which has parent ID 0).

Parameters
$nameWhich root project to look for.
$localeIDLocale ID of the requested project.
Returns
True on success, false otherwise.

Definition at line 248 of file TranslationProject.php.

References Load().

◆ Save()

TranslationProject::Save ( )

Save the current Project in the database (insert or update).

The project may have empty skeleton and original document, as a placeholder project. But name, parentid and LocaleID are mandatory to be set.

Returns
The ID of the created project.

Definition at line 194 of file TranslationProject.php.

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

Referenced by TranslationImportXaraya\ImportFile().

◆ SetDocument()

TranslationProject::SetDocument (   $document)

Set the original Document of this Project (usually the language file's original content).

To apply changes, you must ->Save() into the database.

Parameters
$documentString Original document of the project.

Definition at line 460 of file TranslationProject.php.

Referenced by TranslationImportXaraya\ImportFile().

◆ SetName()

TranslationProject::SetName (   $name)

Set the name of this Project

To apply changes, you must ->Save() into the database.

Parameters
$nameString New name for this project.

Definition at line 433 of file TranslationProject.php.

◆ SetSkeleton()

TranslationProject::SetSkeleton (   $skeleton)

Set the Skeleton of this Project (usually the language file's contents, with replaceable variables for translated strings)

To apply changes, you must ->Save() into the database.

Parameters
$skeletonString Skeleton document for this project.

Definition at line 449 of file TranslationProject.php.

Referenced by TranslationImportXaraya\ImportFile().

Member Data Documentation

◆ $Brief

TranslationProject::$Brief
private

The project did not load Document and Skeleton for performance. Save not possible

Definition at line 42 of file TranslationProject.php.

◆ $Document

TranslationProject::$Document
private

The original untranslated, unchanged file of this project

Definition at line 40 of file TranslationProject.php.

Referenced by GetDocument().

◆ $IsFolder

TranslationProject::$IsFolder
private

True if the project it no a translatable document, just a folder or directory

Definition at line 37 of file TranslationProject.php.

Referenced by GetIsFolder().

◆ $LastSeen

TranslationProject::$LastSeen
private

The date and time (UNIX timestamp) when this project was last updated.

Definition at line 41 of file TranslationProject.php.

Referenced by GetLastSeen().

◆ $LocaleID

TranslationProject::$LocaleID
private

Project locale ID

Definition at line 38 of file TranslationProject.php.

Referenced by GetLocaleID().

◆ $LocaleIDCache

TranslationProject::$LocaleIDCache
static

Static hash table caching the locale names(key) and IDs(value)

Definition at line 44 of file TranslationProject.php.

Referenced by TranslationBackend\__construct(), WebBackend\Event_ExportPack(), TranslationExportXaraya\Export(), TranslationImportXaraya\Import(), and InitLocaleIDCache().

◆ $Name

TranslationProject::$Name
private

Project name

Definition at line 36 of file TranslationProject.php.

Referenced by GetName().

◆ $ParentID

TranslationProject::$ParentID
private

Project's parent project id

Definition at line 34 of file TranslationProject.php.

Referenced by GetParentID().

◆ $ProjectID

TranslationProject::$ProjectID
private

Project's ID if loaded

Definition at line 33 of file TranslationProject.php.

Referenced by GetID(), and Save().

◆ $RootID

TranslationProject::$RootID
private

Root element containing this project - redundant database data but fast

Definition at line 35 of file TranslationProject.php.

Referenced by GetRootID().

◆ $Skeleton

TranslationProject::$Skeleton
private

Project's original file with placeholders for the translatable strings

Definition at line 39 of file TranslationProject.php.

Referenced by GetSkeleton().


The documentation for this class was generated from the following file: