/** * Read the properties of the content from the widget properties * @param \ride\library\widget\WidgetProperties $properties * @return null * @todo remove default value for condition */ public function getFromWidgetProperties(WidgetProperties $properties, $locale) { $this->modelName = $properties->getWidgetProperty(self::PROPERTY_MODEL_NAME); $this->entryId = $properties->getWidgetProperty(self::PROPERTY_ENTRY); $this->recursiveDepth = $properties->getWidgetProperty(self::PROPERTY_RECURSIVE_DEPTH); $this->includeUnlocalized = $properties->getWidgetProperty(self::PROPERTY_INCLUDE_UNLOCALIZED); $this->isPaginationEnabled = $properties->getWidgetProperty(self::PROPERTY_PAGINATION_ENABLE); $this->paginationRows = $properties->getWidgetProperty(self::PROPERTY_PAGINATION_ROWS); $this->paginationOffset = $properties->getWidgetProperty(self::PROPERTY_PAGINATION_OFFSET); $this->hasSearch = $properties->getWidgetProperty(self::PROPERTY_SEARCH); $this->condition = $properties->getLocalizedWidgetProperty($locale, self::PROPERTY_CONDITION); $this->order = $properties->getWidgetProperty(self::PROPERTY_ORDER); $this->parameters = $properties->getWidgetProperty(self::PROPERTY_PARAMETERS); $this->parametersNone = $properties->getWidgetProperty(self::PROPERTY_PARAMETERS_NONE); $this->idField = $properties->getWidgetProperty(self::PROPERTY_ID_FIELD); $this->isPrimaryMapper = $properties->getWidgetProperty(self::PROPERTY_PRIMARY); $this->contentMapper = $properties->getWidgetProperty(self::PROPERTY_MAPPER); $this->template = $properties->getWidgetProperty(self::PROPERTY_TEMPLATE); $this->viewProcessor = $properties->getWidgetProperty(self::PROPERTY_VIEW_PROCESSOR); $this->contentTitleFormat = $properties->getWidgetProperty(self::PROPERTY_FORMAT_TITLE); $this->contentTeaserFormat = $properties->getWidgetProperty(self::PROPERTY_FORMAT_TEASER); $this->contentImageFormat = $properties->getWidgetProperty(self::PROPERTY_FORMAT_IMAGE); $this->contentDateFormat = $properties->getWidgetProperty(self::PROPERTY_FORMAT_DATE); $this->title = $properties->getLocalizedWidgetProperty($locale, self::PROPERTY_TITLE); $this->emptyResultView = $properties->getWidgetProperty(self::PROPERTY_EMPTY_RESULT_VIEW, true); $this->emptyResultMessage = $properties->getLocalizedWidgetProperty($locale, self::PROPERTY_EMPTY_RESULT_MESSAGE); $this->showPagination = $properties->getWidgetProperty(self::PROPERTY_PAGINATION_SHOW); $this->useAjaxForPagination = $properties->getWidgetProperty(self::PROPERTY_PAGINATION_AJAX); $this->showMore = $properties->getLocalizedWidgetProperty($locale, self::PROPERTY_MORE_SHOW); $this->moreLabel = $properties->getLocalizedWidgetProperty($locale, self::PROPERTY_MORE_LABEL); $this->moreNode = $properties->getLocalizedWidgetProperty($locale, self::PROPERTY_MORE_NODE); $this->metaOg = $properties->getWidgetProperty(self::PROPERTY_META_OG); $this->ogTitleFormat = $properties->getWidgetProperty(self::PROPERTY_FORMAT_TITLE_OG); $this->ogTeaserFormat = $properties->getWidgetProperty(self::PROPERTY_FORMAT_TEASER_OG); $this->ogImageFormat = $properties->getWidgetProperty(self::PROPERTY_FORMAT_IMAGE_OG); $this->breadcrumb = $properties->getWidgetProperty(self::PROPERTY_BREADCRUMB); if ($this->parameters && !is_numeric($this->parameters)) { $this->parameters = explode(self::SEPARATOR, $this->parameters); } $this->filters = array(); $filters = $properties->getWidgetProperty(self::PROPERTY_FILTERS); if ($filters) { $filters = explode(self::SEPARATOR, $filters); foreach ($filters as $filter) { list($filterName, $filterType, $filterField) = explode(':', $filter); $this->filters[$filterName] = array('name' => $filterName, 'type' => $filterType, 'field' => $filterField); } } $fieldsString = $properties->getWidgetProperty(self::PROPERTY_MODEL_FIELDS); if (!$fieldsString) { $this->modelFields = null; return; } $this->modelFields = array(); $tokens = explode(self::SEPARATOR, $fieldsString); foreach ($tokens as $token) { $fieldName = trim($token); $this->modelFields[$fieldName] = $fieldName; } }
/** * Gets the text from the data source * @param \ride\library\widget\WidgetProperties $widgetProperties Instance of * the widget properties * @param string $locale Code of the current locale * @return \ride\web\cms\text\Text */ public function getText(WidgetProperties $widgetProperties, $locale) { $textModel = $this->orm->getTextModel(); $text = null; $textId = $widgetProperties->getWidgetProperty(TextWidget::PROPERTY_TEXT); if ($textId) { $query = $textModel->createQuery($locale); $query->setIncludeUnlocalized(true); $query->addCondition('{id} = %1%', $textId); $text = $query->queryFirst(); } if (!$text) { $text = $textModel->createEntry(); $text->setLocale($locale); } return $text; }