<?php
namespace Website\Widgets\ContactForm; use Moto; class Widget extends Moto\System\Widgets\AbstractWidget { protected $_name = 'contact_form'; protected static $_defaultProperties = array( 'preset' => 'default', 'animation' => '', 'align' => array( 'desktop' => 'left', 'tablet' => '', 'mobile-v' => '', 'mobile-h' => '', ), 'spacing' => array( 'top' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'left' => 'auto', ), 'fields' => array(), 'messages' => array(), 'buttons' => array(), 'settings' => array( 'recipient' => '', ), 'postAction' => array( 'action' => 'none', 'properties' => array( 'id' => '', 'target' => '_self', ), ), 'resetAfterSubmission' => false ); protected $_templateType = 'templates'; protected $_widgetId = true; public function getProtectedHash() { $array = array( 'settings' => array( 'recipient' => $this->getPropertyValue('settings.recipient', '') ), ); return Moto\System::encrypt($array); } public function isEmpty() { $fieldList = $this->properties['fields']; foreach ($fieldList as $value) { if ($value['enabled']) { return false; } } return true; } public function getActionAfterSubmission() { $clickAction = Moto\ClickAction\Factory::create($this->properties['postAction']); $data = $clickAction->toArray(['url', 'target']); $data['id'] = Moto\Util::getValue($data, 'properties.id'); return json_encode(Moto\Util::arrayOnly($data, ['action', 'url', 'target', 'id'])); } } 