Document.inc.php in GlobalLink Connect for Drupal 7.7
File
gl_ws/glc/model/Document.inc.php
View source
<?php
class PDDocument {
public $data;
public $name;
public $sourceLanguage;
public $targetLanguages;
public $clientIdentifier;
public $encoding = "UTF-8";
public $fileformat;
public $instructions;
public $metadata;
public function getDocumentInfo($submission) {
$documentInfo = new DocumentInfo();
$documentInfo->projectTicket = $submission->project->ticket;
$documentInfo->name = $this->name;
$documentInfo->sourceLocale = $this->sourceLanguage;
if ($submission->ticket != "") {
$documentInfo->submissionTicket = $submission->ticket;
}
$i = 0;
if (isset($this->metadata)) {
$metadatas = array();
foreach ($this->metadata as $k => $v) {
$metadata = new Metadata();
$metadata->key = substr($k, 0, 255);
$metadata->value = substr($v, 0, 1024);
$metadatas[$i++] = $metadata;
}
$documentInfo->metadata = $metadatas;
}
if (isset($this->clientIdentifier)) {
$documentInfo->clientIdentifier = $this->clientIdentifier;
}
if (isset($this->instructions)) {
$documentInfo->instructions = $this->instructions;
}
else {
$documentInfo->instructions = $submission->instructions;
}
$documentInfo->targetInfos = $this
->getTargetInfos();
return $documentInfo;
}
private function getTargetInfos() {
$targetInfos = array();
foreach ($this->targetLanguages as $language) {
$targetInfo = new TargetInfo();
$targetInfo->targetLocale = $language;
if (isset($submission->dueDate)) {
$targetInfo->requestedDueDate = $submission->dueDate;
}
else {
$targetInfo->requestedDueDate = 0;
}
if (isset($this->encoding)) {
$targetInfo->encoding = $this->encoding;
}
else {
$targetInfo->encoding = "UTF-8";
}
$targetInfos[] = $targetInfo;
}
return $targetInfos;
}
public function getResourceInfo() {
$resourceInfo = new ResourceInfo();
if (isset($this->encoding)) {
$resourceInfo->encoding = $this->encoding;
}
else {
$resourceInfo->encoding = "UTF-8";
}
$resourceInfo->size = strlen($this->data);
$resourceInfo->classifier = $this->fileformat;
$resourceInfo->name = $this->name;
if (isset($this->clientIdentifier)) {
$resourceInfo->clientIdentifier = $this->clientIdentifier;
}
return $resourceInfo;
}
}