public static function getDirtyConfigChunks() { // return the set of chunk IDs, which are the chunks that contain // lids that are in need of some translation. These IDs are calculated // as the segment ID of the first segment in the chunk, divided by // the configured chunk size. So, segments 1 through [chunk size] would // be in chunk #1, etc. $lids = self::getDirtyChunkLids(); $chunk_ids = array(); foreach ($lids as $lid) { $id = LingotekConfigChunk::getIdBySegment($lid); if (array_key_exists($id, $chunk_ids)) { $chunk_ids[$id]++; } else { $chunk_ids[$id] = 1; } } $chunk_ids = self::pruneChunksWithPendingTranslations($chunk_ids); return $chunk_ids; }
/** * Factory method for getting a loaded LingotekConfigChunk object. * * @param int $chunk_id * A Drupal config chunk ID. * * @return mixed * A loaded LingotekConfigChunk object if found, FALSE if the chunk could not be loaded. */ public static function loadById($chunk_id) { $chunk = FALSE; // get any segments that should be associated with this chunk // if segments exist, return a LingotekConfigChunk instance // otherwise, return FALSE $chunk_segments = self::getAllSegments($chunk_id); if ($chunk_segments) { $chunk = new LingotekConfigChunk($chunk_id); $chunk->setApi(LingotekApi::instance()); } return $chunk; }
/** * Updates the content of an existing Lingotek document with the current object contents. * * @param stdClass $translatable_object * A Drupal node object or another object, such as a config chunk, etc. * * @return bool * TRUE on success, FALSE on failure. */ public function updateContentDocument($translatable_object) { $parameters['documentId'] = $translatable_object->getMetadataValue('document_id'); $parameters['documentName'] = $translatable_object->getDocumentName(); $parameters['documentDesc'] = $translatable_object->getDescription(); $parameters['content'] = $translatable_object->documentLingotekXML(); $parameters['url'] = $translatable_object->getUrl(); $parameters['format'] = $this->xmlFormat(); $this->addAdvancedParameters($parameters, $translatable_object); $result = $this->request('updateContentDocumentAsync', $parameters); if ($result) { if (get_class($translatable_object) == 'LingotekConfigChunk') { $translatable_object->setStatus(LingotekSync::STATUS_CURRENT); $translatable_object->setTargetsStatus(LingotekSync::STATUS_PENDING); // WTD: there is a race condition here where a user could modify a locales- // source entry between the time the dirty segments are pulled and the time // they are set to current at this point. This same race condition exists // for nodes as well; however, the odds may be lower due to number of entries. LingotekConfigChunk::setSegmentStatusToCurrentById($translatable_object->getId()); } } return $result ? TRUE : FALSE; }