Ejemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     $filterArgs = array('job' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'segment' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'jpassword' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW), 'err_typing' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'err_translation' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'err_terminology' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'err_language' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'err_style' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'original' => array('filter' => FILTER_UNSAFE_RAW));
     $postInput = filter_input_array(INPUT_POST, $filterArgs);
     $this->id_job = $postInput['job'];
     $this->password_job = $postInput['jpassword'];
     $this->id_segment = $postInput['segment'];
     $this->err_typing = $postInput['err_typing'];
     $this->err_translation = $postInput['err_translation'];
     $this->err_terminology = $postInput['err_terminology'];
     $this->err_language = $postInput['err_language'];
     $this->err_style = $postInput['err_style'];
     list($this->original_translation, $none) = CatUtils::parseSegmentSplit(CatUtils::view2rawxliff($postInput['original']), ' ');
     Log::doLog($_POST);
     if (empty($this->id_job)) {
         $this->result['errors'][] = array('code' => -1, 'message' => 'Job ID missing');
     }
     if (empty($this->id_segment)) {
         $this->result['errors'][] = array('code' => -2, 'message' => 'Segment ID missing');
     }
     if (empty($this->password_job)) {
         $this->result['errors'][] = array('code' => -3, 'message' => 'Job password missing');
     }
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     $filterArgs = array('id_job' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'password' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), 'propagate' => array('filter' => FILTER_VALIDATE_BOOLEAN, 'flags' => FILTER_NULL_ON_FAILURE), 'id_segment' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'time_to_edit' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'id_translator' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), 'translation' => array('filter' => FILTER_UNSAFE_RAW), 'version' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'chosen_suggestion_index' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'status' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), 'splitStatuses' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH));
     $this->__postInput = filter_input_array(INPUT_POST, $filterArgs);
     $this->id_job = $this->__postInput['id_job'];
     $this->password = $this->__postInput['password'];
     $this->propagate = $this->__postInput['propagate'];
     //not used here but used in child class setAutoPropagationController
     $this->id_segment = $this->__postInput['id_segment'];
     $this->time_to_edit = (int) $this->__postInput['time_to_edit'];
     //cast to int, so the default is 0
     $this->id_translator = $this->__postInput['id_translator'];
     $this->client_target_version = empty($this->__postInput['version']) ? '0' : $this->__postInput['version'];
     list($this->translation, $this->split_chunk_lengths) = CatUtils::parseSegmentSplit(CatUtils::view2rawxliff($this->__postInput['translation']), ' ');
     $this->chosen_suggestion_index = $this->__postInput['chosen_suggestion_index'];
     $this->status = strtoupper($this->__postInput['status']);
     $this->split_statuses = explode(",", strtoupper($this->__postInput['splitStatuses']));
     //strtoupper transforms null to ""
     //PATCH TO FIX BOM INSERTIONS
     $this->translation = str_replace("", '', $this->translation);
     if (is_null($this->propagate) || !isset($this->propagate)) {
         $this->propagate = true;
     }
     Log::doLog($this->__postInput);
 }
 public function doAction()
 {
     if (!empty($this->result['errors'])) {
         return;
     }
     //save the 2 arrays in the DB
     $translationStruct = TranslationsSplit_SplitStruct::getStruct();
     $translationStruct->id_segment = $this->id_segment;
     $translationStruct->id_job = $this->id_job;
     list($this->segment, $translationStruct->source_chunk_lengths) = CatUtils::parseSegmentSplit(CatUtils::view2rawxliff($this->segment));
     /* Fill the statuses with DEFAULT DRAFT VALUES */
     $pieces = count($translationStruct->source_chunk_lengths) > 1 ? count($translationStruct->source_chunk_lengths) - 1 : 1;
     $translationStruct->target_chunk_lengths = array('len' => array(0), 'statuses' => array_fill(0, $pieces, Constants_TranslationStatus::STATUS_DRAFT));
     $translationDao = new TranslationsSplit_SplitDAO(Database::obtain());
     $result = $translationDao->update($translationStruct);
     if ($result instanceof TranslationsSplit_SplitStruct) {
         //return success
         $this->result['data'] = 'OK';
     } else {
         Log::doLog("Failed while splitting/merging segment.");
         Log::doLog($translationStruct);
     }
 }