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

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  * @category   Pimcore
  12.  * @package    Document
  13.  *
  14.  * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  15.  * @license    http://www.pimcore.org/license     GPLv3 and PEL
  16.  */
  17. namespace Pimcore\Model\Document\Editable;
  18. use Pimcore\Model;
  19. /**
  20.  * @method \Pimcore\Model\Document\Editable\Dao getDao()
  21.  */
  22. class Input extends Model\Document\Editable
  23. {
  24.     /**
  25.      * Contains the text for this element
  26.      *
  27.      * @var string
  28.      */
  29.     public $text '';
  30.     /**
  31.      * @see EditableInterface::getType
  32.      *
  33.      * @return string
  34.      */
  35.     public function getType()
  36.     {
  37.         return 'input';
  38.     }
  39.     /**
  40.      * @see EditableInterface::getData
  41.      *
  42.      * @return mixed
  43.      */
  44.     public function getData()
  45.     {
  46.         return $this->text;
  47.     }
  48.     /**
  49.      * @see EditableInterface::frontend
  50.      *
  51.      * @return string
  52.      */
  53.     public function frontend()
  54.     {
  55.         $config $this->getConfig();
  56.         $text $this->text;
  57.         if (!isset($config['htmlspecialchars']) || $config['htmlspecialchars'] !== false) {
  58.             $text htmlspecialchars($this->text);
  59.         }
  60.         return $text;
  61.     }
  62.     public function getDataEditmode()
  63.     {
  64.         return htmlentities($this->text);
  65.     }
  66.     /**
  67.      * @see EditableInterface::setDataFromResource
  68.      *
  69.      * @param mixed $data
  70.      *
  71.      * @return $this
  72.      */
  73.     public function setDataFromResource($data)
  74.     {
  75.         $this->text $data;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @see EditableInterface::setDataFromEditmode
  80.      *
  81.      * @param mixed $data
  82.      *
  83.      * @return $this
  84.      */
  85.     public function setDataFromEditmode($data)
  86.     {
  87.         $data html_entity_decode($dataENT_HTML5); // this is because the input is now an div contenteditable -> therefore in entities
  88.         $this->text $data;
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return bool
  93.      */
  94.     public function isEmpty()
  95.     {
  96.         return !(bool) strlen($this->text);
  97.     }
  98.     /**
  99.      * @deprecated
  100.      *
  101.      * @param Model\Webservice\Data\Document\Element $wsElement
  102.      * @param Model\Document\PageSnippet $document
  103.      * @param array $params
  104.      * @param Model\Webservice\IdMapperInterface|null $idMapper
  105.      *
  106.      * @throws \Exception
  107.      */
  108.     public function getFromWebserviceImport($wsElement$document null$params = [], $idMapper null)
  109.     {
  110.         $data $this->sanitizeWebserviceData($wsElement->value);
  111.         if ($data->text === null or is_string($data->text)) {
  112.             $this->text $data->text;
  113.         } else {
  114.             throw new \Exception('cannot get values from web service import - invalid data');
  115.         }
  116.     }
  117. }
  118. class_alias(Input::class, 'Pimcore\Model\Document\Tag\Input');