Merge Master

This commit is contained in:
touffies
2013-10-07 11:50:20 +02:00
69 changed files with 1560 additions and 11105 deletions

View File

@@ -60,6 +60,13 @@ class Address extends BaseAction implements EventSubscriberInterface
$address->delete();
}
public function useDefault(AddressEvent $event)
{
$address = $event->getAddress();
$address->makeItDefault();
}
protected function createOrUpdate(AddressModel $addressModel, AddressCreateOrUpdateEvent $event)
{
$addressModel->setDispatcher($this->getDispatcher());
@@ -125,7 +132,8 @@ class Address extends BaseAction implements EventSubscriberInterface
return array(
TheliaEvents::ADDRESS_CREATE => array("create", 128),
TheliaEvents::ADDRESS_UPDATE => array("update", 128),
TheliaEvents::ADDRESS_DELETE => array("delete", 128)
TheliaEvents::ADDRESS_DELETE => array("delete", 128),
TheliaEvents::ADDRESS_DEFAULT => array('useDefault', 128),
);
}
}

View File

@@ -25,6 +25,7 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\Customer\CustomerAddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
@@ -148,11 +149,11 @@ class Customer extends BaseAction implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
TheliaEvents::CUSTOMER_CREATEACCOUNT => array("create", 128),
TheliaEvents::CUSTOMER_UPDATEACCOUNT => array("modify", 128),
TheliaEvents::CUSTOMER_LOGOUT => array("logout", 128),
TheliaEvents::CUSTOMER_LOGIN => array("login" , 128),
TheliaEvents::CUSTOMER_DELETEACCOUNT => array("delete", 128),
TheliaEvents::CUSTOMER_CREATEACCOUNT => array('create', 128),
TheliaEvents::CUSTOMER_UPDATEACCOUNT => array('modify', 128),
TheliaEvents::CUSTOMER_LOGOUT => array('logout', 128),
TheliaEvents::CUSTOMER_LOGIN => array('login', 128),
TheliaEvents::CUSTOMER_DELETEACCOUNT => array('delete', 128),
);
}
}

View File

@@ -0,0 +1,75 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\PdfEvent;
use Thelia\Core\Event\TheliaEvents;
/**
* Class Pdf
* @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Pdf extends BaseAction implements EventSubscriberInterface
{
public function generatePdf(PdfEvent $event)
{
$html2pdf = new \HTML2PDF($event->getOrientation(), $event->getFormat(), $event->getLang(), $event->getUnicode(), $event->getEncoding(), $event->getMarges());
$html2pdf->pdf->SetDisplayMode('real');
$html2pdf->writeHTML($event->getContent());
$event->setPdf($html2pdf->output(null, 'S'));
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::GENERATE_PDF => array("generatePdf", 128)
);
}
}

View File

@@ -28,6 +28,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Command\ContainerAwareCommand;
use Thelia\Install\CheckPermission;
use Thelia\Install\Database;
/**
@@ -82,6 +83,9 @@ class Install extends ContainerAwareCommand
'',
'Welcome to Thelia install process',
'You need information about your database configuration (host, username, password, database name, etc)',
'',
'<info>Caution : You are installing Thelia in cli mode, we verify some information, but this information are only available for the cli php sapi</info>',
'<info>This informations can be different in your apache or cgi php.ini files</info>',
''
));
@@ -136,40 +140,35 @@ class Install extends ContainerAwareCommand
"Checking some permissions"
));
$confDir = THELIA_ROOT . "local/config";
$cacheDir = THELIA_ROOT . "cache";
$logDir = THELIA_ROOT . "log";
$permissions = new CheckPermission(false, $this->getContainer()->get('thelia.translator'));
$isValid = $permissions->exec();
$conf = is_writable($confDir);
$cache = is_writable($cacheDir);
$log = is_writable($logDir);
foreach($permissions->getValidationMessages() as $item => $data) {
if($data['status']) {
$output->writeln(array(
sprintf("<info>%s ...</info> %s",
$data['text'],
"<info>Ok</info>")
)
);
} else {
$output->writeln(array(
sprintf("<error>%s </error>%s",
$data['text'],
sprintf("<error>%s</error>", $data["hint"])
)
));
}
$output->writeln(array(
sprintf(
"<info>config directory(%s)...</info> %s",
$confDir,
$conf ? "<info>Ok</info>" : "<error>Fail</error>"
),
sprintf(
"<info>cache directory(%s)...</info> %s"
,$cacheDir,
$cache ? "<info>Ok</info>" : "<error>Fail</error>"
),
sprintf(
"<info>log directory(%s)...</info> %s",
$logDir,
$log ? "<info>Ok</info>" : "<error>Fail</error>"
),
));
if ($conf === false || $cache === false || $log === false) {
$output->writeln(array(
"",
"<error>Please put correct permission and reload install process</error>"
));
exit;
}
if(false === $isValid) {
$output->writeln(array(
"",
"<error>Please put correct permissions and reload install process</error>"
));
exit;
}
}
/**

View File

@@ -111,6 +111,11 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.pdf" class="Thelia\Action\Pdf">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</config>

View File

@@ -123,6 +123,32 @@
<!-- end Customer rule management -->
<!-- address management -->
<route id="admin.address.delete" path="/admin/address/delete" methods="post">
<default key="_controller">Thelia\Controller\Admin\AddressController::deleteAction</default>
</route>
<route id="admin.address.makeItDefault" path="/admin/address/use" methods="post">
<default key="_controller">Thelia\Controller\Admin\AddressController::useAddressAction</default>
</route>
<route id="admin.address.create" path="/admin/address/create" methods="post">
<default key="_controller">Thelia\Controller\Admin\AddressController::createAction</default>
</route>
<route id="admin.address.update.view" path="/admin/address/update/{address_id}">
<default key="_controller">Thelia\Controller\Admin\AddressController::updateAction</default>
<requirement key="address_id">\d+</requirement>
</route>
<route id="admin.address.save" path="/admin/address/save/{address_id}">
<default key="_controller">Thelia\Controller\Admin\AddressController::processUpdateAction</default>
<requirement key="address_id">\d+</requirement>
</route>
<!-- end address management -->
<!-- order management -->
<route id="admin.order.list" path="/admin/orders">
@@ -150,6 +176,16 @@
<default key="_controller">Thelia\Controller\Admin\OrderController::updateAddress</default>
</route>
<route id="admin.order.pdf.invoice" path="/admin/order/pdf/invoice/{order_id}">
<default key="_controller">Thelia\Controller\Admin\OrderController::generateInvoicePdf</default>
<requirement key="order_id">\d+</requirement>
</route>
<route id="admin.order.pdf.invoice" path="/admin/order/pdf/delivery/{order_id}">
<default key="_controller">Thelia\Controller\Admin\OrderController::generateDeliveryPdf</default>
<requirement key="order_id">\d+</requirement>
</route>
<!-- end order management -->
<!-- Categories management -->
@@ -370,7 +406,7 @@
</route>
<!-- content routes management -->
<route id="admin.folders.create" path="/admin/content/create">
<route id="admin.content.create" path="/admin/content/create">
<default key="_controller">Thelia\Controller\Admin\ContentController::createAction</default>
</route>

View File

@@ -0,0 +1,306 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\Address\AddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\AddressCreateForm;
use Thelia\Form\AddressUpdateForm;
use Thelia\Model\AddressQuery;
use Thelia\Model\CustomerQuery;
/**
* Class AddressController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class AddressController extends AbstractCrudController
{
public function __construct()
{
parent::__construct(
'address',
null,
null,
'admin.customer.update.view',
'admin.address.create',
'admin.address.update',
'admin.address.delete',
TheliaEvents::ADDRESS_CREATE,
TheliaEvents::ADDRESS_UPDATE,
TheliaEvents::ADDRESS_DELETE,
null,
null
);
}
public function useAddressAction()
{
if (null !== $response = $this->checkAuth("admin.customer.update")) return $response;
$address_id = $this->getRequest()->request->get('address_id');
try {
$address = AddressQuery::create()->findPk($address_id);
if (null === $address) {
throw new \InvalidArgumentException(sprintf('%d address does not exists', $address_id));
}
$addressEvent = new AddressEvent($address);
$this->dispatch(TheliaEvents::ADDRESS_DEFAULT, $addressEvent);
$this->adminLogAppend(sprintf("address %d for customer %d removal", $address_id, $address->getCustomerId()));
} catch(\Exception $e) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during address removal with message %s", $e->getMessage()));
}
$this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId()));
}
/**
* Return the creation form for this object
*/
protected function getCreationForm()
{
return new AddressCreateForm($this->getRequest());
}
/**
* Return the update form for this object
*/
protected function getUpdateForm()
{
return new AddressUpdateForm($this->getRequest());
}
/**
* Hydrate the update form for this object, before passing it to the update template
*
* @param \Thelia\Model\Address $object
*/
protected function hydrateObjectForm($object)
{
$data = array(
"label" => $object->getLabel(),
"title" => $object->getTitleId(),
"firstname" => $object->getFirstname(),
"lastname" => $object->getLastname(),
"address1" => $object->getAddress1(),
"address2" => $object->getAddress2(),
"address3" => $object->getAddress3(),
"zipcode" => $object->getZipcode(),
"city" => $object->getCity(),
"country" => $object->getCountryId(),
"cellphone" => $object->getCellphone(),
"phone" => $object->getPhone(),
"company" => $object->getCompany()
);
return new AddressUpdateForm($this->getRequest(), "form", $data);
}
/**
* Creates the creation event with the provided form data
*
* @param unknown $formData
*/
protected function getCreationEvent($formData)
{
$event = $this->getCreateOrUpdateEvent($formData);
$customer = CustomerQuery::create()->findPk($this->getRequest()->get("customer_id"));
$event->setCustomer($customer);
return $event;
}
/**
* Creates the update event with the provided form data
*
* @param unknown $formData
*/
protected function getUpdateEvent($formData)
{
$event = $this->getCreateOrUpdateEvent($formData);
$event->setAddress($this->getExistingObject());
return $event;
}
protected function getCreateOrUpdateEvent($formData)
{
$event = new AddressCreateOrUpdateEvent(
$formData["label"],
$formData["title"],
$formData["firstname"],
$formData["lastname"],
$formData["address1"],
$formData["address2"],
$formData["address3"],
$formData["zipcode"],
$formData["city"],
$formData["country"],
$formData["cellphone"],
$formData["phone"],
$formData["company"],
$formData["is_default"]
);
return $event;
}
/**
* Creates the delete event with the provided form data
*/
protected function getDeleteEvent()
{
return new AddressEvent($this->getExistingObject());
}
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param unknown $event
*/
protected function eventContainsObject($event)
{
return null !== $event->getAddress();
}
/**
* Get the created object from an event.
*
* @param unknown $createEvent
*/
protected function getObjectFromEvent($event)
{
return null;
}
/**
* Load an existing object from the database
*/
protected function getExistingObject()
{
return AddressQuery::create()->findPk($this->getRequest()->get('address_id'));
}
/**
* Returns the object label form the object event (name, title, etc.)
*
* @param unknown $object
*/
protected function getObjectLabel($object)
{
return $object->getLabel();
}
/**
* Returns the object ID from the object
*
* @param unknown $object
*/
protected function getObjectId($object)
{
return $object->getId();
}
/**
* Render the main list template
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected function renderListTemplate($currentOrder)
{
// TODO: Implement renderListTemplate() method.
}
/**
* Render the edition template
*/
protected function renderEditionTemplate()
{
return $this->render('ajax/address-update-modal', array(
"address_id" => $this->getRequest()->get('address_id'),
"customer_id" => $this->getExistingObject()->getCustomerId()
));
}
/**
* Redirect to the edition template
*/
protected function redirectToEditionTemplate()
{
$address = $this->getExistingObject();
$this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId()));
}
/**
* Redirect to the list template
*/
protected function redirectToListTemplate()
{
// TODO: Implement redirectToListTemplate() method.
}
/**
* Put in this method post object delete processing if required.
*
* @param \Thelia\Core\Event\AddressEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalDeleteAction($deleteEvent)
{
$address = $deleteEvent->getAddress();
$this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId()));
}
/**
* Put in this method post object creation processing if required.
*
* @param AddressCreateOrUpdateEvent $createEvent the create event
* @return Response a response, or null to continue normal processing
*/
protected function performAdditionalCreateAction($createEvent)
{
$this->redirectToEditionTemplate();
}
protected function performAdditionalUpdateAction($event)
{
$this->redirectToEditionTemplate();
}
}

View File

@@ -51,7 +51,7 @@ class BaseAdminController extends BaseController
/**
* Helper to append a message to the admin log.
*
* @param unknown $message
* @param string $message
*/
public function adminLogAppend($message)
{
@@ -187,12 +187,12 @@ class BaseAdminController extends BaseController
/**
* @return a ParserInterface instance parser
*/
protected function getParser()
protected function getParser($template = null)
{
$parser = $this->container->get("thelia.parser");
// Define the template thant shoud be used
$parser->setTemplate(ConfigQuery::read('base_admin_template', 'admin/default'));
$parser->setTemplate($template ?: ConfigQuery::read('base_admin_template', 'admin/default'));
return $parser;
}
@@ -246,9 +246,9 @@ class BaseAdminController extends BaseController
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
*/
public function redirectToRoute($routeId, $urlParameters = array())
public function redirectToRoute($routeId, $urlParameters = array(), $routeParameters = array())
{
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters));
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, $routeParameters), $urlParameters));
}
/**
@@ -378,10 +378,12 @@ class BaseAdminController extends BaseController
* Render the given template, and returns the result as a string.
*
* @param $templateName the complete template name, with extension
* @param array $args the template arguments
* @param array $args the template arguments
* @param null $templateDir
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderRaw($templateName, $args = array())
protected function renderRaw($templateName, $args = array(), $templateDir = null)
{
// Add the template standard extension
@@ -417,7 +419,7 @@ class BaseAdminController extends BaseController
// Render the template.
try {
$data = $this->getParser()->render($templateName, $args);
$data = $this->getParser($templateDir)->render($templateName, $args);
return $data;
} catch (AuthenticationException $ex) {

View File

@@ -22,13 +22,17 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\Form\Form;
use Thelia\Core\Event\Address\AddressEvent;
use Thelia\Core\Event\Customer\CustomerAddressEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\CustomerModification;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\AddressQuery;
use Thelia\Model\CustomerQuery;
use Thelia\Core\Translation\Translator;
@@ -53,6 +57,8 @@ class CustomerController extends BaseAdminController
));
}
/**
* update customer action
*

View File

@@ -23,10 +23,13 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\PdfEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\OrderUpdateAddress;
use Thelia\Model\ConfigQuery;
use Thelia\Model\Base\OrderAddressQuery;
use Thelia\Model\OrderQuery;
use Thelia\Model\OrderStatusQuery;
@@ -193,4 +196,52 @@ class OrderController extends BaseAdminController
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params)));
}
public function generateInvoicePdf($order_id)
{
return $this->generatePdf($order_id, ConfigQuery::read('pdf_invoice_file', 'invoice'));
}
public function generateDeliveryPdf($order_id)
{
return $this->generatePdf($order_id, ConfigQuery::read('pdf_delivery_file', 'delivery'));
}
protected function generatePdf($order_id, $fileName)
{
if (null !== $response = $this->checkAuth("admin.order.update")) return $response;
$html = $this->renderRaw(
$fileName,
array(
'order_id' => $order_id
),
ConfigQuery::read('pdf_template', 'pdf')
);
$order = OrderQuery::create()->findPk($order_id);
try {
$pdfEvent = new PdfEvent($html);
$this->dispatch(TheliaEvents::GENERATE_PDF, $pdfEvent);
if($pdfEvent->hasPdf()) {
return Response::create($pdfEvent->getPdf(), 200,
array(
'Content-type' => "application/pdf",
'Content-Disposition' => sprintf('Attachment;filename=%s.pdf', $order->getRef()),
));
}
} catch (\Exception $e) {
\Thelia\Log\Tlog::getInstance()->error(sprintf('error during generating invoice pdf for order id : %d with message "%s"', $order_id, $e->getMessage()));
}
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", array(
'order_id' => $order_id
))));
}
}

View File

@@ -0,0 +1,193 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
/**
* Class PdfEvent
* @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class PdfEvent extends ActionEvent
{
protected $content;
protected $pdf;
protected $orientation;
protected $format;
protected $lang;
protected $unicode;
protected $encoding;
protected $marges;
/**
* @param $content html content to transform into pdf
* @param string $orientation page orientation, same as TCPDF
* @param string $format The format used for pages, same as TCPDF
* @param string $lang Lang : fr, en, it...
* @param bool $unicode TRUE means that the input text is unicode (default = true)
* @param string $encoding charset encoding; default is UTF-8
* @param array $marges Default marges (left, top, right, bottom)
*/
public function __construct($content, $orientation = 'P', $format = 'A4', $lang='fr', $unicode=true, $encoding='UTF-8',array $marges = array(0, 0, 0, 0))
{
$this->content = $content;
$this->orientation = $orientation;
$this->format = $format;
$this->lang = $lang;
$this->unicode = $unicode;
$this->encoding = $encoding;
$this->marges = $marges;
}
/**
* @param mixed $content
*/
public function setContent($content)
{
$this->content = $content;
}
/**
* @return mixed
*/
public function getContent()
{
return $this->content;
}
public function setPdf($pdf)
{
$this->pdf = $pdf;
}
public function getPdf()
{
return $this->pdf;
}
public function hasPdf()
{
return null !== $this->pdf;
}
/**
* @param mixed $encoding
*/
public function setEncoding($encoding)
{
$this->encoding = $encoding;
}
/**
* @return mixed
*/
public function getEncoding()
{
return $this->encoding;
}
/**
* @param mixed $format
*/
public function setFormat($format)
{
$this->format = $format;
}
/**
* @return mixed
*/
public function getFormat()
{
return $this->format;
}
/**
* @param mixed $lang
*/
public function setLang($lang)
{
$this->lang = $lang;
}
/**
* @return mixed
*/
public function getLang()
{
return $this->lang;
}
/**
* @param mixed $marges
*/
public function setMarges($marges)
{
$this->marges = $marges;
}
/**
* @return mixed
*/
public function getMarges()
{
return $this->marges;
}
/**
* @param mixed $orientation
*/
public function setOrientation($orientation)
{
$this->orientation = $orientation;
}
/**
* @return mixed
*/
public function getOrientation()
{
return $this->orientation;
}
/**
* @param mixed $unicode
*/
public function setUnicode($unicode)
{
$this->unicode = $unicode;
}
/**
* @return mixed
*/
public function getUnicode()
{
return $this->unicode;
}
}

View File

@@ -76,6 +76,11 @@ final class TheliaEvents
*/
const CUSTOMER_DELETEACCOUNT = "action.deleteCustomer";
/**
* sent on customer address removal
*/
const CUSTOMER_ADDRESS_DELETE = "action.customer.deleteAddress";
/**
* sent when a customer need a new password
*/
@@ -134,6 +139,11 @@ final class TheliaEvents
*/
const ADDRESS_DELETE = "action.deleteAddress";
/**
* sent when an address is tag as default
*/
const ADDRESS_DEFAULT = "action.defaultAddress";
const BEFORE_CREATEADDRESS = "action.before_createAddress";
const AFTER_CREATEADDRESS = "action.after_createAddress";
@@ -597,4 +607,6 @@ final class TheliaEvents
*/
const GENERATE_REWRITTENURL = 'action.generate_rewritenurl';
const GENERATE_PDF = 'thelia.generatePdf';
}

View File

@@ -72,7 +72,7 @@ class AsseticHelper
break;
case 'sass' :
$fm->set('less', new Filter\Sass\SassFilter());
$fm->set('sass', new Filter\Sass\SassFilter());
break;
case 'cssembed' :
@@ -87,6 +87,10 @@ class AsseticHelper
$fm->set('cssimport', new Filter\CssImportFilter());
break;
case 'compass':
$fm->set('compass', new Filter\CompassFilter());
break;
default :
throw new \InvalidArgumentException("Unsupported Assetic filter: '$filter_name'");
break;

View File

@@ -30,6 +30,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Security\SecurityContext;
use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Model\ConfigQuery;
use Thelia\Model\CategoryQuery;
use Thelia\Model\ContentQuery;
use Thelia\Model\CountryQuery;
@@ -234,6 +235,17 @@ class DataAccessFunctions extends AbstractSmartyPlugin
return $this->dataAccess("Lang", $params, $this->request->getSession()->getLang());
}
public function ConfigDataAccess($params, $smarty)
{
if(false === array_key_exists("key", $params)) {
return null;
}
$key = $params['key'];
return ConfigQuery::read($key);
}
/**
* @param $objectLabel
* @param $params
@@ -344,6 +356,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'),
new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'),
new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'),
new SmartyPluginDescriptor('function', 'config', $this, 'ConfigDataAccess'),
);
}

View File

@@ -45,6 +45,7 @@ class CheckPermission extends BaseInstall
const DIR_LOG = 'log';
const DIR_CACHE = 'cache';
const DIR_WEB = 'web';
const DIR_SESSION = 'local/session';
/** @var array Directory needed to be writable */
protected $directoriesToBeWritable = array(
@@ -52,11 +53,12 @@ class CheckPermission extends BaseInstall
self::DIR_LOG,
self::DIR_CACHE,
self::DIR_WEB,
self::DIR_SESSION,
);
/** @var array Minimum server configuration necessary */
protected $minServerConfigurationNecessary = array(
'memory_limit' => 134217728,
'memory_limit' => 157286400,
'post_max_size' => 20971520,
'upload_max_filesize' => 2097152
);
@@ -187,9 +189,9 @@ class CheckPermission extends BaseInstall
{
if ($this->translator !== null) {
if ($isValid) {
$sentence = 'Your directory <strong>%directory%</strong> is writable';
$sentence = 'Your directory %directory% is writable';
} else {
$sentence = 'Your directory <strong>%directory%</strong> is not writable';
$sentence = 'Your directory %directory% is not writable';
}
$translatedText = $this->translator->trans(
@@ -216,7 +218,7 @@ class CheckPermission extends BaseInstall
protected function getI18nDirectoryHint($directory)
{
if ($this->translator !== null) {
$sentence = '<span class="label label-primary">chmod 777 %directory%</span> on your server with admin rights could help';
$sentence = 'chmod 777 %directory% on your server with admin rights could help';
$translatedText = $this->translator->trans(
$sentence,
array(
@@ -246,9 +248,9 @@ class CheckPermission extends BaseInstall
protected function getI18nConfigText($key, $expectedValue, $currentValue, $isValid)
{
if ($isValid) {
$sentence = 'Your <span class="label label-primary">%key%</span> server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)';
$sentence = 'Your %key% server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)';
} else {
$sentence = 'Your <span class="label label-primary">%key%</span> server configuration (currently %currentValue%) is not sufficient enough in order to run Thelia2 (%expectedValue% needed)';
$sentence = 'Your %key% server configuration (currently %currentValue%) is not sufficient enough in order to run Thelia2 (%expectedValue% needed)';
}
$translatedText = $this->translator->trans(
@@ -271,7 +273,7 @@ class CheckPermission extends BaseInstall
*/
protected function getI18nConfigHint()
{
$sentence = 'Modifying this value on your server <span class="label label-primary">php.ini</span> file with admin rights could help';
$sentence = 'Modifying this value on your server php.ini file with admin rights could help';
$translatedText = $this->translator->trans(
$sentence,
array(),
@@ -294,9 +296,9 @@ class CheckPermission extends BaseInstall
{
if ($this->translator !== null) {
if ($isValid) {
$sentence = 'Your PHP version <span class="label label-primary">%currentValue%</span> is well enough to run Thelia2 (%expectedValue% needed)';
$sentence = 'Your PHP version %currentValue% is well enough to run Thelia2 (%expectedValue% needed)';
} else {
$sentence = 'Your PHP version <span class="label label-primary">%currentValue%</span> is not sufficient enough to run Thelia2 (%expectedValue% needed)';
$sentence = 'Your PHP version %currentValue% is not sufficient enough to run Thelia2 (%expectedValue% needed)';
}
$translatedText = $this->translator->trans(
@@ -343,6 +345,10 @@ class CheckPermission extends BaseInstall
{
$serverValueInBytes = $this->returnBytes(ini_get($key));
if($serverValueInBytes == -1) {
return true;
}
return ($serverValueInBytes >= $necessaryValueInBytes);
}

View File

@@ -40,21 +40,33 @@ class Database
/**
* Insert all sql needed in database
* Default insert /install/thelia.sql and /install/insert.sql
*
* @param $dbName
* @param string $dbName Database name
* @param array $extraSqlFiles SQL Files uri to insert
*/
public function insertSql($dbName = null)
public function insertSql($dbName = null, array $extraSqlFiles = null)
{
if($dbName) {
if ($dbName) {
$this->connection->query(sprintf("use %s", $dbName));
}
$sql = array();
$sql = array_merge(
$sql,
$this->prepareSql(file_get_contents(THELIA_ROOT . "/install/thelia.sql")),
$this->prepareSql(file_get_contents(THELIA_ROOT . "/install/insert.sql"))
);
if (null === $extraSqlFiles) {
$sql = array_merge(
$sql,
$this->prepareSql(file_get_contents(THELIA_ROOT . '/install/thelia.sql')),
$this->prepareSql(file_get_contents(THELIA_ROOT . '/install/insert.sql'))
);
} else {
foreach ($extraSqlFiles as $fileToInsert) {
$sql = array_merge(
$sql,
$this->prepareSql(file_get_contents($fileToInsert))
);
}
}
for ($i = 0; $i < count($sql); $i ++) {
if (!empty($sql[$i])) {
@@ -75,7 +87,7 @@ class Database
$sql = trim($sql);
$query = array();
$tab = explode(";", $sql);
$tab = explode(";\n", $sql);
for ($i=0; $i<count($tab); $i++) {
$queryTemp = str_replace("-CODE-", ";',", $tab[$i]);