public function onMainHeadBottom(HookRenderEvent $event) { $value = trim(ConfigQuery::read("hookanalytics_trackingcode", "")); if ("" != $value) { $event->add($value); } }
public function __construct() { $this->url = ConfigQuery::read('hookpiwikanalytics_url', false); $this->website_id = ConfigQuery::read('hookpiwikanalytics_website_id', false); \PiwikTracker::$URL = $this->url; $this->tracker = new \PiwikTracker($this->website_id); }
/** * Save the previous URL in session which is based on the referer header or the request, or * the _previous_url request attribute, if defined. * * If the value of _previous_url is "dont-save", the current referrer is not saved. * * @param FilterResponseEvent $event */ public function registerPreviousUrl(PostResponseEvent $event) { $request = $event->getRequest(); $referrer = $request->attributes->get('_previous_url', null); if (null !== $referrer) { // A previous URL (or the keyword 'dont-save') has been specified. if ('dont-save' == $referrer) { // We should not save the current URL as the previous URL $referrer = null; } } else { // The current URL will become the previous URL $referrer = $request->getUri(); } // Set previous URL, if defined if (null !== $referrer) { $session = $request->getSession(); if (ConfigQuery::read("one_domain_foreach_lang", false) == 1) { $components = parse_url($referrer); $lang = LangQuery::create()->filterByUrl(sprintf("%s://%s", $components["scheme"], $components["host"]), ModelCriteria::LIKE)->findOne(); if (null !== $lang) { $session->setReturnToUrl($referrer); } } else { if (false !== strpos($referrer, $request->getSchemeAndHttpHost())) { $session->setReturnToUrl($referrer); } } } }
/** * @inheritdoc */ public function postActivation(ConnectionInterface $con = null) { $fileSystem = new Filesystem(); //Check for environment if ($env = $this->getContainer()->getParameter('kernel.environment')) { //Check for backward compatibility if ($env !== "prod" && $env !== "dev") { //Remove separtion between dev and prod in particular environment $env = str_replace('_dev', '', $env); $this->webMediaEnvPath = $this->webMediaPath . DS . $env; } } // Create symbolic links or hard copy in the web directory // (according to \Thelia\Action\Document::CONFIG_DELIVERY_MODE), // to make the TinyMCE code available. if (false === $fileSystem->exists($this->webJsPath)) { if (ConfigQuery::read(Document::CONFIG_DELIVERY_MODE) === 'symlink') { $fileSystem->symlink($this->jsPath, $this->webJsPath); } else { $fileSystem->mirror($this->jsPath, $this->webJsPath); } } // Create the media directory in the web root , if required if (null !== $this->webMediaEnvPath) { if (false === $fileSystem->exists($this->webMediaEnvPath)) { $fileSystem->mkdir($this->webMediaEnvPath . DS . 'upload'); $fileSystem->mkdir($this->webMediaEnvPath . DS . 'thumbs'); } } else { if (false === $fileSystem->exists($this->webMediaPath)) { $fileSystem->mkdir($this->webMediaPath . DS . 'upload'); $fileSystem->mkdir($this->webMediaPath . DS . 'thumbs'); } } }
public function update_status(OrderEvent $event) { if ($event->getOrder()->getDeliveryModuleId() === LocalPickup::getModCode()) { if ($event->getOrder()->isSent()) { $contact_email = ConfigQuery::read('store_email'); if ($contact_email) { $message = MessageQuery::create()->filterByName('order_confirmation_localpickup')->findOne(); if (false === $message) { throw new \Exception("Failed to load message 'order_confirmation_localpickup'."); } $order = $event->getOrder(); $customer = $order->getCustomer(); $store = ConfigQuery::create(); $country = CountryQuery::create()->findPk($store->read("store_country")); $country = CountryI18nQuery::create()->filterById($country->getId())->findOneByLocale($order->getLang()->getLocale())->getTitle(); $this->parser->assign('order_id', $order->getId()); $this->parser->assign('order_ref', $order->getRef()); $this->parser->assign('store_name', $store->read("store_name")); $this->parser->assign('store_address1', $store->read("store_address1")); $this->parser->assign('store_address2', $store->read("store_address2")); $this->parser->assign('store_address3', $store->read("store_address3")); $this->parser->assign('store_zipcode', $store->read("store_zipcode")); $this->parser->assign('store_city', $store->read("store_city")); $this->parser->assign('store_country', $country); $message->setLocale($order->getLang()->getLocale()); $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name')); // Build subject and body $message->buildMessage($this->parser, $instance); $this->getMailer()->send($instance); } } } }
public function parseResults(LoopResult $loopResult) { $taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry(); $locale = $this->request->getSession()->getLang()->getLocale(); $checkAvailability = ConfigQuery::checkAvailableStock(); $defaultAvailability = intval(ConfigQuery::read('default-available-stock', 100)); foreach ($loopResult->getResultDataCollection() as $cartItem) { $product = $cartItem->getProduct(null, $locale); $productSaleElement = $cartItem->getProductSaleElements(); $loopResultRow = new LoopResultRow(); $loopResultRow->set("ITEM_ID", $cartItem->getId()); $loopResultRow->set("TITLE", $product->getTitle()); $loopResultRow->set("REF", $product->getRef()); $loopResultRow->set("QUANTITY", $cartItem->getQuantity()); $loopResultRow->set("PRODUCT_ID", $product->getId()); $loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale())); if (!$checkAvailability || $product->getVirtual() === 1) { $loopResultRow->set("STOCK", $defaultAvailability); } else { $loopResultRow->set("STOCK", $productSaleElement->getQuantity()); } $loopResultRow->set("PRICE", $cartItem->getPrice())->set("PROMO_PRICE", $cartItem->getPromoPrice())->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry))->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry))->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0); $loopResultRow->set("PRODUCT_SALE_ELEMENTS_ID", $productSaleElement->getId()); $loopResultRow->set("PRODUCT_SALE_ELEMENTS_REF", $productSaleElement->getRef()); $loopResult->addRow($loopResultRow); } return $loopResult; }
public function updateStatus(OrderEvent $event) { $order = $event->getOrder(); $Predict = new Predict(); if ($order->isSent() && $order->getDeliveryModuleId() == $Predict->getModuleModel()->getId()) { $contact_email = ConfigQuery::read('store_email'); if ($contact_email) { $message = MessageQuery::create()->filterByName('mail_predict')->findOne(); if (false === $message) { throw new \Exception(Translator::getInstance()->trans("Failed to load message '%mail_tpl_name'.", ["%mail_tpl_name" => "mail_predict"], Predict::MESSAGE_DOMAIN)); } $order = $event->getOrder(); $customer = $order->getCustomer(); $this->parser->assign('customer_id', $customer->getId()); $this->parser->assign('order_ref', $order->getRef()); $this->parser->assign('order_date', $order->getCreatedAt()); $this->parser->assign('order_id', $order->getId()); $this->parser->assign('update_date', $order->getUpdatedAt()); $this->parser->assign('package', $order->getDeliveryRef()); $message->setLocale($order->getLang()->getLocale()); $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name')); // Build subject and body $message->buildMessage($this->parser, $instance); $this->mailer->send($instance); Tlog::getInstance()->debug("Predict shipping message sent to customer " . $customer->getEmail()); } else { $customer = $order->getCustomer(); Tlog::getInstance()->debug("Predict shipping message no contact email customer_id", $customer->getId()); } } }
public function process() { $logger = Tlog::getInstance(); $logger->setLevel(Tlog::DEBUG); $updatedVersions = array(); $currentVersion = ConfigQuery::read('thelia_version'); $logger->debug("start update process"); if (true === $this->isLatestVersion($currentVersion)) { $logger->debug("You already have the latest version. No update available"); throw new UpToDateException('You already have the latest version. No update available'); } $index = array_search($currentVersion, self::$version); $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME); $con->beginTransaction(); $logger->debug("begin transaction"); $database = new Database($con->getWrappedConnection()); try { $size = count(self::$version); for ($i = ++$index; $i < $size; $i++) { $this->updateToVersion(self::$version[$i], $database, $logger); $updatedVersions[] = self::$version[$i]; } $con->commit(); $logger->debug('update successfully'); } catch (PropelException $e) { $con->rollBack(); $logger->error(sprintf('error during update process with message : %s', $e->getMessage())); throw $e; } $logger->debug('end of update processing'); return $updatedVersions; }
public function testAction() { // Check current user authorization if (null !== ($response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::UPDATE))) { return $response; } $contactEmail = ConfigQuery::read('store_email'); $storeName = ConfigQuery::read('store_name', 'Thelia'); $json_data = array("success" => false, "message" => ""); if ($contactEmail) { $emailTest = $this->getRequest()->get("email", $contactEmail); $message = $this->getTranslator()->trans("Email test from : %store%", array("%store%" => $storeName)); $htmlMessage = "<p>{$message}</p>"; $instance = \Swift_Message::newInstance()->addTo($emailTest, $storeName)->addFrom($contactEmail, $storeName)->setSubject($message)->setBody($message, 'text/plain')->setBody($htmlMessage, 'text/html'); try { $this->getMailer()->send($instance); $json_data["success"] = true; $json_data["message"] = $this->getTranslator()->trans("Your configuration seems to be ok. Checked out your mailbox : %email%", array("%email%" => $emailTest)); } catch (\Exception $ex) { $json_data["message"] = $ex->getMessage(); } } else { $json_data["message"] = $this->getTranslator()->trans("You have to configure your store email first !"); } $response = JsonResponse::create($json_data); return $response; }
/** * Checks if we are the payment module for the order, and if the order is paid, * then send a confirmation email to the customer. * * @params OrderEvent $order */ public function update_status(OrderEvent $event) { $payzen = new Payzen(); if ($event->getOrder()->isPaid() && $payzen->isPaymentModuleFor($event->getOrder())) { $contact_email = ConfigQuery::read('store_email', false); Tlog::getInstance()->debug("Sending confirmation email from store contact e-mail {$contact_email}"); if ($contact_email) { $message = MessageQuery::create()->filterByName(Payzen::CONFIRMATION_MESSAGE_NAME)->findOne(); if (false === $message) { throw new \Exception(sprintf("Failed to load message '%s'.", Payzen::CONFIRMATION_MESSAGE_NAME)); } $order = $event->getOrder(); $customer = $order->getCustomer(); $this->parser->assign('order_id', $order->getId()); $this->parser->assign('order_ref', $order->getRef()); $message->setLocale($order->getLang()->getLocale()); $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name')); // Build subject and body $message->buildMessage($this->parser, $instance); $this->getMailer()->send($instance); Tlog::getInstance()->debug("Confirmation email sent to customer " . $customer->getEmail()); } } else { Tlog::getInstance()->debug("No confirmation email sent (order not paid, or not the proper payement module."); } }
/** * @param $areaId * @param $weight * * @return mixed * @throws DeliveryException */ public static function getPostageAmount($areaId, $weight) { $freeshipping = @(bool) ConfigQuery::read("predict_freeshipping"); $postage = 0; if (!$freeshipping) { $prices = static::getPrices(); /* check if Predict delivers the asked area */ if (!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) { throw new DeliveryException("Predict delivery unavailable for the chosen delivery country"); } $areaPrices = $prices[$areaId]["slices"]; ksort($areaPrices); /* check this weight is not too much */ end($areaPrices); $maxWeight = key($areaPrices); if ($weight > $maxWeight) { throw new DeliveryException(sprintf("Predict delivery unavailable for this cart weight (%s kg)", $weight)); } $postage = current($areaPrices); while (prev($areaPrices)) { if ($weight > key($areaPrices)) { break; } $postage = current($areaPrices); } } return $postage; }
protected function setUp() { // We have to shut down the "One domain for each lang feature" before tests, // to prevent 302 redirections during the tests. $this->isMultiDomainActivated = ConfigQuery::read('one_domain_foreach_lang'); ConfigQuery::write('one_domain_foreach_lang', false); }
/** * Process document and write the result in the document cache. * * When the original document is required, create either a symbolic link with the * original document in the cache dir, or copy it in the cache dir if it's not already done. * * This method updates the cache_file_path and file_url attributes of the event * * @param DocumentEvent $event Event * * @throws \Thelia\Exception\DocumentException * @throws \InvalidArgumentException , DocumentException */ public function processDocument(DocumentEvent $event) { $subdir = $event->getCacheSubdirectory(); $sourceFile = $event->getSourceFilepath(); if (null == $subdir || null == $sourceFile) { throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null"); } $originalDocumentPathInCache = $this->getCacheFilePath($subdir, $sourceFile, true); if (!file_exists($originalDocumentPathInCache)) { if (!file_exists($sourceFile)) { throw new DocumentException(sprintf("Source document file %s does not exists.", $sourceFile)); } $mode = ConfigQuery::read('original_document_delivery_mode', 'symlink'); if ($mode == 'symlink') { if (false == symlink($sourceFile, $originalDocumentPathInCache)) { throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($sourceFile), $subdir)); } } else { // mode = 'copy' if (false == @copy($sourceFile, $originalDocumentPathInCache)) { throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($sourceFile), $subdir)); } } } // Compute the document URL $documentUrl = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache)); // Update the event with file path and file URL $event->setDocumentPath($documentUrl); $event->setDocumentUrl(URL::getInstance()->absoluteUrl($documentUrl, null, URL::PATH_TO_FILE)); }
public function updateStatus(OrderEvent $event) { $order = $event->getOrder(); $socolissimo = new SoColissimo(); if ($order->isSent() && $order->getDeliveryModuleId() == $socolissimo->getModuleModel()->getId()) { $contact_email = ConfigQuery::read('store_email'); if ($contact_email) { $message = MessageQuery::create()->filterByName('mail_socolissimo')->findOne(); if (false === $message) { throw new \Exception("Failed to load message 'order_confirmation'."); } $order = $event->getOrder(); $customer = $order->getCustomer(); $this->parser->assign('customer_id', $customer->getId()); $this->parser->assign('order_ref', $order->getRef()); $this->parser->assign('order_date', $order->getCreatedAt()); $this->parser->assign('update_date', $order->getUpdatedAt()); $this->parser->assign('package', $order->getDeliveryRef()); $message->setLocale($order->getLang()->getLocale()); $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name')); // Build subject and body $message->buildMessage($this->parser, $instance); $this->mailer->send($instance); } } }
public function doRequest(GetResponseEvent $event) { if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) { return; } $prefix = ConfigQuery::read("back_office_path"); $defaultEnabled = intval(ConfigQuery::read("back_office_path_default_enabled", "1")); $pathInfo = $event->getRequest()->getPathInfo(); $url = $event->getRequest()->server->get('REQUEST_URI'); // Discard the default /admin URL $isValid = 1 !== $defaultEnabled && strpos($pathInfo, '/' . BackOfficePath::DEFAULT_THELIA_PREFIX) === 0 && $prefix !== null && $prefix !== ""; if ($isValid) { /** @var \Symfony\Component\Routing\RequestContext $context */ $context = $event->getKernel()->getContainer()->get('request.context'); $context->fromRequest($event->getRequest()); throw new NotFoundHttpException(); } // Check if the URL is an backOffice URL $isValid = strpos($pathInfo, '/' . $prefix) === 0 && $prefix !== null && $prefix !== ""; if ($isValid) { $newUrl = $this->replaceUrl($url, $prefix, BackOfficePath::DEFAULT_THELIA_PREFIX); $event->getRequest()->server->set('REQUEST_URI', $newUrl); $event->getRequest()->initialize($event->getRequest()->query->all(), $event->getRequest()->request->all(), $event->getRequest()->attributes->all(), $event->getRequest()->cookies->all(), $event->getRequest()->files->all(), $event->getRequest()->server->all(), $event->getRequest()->getContent()); } }
/** * this method returns an array ***Thanks cap'tain obvious \(^.^)/*** *-> * @return array */ public function buildArray() { // Find the address ... To find ! \m/ $zipcode = $this->getZipcode(); $city = $this->getCity(); $address = $this->getAddress(); $address = array("zipcode" => $zipcode, "city" => $city, "address" => "", "countrycode" => "FR"); if (empty($zipcode) || empty($city)) { $search = AddressQuery::create(); $customer = $this->securityContext->getCustomerUser(); if ($customer !== null) { $search->filterByCustomerId($customer->getId()); $search->filterByIsDefault("1"); } else { throw new \ErrorException("Customer not connected."); } $search = $search->findOne(); $address["zipcode"] = $search->getZipcode(); $address["city"] = $search->getCity(); $address["address"] = $search->getAddress1(); $address["countrycode"] = $search->getCountry()->getIsoalpha2(); } // Then ask the Web Service $request = new FindByAddress(); $request->setAddress($address["address"])->setZipCode($address["zipcode"])->setCity($address["city"])->setCountryCode($address["countrycode"])->setFilterRelay("1")->setRequestId(md5(microtime()))->setLang("FR")->setOptionInter("1")->setShippingDate(date("d/m/Y"))->setAccountNumber(ConfigQuery::read('socolissimo_login'))->setPassword(ConfigQuery::read('socolissimo_pwd')); try { $response = $request->exec(); } catch (InvalidArgumentException $e) { $response = array(); } catch (\SoapFault $e) { $response = array(); } return $response; }
public function updateStatus(OrderEvent $event) { $order = $event->getOrder(); $paidStatusId = OrderStatusQuery::create()->filterByCode(OrderStatus::CODE_PAID)->select('Id')->findOne(); if ($order->hasVirtualProduct() && $event->getStatus() == $paidStatusId) { $contact_email = ConfigQuery::read('store_email'); if ($contact_email) { $message = MessageQuery::create()->filterByName('mail_virtualproduct')->findOne(); if (false === $message) { throw new \Exception("Failed to load message 'mail_virtualproduct'."); } $order = $event->getOrder(); $customer = $order->getCustomer(); $this->parser->assign('customer_id', $customer->getId()); $this->parser->assign('order_id', $order->getId()); $this->parser->assign('order_ref', $order->getRef()); $this->parser->assign('order_date', $order->getCreatedAt()); $this->parser->assign('update_date', $order->getUpdatedAt()); $message->setLocale($order->getLang()->getLocale()); $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name')); // Build subject and body $message->buildMessage($this->parser, $instance); $this->mailer->send($instance); Tlog::getInstance()->debug("Virtual product download message sent to customer " . $customer->getEmail()); } else { $customer = $order->getCustomer(); Tlog::getInstance()->debug("Virtual product download message no contact email customer_id", $customer->getId()); } } }
public function postActivation(ConnectionInterface $con = null) { if (null === ConfigQuery::read(static::RESOURCE_PATH_CONFIG_NAME)) { $config = new Config(); $config->setHidden(0)->setSecured(0)->setName(static::RESOURCE_PATH_CONFIG_NAME)->setValue(__DIR__ . DS . "Resources")->getTranslation("fr_FR")->setTitle("Chemin de templates pour Thelia studio")->getConfig()->getTranslation("en_US")->setTitle("Templates path for Thelia studio"); $config->save(); } }
public function getPointInfo($point_id) { $req = new FindById(); $req->setId($point_id)->setLangue("FR")->setDate(date("d/m/Y"))->setAccountNumber(ConfigQuery::read('socolissimo_login'))->setPassword(ConfigQuery::read('socolissimo_pwd')); $response = $req->exec(); $response = new JsonResponse($response); return $response; }
protected function buildForm() { $form = $this->formBuilder; $definitions = [["id" => "company_name", "label" => $this->trans("Your company's name"), "constraints" => []], ["id" => "twitter_company_name", "label" => $this->trans("Your company's name on twitter"), "constraints" => [new Callback(["methods" => [[$this, "verifyValue"]]])]], ["id" => "twitter_creator_name", "label" => $this->trans("The creator's name on twitter"), "constraints" => [new Callback(["methods" => [[$this, "verifyValue"]]])]]]; foreach ($definitions as $field) { $value = ConfigQuery::read("opengraph_" . $field["id"], ""); $form->add($field["id"], "text", array("constraints" => $field["constraints"], "data" => $value, "label" => $field["label"], "label_attr" => array("for" => $field["id"])))->add("enable_sharing_buttons", "checkbox", array("label" => "Enable the sharing buttons", "label_attr" => ["for" => "enable_sharing_buttons", "help" => Translator::getInstance()->trans('Check if you want to activate the sharing buttons in the front office', [], OpenGraph::DOMAIN_NAME)], "required" => false, "constraints" => array(), "value" => OpenGraph::getConfigValue(OpenGraphConfigValue::ENABLE_SHARING_BUTTONS, 1))); } }
protected function buildForm() { $form = $this->formBuilder; $definitions = array(array("id" => "twitter", "label" => Translator::getInstance()->trans("Twitter username", array(), 'hooksocial')), array("id" => "facebook", "label" => Translator::getInstance()->trans("Facebook username", array(), 'hooksocial')), array("id" => "google", "label" => Translator::getInstance()->trans("Google + username", array(), 'hooksocial')), array("id" => "instagram", "label" => Translator::getInstance()->trans("Instagram username", array(), 'hooksocial')), array("id" => "pinterest", "label" => Translator::getInstance()->trans("Pinterest username", array(), 'hooksocial')), array("id" => "youtube", "label" => Translator::getInstance()->trans("Youtube URL", array(), 'hooksocial')), array("id" => "rss", "label" => Translator::getInstance()->trans("RSS URL", array(), 'hooksocial'))); foreach ($definitions as $field) { $value = ConfigQuery::read("hooksocial_" . $field["id"], ""); $form->add($field["id"], "text", array('data' => $value, 'label' => $field["label"], 'label_attr' => array('for' => $field["id"]))); } }
protected function buildForm() { parent::buildForm(); $this->formBuilder->remove("label")->remove("is_default")->add("auto_login", "integer")->add("email", "email", array("constraints" => array(new Constraints\NotBlank(), new Constraints\Email(), new Constraints\Callback(array("methods" => array(array($this, "verifyExistingEmail"))))), "label" => Translator::getInstance()->trans("Email Address"), "label_attr" => array("for" => "email")))->add("password", "password", array("constraints" => array(new Constraints\NotBlank(), new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4)))), "label" => Translator::getInstance()->trans("Password"), "label_attr" => array("for" => "password")))->add("password_confirm", "password", array("constraints" => array(new Constraints\NotBlank(), new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), new Constraints\Callback(array("methods" => array(array($this, "verifyPasswordField"))))), "label" => Translator::getInstance()->trans("Password confirmation"), "label_attr" => array("for" => "password_confirmation")))->add("newsletter", "checkbox", array("label" => Translator::getInstance()->trans('I would like to receive the newsletter or the latest news.'), "label_attr" => array("for" => "newsletter"), "required" => false)); //confirm email if (intval(ConfigQuery::read("customer_confirm_email", 0))) { $this->formBuilder->add("email_confirm", "email", array("constraints" => array(new Constraints\NotBlank(), new Constraints\Email(), new Constraints\Callback(array("methods" => array(array($this, "verifyEmailField"))))), "label" => Translator::getInstance()->trans("Confirm Email Address"), "label_attr" => array("for" => "email_confirm"))); } }
public function __construct($name, $title, $label, $default, $type) { $this->name = $name; $this->title = $title; $this->label = $label; $this->default = $default; $this->type = $type; $this->value = ConfigQuery::read($this->name, $this->default); }
public function beforeResponse(FilterResponseEvent $event) { $session = $event->getRequest()->getSession(); if (null !== ($id = $session->get("cart_use_cookie"))) { $response = $event->getResponse(); $response->headers->setCookie(new Cookie(ConfigQuery::read("cart.cookie_name", 'thelia_cart'), $id, time() + ConfigQuery::read("cart.cookie_lifetime", 60 * 60 * 24 * 365), '/')); $session->set("cart_use_cookie", null); } }
/** * Add the javascript script to manage comments * * @param HookRenderEvent $event */ public function jsComment(HookRenderEvent $event) { $allowedRef = explode(',', ConfigQuery::read('comment_ref_allowed', Comment::CONFIG_REF_ALLOWED)); if (in_array($this->getView(), $allowedRef)) { list($ref, $refId) = $this->getParams($event); $event->add($this->render("js.html", ['ref' => $ref, 'ref_id' => $refId])); $event->add($this->addJS('assets/js/comment.js')); } }
/** * @return string the path to the upload directory where files are stored, without final slash */ public function getUploadDir() { $uploadDir = ConfigQuery::read('documents_library_path'); if ($uploadDir === null) { $uploadDir = THELIA_LOCAL_DIR . 'media' . DS . 'documents'; } else { $uploadDir = THELIA_ROOT . $uploadDir; } return $uploadDir . DS . 'brand'; }
public function __construct($function) { $testMode = ConfigQuery::read('socolissimo_test_mode'); if ($testMode) { $url = ConfigQuery::read('socolissimo_url_test'); } else { $url = ConfigQuery::read('socolissimo_url_prod'); } parent::__construct($url, $function); }
/** * * in this function you add all the fields you need for your Form. * Form this you have to call add method on $this->formBuilder attribute : * * $this->formBuilder->add("name", "text") * ->add("email", "email", array( * "attr" => array( * "class" => "field" * ), * "label" => "email", * "constraints" => array( * new \Symfony\Component\Validator\Constraints\NotBlank() * ) * ) * ) * ->add('age', 'integer'); * * @return null */ protected function buildForm() { $account = ConfigQuery::read("store_exapaq_account"); if (!is_numeric($account)) { ConfigQuery::write("store_exapaq_account", 0); $account = 0; } $translator = Translator::getInstance(); $this->formBuilder->add("account_number", "integer", array("label" => $translator->trans("Account number", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "account_number"], "constraints" => [new NotBlank()], "required" => true, "data" => $account))->add("store_cellphone", "text", array("label" => $translator->trans("Store's cellphone", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "store_cellphone"], "required" => false, "data" => ConfigQuery::read("store_cellphone")))->add("predict_option", "checkbox", array("label" => $translator->trans("Predict SMS option", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "predict_option"], "required" => false, "data" => @(bool) ConfigQuery::read("store_predict_option"))); }
public function renderDefault(array $param = array()) { $data = array(); foreach (LangQuery::create()->find() as $lang) { $data[LangUrlForm::LANG_PREFIX . $lang->getId()] = $lang->getUrl(); } $langUrlForm = new LangUrlForm($this->getRequest(), 'form', $data); $this->getParserContext()->addForm($langUrlForm); return $this->render('languages', array_merge($param, array('lang_without_translation' => ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), 'one_domain_per_lang' => ConfigQuery::read("one_domain_foreach_lang", false)))); }
/** * @return mixed|\Thelia\Core\HttpFoundation\Response */ public function defaultAction() { if (null !== ($response = $this->checkAuth(AdminResources::SYSTEM_LOG, array(), AccessManager::VIEW))) { return $response; } // Hydrate the general configuration form $systemLogForm = $this->createForm(AdminForm::SYSTEM_LOG_CONFIGURATION, 'form', array('level' => ConfigQuery::read(Tlog::VAR_LEVEL, Tlog::DEFAULT_LEVEL), 'format' => ConfigQuery::read(Tlog::VAR_PREFIXE, Tlog::DEFAUT_PREFIXE), 'show_redirections' => ConfigQuery::read(Tlog::VAR_SHOW_REDIRECT, Tlog::DEFAUT_SHOW_REDIRECT), 'files' => ConfigQuery::read(Tlog::VAR_FILES, Tlog::DEFAUT_FILES), 'ip_addresses' => ConfigQuery::read(Tlog::VAR_IP, Tlog::DEFAUT_IP))); $this->getParserContext()->addForm($systemLogForm); return $this->renderTemplate(); }