Completed
Branch FET-10724-event-editor-cleanup (09bcbe)
by
unknown
196:42 queued 184:44
created

MessagesAdmin   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 130
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
dl 0
loc 130
rs 10
c 2
b 0
f 1
wmc 9
lcom 1
cbo 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A messageActivityListTableUrl() 0 4 1
A defaultMessageTemplateListTableUrl() 0 4 1
A customMessageTemplateListTableUrl() 0 4 1
A messageSettingsUrl() 0 4 1
A editMessageTemplateClassByMessageType() 0 6 2
A messagesActivityListTableCellSelectorFor() 0 19 3
1
<?php
2
namespace Page;
3
4
/**
5
 * MessagesAdmin
6
 * Selectors/References to elements in the Messages Admin Pages
7
 *
8
 * @package Page
9
 * @author  Darren Ethier
10
 * @since   1.0.0
11
 */
12
class MessagesAdmin extends CoreAdmin
13
{
14
15
    /**
16
     * Context slug for the admin messages context.
17
     * @var string
18
     */
19
    const ADMIN_CONTEXT_SLUG = 'admin';
20
21
    /**
22
     * Context slug for the primary attendee messages context
23
     * @var string
24
     */
25
    const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
26
27
28
    /**
29
     * Status reference for the EEM_Message::status_sent status.
30
     * @var string
31
     */
32
    const MESSAGE_STATUS_SENT = 'MSN';
33
34
35
    /**
36
     * Message type slug for the Payment Failed message type
37
     */
38
    const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
39
40
41
    /**
42
     * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
43
     * @var string
44
     */
45
    const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR = '#global_messages_settings-do-messages-on-same-request';
46
47
48
    /**
49
     * Selector for the Global Messages Settings submit button in the Messages Settings tab.
50
     * @var string
51
     */
52
    const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
53
54
55
56
    /**
57
     * @param string $additional_params Any additional request parameters for the generated url should be included as
58
     *                                  a string.
59
     * @return string
60
     */
61
    public static function messageActivityListTableUrl($additional_params = '')
62
    {
63
        return self::adminUrl('espresso_messages', 'default', $additional_params);
64
    }
65
66
67
    /**
68
     * @param string $additional_params Any additional request parameters for the generated url should be included as
69
     *                                  a string.
70
     * @return string
71
     */
72
    public static function defaultMessageTemplateListTableUrl($additional_params = '')
73
    {
74
        return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
75
    }
76
77
78
    /**
79
     * @param string $additional_params Any additional request parameters for the generated url should be included as
80
     *                                  a string.
81
     * @return string
82
     */
83
    public static function customMessageTemplateListTableUrl($additional_params = '')
84
    {
85
        return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
86
    }
87
88
89
    /**
90
     * @return string
91
     */
92
    public static function messageSettingsUrl()
93
    {
94
        return self::adminUrl('espresso_messages', 'settings');
95
    }
96
97
98
    /**
99
     * @param string $message_type_slug
100
     * @param string $context
101
     * @return string
102
     */
103
    public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
104
    {
105
        return $context
106
            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
107
            : '.' . $message_type_slug . '-edit-link';
108
    }
109
110
111
    /**
112
     * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
113
     * @param        $field
114
     * @param        $message_type_label
115
     * @param string $message_status
116
     * @param string $messenger
117
     * @param string $context
118
     * @param string $table_cell_content_for_field
119
     * @return string
120
     */
121
    public static function messagesActivityListTableCellSelectorFor(
122
        $field,
123
        $message_type_label,
124
        $message_status = self::MESSAGE_STATUS_SENT,
125
        $messenger = 'Email',
126
        $context = 'Event Admin',
127
        $table_cell_content_for_field = ''
128
    ) {
129
        $selector = "//tr[contains(@class, 'msg-status-$message_status')]"
130
                . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
131
        if ($messenger) {
132
            $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
133
        }
134
        $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
135
        $selector .= $table_cell_content_for_field
136
            ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
137
            : "/ancestor::tr/td[contains(@class, 'column-$field')]";
138
        return $selector;
139
    }
140
141
}