/**
  * Stores the text in the data source
  * @param \ride\library\widget\WidgetProperties $widgetProperties Instance
  * of the widget properties
  * @param string|array $locales Code of the current locale
  * @param \ride\web\cms\text\Text $text Instance of the text
  * @param array $data Submitted data
  * @return null
  */
 public function setText(WidgetProperties $widgetProperties, $locales, Text $text, array $data)
 {
     if (!is_array($locales)) {
         $locales = array($locales);
     }
     foreach ($locales as $locale) {
         $widgetProperties->setLocalizedWidgetProperty($locale, TextWidget::PROPERTY_FORMAT, $text->getFormat());
         $widgetProperties->setLocalizedWidgetProperty($locale, TextWidget::PROPERTY_TITLE, $data[TextWidget::PROPERTY_TITLE]);
         $widgetProperties->setLocalizedWidgetProperty($locale, TextWidget::PROPERTY_SUBTITLE, $data[TextWidget::PROPERTY_SUBTITLE]);
         $widgetProperties->setLocalizedWidgetProperty($locale, TextWidget::PROPERTY_BODY, $data[TextWidget::PROPERTY_BODY]);
         $widgetProperties->setLocalizedWidgetProperty($locale, str_replace('-', '.', TextWidget::PROPERTY_IMAGE), $data[TextWidget::PROPERTY_IMAGE]);
         $widgetProperties->setLocalizedWidgetProperty($locale, str_replace('-', '.', TextWidget::PROPERTY_IMAGE_ALIGNMENT), $data[TextWidget::PROPERTY_IMAGE_ALIGNMENT]);
         $widgetProperties->clearWidgetProperties(TextWidget::PROPERTY_CTA . '.' . $locale);
         $index = 1;
         foreach ($data[TextWidget::PROPERTY_CTA] as $cta) {
             $widgetProperties->setWidgetProperty(TextWidget::PROPERTY_CTA . '.' . $locale . '.' . $index . '.label', $cta['label']);
             $widgetProperties->setWidgetProperty(TextWidget::PROPERTY_CTA . '.' . $locale . '.' . $index . '.node', $cta['node']);
             $widgetProperties->setWidgetProperty(TextWidget::PROPERTY_CTA . '.' . $locale . '.' . $index . '.url', $cta['url']);
             $widgetProperties->setWidgetProperty(TextWidget::PROPERTY_CTA . '.' . $locale . '.' . $index . '.type', $cta['type']);
             $index++;
         }
     }
 }
 /**
  * Write the properties of the content to the widget properties
  * @param \ride\library\widget\WidgetSettings $properties
  * @return null
  */
 public function setToWidgetProperties(WidgetProperties $properties, $locale)
 {
     $fields = null;
     if ($this->modelFields) {
         $fields = implode(self::SEPARATOR, $this->modelFields);
     }
     $properties->setWidgetProperty(self::PROPERTY_MODEL_NAME, $this->modelName);
     $properties->setWidgetProperty(self::PROPERTY_ENTRY, $this->entryId);
     $properties->setWidgetProperty(self::PROPERTY_MODEL_FIELDS, $fields);
     $properties->setWidgetProperty(self::PROPERTY_RECURSIVE_DEPTH, $this->recursiveDepth);
     $properties->setWidgetProperty(self::PROPERTY_INCLUDE_UNLOCALIZED, $this->includeUnlocalized);
     $properties->setWidgetProperty(self::PROPERTY_SEARCH, $this->hasSearch ? '1' : '0');
     $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_CONDITION, $this->condition);
     $properties->setWidgetProperty(self::PROPERTY_ORDER, $this->order);
     $properties->setWidgetProperty(self::PROPERTY_PAGINATION_ENABLE, $this->isPaginationEnabled);
     if ($this->isPaginationEnabled) {
         $properties->setWidgetProperty(self::PROPERTY_PAGINATION_ROWS, $this->paginationRows);
         $properties->setWidgetProperty(self::PROPERTY_PAGINATION_OFFSET, $this->paginationOffset);
         $properties->setWidgetProperty(self::PROPERTY_PAGINATION_SHOW, $this->showPagination);
         $properties->setWidgetProperty(self::PROPERTY_PAGINATION_AJAX, $this->useAjaxForPagination);
         if ($this->showMore) {
             $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_SHOW, $this->showMore);
             $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_LABEL, $this->moreLabel);
             $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_NODE, $this->moreNode);
         } else {
             $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_SHOW, null);
             $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_LABEL, null);
             $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_NODE, null);
         }
     } else {
         $properties->setWidgetProperty(self::PROPERTY_PAGINATION_ROWS, null);
         $properties->setWidgetProperty(self::PROPERTY_PAGINATION_OFFSET, null);
         $properties->setWidgetProperty(self::PROPERTY_PAGINATION_SHOW, null);
         $properties->setWidgetProperty(self::PROPERTY_PAGINATION_AJAX, null);
         $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_SHOW, null);
         $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_LABEL, null);
         $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_MORE_NODE, null);
     }
     $properties->setWidgetProperty(self::PROPERTY_ID_FIELD, $this->idField);
     $properties->setWidgetProperty(self::PROPERTY_PRIMARY, $this->isPrimaryMapper);
     $properties->setWidgetProperty(self::PROPERTY_MAPPER, $this->contentMapper);
     $properties->setWidgetProperty(self::PROPERTY_TEMPLATE, $this->template);
     $properties->setWidgetProperty(self::PROPERTY_VIEW_PROCESSOR, $this->viewProcessor);
     $properties->setWidgetProperty(self::PROPERTY_FORMAT_TITLE, $this->contentTitleFormat);
     $properties->setWidgetProperty(self::PROPERTY_FORMAT_TEASER, $this->contentTeaserFormat);
     $properties->setWidgetProperty(self::PROPERTY_FORMAT_IMAGE, $this->contentImageFormat);
     $properties->setWidgetProperty(self::PROPERTY_FORMAT_DATE, $this->contentDateFormat);
     $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_TITLE, $this->title);
     $properties->setWidgetProperty(self::PROPERTY_EMPTY_RESULT_VIEW, $this->emptyResultView ? '1' : '0');
     $properties->setLocalizedWidgetProperty($locale, self::PROPERTY_EMPTY_RESULT_MESSAGE, $this->emptyResultMessage);
     $properties->setWidgetProperty(self::PROPERTY_META_OG, $this->metaOg);
     $properties->setWidgetProperty(self::PROPERTY_FORMAT_TITLE_OG, $this->ogTitleFormat);
     $properties->setWidgetProperty(self::PROPERTY_FORMAT_TEASER_OG, $this->ogTeaserFormat);
     $properties->setWidgetProperty(self::PROPERTY_FORMAT_IMAGE_OG, $this->ogImageFormat);
     $properties->setWidgetProperty(self::PROPERTY_BREADCRUMB, $this->breadcrumb ? '1' : '0');
     $parameters = $this->parameters;
     if ($parameters) {
         if (is_array($parameters)) {
             $parameters = implode(self::SEPARATOR, $parameters);
         }
         $properties->setWidgetProperty(self::PROPERTY_PARAMETERS, $parameters);
     } else {
         $properties->setWidgetProperty(self::PROPERTY_PARAMETERS, null);
     }
     $properties->setWidgetProperty(self::PROPERTY_PARAMETERS_NONE, $this->parametersNone);
     $filters = $this->filters;
     if (is_array($filters)) {
         $filterValues = array();
         foreach ($filters as $filter) {
             $filterValues[] = $filter['name'] . ':' . $filter['type'] . ':' . $filter['field'];
         }
         $properties->setWidgetProperty(self::PROPERTY_FILTERS, implode(self::SEPARATOR, $filterValues));
     } else {
         $properties->setWidgetProperty(self::PROPERTY_FILTERS, null);
     }
 }