vendor/pimcore/pimcore/models/Document/Editable/Input.php line 23

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Commercial License (PCL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  14.  */
  15. namespace Pimcore\Model\Document\Editable;
  16. use Pimcore\Model;
  17. /**
  18.  * @method \Pimcore\Model\Document\Editable\Dao getDao()
  19.  */
  20. class Input extends Model\Document\Editable implements EditmodeDataInterface
  21. {
  22.     /**
  23.      * Contains the text for this element
  24.      *
  25.      * @internal
  26.      *
  27.      */
  28.     protected string $text '';
  29.     public function getType(): string
  30.     {
  31.         return 'input';
  32.     }
  33.     public function getData(): mixed
  34.     {
  35.         return $this->text;
  36.     }
  37.     public function getText(): string
  38.     {
  39.         return $this->getData();
  40.     }
  41.     public function frontend()
  42.     {
  43.         $config $this->getConfig();
  44.         $text $this->text;
  45.         if (!isset($config['htmlspecialchars']) || $config['htmlspecialchars'] !== false) {
  46.             $text htmlspecialchars($this->text);
  47.         }
  48.         return $text;
  49.     }
  50.     public function getDataEditmode(): string
  51.     {
  52.         return htmlentities($this->text);
  53.     }
  54.     public function setDataFromResource(mixed $data): static
  55.     {
  56.         $this->text $data;
  57.         return $this;
  58.     }
  59.     public function setDataFromEditmode(mixed $data): static
  60.     {
  61.         $data html_entity_decode($dataENT_HTML5); // this is because the input is now an div contenteditable -> therefore in entities
  62.         $this->text $data;
  63.         return $this;
  64.     }
  65.     public function isEmpty(): bool
  66.     {
  67.         return !(bool) strlen($this->text);
  68.     }
  69. }