first commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class WPML_Editor_UI_Field_Group extends WPML_Editor_UI_Fields {
|
||||
|
||||
private $title;
|
||||
private $divider;
|
||||
|
||||
function __construct( $title = '', $divider = true ) {
|
||||
$this->title = $title;
|
||||
$this->divider = $divider;
|
||||
|
||||
}
|
||||
|
||||
public function get_layout() {
|
||||
$data = array(
|
||||
'title' => $this->title,
|
||||
'divider' => $this->divider,
|
||||
'field_type' => 'tm-group',
|
||||
);
|
||||
|
||||
$data['fields'] = parent::get_layout();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
class WPML_Editor_UI_Field_Image extends WPML_Editor_UI_Fields {
|
||||
|
||||
private $image_id;
|
||||
private $divider;
|
||||
private $group;
|
||||
|
||||
function __construct( $id, $image_id, $data, $divider = true ) {
|
||||
|
||||
$this->image_id = $image_id;
|
||||
$this->divider = $divider;
|
||||
$this->group = new WPML_Editor_UI_Field_Group( '', false );
|
||||
|
||||
$this->group->add_field( new WPML_Editor_UI_Single_Line_Field( $id . '-title', __( 'Title', 'wpml-translation-management' ), $data, false ) );
|
||||
$this->group->add_field( new WPML_Editor_UI_Single_Line_Field( $id . '-caption', __('Caption', 'wpml-translation-management' ), $data, false ) );
|
||||
$this->group->add_field( new WPML_Editor_UI_Single_Line_Field( $id . '-alt-text', __('Alt Text', 'wpml-translation-management' ), $data, false ) );
|
||||
$this->group->add_field( new WPML_Editor_UI_Single_Line_Field( $id . '-description', __('Description', 'wpml-translation-management' ), $data, false ) );
|
||||
|
||||
$this->add_field( $this->group );
|
||||
}
|
||||
|
||||
public function get_layout() {
|
||||
$image = wp_get_attachment_image_src( $this->image_id, array( 100, 100 ) );
|
||||
$data = array(
|
||||
'field_type' => 'wcml-image',
|
||||
'divider' => $this->divider,
|
||||
'image_src' => isset( $image[0] ) ? $image[0] : '',
|
||||
);
|
||||
|
||||
$data['fields'] = parent::get_layout();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
class WPML_Editor_UI_Field_Section extends WPML_Editor_UI_Fields {
|
||||
|
||||
private $title;
|
||||
private $sub_title;
|
||||
|
||||
function __construct( $title = '', $sub_title = '' ) {
|
||||
$this->title = $title;
|
||||
$this->sub_title = $sub_title;
|
||||
}
|
||||
|
||||
public function get_layout() {
|
||||
$data = array(
|
||||
'empty_message' => '',
|
||||
'empty' => false,
|
||||
'title' => $this->title,
|
||||
'sub_title' => $this->sub_title,
|
||||
'field_type' => 'tm-section',
|
||||
);
|
||||
|
||||
$data['fields'] = parent::get_layout();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class WPML_Editor_UI_Field {
|
||||
|
||||
protected $id;
|
||||
protected $title;
|
||||
protected $original;
|
||||
protected $translation;
|
||||
private $requires_complete;
|
||||
protected $is_complete;
|
||||
|
||||
function __construct( $id, $title, $data, $requires_complete = false ) {
|
||||
|
||||
$this->id = $id;
|
||||
$this->title = $title ? $title : '';
|
||||
$this->original = $data[ $id ]['original'];
|
||||
$this->translation = isset( $data[ $id ]['translation'] ) ? $data[ $id ]['translation'] : '';
|
||||
$this->requires_complete = $requires_complete;
|
||||
$this->is_complete = isset( $data[ $id ]['is_complete'] ) ? $data[ $id ]['is_complete'] : false;
|
||||
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$field = array();
|
||||
$field['field_type'] = $this->id;
|
||||
$field['field_data'] = $this->original;
|
||||
$field['field_data_translated'] = $this->translation;
|
||||
$field['title'] = $this->title;
|
||||
$field['field_finished'] = $this->is_complete ? '1' : '0';
|
||||
$field['tid'] = '0';
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
public function get_layout() {
|
||||
// This is a field with no sub fields so just return the id
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WPML_Editor_UI_Fields {
|
||||
|
||||
private $fields = array();
|
||||
|
||||
public function add_field( $field ) {
|
||||
$this->fields[] = $field;
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$fields = array();
|
||||
/** @var WPML_Editor_UI_Field $field */
|
||||
foreach ( $this->fields as $field ) {
|
||||
$child_fields = $field->get_fields();
|
||||
foreach ( $child_fields as $child_field ) {
|
||||
$fields[] = $child_field;
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function get_layout() {
|
||||
$layout = array();
|
||||
/** @var WPML_Editor_UI_Field $field */
|
||||
foreach ( $this->fields as $field ) {
|
||||
$layout[] = $field->get_layout();
|
||||
}
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
class WPML_Editor_UI_Single_Line_Field extends WPML_Editor_UI_Field {
|
||||
|
||||
private $include_copy_button;
|
||||
|
||||
function __construct( $id, $title, $data, $include_copy_button, $requires_complete = false ) {
|
||||
parent::__construct( $id, $title, $data, $requires_complete );
|
||||
|
||||
$this->include_copy_button = $include_copy_button;
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$field = parent::get_fields();
|
||||
$field['field_style'] = '0';
|
||||
|
||||
return array( $field );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
class WPML_Editor_UI_TextArea_Field extends WPML_Editor_UI_Field {
|
||||
|
||||
private $include_copy_button;
|
||||
|
||||
function __construct( $id, $title, $data, $include_copy_button, $requires_complete = false ) {
|
||||
parent::__construct( $id, $title, $data, $requires_complete );
|
||||
|
||||
$this->include_copy_button = $include_copy_button;
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$field = parent::get_fields();
|
||||
$field['field_style'] = '1';
|
||||
|
||||
return array( $field );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class WPML_Editor_UI_WYSIWYG_Field extends WPML_Editor_UI_Field {
|
||||
|
||||
private $include_copy_button;
|
||||
|
||||
function __construct( $id, $title, $data, $include_copy_button, $requires_complete = false ) {
|
||||
parent::__construct( $id, $title, $data, $requires_complete );
|
||||
|
||||
$this->include_copy_button = $include_copy_button;
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$field = parent::get_fields();
|
||||
$field['field_style'] = '2';
|
||||
|
||||
return array( $field );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user