/** * {@inheritdoc} */ public function getWidgetStaticContent(Widget $widget) { $parameters = parent::getWidgetStaticContent($widget); if (!array_key_exists('disqusShortname', $parameters) || $parameters['disqusShortname'] == null) { $parameters['disqusShortname'] = $this->disqusName; } return $parameters; }
/** * Get the content of the widget for the static mode. * * @param Widget $widget * * @return string */ public function getWidgetStaticContent(Widget $widget) { $parameters = parent::getWidgetStaticContent($widget); $contactEntity = $this->contactEntity; $contactForm = $this->contactForm; $message = new $contactEntity(); $message->setWidget($widget); $form = $this->formFactory->create(new $contactForm(), $message, ['action' => $this->router->generate($this->formActionRoute, ['id' => $message->getWidget()->getId()]), 'method' => 'POST', 'attr' => ['data-toggle' => 'ajax', 'data-update' => 'vic-widget-' . $widget->getId() . '-container']]); $parameters['form'] = $form->createView(); return $parameters; }
/** * Get the static content of the widget. * * @param Widget $widget * * @return string */ public function getWidgetStaticContent(Widget $widget) { // Boolan to check if we have result $hasResult = false; $parameters = parent::getWidgetStaticContent($widget); $parameters['query'] = $this->request->get('q'); if (true === $parameters['emitter']) { $parameters['ajax'] = $parameters['receiver']; } elseif (true === $parameters['receiver']) { $parameters['search'] = ['business' => [], 'pages' => [], 'widgets' => []]; $alreadyAdded = []; if ($parameters['query']) { foreach ([$this->businessIndexConfig, $this->pagesIndexConfig, $this->widgetsIndexConfig] as $_indexConfig) { //Search the query in all the business types (from fos_elastica.yml) foreach ($_indexConfig->getTypes() as $_typeConfig) { $parameters['search'][$_indexConfig->getName()][$_typeConfig->getName()] = []; /** @var Repository $_repo */ $_repo = $this->elasticORM->getRepository($_typeConfig->getModel()); if ('pages' == $_indexConfig->getName()) { $query = self::getI18NQuery($this->request->get('q'), $widget->getView()->getLocale()); } else { $query = self::getBaseQuery($this->request->get('q')); } $query->setHighlight(['order' => 'score', 'tag_schema' => 'styled', 'fields' => ['*' => ['fragment_size' => 1000]]]); foreach ($_repo->findHybrid($query) as $_result) { // We have a result $hasResult = true; $_entity = $_result->getTransformed(); /** @var Result $_result */ $_result = $_result->getResult(); if ($_result->getScore() > 0.4) { if ($_entity instanceof Widget) { $view = $_entity->getView(); if (!in_array($view->getId(), $alreadyAdded) && !$view instanceof Template) { $parameters['search'][$_indexConfig->getName()][$_typeConfig->getName()][] = ['page' => $view, 'result' => $_result, 'highlights' => $_result->getHighlights()]; $alreadyAdded[] = $view->getId() . $view->getName(); } } elseif ($_entity instanceof BasePage) { if (!in_array($_entity->getId(), $alreadyAdded) && !$_entity instanceof Template) { $parameters['search'][$_indexConfig->getName()][$_typeConfig->getName()][] = ['page' => $_entity, 'result' => $_result, 'highlights' => $_result->getHighlights()]; $alreadyAdded[] = $_entity->getId() . $_entity->getName(); } } else { //$_entity is a Business Entity $businessPagesRefs = $this->viewCacheHelper->getAllReferenceByParameters(['entityId' => $_entity->getId(), 'entityNamespace' => $_typeConfig->getModel()]); foreach ($businessPagesRefs as $_businessPageRef) { $_businessPage = $this->pageHelper->findPageByReference($_businessPageRef); if (!in_array($_businessPage->getId(), $alreadyAdded)) { $parameters['search'][$_indexConfig->getName()][$_typeConfig->getName()][] = ['page' => $_businessPage, 'result' => $_result, 'highlights' => $_result->getHighlights()]; $alreadyAdded[] = $_businessPage->getId() . $_businessPage->getName(); } } } } } } } } } $parameters['hasResult'] = $hasResult; return $parameters; }
/** * Get the content of the widget for the query mode. * * @param Widget $widget * * @throws \Exception */ public function getWidgetQueryContent(Widget $widget) { return parent::getWidgetQueryContent($widget); }
/** * Get the static content of the widget * * @param Widget $widget * * @return string */ public function getWidgetStaticContent(Widget $widget) { $parameters = parent::getWidgetStaticContent($widget); $parameters['shareThisPubKey'] = $this->shareThisPubKey; return $parameters; }