/**
  * Converts simple check item keys used in trigger expressions.
  *
  * @param string $expression
  *
  * @return string
  */
 public function convert($expression)
 {
     $new_expression = '';
     for ($pos = 0; isset($expression[$pos]); $pos++) {
         if ($this->function_macro_parser->parse($expression, $pos) != CParser::PARSE_FAIL) {
             $new_expression .= '{' . $this->function_macro_parser->getHost() . ':' . $this->itemKeyConverter->convert($this->function_macro_parser->getItem()) . '.' . $this->function_macro_parser->getFunction() . '}';
             $pos += $this->function_macro_parser->getLength() - 1;
         } else {
             $new_expression .= $expression[$pos];
         }
     }
     return $new_expression;
 }
 /**
  * Convert trigger prototype elements.
  *
  * @param array $trigger_prototypes
  *
  * @return array
  */
 protected function convertTriggerPrototypes(array $trigger_prototypes)
 {
     foreach ($trigger_prototypes as &$trigger_prototype) {
         $trigger_prototype['expression'] = $this->triggerExpressionConverter->convert($trigger_prototype['expression']);
     }
     unset($trigger_prototype);
     return $trigger_prototypes;
 }
 /**
  * Convert map elements.
  *
  * @param array $content
  *
  * @return array
  */
 protected function convertSysmaps(array $content)
 {
     if (!isset($content['sysmaps']) || !$content['sysmaps']) {
         return $content;
     }
     $content = CArrayHelper::renameKeys($content, ['sysmaps' => 'maps']);
     foreach ($content['maps'] as &$map) {
         if (isset($map['selements']) && $map['selements']) {
             foreach ($map['selements'] as &$selement) {
                 $selement = CArrayHelper::renameKeys($selement, ['elementid' => 'element', 'iconid_off' => 'icon_off', 'iconid_on' => 'icon_on', 'iconid_disabled' => 'icon_disabled', 'iconid_maintenance' => 'icon_maintenance']);
                 if (isset($selement['elementtype']) && $selement['elementtype'] == SYSMAP_ELEMENT_TYPE_TRIGGER) {
                     $selement['element']['expression'] = $this->triggerConverter->convert($selement['element']['expression']);
                     unset($selement['element']['host']);
                 }
                 unset($selement['iconid_unknown']);
             }
             unset($selement);
         }
         if (isset($map['links']) && $map['links']) {
             foreach ($map['links'] as &$link) {
                 if (isset($link['linktriggers']) && $link['linktriggers']) {
                     foreach ($link['linktriggers'] as &$linkTrigger) {
                         $linkTrigger = CArrayHelper::renameKeys($linkTrigger, ['triggerid' => 'trigger']);
                         $linkTrigger['trigger']['expression'] = $this->triggerConverter->convert($linkTrigger['trigger']['expression']);
                         unset($linkTrigger['trigger']['host']);
                     }
                     unset($linkTrigger);
                 }
             }
             unset($link);
         }
         $map = CArrayHelper::renameKeys($map, ['backgroundid' => 'background']);
     }
     unset($map);
     return $content;
 }