Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
riccio82 committed Oct 15, 2018
2 parents 303f17b + fab04d1 commit f3872cb
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
81 changes: 80 additions & 1 deletion lib/Features/Microsoft.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Features\Microsoft\View\API\JSON\MicrosoftUrlsDecorator;
use Features\Microsoft\Model\Analysis\CustomPayableRates;
use Features\Microsoft\Utils\Constants\Revise;
use Features\Outsource\Constants\ServiceTypes;
use Features\Traits\PhManagementTagTrait;
use Features\Traits\XliffConversionTrait;
use Klein\Klein;
use Features;
use \Features\Outsource\Traits\Translated as TranslatedTrait;
Expand All @@ -39,6 +39,11 @@ public static function loadRoutes( Klein $klein ) {
route( '/job/[:id_job]/[:password]/hts', 'GET', 'Features\Microsoft\Controller\TranslatedConnectorController', 'sendJob' );
}

/**
* @param ProjectUrls $formatted
*
* @return MicrosoftUrlsDecorator|\Features\ReviewExtended\View\API\JSON\ProjectUrlsDecorator
*/
public static function projectUrls( ProjectUrls $formatted ) {
$projectUrlsDecorator = new MicrosoftUrlsDecorator( $formatted->getData());

Expand All @@ -59,6 +64,80 @@ public function afterTMAnalysisCloseProject( $project_id , $_analyzed_report) {
$this->requestProjectQuote( $projectStruct, $_analyzed_report );
}

/**
* @param \Jobs_JobStruct $job
* @param $eq_word
* @param \Projects_ProjectStruct $project
*
* @return string
*/
protected function prepareQuoteUrl( \Jobs_JobStruct $job, $eq_word, \Projects_ProjectStruct $project ){

if( $project->id_customer == $this->config[ 'microsoft_user1' ] ){
$hts_user = $this->config[ 'translated_username_pilot1' ];
$hts_pass = $this->config[ 'translated_password_pilot1' ];
} elseif( $project->id_customer == $this->config[ 'microsoft_user2' ] ) {
$hts_user = $this->config[ 'translated_username_pilot2' ];
$hts_pass = $this->config[ 'translated_password_pilot2' ];
} else {
$hts_user = 'microsoftdemo';
$hts_pass = 'microsoftdemo';
}

return "http://www.translated.net/hts/index.php?" . http_build_query( [
'f' => 'quote',
'cid' => $hts_user,
'p' => $hts_pass,
's' => $job->source,
't' => $job->target,
'pn' => $project->name,
'w' => $eq_word,
'df' => 'matecat',
'matecat_pid' => $project->id,
'matecat_ppass' => $project->password,
'matecat_pname' => $project->name,
'subject' => $job->subject,
'jt' => ServiceTypes::SERVICE_TYPE_PROFESSIONAL,
'fd' => 0,
'of' => 'json',
'matecat_raw' => $job->total_raw_wc
], PHP_QUERY_RFC3986 );

}

/**
* @param $urls
* @param \Projects_ProjectStruct $project
*
* @return string
*/
protected function prepareConfirmUrl( $urls, \Projects_ProjectStruct $project ){

if( $project->id_customer == $this->config[ 'microsoft_user1' ] ){
$hts_user = $this->config[ 'translated_username_pilot1' ];
$hts_pass = $this->config[ 'translated_password_pilot1' ];
} elseif( $project->id_customer == $this->config[ 'microsoft_user2' ] ) {
$hts_user = $this->config[ 'translated_username_pilot2' ];
$hts_pass = $this->config[ 'translated_password_pilot2' ];
} else {
$hts_user = 'microsoftdemo';
$hts_pass = 'microsoftdemo';
}

return "http://www.translated.net/hts/index.php?" . http_build_query( [
'f' => 'confirm',
'cid' => $hts_user,
'p' => $hts_pass,
'pid' => $this->external_project_id,
'c' => 1,
'of' => "json",
'urls' => json_encode( $urls ),
'append_to_pid' => ( !empty( $this->external_parent_project_id ) ? $this->external_parent_project_id : null ),
'matecat_host' => parse_url( \INIT::$HTTPHOST, PHP_URL_HOST )
], PHP_QUERY_RFC3986 );

}

/**
* @see \ProjectManager::_insertPreTranslations()
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
namespace Features\Microsoft\View\API\JSON;


use \Features\ReviewExtended\View\API\JSON\ProjectUrlsDecorator as UrlDecorator;
use \Features\ReviewExtended\View\API\JSON\ProjectUrlsDecorator;
use LQA\ChunkReviewDao;


class MicrosoftUrlsDecorator extends UrlDecorator {
class MicrosoftUrlsDecorator extends ProjectUrlsDecorator {

public function reviseUrl( $record ) {

Expand Down

0 comments on commit f3872cb

Please sign in to comment.