first commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_AJAX_Feedback_Edit_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_AJAX_Feedback_Edit_Hooks_Factory extends WPML_AJAX_Base_Factory implements IWPML_Backend_Action_Loader {
|
||||
|
||||
const AJAX_ACTION = 'wpml-tf-backend-feedback-edit';
|
||||
|
||||
public function create() {
|
||||
$hooks = null;
|
||||
|
||||
if ( $this->is_valid_action( self::AJAX_ACTION ) ) {
|
||||
$feedback_storage = new WPML_TF_Data_Object_Storage( new WPML_TF_Feedback_Post_Convert() );
|
||||
$message_storage = new WPML_TF_Data_Object_Storage( new WPML_TF_Message_Post_Convert() );
|
||||
|
||||
$feedback_query = new WPML_TF_Feedback_Query(
|
||||
$feedback_storage,
|
||||
$message_storage,
|
||||
new WPML_TF_Collection_Filter_Factory()
|
||||
);
|
||||
|
||||
$feedback_edit = new WPML_TF_Feedback_Edit(
|
||||
$feedback_query,
|
||||
$feedback_storage,
|
||||
$message_storage,
|
||||
class_exists( 'WPML_TP_Client_Factory' ) ? new WPML_TP_Client_Factory() : null
|
||||
);
|
||||
|
||||
$template_loader = new WPML_Twig_Template_Loader(
|
||||
array( WPML_PLUGIN_PATH . WPML_TF_Backend_Feedback_Row_View::TEMPLATE_FOLDER )
|
||||
);
|
||||
$row_view = new WPML_TF_Backend_Feedback_Row_View( $template_loader->get_template() );
|
||||
|
||||
$hooks = new WPML_TF_Backend_AJAX_Feedback_Edit_Hooks(
|
||||
$feedback_edit,
|
||||
$row_view,
|
||||
$_POST
|
||||
);
|
||||
}
|
||||
|
||||
return $hooks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_Hooks_Factory implements IWPML_Backend_Action_Loader {
|
||||
|
||||
/**
|
||||
* @return WPML_TF_Backend_Hooks
|
||||
*/
|
||||
public function create() {
|
||||
/** @var wpdb $wpdb */
|
||||
global $wpdb;
|
||||
|
||||
return new WPML_TF_Backend_Hooks(
|
||||
new WPML_TF_Backend_Bulk_Actions_Factory(),
|
||||
new WPML_TF_Backend_Feedback_List_View_Factory(),
|
||||
new WPML_TF_Backend_Styles(),
|
||||
new WPML_TF_Backend_Scripts(),
|
||||
$wpdb
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_Options_AJAX_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_Options_AJAX_Hooks_Factory extends WPML_AJAX_Base_Factory implements IWPML_Backend_Action_Loader {
|
||||
|
||||
const AJAX_ACTION = 'wpml-tf-backend-options';
|
||||
|
||||
/**
|
||||
* @return IWPML_Action|null
|
||||
*/
|
||||
public function create() {
|
||||
global $sitepress;
|
||||
|
||||
$hooks = null;
|
||||
|
||||
if ( $this->is_valid_action( self::AJAX_ACTION ) ) {
|
||||
$settings_read = new WPML_TF_Settings_Read();
|
||||
/** @var WPML_TF_Settings $tf_settings */
|
||||
$tf_settings = $settings_read->get( 'WPML_TF_Settings' );
|
||||
|
||||
$hooks = new WPML_TF_Backend_Options_AJAX_Hooks(
|
||||
$tf_settings,
|
||||
new WPML_TF_Settings_Write(),
|
||||
new WPML_TF_Promote_Notices( $sitepress ),
|
||||
$_POST
|
||||
);
|
||||
}
|
||||
|
||||
return $hooks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_Options_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_Options_Hooks_Factory extends WPML_Current_Screen_Loader_Factory {
|
||||
|
||||
/** @return string */
|
||||
protected function get_screen_regex() {
|
||||
return '#' . WPML_PLUGIN_FOLDER . '/menu/languages#';
|
||||
}
|
||||
|
||||
/** @return null|WPML_TF_Backend_Options_Hooks */
|
||||
protected function create_hooks() {
|
||||
/** @var SitePress $sitepress */
|
||||
global $sitepress;
|
||||
|
||||
if ( $sitepress->is_setup_complete() ) {
|
||||
$template_loader = new WPML_Twig_Template_Loader(
|
||||
array( WPML_PLUGIN_PATH . WPML_TF_Backend_Options_View::TEMPLATE_FOLDER )
|
||||
);
|
||||
|
||||
$settings_read = new WPML_TF_Settings_Read();
|
||||
/** @var WPML_TF_Settings $tf_settings */
|
||||
$tf_settings = $settings_read->get( 'WPML_TF_Settings' );
|
||||
|
||||
$options_view = new WPML_TF_Backend_Options_View(
|
||||
$template_loader->get_template(),
|
||||
$tf_settings,
|
||||
$sitepress
|
||||
);
|
||||
|
||||
$translation_service = new WPML_TF_Translation_Service(
|
||||
class_exists( 'WPML_TP_Client_Factory' ) ? new WPML_TP_Client_Factory() : null
|
||||
);
|
||||
|
||||
return new WPML_TF_Backend_Options_Hooks(
|
||||
$options_view,
|
||||
new WPML_TF_Backend_Options_Scripts(),
|
||||
new WPML_TF_Backend_Options_Styles(),
|
||||
$translation_service
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_Post_List_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_Post_List_Hooks_Factory extends WPML_Current_Screen_Loader_Factory {
|
||||
|
||||
/** @return string */
|
||||
protected function get_screen_regex() {
|
||||
return '/^edit$/';
|
||||
}
|
||||
|
||||
/** @return WPML_TF_Backend_Post_List_Hooks */
|
||||
protected function create_hooks() {
|
||||
global $wpdb, $sitepress;
|
||||
|
||||
$post_rating_metrics = new WPML_TF_Post_Rating_Metrics( $wpdb );
|
||||
$document_information = new WPML_TF_Document_Information( $sitepress );
|
||||
$backend_styles = new WPML_TF_Backend_Styles();
|
||||
|
||||
return new WPML_TF_Backend_Post_List_Hooks( $post_rating_metrics, $document_information, $backend_styles );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_Promote_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_Promote_Hooks_Factory implements IWPML_Backend_Action_Loader, IWPML_Deferred_Action_Loader {
|
||||
|
||||
/** @return string */
|
||||
public function get_load_action() {
|
||||
return 'wpml_after_tm_loaded';
|
||||
}
|
||||
|
||||
public function create() {
|
||||
/** @var SitePress $sitepress */
|
||||
global $sitepress;
|
||||
|
||||
$hooks = null;
|
||||
|
||||
$settings_read = new WPML_TF_Settings_Read();
|
||||
/** @var WPML_TF_Settings $tf_settings */
|
||||
$tf_settings = $settings_read->get( 'WPML_TF_Settings' );
|
||||
|
||||
if ( ! $tf_settings->is_enabled() ) {
|
||||
$setup_complete = $sitepress->is_setup_complete();
|
||||
|
||||
$translation_service = new WPML_TF_Translation_Service(
|
||||
class_exists( 'WPML_TP_Client_Factory' ) ? new WPML_TP_Client_Factory() : null
|
||||
);
|
||||
|
||||
$hooks = new WPML_TF_Backend_Promote_Hooks(
|
||||
new WPML_TF_Promote_Notices( $sitepress ),
|
||||
$setup_complete,
|
||||
$translation_service
|
||||
);
|
||||
}
|
||||
|
||||
return $hooks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Common_Hooks_Factory
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Common_Hooks_Factory implements IWPML_Backend_Action_Loader, IWPML_Frontend_Action_Loader {
|
||||
|
||||
/**
|
||||
* @return WPML_TF_Common_Hooks
|
||||
*/
|
||||
public function create() {
|
||||
$feedback_storage = new WPML_TF_Data_Object_Storage( new WPML_TF_Feedback_Post_Convert() );
|
||||
|
||||
return new WPML_TF_Common_Hooks( $feedback_storage );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Frontend_AJAX_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Frontend_AJAX_Hooks_Factory extends WPML_AJAX_Base_Factory {
|
||||
|
||||
const AJAX_ACTION = 'wpml-tf-frontend-feedback';
|
||||
|
||||
/**
|
||||
* @return IWPML_Action|null
|
||||
*/
|
||||
public function create() {
|
||||
/** @var SitePress $sitepress */
|
||||
/** @var wpdb $wpdb */
|
||||
global $sitepress, $wpdb;
|
||||
|
||||
if ( $this->is_valid_action( self::AJAX_ACTION ) ) {
|
||||
return new WPML_TF_Frontend_AJAX_Hooks(
|
||||
new WPML_TF_Data_Object_Storage( new WPML_TF_Feedback_Post_Convert() ),
|
||||
new WPML_TF_Document_Information( $sitepress ),
|
||||
new WPML_TF_Post_Rating_Metrics( $wpdb ),
|
||||
class_exists( 'WPML_TP_Client_Factory' ) ? new WPML_TP_Client_Factory() : null,
|
||||
$_POST
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Frontend_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Frontend_Hooks_Factory implements IWPML_Frontend_Action_Loader, IWPML_Deferred_Action_Loader {
|
||||
|
||||
/** @var WPML_Queried_Object $queried_object */
|
||||
private $queried_object;
|
||||
|
||||
/** @var WPML_TF_Frontend_Display_Requirements $display_requirements */
|
||||
private $display_requirements;
|
||||
|
||||
/**
|
||||
* WPML_TF_Frontend_Hooks_Factory constructor.
|
||||
*
|
||||
* @param WPML_Queried_Object $queried_object
|
||||
* @param WPML_TF_Frontend_Display_Requirements $display_requirements
|
||||
*/
|
||||
public function __construct(
|
||||
WPML_Queried_Object $queried_object = null,
|
||||
WPML_TF_Frontend_Display_Requirements $display_requirements = null
|
||||
) {
|
||||
$this->queried_object = $queried_object;
|
||||
$this->display_requirements = $display_requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* The frontend hooks must be loaded when the request has been parsed (in "wp")
|
||||
* to avoid unnecessary instantiation if the current page is not a translation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_load_action() {
|
||||
return 'wp';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|WPML_TF_Frontend_Hooks
|
||||
*/
|
||||
public function create() {
|
||||
global $sitepress;
|
||||
|
||||
$hooks = null;
|
||||
|
||||
if ( $this->get_display_requirements()->verify() ) {
|
||||
$template_loader = new WPML_Twig_Template_Loader(
|
||||
array( WPML_PLUGIN_PATH . WPML_TF_Frontend_Feedback_View::TEMPLATE_FOLDER )
|
||||
);
|
||||
|
||||
$template_service = $template_loader->get_template();
|
||||
|
||||
$settings_reader = new WPML_TF_Settings_Read();
|
||||
/** @var WPML_TF_Settings $settings */
|
||||
$settings = $settings_reader->get( 'WPML_TF_Settings' );
|
||||
|
||||
$frontend_feedback_form = new WPML_TF_Frontend_Feedback_View(
|
||||
$template_service,
|
||||
$sitepress,
|
||||
$this->get_queried_object(),
|
||||
$settings
|
||||
);
|
||||
|
||||
$hooks = new WPML_TF_Frontend_Hooks(
|
||||
$frontend_feedback_form,
|
||||
new WPML_TF_Frontend_Scripts(),
|
||||
new WPML_TF_Frontend_Styles()
|
||||
);
|
||||
}
|
||||
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WPML_Queried_Object
|
||||
*/
|
||||
private function get_queried_object() {
|
||||
global $sitepress;
|
||||
|
||||
if ( ! $this->queried_object ) {
|
||||
$this->queried_object = new WPML_Queried_Object( $sitepress );
|
||||
}
|
||||
|
||||
return $this->queried_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WPML_TF_Frontend_Display_Requirements
|
||||
*/
|
||||
private function get_display_requirements() {
|
||||
if ( ! $this->display_requirements ) {
|
||||
$settings_read = new WPML_TF_Settings_Read();
|
||||
$settings = $settings_read->get( 'WPML_TF_Settings' );
|
||||
/** @var WPML_TF_Settings $settings */
|
||||
$this->display_requirements = new WPML_TF_Frontend_Display_Requirements( $this->get_queried_object(), $settings );
|
||||
}
|
||||
|
||||
return $this->display_requirements;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Translation_Queue_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Translation_Queue_Hooks_Factory extends WPML_Current_Screen_Loader_Factory {
|
||||
|
||||
/** @return string */
|
||||
protected function get_screen_regex() {
|
||||
return '/translations-queue/';
|
||||
}
|
||||
|
||||
/** @return WPML_TF_Translation_Queue_Hooks */
|
||||
protected function create_hooks() {
|
||||
$feedback_storage = new WPML_TF_Data_Object_Storage( new WPML_TF_Feedback_Post_Convert() );
|
||||
return new WPML_TF_Translation_Queue_Hooks( $feedback_storage );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Translation_Service_Change_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Translation_Service_Change_Hooks_Factory implements IWPML_Backend_Action_Loader {
|
||||
|
||||
/** @return WPML_TF_Translation_Service_Change_Hooks */
|
||||
public function create() {
|
||||
return new WPML_TF_Translation_Service_Change_Hooks(
|
||||
new WPML_TF_Settings_Read(),
|
||||
new WPML_TF_Settings_Write(),
|
||||
new WPML_TF_TP_Ratings_Synchronize_Factory()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Common_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_WP_Cron_Events_Factory implements IWPML_Backend_Action_Loader, IWPML_Frontend_Action_Loader {
|
||||
|
||||
/** @return WPML_TF_WP_Cron_Events */
|
||||
public function create() {
|
||||
return new WPML_TF_WP_Cron_Events(
|
||||
new WPML_TF_Settings_Read(),
|
||||
new WPML_TF_TP_Ratings_Synchronize_Factory()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_XML_RPC_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_XML_RPC_Hooks_Factory implements IWPML_Frontend_Action_Loader {
|
||||
|
||||
/** @return WPML_TF_XML_RPC_Hooks */
|
||||
public function create() {
|
||||
return new WPML_TF_XML_RPC_Hooks(
|
||||
new WPML_TF_XML_RPC_Feedback_Update_Factory(),
|
||||
new WPML_WP_API()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TM_TF_AJAX_Feedback_List_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TM_TF_AJAX_Feedback_List_Hooks_Factory implements IWPML_AJAX_Action_Loader {
|
||||
|
||||
/** @return WPML_TM_TF_Feedback_List_Hooks */
|
||||
public function create() {
|
||||
return new WPML_TM_TF_Feedback_List_Hooks();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TM_TF_Feedback_List_Hooks_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TM_TF_Feedback_List_Hooks_Factory extends WPML_Current_Screen_Loader_Factory {
|
||||
|
||||
/** @return string */
|
||||
public function get_screen_regex() {
|
||||
return '/wpml-translation-feedback-list/';
|
||||
}
|
||||
|
||||
/** @return WPML_TM_TF_Feedback_List_Hooks */
|
||||
public function create_hooks() {
|
||||
return new WPML_TM_TF_Feedback_List_Hooks();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_Bulk_Actions_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_Bulk_Actions_Factory {
|
||||
|
||||
/**
|
||||
* @return WPML_TF_Backend_Bulk_Actions
|
||||
*/
|
||||
public function create() {
|
||||
return new WPML_TF_Backend_Bulk_Actions(
|
||||
new WPML_TF_Data_Object_Storage( new WPML_TF_Feedback_Post_Convert() ),
|
||||
new WPML_WP_API(),
|
||||
new WPML_TF_Backend_Notices()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_Feedback_List_View_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_Feedback_List_View_Factory {
|
||||
|
||||
public function create() {
|
||||
/** @var SitePress $sitepress*/
|
||||
global $sitepress;
|
||||
|
||||
$template_loader = new WPML_Twig_Template_Loader(
|
||||
array( WPML_PLUGIN_PATH . WPML_TF_Backend_Feedback_List_View::TEMPLATE_FOLDER )
|
||||
);
|
||||
|
||||
$feedback_query = new WPML_TF_Feedback_Query(
|
||||
new WPML_TF_Data_Object_Storage( new WPML_TF_Feedback_Post_Convert() ),
|
||||
new WPML_TF_Data_Object_Storage( new WPML_TF_Message_Post_Convert() ),
|
||||
new WPML_TF_Collection_Filter_Factory()
|
||||
);
|
||||
|
||||
return new WPML_TF_Backend_Feedback_List_View(
|
||||
$template_loader->get_template(),
|
||||
$feedback_query,
|
||||
new WPML_Admin_Pagination(),
|
||||
new WPML_Admin_Table_Sort(),
|
||||
new WPML_TF_Feedback_Page_Filter( $sitepress, $feedback_query )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_TP_Ratings_Synchronize
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_TP_Ratings_Synchronize_Factory {
|
||||
|
||||
/**
|
||||
* @return WPML_TF_TP_Ratings_Synchronize
|
||||
*/
|
||||
public function create() {
|
||||
$tp_client_factory = new WPML_TP_Client_Factory();
|
||||
$tp_client = $tp_client_factory->create();
|
||||
|
||||
return new WPML_TF_TP_Ratings_Synchronize(
|
||||
new WPML_TF_Data_Object_Storage( new WPML_TF_Feedback_Post_Convert() ),
|
||||
$tp_client->ratings()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_XML_RPC_Feedback_Update_Factory
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_XML_RPC_Feedback_Update_Factory {
|
||||
|
||||
/** @return WPML_TF_XML_RPC_Feedback_Update */
|
||||
public function create() {
|
||||
global $sitepress;
|
||||
|
||||
$translation_service = $sitepress->get_setting( 'translation_service' );
|
||||
$translation_projects = $sitepress->get_setting( 'icl_translation_projects' );
|
||||
$tp_project = new WPML_TP_Project( $translation_service, $translation_projects );
|
||||
|
||||
$feedback_storage = new WPML_TF_Data_Object_Storage( new WPML_TF_Feedback_Post_Convert() );
|
||||
|
||||
return new WPML_TF_XML_RPC_Feedback_Update( $feedback_storage, $tp_project );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user