public function onMainBodyBottom(HookRenderEvent $event)
 {
     $options = array();
     switch ($this->getRequest()->get('_view')) {
         // Category page viewed
         case 'category':
             $categoryId = $this->getRequest()->get('category_id');
             $defaultCategory = CategoryQuery::create()->findPk($categoryId);
             $options[] = array('setEcommerceView', false, false, $defaultCategory->getTitle());
             break;
             // Product detail page viewed
         // Product detail page viewed
         case 'product':
             $productId = $this->getRequest()->getProductId();
             $product = ProductQuery::create()->findPk($productId);
             if ($defaultCategoryId = $product->getDefaultCategoryId()) {
                 $defaultCategory = CategoryQuery::create()->findPk($defaultCategoryId);
             }
             $options[] = array('setEcommerceView', $product->getRef() ? $product->getRef() : $product->getId(), $product->getTitle(), isset($defaultCategory) ? $defaultCategory->getTitle() : false, false);
             break;
     }
     if ($code = $this->generateTrackingCode($options)) {
         $event->add($code);
     }
 }
Exemple #2
0
 public function onMainBodyTop(HookRenderEvent $event)
 {
     $css = $this->addCSS('assets/css/min.css');
     $event->add($css);
     $content = $this->render("main-body-top.html", ['mode' => $this->mode]);
     $event->add($content);
 }
 public function onProductDeliveryDelay(HookRenderEvent $event)
 {
     $productId = $event->getArgument('product');
     $handler = new ProductDelayHandler();
     $delivery = $handler->getDelayForProduct($productId);
     $event->add($this->render('delivery-delay/product-delivery-delay.html', $delivery));
 }
Exemple #4
0
 /**
  * Generates the content of the hook
  *
  * {hook name="hook_code" var1="value1" var2="value2" ... }
  *
  * This function create an event, feed it with the custom variables passed to the function (var1, var2, ...) and
  * dispatch it to the hooks that respond to it.
  *
  * The name of the event is `hook.{context}.{hook_code}` where :
  *      * context : the id of the context of the smarty render : 1: frontoffice, 2: backoffice, 3: email, 4: pdf
  *      * hook_code : the code of the hook
  *
  * The event collects all the fragments of text rendered in each modules functions that listen to this event.
  * Finally, this fragments are concatenated and injected in the template
  *
  * @param array        $params the params passed in the smarty function
  * @param \TheliaSmarty\Template\SmartyParser $smarty the smarty parser
  *
  * @return string the contents generated by modules
  */
 public function processHookFunction($params, &$smarty)
 {
     $hookName = $this->getParam($params, 'name');
     $module = intval($this->getParam($params, 'module', 0));
     $moduleCode = $this->getParam($params, 'modulecode', "");
     $type = $smarty->getTemplateDefinition()->getType();
     $event = new HookRenderEvent($hookName, $params);
     $event->setArguments($this->getArgumentsFromParams($params));
     $eventName = sprintf('hook.%s.%s', $type, $hookName);
     // this is a hook specific to a module
     if (0 === $module && "" !== $moduleCode) {
         if (null !== ($mod = ModuleQuery::create()->findOneByCode($moduleCode))) {
             $module = $mod->getId();
         }
     }
     if (0 !== $module) {
         $eventName .= '.' . $module;
     }
     $this->getDispatcher()->dispatch($eventName, $event);
     $content = trim($event->dump());
     if ($this->debug && $smarty->getRequest()->get('SHOW_HOOK')) {
         $content = sprintf('<div style="background-color: #C82D26; color: #fff; border-color: #000000; border: solid;">%s</div>%s', $hookName, $content);
     }
     $this->hookResults[$hookName] = $content;
     // support for compatibility with module_include
     if ($type === TemplateDefinition::BACK_OFFICE) {
         $content .= $this->moduleIncludeCompat($params, $smarty);
     }
     return $content;
 }
Exemple #5
0
 /**
  * This function is called when hook uses the automatic insert template.
  *
  * @param HookRenderEvent $event
  * @param string $code
  */
 public function insertTemplate(HookRenderEvent $event, $code)
 {
     if (array_key_exists($code, $this->templates)) {
         $templates = explode(';', $this->templates[$code]);
         foreach ($templates as $template) {
             list($type, $filepath) = $this->getTemplateParams($template);
             if ("render" === $type) {
                 $event->add($this->render($filepath, $event->getArguments()));
                 continue;
             }
             if ("dump" === $type) {
                 $event->add($this->render($filepath));
                 continue;
             }
             if ("css" === $type) {
                 $event->add($this->addCSS($filepath));
                 continue;
             }
             if ("js" === $type) {
                 $event->add($this->addJS($filepath));
                 continue;
             }
             if (method_exists($this, $type)) {
                 $this->{$type}($filepath, $event->getArguments());
             }
         }
     }
 }
Exemple #6
0
 public function onMainHeadBottom(HookRenderEvent $event)
 {
     $value = trim(ConfigQuery::read("hookanalytics_trackingcode", ""));
     if ("" != $value) {
         $event->add($value);
     }
 }
 /**
  * @param HookRenderEvent $hookRender
  */
 public function onMainHeadBottom(HookRenderEvent $hookRender)
 {
     $event = new CanonicalUrlEvent();
     $this->eventDispatcher->dispatch(CanonicalUrlEvents::GENERATE_CANONICAL, $event);
     if ($event->getUrl()) {
         $hookRender->add('<link rel="canonical" href="' . $event->getUrl() . '" />');
     }
 }
Exemple #8
0
 public function onAccountOrderAfterProducts(HookRenderEvent $event)
 {
     $orderId = $event->getArgument('order');
     if (null !== $orderId) {
         $render = $this->render('account-order-after-products.html', ["order_id" => $orderId]);
         $event->add($render);
     }
 }
 public function onMainStylesheet(HookRenderEvent $event)
 {
     // Backup current template definition
     $backup = $this->getParser()->getTemplateDefinition();
     $this->getParser()->setTemplateDefinition(new TemplateDefinition("bo-css-module", TemplateDefinition::FRONT_OFFICE));
     $event->add($this->render("hook/stylesheet-renderer.html"));
     // then restore
     $this->getParser()->setTemplateDefinition($backup);
 }
 public function onModuleConfigure(HookRenderEvent $event)
 {
     $vars = [];
     if (null !== ($params = ModuleConfigQuery::create()->findByModuleId(ForcePhone::getModuleId()))) {
         /** @var ModuleConfig $param */
         foreach ($params as $param) {
             $vars[$param->getName()] = $param->getValue();
         }
     }
     $event->add($this->render('force-phone/module-configuration.html', $vars));
 }
Exemple #11
0
 public function onInvoiceAfterDeliveryModule(HookRenderEvent $event)
 {
     // No So Colissimo information if the delivery module is not SoColissimo
     if (SoColissimo::getModuleId() == $event->getArgument('module_id')) {
         return;
     }
     $order = OrderQuery::create()->findOneById($event->getArgument('order'));
     if (!is_null($order)) {
         $event->add($this->render('delivery_mode_infos.html', ['delivery_address_id' => $order->getDeliveryOrderAddressId()]));
     }
 }
 public function onTeamNavBar(HookRenderEvent $event)
 {
     $query = DealerTeamQuery::create();
     $joinPerson = new Join(DealerTeamTableMap::TEAM_ID, PersonTeamLinkTableMap::TEAM_ID, Criteria::LEFT_JOIN);
     $query->addJoinObject($joinPerson)->where(PersonTeamLinkTableMap::PERSON_ID . " " . Criteria::EQUAL . " " . $event->getArgument("person_id"));
     $dealer = $query->findOne();
     $args = $event->getArguments();
     if (null != $dealer) {
         $args["dealer_id"] = $dealer->getDealerId();
     }
     $event->add($this->render("includes/person-edit-link.html", $args));
 }
Exemple #13
0
 public function onMainBeforeContent(HookRenderEvent $event)
 {
     if ($this->securityContext->isGranted(["ADMIN"], [AdminResources::PRODUCT], [], [AccessManager::VIEW])) {
         $products = ProductQuery::create()->filterByVirtual(1)->filterByVisible(1)->count();
         if ($products > 0) {
             $deliveryModule = ModuleQuery::create()->retrieveVirtualProductDelivery();
             if (false === $deliveryModule) {
                 $event->add($this->render('virtual-delivery-warning.html'));
             }
         }
     }
 }
Exemple #14
0
 public function onModuleConfigure(HookRenderEvent $event)
 {
     $logFilePath = sprintf(THELIA_ROOT . "log" . DS . "%s.log", Atos::MODULE_DOMAIN);
     $traces = @file_get_contents($logFilePath);
     if (false === $traces) {
         $traces = $this->translator->trans("The log file '%log' does not exists yet.", ['%log' => $logFilePath], Atos::MODULE_DOMAIN);
     } elseif (empty($traces)) {
         $traces = $this->translator->trans("The log file is currently empty.", [], Atos::MODULE_DOMAIN);
     }
     $vars = ['trace_content' => nl2br($traces)];
     if (null !== ($params = ModuleConfigQuery::create()->findByModuleId(Atos::getModuleId()))) {
         /** @var ModuleConfig $param */
         foreach ($params as $param) {
             $vars[$param->getName()] = $param->getValue();
         }
     }
     $event->add($this->render('atos/module-configuration.html', $vars));
 }
 public function onMainJavascriptInitialization(HookRenderEvent $event)
 {
     // First add moment and fullCalendar assets
     $langCode = strtolower($this->getLang()->getCode());
     $momentI18n = sprintf($this->getAssetPath(static::MOMENT_I18N_PATH), $langCode);
     $fullcalendarI18n = sprintf($this->getAssetPath(static::FULLCALENDAR_I18N_PATH), $langCode);
     $event->add($this->addJs($this->getAssetPath(static::MOMENT_JS_PATH)));
     if (is_file($momentI18n)) {
         $event->add($this->addJS($momentI18n));
     }
     $event->add($this->addJs($this->getAssetPath(static::FULLCALENDAR_JS_PATH)));
     if (is_file($fullcalendarI18n)) {
         $event->add($this->addJS($momentI18n));
     }
     // Then declare all the calendars to the script
     $calendarScripts = "<script>(function(\$) {\n";
     foreach ($this->smartyPlugin->getCalendars() as $calendarId => $options) {
         $calendarScripts .= sprintf("    \$(\"#%s\").fullCalendar(%s);\n", $calendarId, json_encode($options));
     }
     $calendarScripts .= "})(jQuery);</script>";
     $event->add($calendarScripts);
 }
Exemple #16
0
 public function onMiniCart(HookRenderEvent $event)
 {
     $content = $this->render('mini-cart.html');
     $event->add($content);
 }
Exemple #17
0
 public function onModuleConfiguration(HookRenderEvent $event)
 {
     $module_id = self::getModule()->getModuleId();
     $event->add($this->render("module_configuration.html", ['module_id' => $module_id]));
 }
 public function onAccountUpdateAfterJSInclude(HookRenderEvent $event)
 {
     $event->add($this->addJS('assets/js/update.js'));
 }
Exemple #19
0
 public function onMainNavbarSecondary(HookRenderEvent $event)
 {
     $content = $this->render("main-navbar-secondary.html");
     $event->add($content);
 }
 public function onOrderModuleTab(HookRenderEvent $event)
 {
     $event->add($this->render('dpdclassic-order-edit.html'));
 }
Exemple #21
0
 public function onAdditionalPaymentInfo(HookRenderEvent $event)
 {
     $content = $this->render("order-placed.additional-payment-info.html", ['placed_order_id' => $event->getArgument('placed_order_id')]);
     $event->add($content);
 }
 public function orderInvoiceForm(HookRenderEvent $event)
 {
     $event->add($this->render("order-invoice-form.html"));
 }
Exemple #23
0
 public function onMainFooterBottom(HookRenderEvent $event)
 {
     $bottomConfig = HookNavigation::getConfigValue(HookNavigationConfigValue::FOOTER_BOTTOM_FOLDER_ID);
     $content = $this->render('main-footer-bottom.html', ['bottomFolderId' => $bottomConfig]);
     $event->add($content);
 }
 /**
  * Javascript for extra form fields.
  * @param HookRenderEvent $event
  */
 public function onRegisterAfterJSInclude(HookRenderEvent $event)
 {
     $event->add($this->addJS('assets/js/register.js'));
 }
Exemple #25
0
 /**
  * Add the front-office stylesheets.
  * @param HookRenderEvent $event
  */
 public function onMainStylesheet(HookRenderEvent $event)
 {
     $event->add($this->addCSS('assets/less/pop-in.less', [], 'less'));
 }
Exemple #26
0
 public function onMainContentTopOverriding(HookRenderEvent $event)
 {
     $event->add($this->render("override1.html"));
     // redefined in template hooktest in the module
     $event->add($this->render("override2.html"));
     // redefined in template hooktest
     $event->add($this->render("override3.html"));
     $event->add($this->render("override-assets.html"));
 }
 public function onCriteriaSearchSearchJs(HookRenderEvent $event)
 {
     $event->add($this->render('criteria-search/search-js.html'));
 }
 /**
  * Insert the product edition page javascript.
  *
  * @param HookRenderEvent $event
  */
 public function onProductEditJs(HookRenderEvent $event)
 {
     $event->add($this->addJS('assets/js/product-edit.js'));
 }
Exemple #29
0
 public function insertJSSelectCity(HookRenderEvent $event)
 {
     $event->add($this->addJS("form/select-city.js"));
 }
Exemple #30
0
 public function onHomeBody(HookRenderEvent $event)
 {
     $event->add($this->render('carousel.html'));
 }