public function loadConfig() {
$load_values = $this->getLoadValues();
- $destinations = (array)$this->getData();
- if (array_key_exists('Type', $destinations)) {
- $destinations = array($destinations);
+ $dests = $this->getData();
+ if (key_exists('Destinations', $dests)) {
+ $dests = $dests['Destinations'];
}
$directives = array();
- for ($i = 0; $i < count($destinations); $i++) {
- $is_address_type = in_array($destinations[$i]['Type'], $this->destination_address);
+ for ($i = 0; $i < count($dests); $i++) {
+ $dest = (array)$dests[$i];
+ $is_address_type = in_array($dest['Type'], $this->destination_address);
$directive_value = null;
- if ($is_address_type && array_key_exists('Where', $destinations[$i])) {
- $directive_value = implode(',', $destinations[$i]['Where']);
+ if ($is_address_type && key_exists('Where', $dest)) {
+ $directive_value = implode(',', $dest['Where']);
}
- $this->setDirectiveName($destinations[$i]['Type']);
+ $this->setDirectiveName($dest['Type']);
$directives[$i] = array(
'host' => $this->getHost(),
'component_type' => $this->getComponentType(),
'component_name' => $this->getComponentName(),
'resource_type' => $this->getResourceType(),
'resource_name' => $this->getResourceName(),
- 'directive_name' => $destinations[$i]['Type'],
+ 'directive_name' => $dest['Type'],
'directive_value' => $directive_value,
'default_value' => false,
'required' => false,
- 'label' => $destinations[$i]['Type'],
+ 'label' => $dest['Type'],
'field_type' => 'TextBox',
'in_config' => true,
'show' => true,
);
$value_all = $value_not = null;
for ($j = 0; $j < count($this->messages_types); $j++) {
- $value_all = in_array('!' . $this->messages_types[$j], $destinations[$i]['MsgTypes']);
- $value_not = in_array($this->messages_types[$j], $destinations[$i]['MsgTypes']);
+ $value_all = in_array('!' . $this->messages_types[$j], $dest['MsgTypes']);
+ $value_not = in_array($this->messages_types[$j], $dest['MsgTypes']);
$directives[$i]['messages_types'][] = array(
'host' => $this->getHost(),
'component_type' => $this->getComponentType(),
'required' => false,
'label' => $this->messages_types[$j],
'field_type' => 'Messages',
- 'data' => $destinations[$i]['Type'],
+ 'data' => $dest['Type'],
'in_config' => true,
'show' => true,
'parent_name' => __CLASS__
if (count($directive_values) === 0) {
continue;
}
- $values[$directive_name] = implode(' ', $directive_values);
- }
- $ret = null;
- if (count($values) > 1) {
- // multiple messages values
- $ret = $values;
- } else {
- // single messages value
- $ret = implode('', array_values($values));
+ if (!key_exists($directive_name, $values)) {
+ $values[$directive_name] = array();
+ }
+ $values[$directive_name][] = implode(' ', $directive_values);
}
- return $ret;
+ return $values;
}
public function getDirectiveData() {
$data = $this->getDirectiveData();
$msg_type = $sender->getID();
array_push($data, array('Type' => $msg_type, 'MsgTypes' => array()));
- $data = (object)$data;
$this->setData($data);
- $this->loadConfig(null, null);
+ $this->loadConfig();
}
+
+ public function removeMessages($sender, $param) {
+ if ($param instanceof Prado\Web\UI\TCommandEventParameter) {
+ $idx = $param->getCommandName();
+ $data = $this->getDirectiveData();
+ array_splice($data, $idx, 1);
+ $this->setData($data);
+ $this->loadConfig();
+ }
+ }
+
}
<button type="button" class="w3-button w3-green w3-margin" onmousedown="openElementOnCursor(event, '<%=$this->MessagesMenu->ClientID%>_new_messages', 0, 20);"><i class="fa fa-plus"></i> <%[ Add ]%></button>
+<p class="bold"><%[ Tip: checking 'All' message type causes, that rest checked message types are saved with negation ex. Catalog = All, !Debug, !Saved, !Skipped ]%></p>
<com:Application.Web.Portlets.NewMessagesMenu ID="MessagesMenu" />
<com:TActiveRepeater ID="RepeaterMessages" OnItemCreated="createDirectiveListElement" OnItemDataBound="loadMessageTypes">
<prop:ItemTemplate>
<div class="w3-card w3-padding directive">
+ <com:TActiveLinkButton
+ CssClass="w3-button w3-green w3-right"
+ OnCommand="SourceTemplateControl.removeMessages"
+ CommandName="<%=$this->ItemIndex%>"
+ CommandParameter="save"
+ >
+ <i class="fa fa-trash-alt"></i> <%[ Remove ]%>
+ </com:TActiveLinkButton>
<h2><%=$this->Data['directive_name']%></h2>
<com:Application.Web.Portlets.DirectiveTextBox />
<com:Application.Web.Portlets.MessageTypes ID="Types" />