width = $width; // Height. $this->height = $height; // Grid Width. $this->gridWidth = $gridWidth; // Options. $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); // Page. $this->page = basename(__FILE__); // ClassName. $class = new \ReflectionClass($this); $this->className = $class->getShortName(); // Title. $this->title = __('Panel with a message'); // Name. if (empty($this->name) === true) { $this->name = 'post'; } // This forces at least a first configuration. $this->configurationRequired = false; if (empty($this->values['text']) === true) { $this->configurationRequired = true; } $this->overflow_scrollbars = false; } /** * Decoders hack for retrocompability. * * @param array $decoder Values. * * @return array Returns the values ​​with the correct key. */ public function decoders(array $decoder): array { $values = []; // Retrieve global - common inputs. $values = parent::decoders($decoder); if (isset($decoder['textit']) === true) { $values['text'] = $decoder['textit']; } if (isset($decoder['text']) === true) { $values['text'] = $decoder['text']; } return $values; } /** * Generates inputs for form (specific). * * @return array Of inputs. * * @throws Exception On error. */ public function getFormInputs(): array { $values = $this->values; // Retrieve global - common inputs. $inputs = parent::getFormInputs(); $inputs[] = ['label' => __('Text')]; $inputs[] = [ 'class' => 'flex-row', 'id' => 'div-textarea', 'arguments' => [ 'name' => 'text', 'type' => 'textarea', 'value' => $values['text'], 'return' => true, 'rows' => 1, 'columns' => 1, 'size' => 25, ], ]; return $inputs; } /** * Get Post for widget. * * @return array */ public function getPost():array { // Retrieve global - common inputs. $values = parent::getPost(); $values['text'] = \get_parameter('text', ''); return $values; } /** * Draw widget. * * @return string; */ public function load() { $output = ''; if (isset($this->values['text']) === true) { $output .= '
'; $output .= io_safe_output($this->values['text']); $output .= '
'; } return $output; } /** * Get description. * * @return string. */ public static function getDescription() { return __('Panel with a message'); } /** * Get Name. * * @return string. */ public static function getName() { return 'post'; } }