first commit

This commit is contained in:
2023-09-12 21:41:04 +02:00
commit 3361a7f053
13284 changed files with 2116755 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
<?php
class WPML_ST_ICL_String_Translations extends WPML_WPDB_User {
private $table = 'icl_string_translations';
private $string_id = 0;
private $lang_code;
private $id;
/**
* WPML_ST_ICL_String_Translations constructor.
*
* @param wpdb $wpdb
* @param int $string_id
* @param string $lang_code
*/
public function __construct( &$wpdb, $string_id, $lang_code ) {
parent::__construct( $wpdb );
$string_id = (int) $string_id;
if ( $string_id > 0 && $lang_code ) {
$this->string_id = $string_id;
$this->lang_code = $lang_code;
} else {
throw new InvalidArgumentException(
'Invalid String ID: '
. $string_id . ' or language_code: ' . $lang_code
);
}
}
/**
* @return int|string
*/
public function translator_id() {
return $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT translator_id
FROM {$this->wpdb->prefix}{$this->table}
WHERE id = %d LIMIT 1",
$this->id()
)
);
}
/**
* @return string
*/
public function value() {
return $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT value
FROM {$this->wpdb->prefix}{$this->table}
WHERE id = %d LIMIT 1",
$this->id()
)
);
}
/**
* @return int
*/
public function id() {
return (int) ( $this->id
? $this->id
: $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT id
FROM {$this->wpdb->prefix}{$this->table}
WHERE string_id = %d AND language = %s
LIMIT 1",
$this->string_id,
$this->lang_code
)
) );
}
}

View File

@@ -0,0 +1,83 @@
<?php
class WPML_ST_ICL_Strings extends WPML_WPDB_User {
private $table = 'icl_strings';
private $string_id = 0;
/**
* WPML_TM_ICL_Strings constructor.
*
* @param wpdb $wpdb
* @param int $string_id
*/
public function __construct( &$wpdb, $string_id ) {
parent::__construct( $wpdb );
$string_id = (int) $string_id;
if ( $string_id > 0 ) {
$this->string_id = $string_id;
} else {
throw new InvalidArgumentException( 'Invalid String ID: ' . $string_id );
}
}
/**
* @param array $args in the same format used by \wpdb::update()
*
* @return $this
*/
public function update( $args ) {
$this->wpdb->update(
$this->wpdb->prefix . $this->table,
$args,
array( 'id' => $this->string_id )
);
return $this;
}
/**
* @return string
*/
public function value() {
return $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT value
FROM {$this->wpdb->prefix}{$this->table}
WHERE id = %d LIMIT 1",
$this->string_id
)
);
}
/**
* @return string
*/
public function language() {
return $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT language
FROM {$this->wpdb->prefix}{$this->table}
WHERE id = %d LIMIT 1",
$this->string_id
)
);
}
/**
* @return int
*/
public function status() {
return (int) $this->wpdb->get_var(
$this->wpdb->prepare(
" SELECT status
FROM {$this->wpdb->prefix}{$this->table}
WHERE id = %d LIMIT 1",
$this->string_id
)
);
}
}

View File

@@ -0,0 +1,40 @@
<?php
class WPML_ST_Records {
/** @var wpdb $wpdb */
public $wpdb;
/**
* @param wpdb $wpdb
*/
public function __construct( wpdb $wpdb ) {
$this->wpdb = $wpdb;
}
/** @retur wpdb */
public function get_wpdb() {
return $this->wpdb;
}
/**
* @param int $string_id
*
* @return WPML_ST_ICL_Strings
*/
public function icl_strings_by_string_id( $string_id ) {
return new WPML_ST_ICL_Strings( $this->wpdb, $string_id );
}
/**
* @param int $string_id
* @param string $language_code
*
* @return WPML_ST_ICL_String_Translations
*/
public function icl_string_translations_by_string_id_and_language( $string_id, $language_code ) {
return new WPML_ST_ICL_String_Translations( $this->wpdb, $string_id, $language_code );
}
}