| Server IP : 89.108.64.180 / Your IP : 216.73.217.92 Web Server : Apache/2.4.41 (Ubuntu) System : Linux 89-108-64-180.cloudvps.regruhosting.ru 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-root ( 1010) PHP Version : 8.0.30 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/hotel1.agast.ru/wp-content/plugins/loco-translate/src/fs/ |
Upload File : |
<?php
/**
* Manages a POT or PO/MO pair and its on-disk dependants
*/
class Loco_fs_Siblings {
/**
* @var Loco_fs_File
*/
private $po;
/**
* @var Loco_fs_File
*/
private $mo;
public function __construct( Loco_fs_File $file ){
$ext = $file->extension();
if( 'pot' === $ext ){
$this->po = $file;
}
else if( 'po' === $ext ){
$this->po = $file;
$this->mo = $file->cloneExtension('mo');
}
else if( 'mo' === $ext ){
$this->mo = $file;
$this->po = $file->cloneExtension('po');
}
else {
throw new InvalidArgumentException('Unexpected file extension: '.$ext);
}
}
/**
* Get all dependant files (including self) that actually exist on disk
* @return Loco_fs_File[]
*/
public function expand(){
$siblings = array();
// Source and binary pair
foreach( array( $this->po, $this->mo ) as $file ){
if( $file && $file->exists() ){
$siblings[] = $file;
}
}
// Revisions / backup files:
$revs = new Loco_fs_Revisions( $this->po );
foreach( $revs->getPaths() as $path ){
$siblings[] = new Loco_fs_File( $path );
}
// JSON exports, unless in POT mode:
if( 'po' === $this->po->extension() ){
$name = $this->po->filename();
$finder = new Loco_fs_FileFinder( $this->po->dirname() );
$regex = '/^'.preg_quote($name,'/').'-[0-9a-f]{32}$/';
/* @var $file Loco_fs_File */
foreach( $finder->group('json')->exportGroups() as $files ) {
foreach( $files as $file ){
$match = $file->filename();
if( $match === $name || preg_match($regex,$match) ) {
$siblings[] = $file;
}
}
}
}
return $siblings;
}
/**
* @return Loco_fs_File
*/
public function getSource(){
return $this->po;
}
/**
* @return Loco_fs_File
*/
public function getBinary(){
return $this->mo;
}
}