Merge branch 'coupon' of https://github.com/thelia/thelia into coupon
# By Manuel Raynaud (80) and others # Via Etienne Roudeix (18) and others * 'coupon' of https://github.com/thelia/thelia: (179 commits) Working : coupon creation : Fix js Working : coupon creation : add default rule (thelia.constraint.rule.available_for_everyone) order tests action order tests cache dataccessfunctions order action test fire event on insert content in createmethod fix issue, default foler is set on content creation allow to create new content update default param of content model create content listener for crud management dispatch event in pre/post crud method for content model display content modification page create contentUpdateEvent create contentCreateEvent create ContentEvent create contentModificationForm create content controller change folder_id parm by parent in list folder view use placeholder in folder update route ...
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,7 +19,6 @@ local/media/documents/*
|
||||
local/media/images/*
|
||||
web/assets/*
|
||||
web/cache/*
|
||||
web/.htaccess
|
||||
phpdoc*.log
|
||||
php-cs
|
||||
xhprof/
|
||||
|
||||
@@ -35,10 +35,10 @@ Installation
|
||||
------------
|
||||
|
||||
``` bash
|
||||
$ git clone --recursive https://github.com/thelia/thelia.git
|
||||
$ git clone https://github.com/thelia/thelia.git
|
||||
$ cd thelia
|
||||
$ curl -sS https://getcomposer.org/installer | php
|
||||
$ php composer.phar install --optimize-autoloader
|
||||
$ php composer.phar install --prefer-dist --optimize-autoloader
|
||||
```
|
||||
|
||||
Finish the installation using cli tools :
|
||||
|
||||
178
core/lib/Thelia/Action/BaseCachedFile.php
Normal file
178
core/lib/Thelia/Action/BaseCachedFile.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?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\CachedFileEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* Cached file management actions. This class handles file caching in the web space
|
||||
*
|
||||
* Basically, files are stored outside the web space (by default in local/media/<dirname>),
|
||||
* and cached in the web space (by default in web/local/<dirname>).
|
||||
*
|
||||
* In the file cache directory, a subdirectory for files categories (eg. product, category, folder, etc.) is
|
||||
* automatically created, and the cached file is created here. Plugin may use their own subdirectory as required.
|
||||
*
|
||||
* A copy (or symbolic link, by default) of the original file is created in the cache.
|
||||
*
|
||||
* @package Thelia\Action
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
abstract class BaseCachedFile extends BaseAction
|
||||
{
|
||||
/**
|
||||
* @return string root of the file cache directory in web space
|
||||
*/
|
||||
protected abstract function getCacheDirFromWebRoot();
|
||||
|
||||
/**
|
||||
* Clear the file cache. Is a subdirectory is specified, only this directory is cleared.
|
||||
* If no directory is specified, the whole cache is cleared.
|
||||
* Only files are deleted, directories will remain.
|
||||
*
|
||||
* @param CachedFileEvent $event
|
||||
*/
|
||||
public function clearCache(CachedFileEvent $event)
|
||||
{
|
||||
$path = $this->getCachePath($event->getCacheSubdirectory(), false);
|
||||
|
||||
$this->clearDirectory($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively clears the specified directory.
|
||||
*
|
||||
* @param string $path the directory path
|
||||
*/
|
||||
protected function clearDirectory($path)
|
||||
{
|
||||
$iterator = new \DirectoryIterator($path);
|
||||
|
||||
foreach ($iterator as $fileinfo) {
|
||||
|
||||
if ($fileinfo->isDot()) continue;
|
||||
|
||||
if ($fileinfo->isFile() || $fileinfo->isLink()) {
|
||||
@unlink($fileinfo->getPathname());
|
||||
} elseif ($fileinfo->isDir()) {
|
||||
$this->clearDirectory($fileinfo->getPathname());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the absolute URL to the cached file
|
||||
*
|
||||
* @param string $subdir the subdirectory related to cache base
|
||||
* @param string $filename the safe filename, as returned by getCacheFilePath()
|
||||
* @return string the absolute URL to the cached file
|
||||
*/
|
||||
protected function getCacheFileURL($subdir, $safe_filename)
|
||||
{
|
||||
$path = $this->getCachePathFromWebRoot($subdir);
|
||||
|
||||
return URL::getInstance()->absoluteUrl(sprintf("%s/%s", $path, $safe_filename), null, URL::PATH_TO_FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the full path of the cached file
|
||||
*
|
||||
* @param string $subdir the subdirectory related to cache base
|
||||
* @param string $filename the filename
|
||||
* @param string $hashed_options a hash of transformation options, or null if no transformations have been applied
|
||||
* @param boolean $forceOriginalDocument if true, the original file path in the cache dir is returned.
|
||||
* @return string the cache directory path relative to Web Root
|
||||
*/
|
||||
protected function getCacheFilePath($subdir, $filename, $forceOriginalFile = false, $hashed_options = null)
|
||||
{
|
||||
$path = $this->getCachePath($subdir);
|
||||
|
||||
$safe_filename = preg_replace("[^:alnum:\-\._]", "-", strtolower(basename($filename)));
|
||||
|
||||
// Keep original safe name if no tranformations are applied
|
||||
if ($forceOriginalFile || $hashed_options == null)
|
||||
return sprintf("%s/%s", $path, $safe_filename);
|
||||
else
|
||||
return sprintf("%s/%s-%s", $path, $hashed_options, $safe_filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cache directory path relative to Web Root
|
||||
*
|
||||
* @param string $subdir the subdirectory related to cache base, or null to get the cache directory only.
|
||||
* @return string the cache directory path relative to Web Root
|
||||
*/
|
||||
protected function getCachePathFromWebRoot($subdir = null)
|
||||
{
|
||||
$cache_dir_from_web_root = $this->getCacheDirFromWebRoot();
|
||||
|
||||
if ($subdir != null) {
|
||||
$safe_subdir = basename($subdir);
|
||||
|
||||
$path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir);
|
||||
} else
|
||||
$path = $cache_dir_from_web_root;
|
||||
|
||||
// Check if path is valid, e.g. in the cache dir
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the absolute cache directory path
|
||||
*
|
||||
* @param string $subdir the subdirectory related to cache base, or null to get the cache base directory.
|
||||
* @throws \RuntimeException if cache directory cannot be created
|
||||
* @return string the absolute cache directory path
|
||||
*/
|
||||
protected function getCachePath($subdir = null, $create_if_not_exists = true)
|
||||
{
|
||||
$cache_base = $this->getCachePathFromWebRoot($subdir);
|
||||
|
||||
$web_root = rtrim(THELIA_WEB_DIR, '/');
|
||||
|
||||
$path = sprintf("%s/%s", $web_root, $cache_base);
|
||||
|
||||
// Create directory (recursively) if it does not exists.
|
||||
if ($create_if_not_exists && !is_dir($path)) {
|
||||
if (!@mkdir($path, 0777, true)) {
|
||||
throw new \RuntimeException(sprintf("Failed to create %s/%s file in cache directory", $cache_base));
|
||||
}
|
||||
}
|
||||
|
||||
// Check if path is valid, e.g. in the cache dir
|
||||
$cache_base = realpath(sprintf("%s/%s", $web_root, $this->getCachePathFromWebRoot()));
|
||||
|
||||
if (strpos(realpath($path), $cache_base) !== 0) {
|
||||
throw new \InvalidArgumentException(sprintf("Invalid cache path %s, with subdirectory %s", $path, $subdir));
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,10 @@ use Thelia\Core\Event\CategoryDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\CategoryAddContentEvent;
|
||||
use Thelia\Core\Event\CategoryDeleteContentEvent;
|
||||
use Thelia\Model\CategoryAssociatedContent;
|
||||
use Thelia\Model\CategoryAssociatedContentQuery;
|
||||
|
||||
class Category extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -147,6 +151,38 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addContent(CategoryAddContentEvent $event) {
|
||||
|
||||
if (CategoryAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByCategory($event->getCategory())->count() <= 0) {
|
||||
|
||||
$content = new CategoryAssociatedContent();
|
||||
|
||||
$content
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setCategory($event->getCategory())
|
||||
->setContentId($event->getContentId())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeContent(CategoryDeleteContentEvent $event) {
|
||||
|
||||
$content = CategoryAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByCategory($event->getCategory())->findOne()
|
||||
;
|
||||
|
||||
if ($content !== null) {
|
||||
$content
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -157,7 +193,12 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
TheliaEvents::CATEGORY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CATEGORY_DELETE => array("delete", 128),
|
||||
TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128)
|
||||
|
||||
TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
TheliaEvents::CATEGORY_ADD_CONTENT => array("addContent", 128),
|
||||
TheliaEvents::CATEGORY_REMOVE_CONTENT => array("removeContent", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
112
core/lib/Thelia/Action/Content.php
Normal file
112
core/lib/Thelia/Action/Content.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?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\Content\ContentCreateEvent;
|
||||
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\Content as ContentModel;
|
||||
use Thelia\Model\FolderQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class Content
|
||||
* @package Thelia\Action
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class Content extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
|
||||
public function create(ContentCreateEvent $event)
|
||||
{
|
||||
$content = new ContentModel();
|
||||
|
||||
$content
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->create($event->getDefaultFolder())
|
||||
;
|
||||
|
||||
$event->setContent($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* process update content
|
||||
*
|
||||
* @param ContentUpdateEvent $event
|
||||
*/
|
||||
public function update(ContentUpdateEvent $event)
|
||||
{
|
||||
if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) {
|
||||
$content->setDispatcher($this->getDispatcher());
|
||||
|
||||
$content
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setContent($content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::CONTENT_CREATE => array("create", 128),
|
||||
TheliaEvents::CONTENT_UPDATE => array("update", 128),
|
||||
TheliaEvents::CONTENT_DELETE => array("delete", 128),
|
||||
TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
|
||||
TheliaEvents::CONTENT_UPDATE_POSITION => array("updatePosition", 128),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Coupon\CouponFactory;
|
||||
use Thelia\Coupon\CouponManager;
|
||||
use Thelia\Coupon\CouponRuleCollection;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Model\Coupon as CouponModel;
|
||||
|
||||
@@ -137,11 +138,21 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$coupon->setDispatcher($this->getDispatcher());
|
||||
|
||||
// Set default rule if none found
|
||||
$noConditionRule = $this->container->get('thelia.constraint.rule.available_for_everyone');
|
||||
$constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
$couponRuleCollection = new CouponRuleCollection();
|
||||
$couponRuleCollection->add($noConditionRule);
|
||||
$defaultSerializedRule = $constraintFactory->serializeCouponRuleCollection(
|
||||
$couponRuleCollection
|
||||
);
|
||||
|
||||
|
||||
$coupon->createOrUpdate(
|
||||
$event->getCode(),
|
||||
$event->getTitle(),
|
||||
$event->getAmount(),
|
||||
$event->getEffect(),
|
||||
$event->getType(),
|
||||
$event->isRemovingPostage(),
|
||||
$event->getShortDescription(),
|
||||
$event->getDescription(),
|
||||
@@ -150,9 +161,12 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$event->isAvailableOnSpecialOffers(),
|
||||
$event->isCumulative(),
|
||||
$event->getMaxUsage(),
|
||||
$defaultSerializedRule,
|
||||
$event->getLocale()
|
||||
);
|
||||
|
||||
|
||||
|
||||
$event->setCoupon($coupon);
|
||||
}
|
||||
|
||||
|
||||
139
core/lib/Thelia/Action/Document.php
Normal file
139
core/lib/Thelia/Action/Document.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?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\DocumentEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
use Imagine\Document\ImagineInterface;
|
||||
use Imagine\Document\DocumentInterface;
|
||||
use Imagine\Document\Box;
|
||||
use Imagine\Document\Color;
|
||||
use Imagine\Document\Point;
|
||||
use Thelia\Exception\DocumentException;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
/**
|
||||
*
|
||||
* Document management actions. This class handles document processing an caching.
|
||||
*
|
||||
* Basically, documents are stored outside the web space (by default in local/media/documents),
|
||||
* and cached in the web space (by default in web/local/documents).
|
||||
*
|
||||
* In the documents caches directory, a subdirectory for documents categories (eg. product, category, folder, etc.) is
|
||||
* automatically created, and the cached document is created here. Plugin may use their own subdirectory as required.
|
||||
*
|
||||
* The cached document name contains a hash of the processing options, and the original (normalized) name of the document.
|
||||
*
|
||||
* A copy (or symbolic link, by default) of the original document is always created in the cache, so that the full
|
||||
* resolution document is always available.
|
||||
*
|
||||
* Various document processing options are available :
|
||||
*
|
||||
* - resizing, with border, crop, or by keeping document aspect ratio
|
||||
* - rotation, in degrees, positive or negative
|
||||
* - background color, applyed to empty background when creating borders or rotating
|
||||
* - effects. The effects are applied in the specified order. The following effects are available:
|
||||
* - gamma:value : change the document Gamma to the specified value. Example: gamma:0.7
|
||||
* - grayscale or greyscale: switch document to grayscale
|
||||
* - colorize:color : apply a color mask to the document. Exemple: colorize:#ff2244
|
||||
* - negative : transform the document in its negative equivalent
|
||||
* - vflip or vertical_flip : vertical flip
|
||||
* - hflip or horizontal_flip : horizontal flip
|
||||
*
|
||||
* If a problem occurs, an DocumentException may be thrown.
|
||||
*
|
||||
* @package Thelia\Action
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
class Document extends BaseCachedFile implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @return string root of the document cache directory in web space
|
||||
*/
|
||||
protected function getCacheDirFromWebRoot() {
|
||||
return ConfigQuery::read('document_cache_dir_from_web_root', 'cache');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws \InvalidArgumentException, DocumentException
|
||||
*/
|
||||
public function processDocument(DocumentEvent $event)
|
||||
{
|
||||
$subdir = $event->getCacheSubdirectory();
|
||||
$source_file = $event->getSourceFilepath();
|
||||
|
||||
if (null == $subdir || null == $source_file) {
|
||||
throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null");
|
||||
}
|
||||
|
||||
$originalDocumentPathInCache = $this->getCacheFilePath($subdir, $source_file, true);
|
||||
|
||||
if (! file_exists($originalDocumentPathInCache)) {
|
||||
|
||||
if (! file_exists($source_file)) {
|
||||
throw new DocumentException(sprintf("Source document file %s does not exists.", $source_file));
|
||||
}
|
||||
|
||||
$mode = ConfigQuery::read('original_document_delivery_mode', 'symlink');
|
||||
|
||||
if ($mode == 'symlink') {
|
||||
if (false == symlink($source_file, $originalDocumentPathInCache)) {
|
||||
throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($source_file), $subdir));
|
||||
}
|
||||
} else {// mode = 'copy'
|
||||
if (false == @copy($source_file, $originalDocumentPathInCache)) {
|
||||
throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($source_file), $subdir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute the document URL
|
||||
$document_url = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache));
|
||||
|
||||
// Update the event with file path and file URL
|
||||
$event->setDocumentPath($originalDocumentPathInCache);
|
||||
$event->setDocumentUrl(URL::getInstance()->absoluteUrl($document_url, null, URL::PATH_TO_FILE));
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::DOCUMENT_PROCESS => array("processDocument", 128),
|
||||
TheliaEvents::DOCUMENT_CLEAR_CACHE => array("clearCache", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
155
core/lib/Thelia/Action/Folder.php
Normal file
155
core/lib/Thelia/Action/Folder.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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\FolderCreateEvent;
|
||||
use Thelia\Core\Event\FolderDeleteEvent;
|
||||
use Thelia\Core\Event\FolderToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\FolderUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\Folder as FolderModel;
|
||||
|
||||
|
||||
/**
|
||||
* Class Folder
|
||||
* @package Thelia\Action
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class Folder extends BaseAction implements EventSubscriberInterface {
|
||||
|
||||
|
||||
public function update(FolderUpdateEvent $event)
|
||||
{
|
||||
|
||||
if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) {
|
||||
$folder->setDispatcher($this->getDispatcher());
|
||||
|
||||
$folder
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
->save();
|
||||
;
|
||||
|
||||
$event->setFolder($folder);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(FolderDeleteEvent $event)
|
||||
{
|
||||
if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) {
|
||||
$folder->setDispatcher($this->getDispatcher())
|
||||
->delete();
|
||||
|
||||
$event->setFolder($folder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FolderCreateEvent $event
|
||||
*/
|
||||
public function create(FolderCreateEvent $event)
|
||||
{
|
||||
$folder = new FolderModel();
|
||||
$folder->setDispatcher($this->getDispatcher());
|
||||
|
||||
$folder
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->save();
|
||||
|
||||
$event->setFolder($folder);
|
||||
}
|
||||
|
||||
public function toggleVisibility(FolderToggleVisibilityEvent $event)
|
||||
{
|
||||
$folder = $event->getFolder();
|
||||
|
||||
$folder
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible(!$folder->getVisible())
|
||||
->save();
|
||||
|
||||
}
|
||||
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if(null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) {
|
||||
$folder->setDispatcher($this->getDispatcher());
|
||||
|
||||
switch($event->getMode())
|
||||
{
|
||||
case UpdatePositionEvent::POSITION_ABSOLUTE:
|
||||
$folder->changeAbsolutePosition($event->getPosition());
|
||||
break;
|
||||
case UpdatePositionEvent::POSITION_DOWN:
|
||||
$folder->movePositionDown();
|
||||
break;
|
||||
case UpdatePositionEvent::POSITION_UP:
|
||||
$folder->movePositionUp();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::FOLDER_CREATE => array("create", 128),
|
||||
TheliaEvents::FOLDER_UPDATE => array("update", 128),
|
||||
TheliaEvents::FOLDER_DELETE => array("delete", 128),
|
||||
TheliaEvents::FOLDER_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
|
||||
TheliaEvents::FOLDER_UPDATE_POSITION => array("updatePosition", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ use Thelia\Core\Event\TheliaEvents;
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
class Image extends BaseAction implements EventSubscriberInterface
|
||||
class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
{
|
||||
// Resize mode constants
|
||||
const EXACT_RATIO_WITH_BORDERS = 1;
|
||||
@@ -79,38 +79,10 @@ class Image extends BaseAction implements EventSubscriberInterface
|
||||
const KEEP_IMAGE_RATIO = 3;
|
||||
|
||||
/**
|
||||
* Clear the image cache. Is a subdirectory is specified, only this directory is cleared.
|
||||
* If no directory is specified, the whole cache is cleared.
|
||||
* Only files are deleted, directories will remain.
|
||||
*
|
||||
* @param ImageEvent $event
|
||||
* @return string root of the image cache directory in web space
|
||||
*/
|
||||
public function clearCache(ImageEvent $event)
|
||||
{
|
||||
$path = $this->getCachePath($event->getCacheSubdirectory(), false);
|
||||
|
||||
$this->clearDirectory($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively clears the specified directory.
|
||||
*
|
||||
* @param string $path the directory path
|
||||
*/
|
||||
protected function clearDirectory($path)
|
||||
{
|
||||
$iterator = new \DirectoryIterator($path);
|
||||
|
||||
foreach ($iterator as $fileinfo) {
|
||||
|
||||
if ($fileinfo->isDot()) continue;
|
||||
|
||||
if ($fileinfo->isFile() || $fileinfo->isLink()) {
|
||||
@unlink($fileinfo->getPathname());
|
||||
} elseif ($fileinfo->isDir()) {
|
||||
$this->clearDirectory($fileinfo->getPathname());
|
||||
}
|
||||
}
|
||||
protected function getCacheDirFromWebRoot() {
|
||||
return ConfigQuery::read('image_cache_dir_from_web_root', 'cache');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,9 +110,9 @@ class Image extends BaseAction implements EventSubscriberInterface
|
||||
// echo basename($source_file).": ";
|
||||
|
||||
// Find cached file path
|
||||
$cacheFilePath = $this->getCacheFilePath($subdir, $source_file, $event);
|
||||
$cacheFilePath = $this->getCacheFilePath($subdir, $source_file, $event->isOriginalImage(), $event->getOptionsHash());
|
||||
|
||||
$originalImagePathInCache = $this->getCacheFilePath($subdir, $source_file, $event, true);
|
||||
$originalImagePathInCache = $this->getCacheFilePath($subdir, $source_file, true);
|
||||
|
||||
if (! file_exists($cacheFilePath)) {
|
||||
|
||||
@@ -257,7 +229,7 @@ class Image extends BaseAction implements EventSubscriberInterface
|
||||
// Compute the image URL
|
||||
$processed_image_url = $this->getCacheFileURL($subdir, basename($cacheFilePath));
|
||||
|
||||
// compute the full resulution image path in cache
|
||||
// compute the full resolution image path in cache
|
||||
$original_image_url = $this->getCacheFileURL($subdir, basename($originalImagePathInCache));
|
||||
|
||||
// Update the event with file path and file URL
|
||||
@@ -359,94 +331,6 @@ class Image extends BaseAction implements EventSubscriberInterface
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the absolute URL to the cached image
|
||||
*
|
||||
* @param string $subdir the subdirectory related to cache base
|
||||
* @param string $filename the safe filename, as returned by getCacheFilePath()
|
||||
* @return string the absolute URL to the cached image
|
||||
*/
|
||||
protected function getCacheFileURL($subdir, $safe_filename)
|
||||
{
|
||||
$path = $this->getCachePathFromWebRoot($subdir);
|
||||
|
||||
return URL::getInstance()->absoluteUrl(sprintf("%s/%s", $path, $safe_filename), null, URL::PATH_TO_FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the full path of the cached file
|
||||
*
|
||||
* @param string $subdir the subdirectory related to cache base
|
||||
* @param string $filename the filename
|
||||
* @param boolean $forceOriginalImage if true, the origiunal image path in the cache dir is returned.
|
||||
* @return string the cache directory path relative to Web Root
|
||||
*/
|
||||
protected function getCacheFilePath($subdir, $filename, ImageEvent $event, $forceOriginalImage = false)
|
||||
{
|
||||
$path = $this->getCachePath($subdir);
|
||||
|
||||
$safe_filename = preg_replace("[^:alnum:\-\._]", "-", strtolower(basename($filename)));
|
||||
|
||||
// Keep original safe name if no tranformations are applied
|
||||
if ($forceOriginalImage || $event->isOriginalImage())
|
||||
return sprintf("%s/%s", $path, $safe_filename);
|
||||
else
|
||||
return sprintf("%s/%s-%s", $path, $event->getOptionsHash(), $safe_filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cache directory path relative to Web Root
|
||||
*
|
||||
* @param string $subdir the subdirectory related to cache base, or null to get the cache directory only.
|
||||
* @return string the cache directory path relative to Web Root
|
||||
*/
|
||||
protected function getCachePathFromWebRoot($subdir = null)
|
||||
{
|
||||
$cache_dir_from_web_root = ConfigQuery::read('image_cache_dir_from_web_root', 'cache');
|
||||
|
||||
if ($subdir != null) {
|
||||
$safe_subdir = basename($subdir);
|
||||
|
||||
$path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir);
|
||||
} else
|
||||
$path = $cache_dir_from_web_root;
|
||||
|
||||
// Check if path is valid, e.g. in the cache dir
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the absolute cache directory path
|
||||
*
|
||||
* @param string $subdir the subdirectory related to cache base, or null to get the cache base directory.
|
||||
* @throws \RuntimeException if cache directory cannot be created
|
||||
* @return string the absolute cache directory path
|
||||
*/
|
||||
protected function getCachePath($subdir = null, $create_if_not_exists = true)
|
||||
{
|
||||
$cache_base = $this->getCachePathFromWebRoot($subdir);
|
||||
|
||||
$web_root = rtrim(THELIA_WEB_DIR, '/');
|
||||
|
||||
$path = sprintf("%s/%s", $web_root, $cache_base);
|
||||
|
||||
// Create directory (recursively) if it does not exists.
|
||||
if ($create_if_not_exists && !is_dir($path)) {
|
||||
if (!@mkdir($path, 0777, true)) {
|
||||
throw new ImageException(sprintf("Failed to create %s/%s image cache directory", $cache_base));
|
||||
}
|
||||
}
|
||||
|
||||
// Check if path is valid, e.g. in the cache dir
|
||||
$cache_base = realpath(sprintf("%s/%s", $web_root, $this->getCachePathFromWebRoot()));
|
||||
|
||||
if (strpos(realpath($path), $cache_base) !== 0) {
|
||||
throw new \InvalidArgumentException(sprintf("Invalid cache path %s, with subdirectory %s", $path, $subdir));
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Imagine object using current driver configuration
|
||||
*
|
||||
|
||||
350
core/lib/Thelia/Action/Order.php
Executable file
350
core/lib/Thelia/Action/Order.php
Executable file
@@ -0,0 +1,350 @@
|
||||
<?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 Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\OrderProductAttributeCombination;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\OrderProduct;
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Model\Map\OrderTableMap;
|
||||
use Thelia\Model\OrderAddress;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\I18n;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class Order
|
||||
* @package Thelia\Action
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Order extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setDeliveryAddress(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->chosenDeliveryAddress = $event->getDeliveryAddress();
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setDeliveryModule(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->setDeliveryModuleId($event->getDeliveryModule());
|
||||
$order->setPostage($event->getPostage());
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setInvoiceAddress(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->chosenInvoiceAddress = $event->getInvoiceAddress();
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setPaymentModule(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->setPaymentModuleId($event->getPaymentModule());
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function create(OrderEvent $event)
|
||||
{
|
||||
$con = \Propel\Runtime\Propel::getConnection(
|
||||
OrderTableMap::DATABASE_NAME
|
||||
);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
$sessionOrder = $event->getOrder();
|
||||
|
||||
/* use a copy to avoid errored reccord in session */
|
||||
$placedOrder = $sessionOrder->copy();
|
||||
$placedOrder->setDispatcher($this->getDispatcher());
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$currency = $this->getSession()->getCurrency();
|
||||
$lang = $this->getSession()->getLang();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress);
|
||||
$taxCountry = $deliveryAddress->getCountry();
|
||||
$invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress);
|
||||
$cart = $this->getSession()->getCart();
|
||||
$cartItems = $cart->getCartItems();
|
||||
|
||||
$paymentModule = ModuleQuery::create()->findPk($placedOrder->getPaymentModuleId());
|
||||
|
||||
/* fulfill order */
|
||||
$placedOrder->setCustomerId($customer->getId());
|
||||
$placedOrder->setCurrencyId($currency->getId());
|
||||
$placedOrder->setCurrencyRate($currency->getRate());
|
||||
$placedOrder->setLangId($lang->getId());
|
||||
|
||||
/* hard save the delivery and invoice addresses */
|
||||
$deliveryOrderAddress = new OrderAddress();
|
||||
$deliveryOrderAddress
|
||||
->setCustomerTitleId($deliveryAddress->getTitleId())
|
||||
->setCompany($deliveryAddress->getCompany())
|
||||
->setFirstname($deliveryAddress->getFirstname())
|
||||
->setLastname($deliveryAddress->getLastname())
|
||||
->setAddress1($deliveryAddress->getAddress1())
|
||||
->setAddress2($deliveryAddress->getAddress2())
|
||||
->setAddress3($deliveryAddress->getAddress3())
|
||||
->setZipcode($deliveryAddress->getZipcode())
|
||||
->setCity($deliveryAddress->getCity())
|
||||
->setPhone($deliveryAddress->getPhone())
|
||||
->setCountryId($deliveryAddress->getCountryId())
|
||||
->save($con)
|
||||
;
|
||||
|
||||
$invoiceOrderAddress = new OrderAddress();
|
||||
$invoiceOrderAddress
|
||||
->setCustomerTitleId($invoiceAddress->getTitleId())
|
||||
->setCompany($invoiceAddress->getCompany())
|
||||
->setFirstname($invoiceAddress->getFirstname())
|
||||
->setLastname($invoiceAddress->getLastname())
|
||||
->setAddress1($invoiceAddress->getAddress1())
|
||||
->setAddress2($invoiceAddress->getAddress2())
|
||||
->setAddress3($invoiceAddress->getAddress3())
|
||||
->setZipcode($invoiceAddress->getZipcode())
|
||||
->setCity($invoiceAddress->getCity())
|
||||
->setPhone($invoiceAddress->getPhone())
|
||||
->setCountryId($invoiceAddress->getCountryId())
|
||||
->save($con)
|
||||
;
|
||||
|
||||
$placedOrder->setDeliveryOrderAddressId($deliveryOrderAddress->getId());
|
||||
$placedOrder->setInvoiceOrderAddressId($invoiceOrderAddress->getId());
|
||||
|
||||
$placedOrder->setStatusId(
|
||||
OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_NOT_PAID)->getId()
|
||||
);
|
||||
|
||||
$placedOrder->save($con);
|
||||
|
||||
/* fulfill order_products and decrease stock */
|
||||
|
||||
foreach($cartItems as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
|
||||
/* get translation */
|
||||
$productI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Product', $product->getId());
|
||||
|
||||
$pse = $cartItem->getProductSaleElements();
|
||||
|
||||
/* check still in stock */
|
||||
if($cartItem->getQuantity() > $pse->getQuantity()) {
|
||||
throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem);
|
||||
}
|
||||
|
||||
/* decrease stock */
|
||||
$pse->setQuantity(
|
||||
$pse->getQuantity() - $cartItem->getQuantity()
|
||||
);
|
||||
$pse->save($con);
|
||||
|
||||
/* get tax */
|
||||
$taxRuleI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'TaxRule', $product->getTaxRuleId());
|
||||
|
||||
$taxDetail = $product->getTaxRule()->getTaxDetail(
|
||||
$taxCountry,
|
||||
$cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice(),
|
||||
$this->getSession()->getLang()->getLocale()
|
||||
);
|
||||
|
||||
$orderProduct = new OrderProduct();
|
||||
$orderProduct
|
||||
->setOrderId($placedOrder->getId())
|
||||
->setProductRef($product->getRef())
|
||||
->setProductSaleElementsRef($pse->getRef())
|
||||
->setTitle($productI18n->getTitle())
|
||||
->setChapo($productI18n->getChapo())
|
||||
->setDescription($productI18n->getDescription())
|
||||
->setPostscriptum($productI18n->getPostscriptum())
|
||||
->setQuantity($cartItem->getQuantity())
|
||||
->setPrice($cartItem->getPrice())
|
||||
->setPromoPrice($cartItem->getPromoPrice())
|
||||
->setWasNew($pse->getNewness())
|
||||
->setWasInPromo($cartItem->getPromo())
|
||||
->setWeight($pse->getWeight())
|
||||
->setTaxRuleTitle($taxRuleI18n->getTitle())
|
||||
->setTaxRuleDescription($taxRuleI18n->getDescription())
|
||||
;
|
||||
$orderProduct->setDispatcher($this->getDispatcher());
|
||||
$orderProduct->save($con);
|
||||
|
||||
/* fulfill order_product_tax */
|
||||
foreach($taxDetail as $tax) {
|
||||
$tax->setOrderProductId($orderProduct->getId());
|
||||
$tax->save($con);
|
||||
}
|
||||
|
||||
/* fulfill order_attribute_combination and decrease stock */
|
||||
foreach($pse->getAttributeCombinations() as $attributeCombination) {
|
||||
$attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId());
|
||||
$attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId());
|
||||
|
||||
$orderAttributeCombination = new OrderProductAttributeCombination();
|
||||
$orderAttributeCombination
|
||||
->setOrderProductId($orderProduct->getId())
|
||||
->setAttributeTitle($attribute->getTitle())
|
||||
->setAttributeChapo($attribute->getChapo())
|
||||
->setAttributeDescription($attribute->getDescription())
|
||||
->setAttributePostscriptumn($attribute->getPostscriptum())
|
||||
->setAttributeAvTitle($attributeAv->getTitle())
|
||||
->setAttributeAvChapo($attributeAv->getChapo())
|
||||
->setAttributeAvDescription($attributeAv->getDescription())
|
||||
->setAttributeAvPostscriptum($attributeAv->getPostscriptum())
|
||||
;
|
||||
|
||||
$orderAttributeCombination->save($con);
|
||||
}
|
||||
}
|
||||
|
||||
/* discount @todo */
|
||||
|
||||
$con->commit();
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder));
|
||||
|
||||
/* clear session */
|
||||
/* but memorize placed order */
|
||||
$sessionOrder = new \Thelia\Model\Order();
|
||||
$event->setOrder($sessionOrder);
|
||||
$event->setPlacedOrder($placedOrder);
|
||||
$this->getSession()->setOrder($sessionOrder);
|
||||
|
||||
/* empty cart @todo */
|
||||
|
||||
/* call pay method */
|
||||
$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
$paymentModuleInstance = $paymentModuleReflection->newInstance();
|
||||
|
||||
$paymentModuleInstance->setRequest($this->getRequest());
|
||||
$paymentModuleInstance->setDispatcher($this->getDispatcher());
|
||||
|
||||
$paymentModuleInstance->pay($placedOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function sendOrderEmail(OrderEvent $event)
|
||||
{
|
||||
/* @todo */
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::ORDER_SET_DELIVERY_ADDRESS => array("setDeliveryAddress", 128),
|
||||
TheliaEvents::ORDER_SET_DELIVERY_MODULE => array("setDeliveryModule", 128),
|
||||
TheliaEvents::ORDER_SET_INVOICE_ADDRESS => array("setInvoiceAddress", 128),
|
||||
TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128),
|
||||
TheliaEvents::ORDER_PAY => array("create", 128),
|
||||
TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the security context
|
||||
*
|
||||
* @return SecurityContext
|
||||
*/
|
||||
protected function getSecurityContext()
|
||||
{
|
||||
return $this->container->get('thelia.securityContext');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected function getRequest()
|
||||
{
|
||||
return $this->container->get('request');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the session from the current request
|
||||
*
|
||||
* @return \Thelia\Core\HttpFoundation\Session\Session
|
||||
*/
|
||||
protected function getSession()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
return $request->getSession();
|
||||
}
|
||||
}
|
||||
271
core/lib/Thelia/Action/Product.php
Normal file
271
core/lib/Thelia/Action/Product.php
Normal file
@@ -0,0 +1,271 @@
|
||||
<?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\Model\ProductQuery;
|
||||
use Thelia\Model\Product as ProductModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\ProductUpdateEvent;
|
||||
use Thelia\Core\Event\ProductCreateEvent;
|
||||
use Thelia\Core\Event\ProductDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\ProductToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\ProductAddContentEvent;
|
||||
use Thelia\Core\Event\ProductDeleteContentEvent;
|
||||
use Thelia\Model\ProductAssociatedContent;
|
||||
use Thelia\Model\ProductAssociatedContentQuery;
|
||||
use Thelia\Model\ProductCategory;
|
||||
use Thelia\Model\TaxRule;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
use Thelia\Model\TaxQuery;
|
||||
use Thelia\Model\AccessoryQuery;
|
||||
use Thelia\Model\Accessory;
|
||||
use Thelia\Core\Event\ProductAddAccessoryEvent;
|
||||
use Thelia\Core\Event\ProductDeleteAccessoryEvent;
|
||||
|
||||
class Product extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new product entry
|
||||
*
|
||||
* @param ProductCreateEvent $event
|
||||
*/
|
||||
public function create(ProductCreateEvent $event)
|
||||
{
|
||||
$product = new ProductModel();
|
||||
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setRef($event->getRef())
|
||||
->setTitle($event->getTitle())
|
||||
->setLocale($event->getLocale())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
// Set the default tax rule to this product
|
||||
->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true))
|
||||
|
||||
->create($event->getDefaultCategory())
|
||||
;
|
||||
|
||||
$event->setProduct($product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product
|
||||
*
|
||||
* @param ProductUpdateEvent $event
|
||||
*/
|
||||
public function update(ProductUpdateEvent $event)
|
||||
{
|
||||
$search = ProductQuery::create();
|
||||
|
||||
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
|
||||
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setProduct($product);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product entry
|
||||
*
|
||||
* @param ProductDeleteEvent $event
|
||||
*/
|
||||
public function delete(ProductDeleteEvent $event)
|
||||
{
|
||||
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
|
||||
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setProduct($product);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle product visibility. No form used here
|
||||
*
|
||||
* @param ActionEvent $event
|
||||
*/
|
||||
public function toggleVisibility(ProductToggleVisibilityEvent $event)
|
||||
{
|
||||
$product = $event->getProduct();
|
||||
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible($product->getVisible() ? false : true)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param ProductChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $product = ProductQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$product->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $product->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $product->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $product->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
public function addContent(ProductAddContentEvent $event) {
|
||||
|
||||
if (ProductAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByProduct($event->getProduct())->count() <= 0) {
|
||||
|
||||
$content = new ProductAssociatedContent();
|
||||
|
||||
$content
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setProduct($event->getProduct())
|
||||
->setContentId($event->getContentId())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeContent(ProductDeleteContentEvent $event) {
|
||||
|
||||
$content = ProductAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByProduct($event->getProduct())->findOne()
|
||||
;
|
||||
|
||||
if ($content !== null)
|
||||
$content
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
}
|
||||
|
||||
public function addAccessory(ProductAddAccessoryEvent $event) {
|
||||
|
||||
if (AccessoryQuery::create()
|
||||
->filterByAccessory($event->getAccessoryId())
|
||||
->filterByProductId($event->getProduct()->getId())->count() <= 0) {
|
||||
|
||||
$accessory = new Accessory();
|
||||
|
||||
$accessory
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setProductId($event->getProduct()->getId())
|
||||
->setAccessory($event->getAccessoryId())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAccessory(ProductDeleteAccessoryEvent $event) {
|
||||
|
||||
$accessory = AccessoryQuery::create()
|
||||
->filterByAccessory($event->getAccessoryId())
|
||||
->filterByProductId($event->getProduct()->getId())->findOne()
|
||||
;
|
||||
|
||||
if ($accessory !== null)
|
||||
$accessory
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param ProductChangePositionEvent $event
|
||||
*/
|
||||
public function updateAccessoryPosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $accessory = AccessoryQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$accessory->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $accessory->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $accessory->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $accessory->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::PRODUCT_CREATE => array("create", 128),
|
||||
TheliaEvents::PRODUCT_UPDATE => array("update", 128),
|
||||
TheliaEvents::PRODUCT_DELETE => array("delete", 128),
|
||||
TheliaEvents::PRODUCT_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_ADD_CONTENT => array("addContent", 128),
|
||||
TheliaEvents::PRODUCT_REMOVE_CONTENT => array("removeContent", 128),
|
||||
TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION => array("updateAccessoryPosition", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128),
|
||||
TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -139,4 +139,6 @@ trait CartTrait
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
abstract public function getDispatcher();
|
||||
}
|
||||
|
||||
@@ -62,18 +62,26 @@ class CacheClear extends ContainerAwareCommand
|
||||
|
||||
$this->clearCache($cacheDir, $output);
|
||||
if (!$input->getOption("without-assets")) {
|
||||
$this->clearCache(THELIA_WEB_DIR . "/assets", $output);
|
||||
$this->clearCache(THELIA_WEB_DIR . "assets", $output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function clearCache($dir, OutputInterface $output)
|
||||
{
|
||||
if (!is_writable($dir)) {
|
||||
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $dir));
|
||||
$output->writeln(sprintf("Clearing cache in <info>%s</info> directory", $dir));
|
||||
|
||||
try {
|
||||
$directoryBrowser = new \DirectoryIterator($dir);
|
||||
} catch(\UnexpectedValueException $e) {
|
||||
// throws same exception code for does not exist and permission denied ...
|
||||
if(!file_exists($dir)) {
|
||||
$output->writeln(sprintf("<info>%s cache dir already clear</info>", $dir));
|
||||
return;
|
||||
}
|
||||
|
||||
$output->writeln(sprintf("Clearing cache in <info>%s</info> directory", $dir));
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$fs = new Filesystem();
|
||||
try {
|
||||
@@ -81,7 +89,7 @@ class CacheClear extends ContainerAwareCommand
|
||||
|
||||
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
|
||||
} catch (IOException $e) {
|
||||
$output->writeln(sprintf("error during clearing cache : %s", $e->getMessage()));
|
||||
$output->writeln(sprintf("Error during clearing cache : %s", $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
core/lib/Thelia/Command/ModuleActivateCommand.php
Executable file
90
core/lib/Thelia/Command/ModuleActivateCommand.php
Executable file
@@ -0,0 +1,90 @@
|
||||
<?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\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Filesystem\Exception\IOException;
|
||||
|
||||
use Thelia\Command\ContainerAwareCommand;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
/**
|
||||
* activates a module
|
||||
*
|
||||
* Class ModuleActivateCommand
|
||||
* @package Thelia\Command
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ModuleActivateCommand extends BaseModuleGenerate
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("module:activate")
|
||||
->setDescription("Activates a module")
|
||||
->addArgument(
|
||||
"module" ,
|
||||
InputArgument::REQUIRED,
|
||||
"module to activate"
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$moduleCode = $this->formatModuleName($input->getArgument("module"));
|
||||
|
||||
$module = ModuleQuery::create()->findOneByCode($moduleCode);
|
||||
|
||||
if(null === $module) {
|
||||
throw new \RuntimeException(sprintf("module %s not found", $moduleCode));
|
||||
}
|
||||
|
||||
try {
|
||||
new \TheliaDebugBar\TheliaDebugBar();
|
||||
|
||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
||||
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->activate();
|
||||
} catch(\Exception $e) {
|
||||
throw new \RuntimeException(sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage()));
|
||||
}
|
||||
|
||||
//impossible to change output class in CommandTester...
|
||||
if (method_exists($output, "renderBlock")) {
|
||||
$output->renderBlock(array(
|
||||
'',
|
||||
sprintf("Activation succeed for module %s", $moduleCode),
|
||||
''
|
||||
), "bg=green;fg=black");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,13 @@ class ReloadDatabaseCommand extends BaseModuleGenerate
|
||||
$connection = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
||||
$connection = $connection->getWrappedConnection();
|
||||
|
||||
$tables = $connection->query("SHOW TABLES");
|
||||
$connection->query("SET FOREIGN_KEY_CHECKS = 0");
|
||||
foreach($tables as $table) {
|
||||
$connection->query(sprintf("DROP TABLE `%s`", $table[0]));
|
||||
}
|
||||
$connection->query("SET FOREIGN_KEY_CHECKS = 1");
|
||||
|
||||
$database = new Database($connection);
|
||||
$output->writeln(array(
|
||||
'',
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.order" class="Thelia\Action\Order">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.customer" class="Thelia\Action\Customer">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
@@ -37,6 +42,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.product" class="Thelia\Action\Product">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.config" class="Thelia\Action\Config">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
@@ -87,6 +97,16 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.folder" class="Thelia\Action\Folder">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.content" class="Thelia\Action\Content">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
</services>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -18,18 +18,21 @@
|
||||
<loop class="Thelia\Core\Template\Loop\Currency" name="currency"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Customer" name="customer"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Feature" name="feature"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureAvailability" name="feature_availability"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureAvailability" name="feature-availability"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureValue" name="feature_value"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Folder" name="folder"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Module" name="module"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Order" name="order"/>
|
||||
<loop class="Thelia\Core\Template\Loop\OrderStatus" name="order-status"/>
|
||||
<loop class="Thelia\Core\Template\Loop\CategoryPath" name="category-path"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Payment" name="payment"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Product" name="product"/>
|
||||
<loop class="Thelia\Core\Template\Loop\ProductSaleElements" name="product_sale_elements"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Feed" name="feed"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Title" name="title"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Lang" name="lang"/>
|
||||
<loop class="Thelia\Core\Template\Loop\CategoryTree" name="category-tree"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FolderTree" name="folder-tree"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Cart" name="cart"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Image" name="image"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Config" name="config"/>
|
||||
@@ -37,9 +40,12 @@
|
||||
<loop class="Thelia\Core\Template\Loop\Message" name="message"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Delivery" name="delivery"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Template" name="template"/> <!-- This is product templates ;-) -->
|
||||
<loop class="Thelia\Core\Template\Loop\TaxRule" name="tax-rule"/>
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<form name="thelia.install.step3" class="Thelia\Form\InstallStep3Form"/>
|
||||
|
||||
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
|
||||
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
|
||||
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
|
||||
@@ -53,11 +59,23 @@
|
||||
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
|
||||
<form name="thelia.admin.category.modification" class="Thelia\Form\CategoryModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||
<form name="thelia.admin.product.modification" class="Thelia\Form\ProductModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||
<form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.folder.creation" class="Thelia\Form\FolderCreationForm"/>
|
||||
<form name="thelia.admin.folder.modification" class="Thelia\Form\FolderModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.content.creation" class="Thelia\Form\ContentCreationForm"/>
|
||||
<form name="thelia.admin.content.modification" class="Thelia\Form\ContentModificationForm"/>
|
||||
|
||||
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
|
||||
|
||||
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>
|
||||
<form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/>
|
||||
|
||||
<form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/>
|
||||
<form name="thelia.admin.config.modification" class="Thelia\Form\ConfigModificationForm"/>
|
||||
|
||||
@@ -85,6 +103,8 @@
|
||||
<form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/>
|
||||
<form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/>
|
||||
|
||||
</forms>
|
||||
|
||||
|
||||
@@ -95,6 +115,7 @@
|
||||
<command class="Thelia\Command\ModuleGenerateCommand"/>
|
||||
<command class="Thelia\Command\ModuleGenerateModelCommand"/>
|
||||
<command class="Thelia\Command\ModuleGenerateSqlCommand"/>
|
||||
<command class="Thelia\Command\ModuleActivateCommand"/>
|
||||
<command class="Thelia\Command\CreateAdminUser"/>
|
||||
<command class="Thelia\Command\ReloadDatabaseCommand"/>
|
||||
</commands>
|
||||
@@ -201,6 +222,7 @@
|
||||
|
||||
<service id="smarty.plugin.security" class="Thelia\Core\Template\Smarty\Plugins\Security" scope="request">
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
<argument type="service" id="request" />
|
||||
<argument type="service" id="thelia.securityContext" />
|
||||
</service>
|
||||
|
||||
@@ -209,6 +231,7 @@
|
||||
<argument type="service" id="request" />
|
||||
<argument type="service" id="thelia.securityContext" />
|
||||
<argument type="service" id="thelia.parser.context"/>
|
||||
<argument type="service" id="event_dispatcher"/>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.adminUtilities" class="Thelia\Core\Template\Smarty\Plugins\AdminUtilities" scope="request">
|
||||
|
||||
@@ -56,17 +56,6 @@
|
||||
<tag name="router.register" priority="0"/>
|
||||
</service>
|
||||
|
||||
<service id="router.install" class="%router.class%">
|
||||
<argument type="service" id="router.xmlLoader"/>
|
||||
<argument>install.xml</argument>
|
||||
<argument type="collection">
|
||||
<argument key="cache_dir">%kernel.cache_dir%</argument>
|
||||
<argument key="debug">%kernel.debug%</argument>
|
||||
</argument>
|
||||
<argument type="service" id="request.context"/>
|
||||
<tag name="router.register" priority="-1"/>
|
||||
</service>
|
||||
|
||||
<service id="router.front" class="%router.class%">
|
||||
<argument type="service" id="router.xmlLoader"/>
|
||||
<argument>front.xml</argument>
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\SessionController::checkLoginAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Route to edit admin profile -->
|
||||
<route id="admin.profile.update.view" path="/admin/profile/update" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdminController::updateAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
|
||||
<!-- Route to the catalog controller -->
|
||||
|
||||
@@ -95,34 +101,168 @@
|
||||
<route id="admin.categories.update-position" path="/admin/categories/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.categories.related-content.add" path="/admin/categories/related-content/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::addRelatedContentAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.categories.related-content.delete" path="/admin/categories/related-content/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::deleteRelatedContentAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.category.available-related-content" path="/admin/category/{categoryId}/available-related-content/{folderId}.{_format}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::getAvailableRelatedContentAction</default>
|
||||
<requirement key="_format">xml|json</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.category.ajax" path="/admin/catalog/category/parent/{parentId}.{_format}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::getByParentIdAction</default>
|
||||
<requirement key="_format">xml|json</requirement>
|
||||
</route>
|
||||
|
||||
<!-- Product Management -->
|
||||
|
||||
<route id="admin.products.default" path="/admin/products">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.create" path="/admin/products/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.update" path="/admin/products/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.save" path="/admin/products/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.set-default" path="/admin/products/toggle-online">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::setToggleVisibilityAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.delete" path="/admin/products/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.update-position" path="/admin/products/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Related content -->
|
||||
|
||||
<route id="admin.products.related-content.add" path="/admin/products/related-content/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::addRelatedContentAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.related-content.delete" path="/admin/products/related-content/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::deleteRelatedContentAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.product.available-related-content" path="/admin/product/{productId}/available-related-content/{folderId}.{_format}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::getAvailableRelatedContentAction</default>
|
||||
<requirement key="_format">xml|json</requirement>
|
||||
</route>
|
||||
|
||||
<!-- Product accessories -->
|
||||
|
||||
<route id="admin.products.accessories.add" path="/admin/products/accessory/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::addAccessoryAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.accessories.delete" path="/admin/products/accessory/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::deleteAccessoryAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.product.accessories-content" path="/admin/product/{productId}/available-accessories/{categoryId}.{_format}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::getAvailableAccessoriesAction</default>
|
||||
<requirement key="_format">xml|json</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.update-accessory-position" path="/admin/products/update-accessory-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateAccessoryPositionAction</default>
|
||||
</route>
|
||||
|
||||
<!--Features and attributes -->
|
||||
|
||||
<route id="admin.products.update-attributes-and-features" path="/admin/product/{productId}/update-attributes-and-features">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateAttributesAndFeaturesAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- Folder routes management -->
|
||||
<route id="admin.folders.default" path="/admin/folders">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.create" path="/admin/folders/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.update" path="/admin/folders/update/{folder_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::updateAction</default>
|
||||
<requirement key="folder_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.toggle-online" path="/admin/folders/toggle-online">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::setToggleVisibilityAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.save" path="/admin/folders/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.delete" path="/admin/folders/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.update-position" path="/admin/folders/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<!-- content routes management -->
|
||||
<route id="admin.folders.create" path="/admin/content/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\ContentController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.content.update" path="admin/content/update/{content_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\ContentController::updateAction</default>
|
||||
<requirement key="content_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.content.save" path="/admin/content/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\ContentController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- Route to the Coupon controller (process Coupon browsing) -->
|
||||
|
||||
<route id="admin.coupon.list" path="/admin/coupon/">
|
||||
<route id="admin.coupon.list" path="/admin/coupon">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::browseAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.create" path="/admin/coupon/create/">
|
||||
<route id="admin.coupon.create" path="/admin/coupon/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::createAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.update" path="/admin/coupon/update/{couponId}/">
|
||||
<route id="admin.coupon.update" path="/admin/coupon/update/{couponId}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::updateAction</default>
|
||||
<requirement key="couponId">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.coupon.read" path="/admin/coupon/read/{couponId}/">
|
||||
<route id="admin.coupon.read" path="/admin/coupon/read/{couponId}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::readAction</default>
|
||||
<requirement key="couponId">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.coupon.rule.input" path="/admin/coupon/rule/{ruleId}/">
|
||||
<route id="admin.coupon.rule.input" path="/admin/coupon/rule/{ruleId}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::getRuleInputAction</default>
|
||||
<requirement key="ruleId">.*</requirement>
|
||||
</route>
|
||||
<route id="admin.coupon.rule.update" path="/admin/coupon/{couponId}/rule/update/">
|
||||
<route id="admin.coupon.rule.update" path="/admin/coupon/{couponId}/rule/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::updateRulesAction</default>
|
||||
<requirement key="couponId">\d+</requirement>
|
||||
</route>
|
||||
<route id="admin.coupon.consume" path="/admin/coupon/consume/{couponCode}/">
|
||||
<route id="admin.coupon.consume" path="/admin/coupon/consume/{couponCode}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::consumeAction</default>
|
||||
<requirement key="couponCode">.*</requirement>
|
||||
</route>
|
||||
|
||||
<!-- Routes to the Config (system variables) controller -->
|
||||
@@ -333,6 +473,33 @@
|
||||
|
||||
<!-- end countries routes management -->
|
||||
|
||||
<!-- Shipping zones routes management -->
|
||||
|
||||
<route id="admin.configuration.shipping-zones.default" path="/admin/configuration/shipping_zones">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-zones.update.view" path="/admin/configuration/shipping_zones/update/{shipping_zones_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::updateAction</default>
|
||||
<requirement key="shipping_zones_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end shipping routes management -->
|
||||
|
||||
<!-- Shipping zones routes management -->
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.default" path="/admin/configuration/shipping_configuration">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.update.view" path="/admin/configuration/shipping_configuration/update/{shipping_configuration_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::updateAction</default>
|
||||
<requirement key="shipping_configuration_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end shipping routes management -->
|
||||
|
||||
|
||||
<!-- feature and features value management -->
|
||||
|
||||
<route id="admin.configuration.features.default" path="/admin/configuration/features">
|
||||
@@ -390,6 +557,15 @@
|
||||
|
||||
<!-- end feature and feature routes management -->
|
||||
|
||||
<!-- Modules rule management -->
|
||||
|
||||
<route id="admin.module" path="/admin/modules">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end Modules rule management -->
|
||||
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
<route id="admin.processTemplate" path="/admin/{template}">
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.add.process" path="/cart/add">
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::addItem</default>
|
||||
</route>
|
||||
@@ -114,9 +115,33 @@
|
||||
<!-- end cart routes -->
|
||||
|
||||
<!-- order management process -->
|
||||
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>
|
||||
<requirement key="delivery_id">\d+</requirement>
|
||||
<route id="order.delivery.process" path="/order/delivery" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::deliver</default>
|
||||
<default key="_view">order_delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="order.delivery" path="/order/delivery">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">order_delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice.process" path="/order/invoice" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::invoice</default>
|
||||
<default key="_view">order_invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice" path="/order/invoice">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">order_invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.payment.process" path="/order/pay">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
|
||||
</route>
|
||||
|
||||
<route id="order.placed" path="/order/placed/{order_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::orderPlaced</default>
|
||||
<default key="_view">order_placed</default>
|
||||
</route>
|
||||
<!-- end order management process -->
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="install.step1" path="/install" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::index</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step2" path="/install/step/2" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::checkPermission</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step3" path="/install/step/3" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::databaseConnection</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step4" path="/install/step/4" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::databaseSelection</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step5" path="/install/step/5" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::generalInformation</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step6" path="/install/thanks" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::thanks</default>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
@@ -224,7 +224,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
* @param unknown $updateEvent the update event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateeEvent)
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -492,9 +492,6 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
|
||||
$changeEvent = $this->createToggleVisibilityEvent($this->getRequest());
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent->setIsDefault(true);
|
||||
|
||||
try {
|
||||
$this->dispatch($this->visibilityToggleEventIdentifier, $changeEvent);
|
||||
} catch (\Exception $ex) {
|
||||
@@ -502,7 +499,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToListTemplate();
|
||||
return $this->nullResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,4 +33,9 @@ class AdminController extends BaseAdminController
|
||||
{
|
||||
return $this->render("home");
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
return $this->render("profile-edit");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,13 @@ use Thelia\Form\CategoryModificationForm;
|
||||
use Thelia\Form\CategoryCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\CategoryDeleteContentEvent;
|
||||
use Thelia\Core\Event\CategoryAddContentEvent;
|
||||
use Thelia\Model\CategoryAssociatedContent;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Model\CategoryAssociatedContentQuery;
|
||||
|
||||
/**
|
||||
* Manages categories
|
||||
@@ -126,7 +133,7 @@ class CategoryController extends AbstractCrudController
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewritenUrl($this->getCurrentEditionLocale()),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'parent' => $object->getParent()
|
||||
);
|
||||
|
||||
@@ -152,24 +159,26 @@ class CategoryController extends AbstractCrudController
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'category_id' => $this->getRequest()->get('category_id', 0),
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder) {
|
||||
|
||||
// Get product order
|
||||
$product_order = $this->getListOrderFromSession('product', 'product_order', 'manual');
|
||||
|
||||
return $this->render('categories',
|
||||
array(
|
||||
'category_order' => $currentOrder,
|
||||
'product_order' => $product_order,
|
||||
'category_id' => $this->getRequest()->get('category_id', 0)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate() {
|
||||
return $this->render('category-edit', array('category_id' => $this->getRequest()->get('category_id', 0)));
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate() {
|
||||
$this->redirectToRoute(
|
||||
"admin.categories.update",
|
||||
array('category_id' => $this->getRequest()->get('category_id', 0))
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate() {
|
||||
@@ -179,6 +188,15 @@ class CategoryController extends AbstractCrudController
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate() {
|
||||
|
||||
return $this->render('category-edit', $this->getEditionArguments());
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate() {
|
||||
$this->redirectToRoute("admin.categories.update", $this->getEditionArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Online status toggle category
|
||||
*/
|
||||
@@ -209,6 +227,18 @@ class CategoryController extends AbstractCrudController
|
||||
);
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
if ($this->getRequest()->get('save_mode') != 'stay') {
|
||||
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $updateEvent->getCategory()->getParent())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdatePositionAction($event)
|
||||
{
|
||||
|
||||
@@ -224,4 +254,81 @@ class CategoryController extends AbstractCrudController
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAvailableRelatedContentAction($categoryId, $folderId) {
|
||||
|
||||
$result = array();
|
||||
|
||||
$folders = FolderQuery::create()->filterById($folderId)->find();
|
||||
|
||||
if ($folders !== null) {
|
||||
|
||||
$list = ContentQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByFolder($folders, Criteria::IN)
|
||||
->filterById(CategoryAssociatedContentQuery::create()->select('content_id')->findByCategoryId($categoryId), Criteria::NOT_IN)
|
||||
->find();
|
||||
;
|
||||
|
||||
if ($list !== null) {
|
||||
foreach($list as $item) {
|
||||
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->jsonResponse(json_encode($result));
|
||||
}
|
||||
|
||||
public function addRelatedContentAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
$content_id = intval($this->getRequest()->get('content_id'));
|
||||
|
||||
if ($content_id > 0) {
|
||||
|
||||
$event = new CategoryAddContentEvent(
|
||||
$this->getExistingObject(),
|
||||
$content_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteRelatedContentAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
$content_id = intval($this->getRequest()->get('content_id'));
|
||||
|
||||
if ($content_id > 0) {
|
||||
|
||||
$event = new CategoryDeleteContentEvent(
|
||||
$this->getExistingObject(),
|
||||
$content_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
289
core/lib/Thelia/Controller/Admin/ContentController.php
Normal file
289
core/lib/Thelia/Controller/Admin/ContentController.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?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\Content\ContentCreateEvent;
|
||||
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\ContentCreationForm;
|
||||
use Thelia\Form\ContentModificationForm;
|
||||
use Thelia\Model\ContentQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentController extends AbstractCrudController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'content',
|
||||
'manual',
|
||||
'content_order',
|
||||
|
||||
'admin.content.default',
|
||||
'admin.content.create',
|
||||
'admin.content.update',
|
||||
'admin.content.delete',
|
||||
|
||||
TheliaEvents::CONTENT_CREATE,
|
||||
TheliaEvents::CONTENT_UPDATE,
|
||||
TheliaEvents::CONTENT_DELETE,
|
||||
TheliaEvents::CONTENT_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::CONTENT_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the creation form for this object
|
||||
*/
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new ContentCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the update form for this object
|
||||
*/
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new ContentModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate the update form for this object, before passing it to the update template
|
||||
*
|
||||
* @param \Thelia\Form\ContentModificationForm $object
|
||||
*/
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new ContentModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the creation event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$contentCreateEvent = new ContentCreateEvent();
|
||||
|
||||
$contentCreateEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setDefaultFolder($formData['default_folder'])
|
||||
->setTitle($formData['title'])
|
||||
->setVisible($formData['visible'])
|
||||
;
|
||||
|
||||
return $contentCreateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the update event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$contentUpdateEvent = new ContentUpdateEvent($formData['id']);
|
||||
|
||||
$contentUpdateEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setDefaultFolder($formData['default_folder']);
|
||||
|
||||
return $contentUpdateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the delete event with the provided form data
|
||||
*/
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
// TODO: Implement getDeleteEvent() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the event contains the object, e.g. the action has updated the object in the event.
|
||||
*
|
||||
* @param \Thelia\Core\Event\Content\ContentEvent $event
|
||||
*/
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the created object from an event.
|
||||
*
|
||||
* @param $event \Thelia\Core\Event\Content\ContentEvent
|
||||
*
|
||||
* @return null|\Thelia\Model\Content
|
||||
*/
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an existing object from the database
|
||||
*
|
||||
* @return \Thelia\Model\Content
|
||||
*/
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return ContentQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('content_id', 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object label form the object event (name, title, etc.)
|
||||
*
|
||||
* @param $object \Thelia\Model\Content
|
||||
*
|
||||
* @return string content title
|
||||
*
|
||||
*/
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object ID from the object
|
||||
*
|
||||
* @param $object \Thelia\Model\Content
|
||||
*
|
||||
* @return int content id
|
||||
*/
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getFolderId()
|
||||
{
|
||||
$folderId = $this->getRequest()->get('folder_id', null);
|
||||
|
||||
if(null === $folderId) {
|
||||
$content = $this->getExistingObject();
|
||||
|
||||
if($content) {
|
||||
$folderId = $content->getDefaultFolderId();
|
||||
}
|
||||
}
|
||||
|
||||
return $folderId ?: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the main list template
|
||||
*
|
||||
* @param unknown $currentOrder, if any, null otherwise.
|
||||
*/
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
$this->getListOrderFromSession('content', 'content_order', 'manual');
|
||||
|
||||
return $this->render('folders',
|
||||
array(
|
||||
'content_order' => $currentOrder,
|
||||
'parent' => $this->getFolderId()
|
||||
));
|
||||
}
|
||||
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'content_id' => $this->getRequest()->get('content_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the edition template
|
||||
*/
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render('content-edit', $this->getEditionArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the edition template
|
||||
*/
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirect($this->getRoute('admin.content.update', $this->getEditionArguments()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the list template
|
||||
*/
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
'admin.content.default',
|
||||
array('parent' => $this->getFolderId())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent
|
||||
* @return Response|void
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
if ($this->getRequest()->get('save_mode') != 'stay') {
|
||||
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $this->getFolderId())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,13 +78,13 @@ class CouponController extends BaseAdminController
|
||||
|
||||
$args['urlReadCoupon'] = $this->getRoute(
|
||||
'admin.coupon.read',
|
||||
array('couponId' => 'couponId'),
|
||||
array('couponId' => 0),
|
||||
Router::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
$args['urlEditCoupon'] = $this->getRoute(
|
||||
'admin.coupon.update',
|
||||
array('couponId' => 'couponId'),
|
||||
array('couponId' => 0),
|
||||
Router::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
@@ -164,7 +164,7 @@ class CouponController extends BaseAdminController
|
||||
|
||||
$args['dateFormat'] = $this->getSession()->getLang()->getDateFormat();
|
||||
$args['availableCoupons'] = $this->getAvailableCoupons();
|
||||
$args['formAction'] = 'admin/coupon/create/';
|
||||
$args['formAction'] = 'admin/coupon/create';
|
||||
|
||||
return $this->render(
|
||||
'coupon-create',
|
||||
@@ -201,7 +201,7 @@ class CouponController extends BaseAdminController
|
||||
$lang = $this->getSession()->getLang();
|
||||
$eventToDispatch = TheliaEvents::COUPON_UPDATE;
|
||||
|
||||
// Create
|
||||
// Update
|
||||
if ($this->getRequest()->isMethod('POST')) {
|
||||
$this->validateCreateOrUpdateForm(
|
||||
$i18n,
|
||||
@@ -210,7 +210,7 @@ class CouponController extends BaseAdminController
|
||||
'updated',
|
||||
'update'
|
||||
);
|
||||
} else { // Update
|
||||
} else { // Display
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
/** @var ConstraintFactory $constraintFactory */
|
||||
@@ -223,7 +223,7 @@ class CouponController extends BaseAdminController
|
||||
'code' => $coupon->getCode(),
|
||||
'title' => $coupon->getTitle(),
|
||||
'amount' => $coupon->getAmount(),
|
||||
'effect' => $coupon->getType(),
|
||||
'type' => $coupon->getType(),
|
||||
'shortDescription' => $coupon->getShortDescription(),
|
||||
'description' => $coupon->getDescription(),
|
||||
'isEnabled' => ($coupon->getIsEnabled() == 1),
|
||||
@@ -271,7 +271,7 @@ class CouponController extends BaseAdminController
|
||||
Router::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
$args['formAction'] = 'admin/coupon/update/' . $couponId;
|
||||
$args['formAction'] = 'admin/coupon/update' . $couponId;
|
||||
|
||||
return $this->render('coupon-update', $args);
|
||||
}
|
||||
@@ -347,20 +347,7 @@ class CouponController extends BaseAdminController
|
||||
);
|
||||
|
||||
$couponEvent = new CouponCreateOrUpdateEvent(
|
||||
$coupon->getCode(),
|
||||
$coupon->getTitle(),
|
||||
$coupon->getAmount(),
|
||||
$coupon->getType(),
|
||||
$coupon->getShortDescription(),
|
||||
$coupon->getDescription(),
|
||||
$coupon->getIsEnabled(),
|
||||
$coupon->getExpirationDate(),
|
||||
$coupon->getIsAvailableOnSpecialOffers(),
|
||||
$coupon->getIsCumulative(),
|
||||
$coupon->getIsRemovingPostage(),
|
||||
$coupon->getMaxUsage(),
|
||||
$rules,
|
||||
$coupon->getLocale()
|
||||
$coupon->getCode(), $coupon->getTitle(), $coupon->getAmount(), $coupon->getType(), $coupon->getShortDescription(), $coupon->getDescription(), $coupon->getIsEnabled(), $coupon->getExpirationDate(), $coupon->getIsAvailableOnSpecialOffers(), $coupon->getIsCumulative(), $coupon->getIsRemovingPostage(), $coupon->getMaxUsage(), $coupon->getLocale()
|
||||
);
|
||||
$couponEvent->setCoupon($coupon);
|
||||
|
||||
@@ -495,21 +482,9 @@ class CouponController extends BaseAdminController
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$couponEvent = new CouponCreateOrUpdateEvent(
|
||||
$data['code'],
|
||||
$data['title'],
|
||||
$data['amount'],
|
||||
$data['effect'],
|
||||
$data['shortDescription'],
|
||||
$data['description'],
|
||||
$data['isEnabled'],
|
||||
\DateTime::createFromFormat('Y-m-d', $data['expirationDate']),
|
||||
$data['isAvailableOnSpecialOffers'],
|
||||
$data['isCumulative'],
|
||||
$data['isRemovingPostage'],
|
||||
$data['maxUsage'],
|
||||
new CouponRuleCollection(array()),
|
||||
$data['locale']
|
||||
$data['code'], $data['title'], $data['amount'], $data['type'], $data['shortDescription'], $data['description'], $data['isEnabled'], \DateTime::createFromFormat('Y-m-d', $data['expirationDate']), $data['isAvailableOnSpecialOffers'], $data['isCumulative'], $data['isRemovingPostage'], $data['maxUsage'], $data['locale']
|
||||
);
|
||||
|
||||
// Dispatch Event to the Action
|
||||
@@ -537,7 +512,6 @@ class CouponController extends BaseAdminController
|
||||
} catch (FormValidationException $e) {
|
||||
// Invalid data entered
|
||||
$message = 'Please check your input:';
|
||||
$this->logError($action, $message, $e);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Any other error
|
||||
|
||||
328
core/lib/Thelia/Controller/Admin/FolderController.php
Normal file
328
core/lib/Thelia/Controller/Admin/FolderController.php
Normal file
@@ -0,0 +1,328 @@
|
||||
<?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\FolderCreateEvent;
|
||||
use Thelia\Core\Event\FolderDeleteEvent;
|
||||
use Thelia\Core\Event\FolderToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\FolderUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Form\FolderCreationForm;
|
||||
use Thelia\Form\FolderModificationForm;
|
||||
use Thelia\Model\FolderQuery;
|
||||
|
||||
/**
|
||||
* Class FolderController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderController extends AbstractCrudController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'folder',
|
||||
'manual',
|
||||
'folder_order',
|
||||
|
||||
'admin.folder.default',
|
||||
'admin.folder.create',
|
||||
'admin.folder.update',
|
||||
'admin.folder.delete',
|
||||
|
||||
TheliaEvents::FOLDER_CREATE,
|
||||
TheliaEvents::FOLDER_UPDATE,
|
||||
TheliaEvents::FOLDER_DELETE,
|
||||
TheliaEvents::FOLDER_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::FOLDER_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the creation form for this object
|
||||
*/
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new FolderCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the update form for this object
|
||||
*/
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new FolderModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate the update form for this object, before passing it to the update template
|
||||
*
|
||||
* @param \Thelia\Model\Folder $object
|
||||
*/
|
||||
protected function hydrateObjectForm($object) {
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'parent' => $object->getParent()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new FolderModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the creation event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$creationEvent = new FolderCreateEvent();
|
||||
|
||||
$creationEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setVisible($formData['visible'])
|
||||
->setParent($formData['parent']);
|
||||
|
||||
return $creationEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the update event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$updateEvent = new FolderUpdateEvent($formData['id']);
|
||||
|
||||
$updateEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setParent($formData['parent'])
|
||||
;
|
||||
|
||||
return $updateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the delete event with the provided form data
|
||||
*/
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new FolderDeleteEvent($this->getRequest()->get('folder_id'), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FolderToggleVisibilityEvent|void
|
||||
*/
|
||||
protected function createToggleVisibilityEvent()
|
||||
{
|
||||
return new FolderToggleVisibilityEvent($this->getExistingObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $positionChangeMode
|
||||
* @param $positionValue
|
||||
* @return UpdatePositionEvent|void
|
||||
*/
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
|
||||
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('folder_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the event contains the object, e.g. the action has updated the object in the event.
|
||||
*
|
||||
* @param \Thelia\Core\Event\FolderEvent $event
|
||||
*/
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasFolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the created object from an event.
|
||||
*
|
||||
* @param $event \Thelia\Core\Event\FolderEvent $event
|
||||
*
|
||||
* @return null|\Thelia\Model\Folder
|
||||
*/
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasFolder() ? $event->getFolder() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an existing object from the database
|
||||
*/
|
||||
protected function getExistingObject() {
|
||||
return FolderQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('folder_id', 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object label form the object event (name, title, etc.)
|
||||
*
|
||||
* @param unknown $object
|
||||
*/
|
||||
protected function getObjectLabel($object) {
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
// Get content order
|
||||
$content_order = $this->getListOrderFromSession('content', 'content_order', 'manual');
|
||||
|
||||
return $this->render('folders',
|
||||
array(
|
||||
'folder_order' => $currentOrder,
|
||||
'content_order' => $content_order,
|
||||
'parent' => $this->getRequest()->get('parent', 0)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render the edition template
|
||||
*/
|
||||
protected function renderEditionTemplate() {
|
||||
|
||||
return $this->render('folder-edit', $this->getEditionArguments());
|
||||
}
|
||||
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\FolderUpdateEvent $updateEvent
|
||||
* @return Response|void
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
if ($this->getRequest()->get('save_mode') != 'stay') {
|
||||
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $updateEvent->getFolder()->getParent())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in this method post object delete processing if required.
|
||||
*
|
||||
* @param \Thelia\Core\Event\FolderDeleteEvent $deleteEvent the delete event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $deleteEvent->getFolder()->getParent())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $event \Thelia\Core\Event\UpdatePositionEvent
|
||||
* @return null|Response
|
||||
*/
|
||||
protected function performAdditionalUpdatePositionAction($event)
|
||||
{
|
||||
|
||||
$folder = FolderQuery::create()->findPk($event->getObjectId());
|
||||
|
||||
if ($folder != null) {
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $folder->getParent())
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the edition template
|
||||
*/
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirect($this->getRoute('admin.folders.update', $this->getEditionArguments()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the list template
|
||||
*/
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $this->getRequest()->get('parent', 0))
|
||||
);
|
||||
}
|
||||
}
|
||||
46
core/lib/Thelia/Controller/Admin/ModuleController.php
Normal file
46
core/lib/Thelia/Controller/Admin/ModuleController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Class ModuleController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ModuleController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.module.view")) return $response;
|
||||
return $this->render("modules", array("display_module" => 20));
|
||||
}
|
||||
|
||||
public function updateAction($module_id)
|
||||
{
|
||||
|
||||
return $this->render("module-edit", array(
|
||||
"module_id" => $module_id
|
||||
));
|
||||
}
|
||||
}
|
||||
477
core/lib/Thelia/Controller/Admin/ProductController.php
Normal file
477
core/lib/Thelia/Controller/Admin/ProductController.php
Normal file
@@ -0,0 +1,477 @@
|
||||
<?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\ProductDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\ProductUpdateEvent;
|
||||
use Thelia\Core\Event\ProductCreateEvent;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Form\ProductModificationForm;
|
||||
use Thelia\Form\ProductCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\ProductToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\ProductDeleteContentEvent;
|
||||
use Thelia\Core\Event\ProductAddContentEvent;
|
||||
use Thelia\Model\ProductAssociatedContent;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Model\ProductAssociatedContentQuery;
|
||||
use Thelia\Model\AccessoryQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Core\Event\ProductAddAccessoryEvent;
|
||||
use Thelia\Core\Event\ProductDeleteAccessoryEvent;
|
||||
|
||||
/**
|
||||
* Manages products
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class ProductController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'product',
|
||||
'manual',
|
||||
'product_order',
|
||||
|
||||
'admin.products.default',
|
||||
'admin.products.create',
|
||||
'admin.products.update',
|
||||
'admin.products.delete',
|
||||
|
||||
TheliaEvents::PRODUCT_CREATE,
|
||||
TheliaEvents::PRODUCT_UPDATE,
|
||||
TheliaEvents::PRODUCT_DELETE,
|
||||
|
||||
TheliaEvents::PRODUCT_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::PRODUCT_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new ProductCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new ProductModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new ProductCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setRef($formData['ref'])
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData['locale'])
|
||||
->setDefaultCategory($formData['default_category'])
|
||||
->setVisible($formData['visible'])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new ProductUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setParent($formData['parent'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
{
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('product_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new ProductDeleteEvent($this->getRequest()->get('product_id', 0));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasProduct();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'default_category' => $object->getDefaultCategoryId()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new ProductModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasProduct() ? $event->getProduct() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return ProductQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('product_id', 0));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'category_id' => $this->getCategoryId(),
|
||||
'product_id' => $this->getRequest()->get('product_id', 0),
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'accessory_category_id'=> $this->getRequest()->get('accessory_category_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCategoryId() {
|
||||
// Trouver le category_id, soit depuis la reques, souit depuis le produit courant
|
||||
$category_id = $this->getRequest()->get('category_id', null);
|
||||
|
||||
if ($category_id == null) {
|
||||
$product = $this->getExistingObject();
|
||||
|
||||
if ($product !== null) $category_id = $product->getDefaultCategoryId();
|
||||
}
|
||||
|
||||
return $category_id != null ? $category_id : 0;
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
$this->getListOrderFromSession('product', 'product_order', 'manual');
|
||||
|
||||
return $this->render('categories',
|
||||
array(
|
||||
'product_order' => $currentOrder,
|
||||
'category_id' => $this->getCategoryId()
|
||||
));
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
'admin.products.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render('product-edit', $this->getEditionArguments());
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute("admin.products.update", $this->getEditionArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Online status toggle product
|
||||
*/
|
||||
public function setToggleVisibilityAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$event = new ProductToggleVisibilityEvent($this->getExistingObject());
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_TOGGLE_VISIBILITY, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
// Ajax response -> no action
|
||||
return $this->nullResponse();
|
||||
}
|
||||
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.products.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
if ($this->getRequest()->get('save_mode') != 'stay') {
|
||||
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdatePositionAction($positionEvent)
|
||||
{
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
// -- Related content management -------------------------------------------
|
||||
|
||||
public function getAvailableRelatedContentAction($productId, $folderId)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
$folders = FolderQuery::create()->filterById($folderId)->find();
|
||||
|
||||
if ($folders !== null) {
|
||||
|
||||
$list = ContentQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByFolder($folders, Criteria::IN)
|
||||
->filterById(ProductAssociatedContentQuery::create()->select('content_id')->findByProductId($productId), Criteria::NOT_IN)
|
||||
->find();
|
||||
;
|
||||
|
||||
if ($list !== null) {
|
||||
foreach($list as $item) {
|
||||
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->jsonResponse(json_encode($result));
|
||||
}
|
||||
|
||||
public function addRelatedContentAction()
|
||||
{
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$content_id = intval($this->getRequest()->get('content_id'));
|
||||
|
||||
if ($content_id > 0) {
|
||||
|
||||
$event = new ProductAddContentEvent(
|
||||
$this->getExistingObject(),
|
||||
$content_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteRelatedContentAction()
|
||||
{
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$content_id = intval($this->getRequest()->get('content_id'));
|
||||
|
||||
if ($content_id > 0) {
|
||||
|
||||
$event = new ProductDeleteContentEvent(
|
||||
$this->getExistingObject(),
|
||||
$content_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
|
||||
// -- Accessories management ----------------------------------------------
|
||||
|
||||
public function getAvailableAccessoriesAction($productId, $categoryId)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
$categories = CategoryQuery::create()->filterById($categoryId)->find();
|
||||
|
||||
if ($categories !== null) {
|
||||
|
||||
$list = ProductQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByCategory($categories, Criteria::IN)
|
||||
->filterById(AccessoryQuery::create()->select('accessory')->findByProductId($productId), Criteria::NOT_IN)
|
||||
->find();
|
||||
;
|
||||
|
||||
if ($list !== null) {
|
||||
foreach($list as $item) {
|
||||
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->jsonResponse(json_encode($result));
|
||||
}
|
||||
|
||||
public function addAccessoryAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$accessory_id = intval($this->getRequest()->get('accessory_id'));
|
||||
|
||||
if ($accessory_id > 0) {
|
||||
|
||||
$event = new ProductAddAccessoryEvent(
|
||||
$this->getExistingObject(),
|
||||
$accessory_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteAccessoryAction()
|
||||
{
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$accessory_id = intval($this->getRequest()->get('accessory_id'));
|
||||
|
||||
if ($accessory_id > 0) {
|
||||
|
||||
$event = new ProductDeleteAccessoryEvent(
|
||||
$this->getExistingObject(),
|
||||
$accessory_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_ACCESSORY, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update accessory position (only for objects whichsupport that)
|
||||
*/
|
||||
public function updateAccessoryPositionAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth('admin.products.update')) return $response;
|
||||
|
||||
try {
|
||||
$mode = $this->getRequest()->get('mode', null);
|
||||
|
||||
if ($mode == 'up')
|
||||
$mode = UpdatePositionEvent::POSITION_UP;
|
||||
else if ($mode == 'down')
|
||||
$mode = UpdatePositionEvent::POSITION_DOWN;
|
||||
else
|
||||
$mode = UpdatePositionEvent::POSITION_ABSOLUTE;
|
||||
|
||||
$position = $this->getRequest()->get('position', null);
|
||||
|
||||
$event = new UpdatePositionEvent($mode, $position);
|
||||
|
||||
$this->dispatch(TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Class ShippingConfigurationController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingConfigurationController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response;
|
||||
return $this->render("shipping-configuration", array("display_shipping_configuration" => 20));
|
||||
}
|
||||
|
||||
public function updateAction($shipping_configuration_id)
|
||||
{
|
||||
|
||||
return $this->render("shipping-configuration-edit", array(
|
||||
"shipping_configuration_id" => $shipping_configuration_id
|
||||
));
|
||||
}
|
||||
}
|
||||
46
core/lib/Thelia/Controller/Admin/ShippingZoneController.php
Normal file
46
core/lib/Thelia/Controller/Admin/ShippingZoneController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Class ShippingZoneController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingZoneController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
|
||||
return $this->render("shipping-zones", array("display_shipping_zone" => 20));
|
||||
}
|
||||
|
||||
public function updateAction($shipping_zones_id)
|
||||
{
|
||||
|
||||
return $this->render("shipping-zones-edit", array(
|
||||
"shipping_zones_id" => $shipping_zones_id
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
@@ -62,6 +63,14 @@ class BaseController extends ContainerAware
|
||||
return new Response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a JSON response
|
||||
*/
|
||||
protected function jsonResponse($json_data)
|
||||
{
|
||||
return new Response($json_data, 200, array('content-type' => 'application/json'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a Thelia event
|
||||
*
|
||||
@@ -89,7 +98,7 @@ class BaseController extends ContainerAware
|
||||
*
|
||||
* return the Translator
|
||||
*
|
||||
* @return mixed \Thelia\Core\Translation\Translator
|
||||
* @return Translator
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace Thelia\Controller\Front;
|
||||
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Controller\BaseController;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
class BaseFrontController extends BaseController
|
||||
@@ -57,4 +59,28 @@ class BaseFrontController extends BaseController
|
||||
$this->redirectToRoute("customer.login.view");
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkCartNotEmpty()
|
||||
{
|
||||
$cart = $this->getSession()->getCart();
|
||||
if($cart===null || $cart->countCartItems() == 0) {
|
||||
$this->redirectToRoute("cart.view");
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkValidDelivery()
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) {
|
||||
$this->redirectToRoute("order.delivery");
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkValidInvoice()
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
|
||||
$this->redirectToRoute("order.invoice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
246
core/lib/Thelia/Controller/Front/OrderController.php
Executable file
246
core/lib/Thelia/Controller/Front/OrderController.php
Executable file
@@ -0,0 +1,246 @@
|
||||
<?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\Front;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Form\OrderDelivery;
|
||||
use Thelia\Form\OrderPayment;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\AreaDeliveryModuleQuery;
|
||||
use Thelia\Model\Base\OrderQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class OrderController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderController extends BaseFrontController
|
||||
{
|
||||
/**
|
||||
* set delivery address
|
||||
* set delivery module
|
||||
*/
|
||||
public function deliver()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
$message = false;
|
||||
|
||||
$orderDelivery = new OrderDelivery($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($orderDelivery, "post");
|
||||
|
||||
$deliveryAddressId = $form->get("delivery-address")->getData();
|
||||
$deliveryModuleId = $form->get("delivery-module")->getData();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
|
||||
$deliveryModule = ModuleQuery::create()->findPk($deliveryModuleId);
|
||||
|
||||
/* check that the delivery address belongs to the current customer */
|
||||
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
|
||||
if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
throw new \Exception("Delivery address does not belong to the current customer");
|
||||
}
|
||||
|
||||
/* check that the delivery module fetches the delivery address area */
|
||||
if(AreaDeliveryModuleQuery::create()
|
||||
->filterByAreaId($deliveryAddress->getCountry()->getAreaId())
|
||||
->filterByDeliveryModuleId($deliveryModuleId)
|
||||
->count() == 0) {
|
||||
throw new \Exception("Delivery module cannot be use with selected delivery address");
|
||||
}
|
||||
|
||||
/* get postage amount */
|
||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
$postage = $moduleInstance->getPostage($deliveryAddress->getCountry());
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setDeliveryAddress($deliveryAddressId);
|
||||
$orderEvent->setDeliveryModule($deliveryModuleId);
|
||||
$orderEvent->setPostage($postage);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
|
||||
|
||||
$this->redirectToRoute("order.invoice");
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$orderDelivery->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($orderDelivery)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* set invoice address
|
||||
* set payment module
|
||||
*/
|
||||
public function invoice()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
$this->checkValidDelivery();
|
||||
|
||||
$message = false;
|
||||
|
||||
$orderPayment = new OrderPayment($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($orderPayment, "post");
|
||||
|
||||
$invoiceAddressId = $form->get("invoice-address")->getData();
|
||||
$paymentModuleId = $form->get("payment-module")->getData();
|
||||
|
||||
/* check that the invoice address belongs to the current customer */
|
||||
$invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId);
|
||||
if($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
throw new \Exception("Invoice address does not belong to the current customer");
|
||||
}
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setInvoiceAddress($invoiceAddressId);
|
||||
$orderEvent->setPaymentModule($paymentModuleId);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_INVOICE_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_PAYMENT_MODULE, $orderEvent);
|
||||
|
||||
$this->redirectToRoute("order.payment.process");
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during order payment process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$orderPayment->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($orderPayment)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function pay()
|
||||
{
|
||||
/* check customer */
|
||||
$this->checkAuth();
|
||||
|
||||
/* check cart count */
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
/* check delivery address and module */
|
||||
$this->checkValidDelivery();
|
||||
|
||||
/* check invoice address and payment module */
|
||||
$this->checkValidInvoice();
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent);
|
||||
|
||||
$placedOrder = $orderEvent->getPlacedOrder();
|
||||
|
||||
if(null !== $placedOrder && null !== $placedOrder->getId()) {
|
||||
/* order has been placed */
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId()))));
|
||||
} else {
|
||||
/* order has not been placed */
|
||||
$this->redirectToRoute("cart.view");
|
||||
}
|
||||
}
|
||||
|
||||
public function orderPlaced($order_id)
|
||||
{
|
||||
/* check if the placed order matched the customer */
|
||||
$placedOrder = OrderQuery::create()->findPk(
|
||||
$this->getRequest()->attributes->get('order_id')
|
||||
);
|
||||
|
||||
if(null === $placedOrder) {
|
||||
throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder);
|
||||
}
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
if(null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) {
|
||||
throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder);
|
||||
}
|
||||
|
||||
$this->getParserContext()->set("placed_order_id", $placedOrder->getId());
|
||||
}
|
||||
|
||||
protected function getOrderEvent()
|
||||
{
|
||||
$order = $this->getOrder($this->getRequest());
|
||||
|
||||
return new OrderEvent($order);
|
||||
}
|
||||
|
||||
public function getOrder(Request $request)
|
||||
{
|
||||
$session = $request->getSession();
|
||||
|
||||
if (null !== $order = $session->getOrder()) {
|
||||
return $order;
|
||||
}
|
||||
|
||||
$order = new Order();
|
||||
|
||||
$session->setOrder($order);
|
||||
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Core/Event/AccessoryEvent.php
Normal file
54
core/lib/Thelia/Core/Event/AccessoryEvent.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Accessory;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class AccessoryEvent extends ActionEvent
|
||||
{
|
||||
public $accessory = null;
|
||||
|
||||
public function __construct(Accessory $accessory = null)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
}
|
||||
|
||||
public function hasAccessory()
|
||||
{
|
||||
return ! is_null($this->accessory);
|
||||
}
|
||||
|
||||
public function getAccessory()
|
||||
{
|
||||
return $this->accessory;
|
||||
}
|
||||
|
||||
public function setAccessory(Accessory $accessory)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
94
core/lib/Thelia/Core/Event/CachedFileEvent.php
Normal file
94
core/lib/Thelia/Core/Event/CachedFileEvent.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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 CachedFileEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var string The complete file name (with path) of the source file
|
||||
*/
|
||||
protected $source_filepath = null;
|
||||
/**
|
||||
* @var string The target subdirectory in the cache
|
||||
*/
|
||||
protected $cache_subdirectory = null;
|
||||
|
||||
/**
|
||||
* @var string The absolute URL of the cached file (in the web space)
|
||||
*/
|
||||
protected $file_url = null;
|
||||
|
||||
/**
|
||||
* @var string The absolute path of the cached file
|
||||
*/
|
||||
protected $cache_filepath = null;
|
||||
|
||||
public function getFileUrl()
|
||||
{
|
||||
return $this->file_url;
|
||||
}
|
||||
|
||||
public function setFileUrl($file_url)
|
||||
{
|
||||
$this->file_url = $file_url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCacheFilepath()
|
||||
{
|
||||
return $this->cache_filepath;
|
||||
}
|
||||
|
||||
public function setCacheFilepath($cache_filepath)
|
||||
{
|
||||
$this->cache_filepath = $cache_filepath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSourceFilepath()
|
||||
{
|
||||
return $this->source_filepath;
|
||||
}
|
||||
|
||||
public function setSourceFilepath($source_filepath)
|
||||
{
|
||||
$this->source_filepath = $source_filepath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCacheSubdirectory()
|
||||
{
|
||||
return $this->cache_subdirectory;
|
||||
}
|
||||
|
||||
public function setCacheSubdirectory($cache_subdirectory)
|
||||
{
|
||||
$this->cache_subdirectory = $cache_subdirectory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/CategoryAddContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/CategoryAddContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryAddContentEvent extends CategoryEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
public function __construct(Category $category, $content_id)
|
||||
{
|
||||
parent::__construct($category);
|
||||
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\CategoryAssociatedContent;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CategoryAssociatedContentEvent extends ActionEvent
|
||||
{
|
||||
public $content = null;
|
||||
|
||||
public function __construct(CategoryAssociatedContent $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function hasCategoryAssociatedContent()
|
||||
{
|
||||
return ! is_null($this->content);
|
||||
}
|
||||
|
||||
public function getCategoryAssociatedContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setCategoryAssociatedContent(CategoryAssociatedContent $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryDeleteContentEvent extends CategoryEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
public function __construct(Category $category, $content_id)
|
||||
{
|
||||
parent::__construct($category);
|
||||
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
}
|
||||
124
core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php
Normal file
124
core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?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\Content;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentCreateEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentCreateEvent extends ContentEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $default_folder;
|
||||
protected $locale;
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $default_folder
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultFolder($default_folder)
|
||||
{
|
||||
$this->default_folder = $default_folder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultFolder()
|
||||
{
|
||||
return $this->default_folder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $visible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
73
core/lib/Thelia/Core/Event/Content/ContentEvent.php
Normal file
73
core/lib/Thelia/Core/Event/Content/ContentEvent.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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\Content;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Content;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Content
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
function __construct(Content $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Content $content
|
||||
*/
|
||||
public function setContent(Content $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Content
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if content exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasContent()
|
||||
{
|
||||
return null !== $this->content;
|
||||
}
|
||||
}
|
||||
150
core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php
Normal file
150
core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?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\Content;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentUpdateEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentUpdateEvent extends ContentCreateEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
protected $url;
|
||||
|
||||
function __construct($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $content_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -78,8 +78,8 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
/** @var Coupon Coupon model */
|
||||
protected $coupon = null;
|
||||
|
||||
/** @var string Coupon effect */
|
||||
protected $effect;
|
||||
/** @var string Coupon type */
|
||||
protected $type;
|
||||
|
||||
/** @var string Language code ISO (ex: fr_FR) */
|
||||
protected $locale = null;
|
||||
@@ -90,7 +90,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param float $amount Amount removed from the Total Checkout
|
||||
* @param string $effect Coupon effect
|
||||
* @param string $type Coupon type
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param boolean $isEnabled Enable/Disable
|
||||
@@ -99,24 +99,10 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param boolean $isCumulative Is cumulative
|
||||
* @param boolean $isRemovingPostage Is removing Postage
|
||||
* @param int $maxUsage Coupon quantity
|
||||
* @param CouponRuleCollection $rules CouponRuleInterface to add
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
*/
|
||||
public function __construct(
|
||||
$code,
|
||||
$title,
|
||||
$amount,
|
||||
$effect,
|
||||
$shortDescription,
|
||||
$description,
|
||||
$isEnabled,
|
||||
\DateTime $expirationDate,
|
||||
$isAvailableOnSpecialOffers,
|
||||
$isCumulative,
|
||||
$isRemovingPostage,
|
||||
$maxUsage,
|
||||
$rules,
|
||||
$locale
|
||||
$code, $title, $amount, $type, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale
|
||||
) {
|
||||
$this->amount = $amount;
|
||||
$this->code = $code;
|
||||
@@ -127,10 +113,9 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
$this->isEnabled = $isEnabled;
|
||||
$this->isRemovingPostage = $isRemovingPostage;
|
||||
$this->maxUsage = $maxUsage;
|
||||
$this->rules = $rules;
|
||||
$this->shortDescription = $shortDescription;
|
||||
$this->title = $title;
|
||||
$this->effect = $effect;
|
||||
$this->type = $type;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
@@ -206,22 +191,6 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return condition to validate the Coupon or not
|
||||
*
|
||||
* @return CouponRuleCollection
|
||||
*/
|
||||
public function getRules()
|
||||
{
|
||||
if ($this->rules === null || !is_object($this->rules)) {
|
||||
$rules = $this->rules;
|
||||
} else {
|
||||
$rules = clone $this->rules;
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon expiration date
|
||||
*
|
||||
@@ -264,13 +233,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon effect
|
||||
* Get Coupon type (effect)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEffect()
|
||||
public function getType()
|
||||
{
|
||||
return $this->effect;
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
67
core/lib/Thelia/Core/Event/DocumentEvent.php
Normal file
67
core/lib/Thelia/Core/Event/DocumentEvent.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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 DocumentEvent extends CachedFileEvent
|
||||
{
|
||||
protected $document_path;
|
||||
protected $document_url;
|
||||
|
||||
/**
|
||||
* @return the document file path
|
||||
*/
|
||||
public function getDocumentPath()
|
||||
{
|
||||
return $this->document_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $document_path the document file path
|
||||
*/
|
||||
public function setDocumentPath($document_path)
|
||||
{
|
||||
$this->document_path = $document_path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the document URL
|
||||
*/
|
||||
public function getDocumentUrl()
|
||||
{
|
||||
return $this->document_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $document_url the document URL
|
||||
*/
|
||||
public function setDocumentUrl($document_url)
|
||||
{
|
||||
$this->document_url = $document_url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
120
core/lib/Thelia/Core/Event/FolderCreateEvent.php
Normal file
120
core/lib/Thelia/Core/Event/FolderCreateEvent.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?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 FolderCreateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderCreateEvent extends FolderEvent {
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $parent
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $visible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,35 +21,44 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Front;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Tools\URL;
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class DeliveryController
|
||||
* @package Thelia\Controller\Front
|
||||
* Class FolderDeleteEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class DeliveryController extends BaseFrontController
|
||||
class FolderDeleteEvent extends FolderEvent{
|
||||
|
||||
/**
|
||||
* @var int folder id
|
||||
*/
|
||||
protected $folder_id;
|
||||
|
||||
/**
|
||||
* @param int $folder_id
|
||||
*/
|
||||
function __construct($folder_id)
|
||||
{
|
||||
public function select($delivery_id)
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $folder_id
|
||||
*/
|
||||
public function setFolderId($folder_id)
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirect(URL::getInstance()->getIndexPage());
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFolderId()
|
||||
{
|
||||
return $this->folder_id;
|
||||
}
|
||||
|
||||
$deliveryModule = ModuleQuery::create()
|
||||
->filterById($delivery_id)
|
||||
->filterByActivate(1)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
if ($deliveryModule) {
|
||||
$request->getSession()->setDelivery($delivery_id);
|
||||
} else {
|
||||
$this->pageNotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,39 +21,53 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Install;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Controller\BaseController;
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Folder;
|
||||
|
||||
|
||||
/**
|
||||
* Class BaseInstallController
|
||||
* @package Thelia\Controller\Install
|
||||
* Class FolderEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class BaseInstallController extends BaseController
|
||||
{
|
||||
class FolderEvent extends ActionEvent {
|
||||
|
||||
/**
|
||||
* @return a ParserInterface instance parser
|
||||
* @var \Thelia\Model\Folder
|
||||
*/
|
||||
protected function getParser()
|
||||
protected $folder;
|
||||
|
||||
function __construct(Folder $folder = null)
|
||||
{
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template that shoud be used
|
||||
$parser->setTemplate("install");
|
||||
|
||||
return $parser;
|
||||
$this->folder = $folder;
|
||||
}
|
||||
|
||||
public function render($templateName, $args = array())
|
||||
/**
|
||||
* @param \Thelia\Model\Folder $folder
|
||||
*/
|
||||
public function setFolder(Folder $folder)
|
||||
{
|
||||
return new Response($this->renderRaw($templateName, $args));
|
||||
$this->folder = $folder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function renderRaw($templateName, $args = array())
|
||||
/**
|
||||
* @return \Thelia\Model\Folder
|
||||
*/
|
||||
public function getFolder()
|
||||
{
|
||||
$data = $this->getParser()->render($templateName, $args);
|
||||
return $this->folder;
|
||||
}
|
||||
|
||||
return $data;
|
||||
/**
|
||||
* test if a folder object exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFolder()
|
||||
{
|
||||
return null !== $this->folder;
|
||||
}
|
||||
|
||||
}
|
||||
34
core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php
Normal file
34
core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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 FolderToggleVisibilityEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderToggleVisibilityEvent extends FolderEvent {
|
||||
|
||||
}
|
||||
@@ -21,91 +21,116 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Install;
|
||||
use Thelia\Install\CheckPermission;
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class InstallController
|
||||
* @package Thelia\Controller\Install
|
||||
* Class FolderUpdateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class InstallController extends BaseInstallController
|
||||
class FolderUpdateEvent extends FolderCreateEvent {
|
||||
protected $folder_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
protected $url;
|
||||
|
||||
function __construct($folder_id)
|
||||
{
|
||||
public function index()
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
//$this->verifyStep(1);
|
||||
$this->chapo = $chapo;
|
||||
|
||||
$this->getSession()->set("step", 1);
|
||||
|
||||
return $this->render("index.html");
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function checkPermission()
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 2);
|
||||
return $this->render("step-2.html");
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function databaseConnection()
|
||||
/**
|
||||
* @param mixed $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
$this->description = $description;
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 3);
|
||||
return $this->render("step-3.html");
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function databaseSelection()
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 4);
|
||||
return $this->render("step-4.html");
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function generalInformation()
|
||||
/**
|
||||
* @param mixed $folder_id
|
||||
*/
|
||||
public function setFolderId($folder_id)
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
$this->folder_id = $folder_id;
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 5);
|
||||
return $this->render("step-5.html");
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function thanks()
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFolderId()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 6);
|
||||
return $this->render("thanks.html");
|
||||
return $this->folder_id;
|
||||
}
|
||||
|
||||
protected function verifyStep($step)
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$session = $this->getSession();
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
if ($session->has("step")) {
|
||||
$sessionStep = $session->get("step");
|
||||
} else {
|
||||
return true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
switch ($step) {
|
||||
case "1" :
|
||||
if ($sessionStep > 1) {
|
||||
$this->redirect("/install/step/2");
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
break;
|
||||
|
||||
/**
|
||||
* @param mixed $url
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
}
|
||||
60
core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php
Normal file
60
core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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 GenerateRewrittenUrlEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class GenerateRewrittenUrlEvent extends ActionEvent {
|
||||
|
||||
protected $object;
|
||||
protected $locale;
|
||||
|
||||
protected $url;
|
||||
|
||||
public function __construct($object, $locale)
|
||||
{
|
||||
$this->object;
|
||||
$this->locale;
|
||||
}
|
||||
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function isRewritten()
|
||||
{
|
||||
return null !== $this->url;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,22 +23,8 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class ImageEvent extends ActionEvent
|
||||
class ImageEvent extends CachedFileEvent
|
||||
{
|
||||
/**
|
||||
* @var string The complete file name (with path) of the source image
|
||||
*/
|
||||
protected $source_filepath = null;
|
||||
/**
|
||||
* @var string The target subdirectory in the image cache
|
||||
*/
|
||||
protected $cache_subdirectory = null;
|
||||
|
||||
/**
|
||||
* @var string The absolute URL of the cached image (in the web space)
|
||||
*/
|
||||
protected $file_url = null;
|
||||
|
||||
/**
|
||||
* @var string The absolute path of the cached image file
|
||||
*/
|
||||
@@ -121,6 +107,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setCategory($category)
|
||||
{
|
||||
$this->category = $category;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWidth()
|
||||
@@ -131,6 +119,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setWidth($width)
|
||||
{
|
||||
$this->width = $width;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHeight()
|
||||
@@ -141,6 +131,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setHeight($height)
|
||||
{
|
||||
$this->height = $height;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getResizeMode()
|
||||
@@ -151,6 +143,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setResizeMode($resize_mode)
|
||||
{
|
||||
$this->resize_mode = $resize_mode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBackgroundColor()
|
||||
@@ -161,6 +155,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setBackgroundColor($background_color)
|
||||
{
|
||||
$this->background_color = $background_color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEffects()
|
||||
@@ -171,6 +167,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setEffects(array $effects)
|
||||
{
|
||||
$this->effects = $effects;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRotation()
|
||||
@@ -181,46 +179,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setRotation($rotation)
|
||||
{
|
||||
$this->rotation = $rotation;
|
||||
}
|
||||
|
||||
public function getFileUrl()
|
||||
{
|
||||
return $this->file_url;
|
||||
}
|
||||
|
||||
public function setFileUrl($file_url)
|
||||
{
|
||||
$this->file_url = $file_url;
|
||||
}
|
||||
|
||||
public function getCacheFilepath()
|
||||
{
|
||||
return $this->cache_filepath;
|
||||
}
|
||||
|
||||
public function setCacheFilepath($cache_filepath)
|
||||
{
|
||||
$this->cache_filepath = $cache_filepath;
|
||||
}
|
||||
|
||||
public function getSourceFilepath()
|
||||
{
|
||||
return $this->source_filepath;
|
||||
}
|
||||
|
||||
public function setSourceFilepath($source_filepath)
|
||||
{
|
||||
$this->source_filepath = $source_filepath;
|
||||
}
|
||||
|
||||
public function getCacheSubdirectory()
|
||||
{
|
||||
return $this->cache_subdirectory;
|
||||
}
|
||||
|
||||
public function setCacheSubdirectory($cache_subdirectory)
|
||||
{
|
||||
$this->cache_subdirectory = $cache_subdirectory;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuality()
|
||||
@@ -231,6 +191,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setQuality($quality)
|
||||
{
|
||||
$this->quality = $quality;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOriginalFileUrl()
|
||||
@@ -241,6 +203,8 @@ class ImageEvent extends ActionEvent
|
||||
public function setOriginalFileUrl($original_file_url)
|
||||
{
|
||||
$this->original_file_url = $original_file_url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCacheOriginalFilepath()
|
||||
@@ -251,5 +215,7 @@ class ImageEvent extends ActionEvent
|
||||
public function setCacheOriginalFilepath($cache_original_filepath)
|
||||
{
|
||||
$this->cache_original_filepath = $cache_original_filepath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
174
core/lib/Thelia/Core/Event/OrderEvent.php
Executable file
174
core/lib/Thelia/Core/Event/OrderEvent.php
Executable file
@@ -0,0 +1,174 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Order;
|
||||
|
||||
class OrderEvent extends ActionEvent
|
||||
{
|
||||
protected $order = null;
|
||||
protected $placedOrder = null;
|
||||
protected $invoiceAddress = null;
|
||||
protected $deliveryAddress = null;
|
||||
protected $deliveryModule = null;
|
||||
protected $paymentModule = null;
|
||||
protected $postage = null;
|
||||
protected $ref = null;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function setOrder(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function setPlacedOrder(Order $order)
|
||||
{
|
||||
$this->placedOrder = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $address
|
||||
*/
|
||||
public function setInvoiceAddress($address)
|
||||
{
|
||||
$this->invoiceAddress = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $address
|
||||
*/
|
||||
public function setDeliveryAddress($address)
|
||||
{
|
||||
$this->deliveryAddress = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $module
|
||||
*/
|
||||
public function setDeliveryModule($module)
|
||||
{
|
||||
$this->deliveryModule = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $module
|
||||
*/
|
||||
public function setPaymentModule($module)
|
||||
{
|
||||
$this->paymentModule = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $postage
|
||||
*/
|
||||
public function setPostage($postage)
|
||||
{
|
||||
$this->postage = $postage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ref
|
||||
*/
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
public function getPlacedOrder()
|
||||
{
|
||||
return $this->placedOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getInvoiceAddress()
|
||||
{
|
||||
return $this->invoiceAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getDeliveryAddress()
|
||||
{
|
||||
return $this->deliveryAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getDeliveryModule()
|
||||
{
|
||||
return $this->deliveryModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getPaymentModule()
|
||||
{
|
||||
return $this->paymentModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getPostage()
|
||||
{
|
||||
return $this->postage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
|
||||
class ProductAddAccessoryEvent extends ProductEvent
|
||||
{
|
||||
protected $accessory_id;
|
||||
|
||||
public function __construct(Product $product, $accessory_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
|
||||
public function getAccessoryId()
|
||||
{
|
||||
return $this->accessory_id;
|
||||
}
|
||||
|
||||
public function setAccessoryId($accessory_id)
|
||||
{
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/ProductAddContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductAddContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
|
||||
class ProductAddContentEvent extends ProductEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
public function __construct(Product $product, $content_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php
Normal file
54
core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\ProductAssociatedContent;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class ProductAssociatedContentEvent extends ActionEvent
|
||||
{
|
||||
public $content = null;
|
||||
|
||||
public function __construct(ProductAssociatedContent $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function hasProductAssociatedContent()
|
||||
{
|
||||
return ! is_null($this->content);
|
||||
}
|
||||
|
||||
public function getProductAssociatedContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setProductAssociatedContent(ProductAssociatedContent $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
88
core/lib/Thelia/Core/Event/ProductCreateEvent.php
Normal file
88
core/lib/Thelia/Core/Event/ProductCreateEvent.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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 ProductCreateEvent extends ProductEvent
|
||||
{
|
||||
protected $ref;
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $default_category;
|
||||
protected $visible;
|
||||
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDefaultCategory()
|
||||
{
|
||||
return $this->default_category;
|
||||
}
|
||||
|
||||
public function setDefaultCategory($default_category)
|
||||
{
|
||||
$this->default_category = $default_category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
|
||||
class ProductDeleteAccessoryEvent extends ProductEvent
|
||||
{
|
||||
protected $accessory_id;
|
||||
|
||||
public function __construct(Product $product, $accessory_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
|
||||
public function getAccessoryId()
|
||||
{
|
||||
return $this->accessory_id;
|
||||
}
|
||||
|
||||
public function setAccessoryId($accessory_id)
|
||||
{
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
|
||||
class ProductDeleteContentEvent extends ProductEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
public function __construct(Product $product, $content_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
}
|
||||
44
core/lib/Thelia/Core/Event/ProductDeleteEvent.php
Normal file
44
core/lib/Thelia/Core/Event/ProductDeleteEvent.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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 ProductDeleteEvent extends ProductEvent
|
||||
{
|
||||
public function __construct($product_id)
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
}
|
||||
|
||||
public function getProductId()
|
||||
{
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
public function setProductId($product_id)
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Core/Event/ProductEvent.php
Normal file
54
core/lib/Thelia/Core/Event/ProductEvent.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class ProductEvent extends ActionEvent
|
||||
{
|
||||
public $product = null;
|
||||
|
||||
public function __construct(Product $product = null)
|
||||
{
|
||||
$this->product = $product;
|
||||
}
|
||||
|
||||
public function hasProduct()
|
||||
{
|
||||
return ! is_null($this->product);
|
||||
}
|
||||
|
||||
public function getProduct()
|
||||
{
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function setProduct(Product $product)
|
||||
{
|
||||
$this->product = $product;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
28
core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php
Normal file
28
core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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 ProductToggleVisibilityEvent extends ProductEvent
|
||||
{
|
||||
}
|
||||
113
core/lib/Thelia/Core/Event/ProductUpdateEvent.php
Normal file
113
core/lib/Thelia/Core/Event/ProductUpdateEvent.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?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 ProductUpdateEvent extends ProductCreateEvent
|
||||
{
|
||||
protected $product_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
protected $url;
|
||||
protected $parent;
|
||||
|
||||
public function __construct($product_id)
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
}
|
||||
|
||||
public function getProductId()
|
||||
{
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
public function setProductId($product_id)
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,9 @@ final class TheliaEvents
|
||||
const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility";
|
||||
const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition";
|
||||
|
||||
const CATEGORY_ADD_CONTENT = "action.categoryAddContent";
|
||||
const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent";
|
||||
|
||||
const BEFORE_CREATECATEGORY = "action.before_createcategory";
|
||||
const AFTER_CREATECATEGORY = "action.after_createcategory";
|
||||
|
||||
@@ -162,6 +165,103 @@ final class TheliaEvents
|
||||
const BEFORE_UPDATECATEGORY = "action.before_updateCategory";
|
||||
const AFTER_UPDATECATEGORY = "action.after_updateCategory";
|
||||
|
||||
// -- folder management -----------------------------------------------
|
||||
|
||||
const FOLDER_CREATE = "action.createFolder";
|
||||
const FOLDER_UPDATE = "action.updateFolder";
|
||||
const FOLDER_DELETE = "action.deleteFolder";
|
||||
const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility";
|
||||
const FOLDER_UPDATE_POSITION = "action.updateFolderPosition";
|
||||
|
||||
// const FOLDER_ADD_CONTENT = "action.categoryAddContent";
|
||||
// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent";
|
||||
|
||||
const BEFORE_CREATEFOLDER = "action.before_createFolder";
|
||||
const AFTER_CREATEFOLDER = "action.after_createFolder";
|
||||
|
||||
const BEFORE_DELETEFOLDER = "action.before_deleteFolder";
|
||||
const AFTER_DELETEFOLDER = "action.after_deleteFolder";
|
||||
|
||||
const BEFORE_UPDATEFOLDER = "action.before_updateFolder";
|
||||
const AFTER_UPDATEFOLDER = "action.after_updateFolder";
|
||||
|
||||
// -- content management -----------------------------------------------
|
||||
|
||||
const CONTENT_CREATE = "action.createContent";
|
||||
const CONTENT_UPDATE = "action.updateContent";
|
||||
const CONTENT_DELETE = "action.deleteContent";
|
||||
const CONTENT_TOGGLE_VISIBILITY = "action.toggleContentVisibility";
|
||||
const CONTENT_UPDATE_POSITION = "action.updateContentPosition";
|
||||
|
||||
// const FOLDER_ADD_CONTENT = "action.categoryAddContent";
|
||||
// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent";
|
||||
|
||||
const BEFORE_CREATECONTENT = "action.before_createContent";
|
||||
const AFTER_CREATECONTENT = "action.after_createContent";
|
||||
|
||||
const BEFORE_DELETECONTENT = "action.before_deleteContent";
|
||||
const AFTER_DELETECONTENT = "action.after_deleteContent";
|
||||
|
||||
const BEFORE_UPDATECONTENT = "action.before_updateContent";
|
||||
const AFTER_UPDATECONTENT = "action.after_updateContent";
|
||||
|
||||
// -- Categories Associated Content ----------------------------------------
|
||||
|
||||
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";
|
||||
const AFTER_CREATECATEGORY_ASSOCIATED_CONTENT = "action.after_createCategoryAssociatedContent";
|
||||
|
||||
const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContenty";
|
||||
const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteproduct_accessory";
|
||||
|
||||
const BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.before_updateCategoryAssociatedContent";
|
||||
const AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.after_updateCategoryAssociatedContent";
|
||||
|
||||
// -- Product management -----------------------------------------------
|
||||
|
||||
const PRODUCT_CREATE = "action.createProduct";
|
||||
const PRODUCT_UPDATE = "action.updateProduct";
|
||||
const PRODUCT_DELETE = "action.deleteProduct";
|
||||
const PRODUCT_TOGGLE_VISIBILITY = "action.toggleProductVisibility";
|
||||
const PRODUCT_UPDATE_POSITION = "action.updateProductPosition";
|
||||
|
||||
const PRODUCT_ADD_CONTENT = "action.productAddContent";
|
||||
const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent";
|
||||
|
||||
const PRODUCT_ADD_ACCESSORY = "action.productAddAccessory";
|
||||
const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveAccessory";
|
||||
const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductPosition";
|
||||
|
||||
const BEFORE_CREATEPRODUCT = "action.before_createproduct";
|
||||
const AFTER_CREATEPRODUCT = "action.after_createproduct";
|
||||
|
||||
const BEFORE_DELETEPRODUCT = "action.before_deleteproduct";
|
||||
const AFTER_DELETEPRODUCT = "action.after_deleteproduct";
|
||||
|
||||
const BEFORE_UPDATEPRODUCT = "action.before_updateProduct";
|
||||
const AFTER_UPDATEPRODUCT = "action.after_updateProduct";
|
||||
|
||||
// -- Product Accessories --------------------------------------------------
|
||||
|
||||
const BEFORE_CREATEACCESSORY = "action.before_createAccessory";
|
||||
const AFTER_CREATEACCESSORY = "action.after_createAccessory";
|
||||
|
||||
const BEFORE_DELETEACCESSORY = "action.before_deleteAccessory";
|
||||
const AFTER_DELETEACCESSORY = "action.after_deleteAccessory";
|
||||
|
||||
const BEFORE_UPDATEACCESSORY = "action.before_updateAccessory";
|
||||
const AFTER_UPDATEACCESSORY = "action.after_updateAccessory";
|
||||
|
||||
// -- Product Associated Content --------------------------------------------------
|
||||
|
||||
const BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT = "action.before_createProductAssociatedContent";
|
||||
const AFTER_CREATEPRODUCT_ASSOCIATED_CONTENT = "action.after_createProductAssociatedContent";
|
||||
|
||||
const BEFORE_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.before_deleteProductAssociatedContenty";
|
||||
const AFTER_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.after_deleteproduct_accessory";
|
||||
|
||||
const BEFORE_UPDATEPRODUCT_ASSOCIATED_CONTENT = "action.before_updateProductAssociatedContent";
|
||||
const AFTER_UPDATEPRODUCT_ASSOCIATED_CONTENT = "action.after_updateProductAssociatedContent";
|
||||
|
||||
/**
|
||||
* sent when a new existing cat id duplicated. This append when current customer is different from current cart
|
||||
*/
|
||||
@@ -189,13 +289,33 @@ final class TheliaEvents
|
||||
|
||||
const CART_DELETEITEM = "action.deleteArticle";
|
||||
|
||||
/**
|
||||
* Order linked event
|
||||
*/
|
||||
const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress";
|
||||
const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule";
|
||||
const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress";
|
||||
const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule";
|
||||
const ORDER_PAY = "action.order.pay";
|
||||
const ORDER_BEFORE_CREATE = "action.order.beforeCreate";
|
||||
const ORDER_AFTER_CREATE = "action.order.afterCreate";
|
||||
const ORDER_BEFORE_PAYMENT = "action.order.beforePayment";
|
||||
|
||||
const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate";
|
||||
const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate";
|
||||
|
||||
/**
|
||||
* Sent on image processing
|
||||
*/
|
||||
const IMAGE_PROCESS = "action.processImage";
|
||||
|
||||
/**
|
||||
* Sent on cimage cache clear request
|
||||
* Sent on document processing
|
||||
*/
|
||||
const DOCUMENT_PROCESS = "action.processDocument";
|
||||
|
||||
/**
|
||||
* Sent on image cache clear request
|
||||
*/
|
||||
const IMAGE_CLEAR_CACHE = "action.clearImageCache";
|
||||
|
||||
@@ -406,4 +526,9 @@ final class TheliaEvents
|
||||
*/
|
||||
const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config';
|
||||
|
||||
/**
|
||||
* sent when Thelia try to generate a rewriten url
|
||||
*/
|
||||
const GENERATE_REWRITTENURL = 'action.generate_rewritenurl';
|
||||
|
||||
}
|
||||
|
||||
@@ -28,8 +28,10 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Core\Template\Exception\ResourceNotFoundException;
|
||||
use Thelia\Core\Template\ParserInterface;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
@@ -77,16 +79,39 @@ class ViewListener implements EventSubscriberInterface
|
||||
$content = $parser->getContent();
|
||||
|
||||
if ($content instanceof Response) {
|
||||
$event->setResponse($content);
|
||||
$response = $content;$event->setResponse($content);
|
||||
} else {
|
||||
$event->setResponse(new Response($content, $parser->getStatus() ?: 200));
|
||||
$response = new Response($content, $parser->getStatus() ?: 200);
|
||||
}
|
||||
|
||||
$response->setCache(array(
|
||||
'last_modified' => new \DateTime(),
|
||||
'max_age' => 600,
|
||||
's_maxage' => 600,
|
||||
'private' => false,
|
||||
'public' => true,
|
||||
));
|
||||
|
||||
$event->setResponse($response);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
$event->setResponse(new Response($e->getMessage(), 404));
|
||||
} catch (AuthenticationException $ex) {
|
||||
|
||||
// Redirect to the login template
|
||||
Redirect::exec($this->container->get('thelia.url.manager')->viewUrl($ex->getLoginTemplate()));
|
||||
} catch (OrderException $e) {
|
||||
switch($e->getCode()) {
|
||||
case OrderException::CART_EMPTY:
|
||||
// Redirect to the cart template
|
||||
Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL));
|
||||
break;
|
||||
case OrderException::UNDEFINED_DELIVERY:
|
||||
// Redirect to the delivery choice template
|
||||
Redirect::exec($this->container->get('router.chainRequest')->generate($e->orderDeliveryRoute, $e->arguments, Router::ABSOLUTE_URL));
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ use Thelia\Exception\InvalidCartException;
|
||||
use Thelia\Model\CartQuery;
|
||||
use Thelia\Model\Cart;
|
||||
use Thelia\Model\Currency;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Model\Lang;
|
||||
|
||||
@@ -43,6 +44,8 @@ use Thelia\Model\Lang;
|
||||
class Session extends BaseSession
|
||||
{
|
||||
/**
|
||||
* @param bool $forceDefault
|
||||
*
|
||||
* @return \Thelia\Model\Lang|null
|
||||
*/
|
||||
public function getLang($forceDefault = true)
|
||||
@@ -205,22 +208,22 @@ class Session extends BaseSession
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* assign delivery id in session
|
||||
*
|
||||
* @param $delivery_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setDelivery($delivery_id)
|
||||
// -- Order ------------------------------------------------------------------
|
||||
|
||||
|
||||
public function setOrder(Order $order)
|
||||
{
|
||||
$this->set("thelia.delivery_id", $delivery_id);
|
||||
$this->set("thelia.order", $order);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDelivery()
|
||||
/**
|
||||
* @return Order
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->get("thelia.delivery_id");
|
||||
return $this->get("thelia.order");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
// TODO: Implement generate() method.
|
||||
throw new RouteNotFoundException();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,6 +65,8 @@ abstract class BaseI18nLoop extends BaseLoop
|
||||
{
|
||||
/* manage translations */
|
||||
|
||||
$fr = $this->getForce_return();
|
||||
|
||||
return ModelCriteriaTools::getI18n(
|
||||
$this->getBackend_context(),
|
||||
$this->getLang(),
|
||||
|
||||
@@ -93,8 +93,10 @@ class Accessory extends Product
|
||||
$accessories = $this->search($search);
|
||||
|
||||
$accessoryIdList = array(0);
|
||||
$accessoryPosition = array();
|
||||
foreach ($accessories as $accessory) {
|
||||
array_push($accessoryIdList, $accessory->getAccessory());
|
||||
$accessoryPosition[$accessory->getAccessory()] = $accessory->getPosition();
|
||||
}
|
||||
|
||||
$receivedIdList = $this->getId();
|
||||
@@ -106,7 +108,15 @@ class Accessory extends Product
|
||||
$this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $accessoryIdList)) );
|
||||
}
|
||||
|
||||
return parent::exec($pagination);
|
||||
$loopResult = parent::exec($pagination);
|
||||
|
||||
foreach($loopResult as $loopResultRow) {
|
||||
$loopResultRow
|
||||
->set("POSITION" , $accessoryPosition[$loopResultRow->get('ID')])
|
||||
;
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,13 @@ class Address extends BaseLoop
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
new Argument(
|
||||
'id',
|
||||
new TypeCollection(
|
||||
new Type\IntListType(),
|
||||
new Type\EnumType(array('*', 'any'))
|
||||
)
|
||||
),
|
||||
new Argument(
|
||||
'customer',
|
||||
new TypeCollection(
|
||||
@@ -63,8 +69,14 @@ class Address extends BaseLoop
|
||||
),
|
||||
'current'
|
||||
),
|
||||
Argument::createBooleanTypeArgument('default'),
|
||||
Argument::createIntListTypeArgument('exclude')
|
||||
Argument::createBooleanOrBothTypeArgument('default'),
|
||||
new Argument(
|
||||
'exclude',
|
||||
new TypeCollection(
|
||||
new Type\IntListType(),
|
||||
new Type\EnumType(array('none'))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,7 +91,7 @@ class Address extends BaseLoop
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
if (null !== $id && !in_array($id, array('*', 'any'))) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
@@ -106,7 +118,7 @@ class Address extends BaseLoop
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
if (null !== $exclude && 'none' !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,19 @@ class Argument
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value === null ? null : (string) $value;
|
||||
$x = $value === null;
|
||||
|
||||
if($value === null) {
|
||||
$this->value = null;
|
||||
} else {
|
||||
if(false === $value) {
|
||||
/* (string) $value = "" */
|
||||
$this->value = 0;
|
||||
} else {
|
||||
$this->value = (string) $value;
|
||||
}
|
||||
}
|
||||
//$this->value = $value === null ? null : (string) $value;
|
||||
}
|
||||
|
||||
public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true)
|
||||
|
||||
@@ -53,8 +53,12 @@ class AssociatedContent extends Content
|
||||
{
|
||||
$argumentCollection = parent::getArgDefinitions();
|
||||
|
||||
$argumentCollection->addArgument(Argument::createIntTypeArgument('product'))
|
||||
->addArgument(Argument::createIntTypeArgument('category'));
|
||||
$argumentCollection
|
||||
->addArgument(Argument::createIntTypeArgument('product'))
|
||||
->addArgument(Argument::createIntTypeArgument('category'))
|
||||
->addArgument(Argument::createIntTypeArgument('exclude_product'))
|
||||
->addArgument(Argument::createIntTypeArgument('exclude_category'))
|
||||
;
|
||||
|
||||
$argumentCollection->get('order')->default = "associated_content";
|
||||
|
||||
@@ -91,6 +95,28 @@ class AssociatedContent extends Content
|
||||
$search->filterByCategoryId($category, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$exclude_product = $this->getExcludeProduct();
|
||||
|
||||
// If we have to filter by product, find all products assigned to this product, and filter by found IDs
|
||||
if (null !== $exclude_product) {
|
||||
// Exclude all contents related to the given product
|
||||
$search->filterById(
|
||||
ProductAssociatedContentQuery::create()->filterByProductId($exclude_product)->select('product_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
$exclude_category = $this->getExcludeCategory();
|
||||
|
||||
// If we have to filter by category, find all contents assigned to this category, and filter by found IDs
|
||||
if (null !== $exclude_category) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
$search->filterById(
|
||||
CategoryAssociatedContentQuery::create()->filterByProductId($exclude_category)->select('category_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
$order = $this->getOrder();
|
||||
$orderByAssociatedContent = array_search('associated_content', $order);
|
||||
$orderByAssociatedContentReverse = array_search('associated_content_reverse', $order);
|
||||
|
||||
@@ -29,7 +29,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
/**
|
||||
* Class Delivery
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
@@ -93,6 +92,8 @@ class BaseSpecificModule extends BaseI18nLoop
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
$search->filterByActivate(1);
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$search->filterById($id);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\CountryQuery;
|
||||
|
||||
class Cart extends BaseLoop
|
||||
{
|
||||
@@ -80,9 +81,11 @@ class Cart extends BaseLoop
|
||||
return $result;
|
||||
}
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic;
|
||||
|
||||
foreach ($cartItems as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
//$product->setLocale($this->request->getSession()->getLocale());
|
||||
$productSaleElement = $cartItem->getProductSaleElements();
|
||||
|
||||
$loopResultRow = new LoopResultRow($result, $cartItem, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
@@ -92,10 +95,26 @@ class Cart extends BaseLoop
|
||||
$loopResultRow->set("QUANTITY", $cartItem->getQuantity());
|
||||
$loopResultRow->set("PRICE", $cartItem->getPrice());
|
||||
$loopResultRow->set("PRODUCT_ID", $product->getId());
|
||||
$loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale()))
|
||||
->set("STOCK", $productSaleElement->getQuantity())
|
||||
->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);
|
||||
$result->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the event dispatcher,
|
||||
*
|
||||
* @return \Symfony\Component\EventDispatcher\EventDispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,8 @@ class Category extends BaseI18nLoop
|
||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $category->getParent())
|
||||
->set("URL", $category->getUrl($locale))
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("PRODUCT_COUNT", $category->countAllProducts())
|
||||
->set("CHILD_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class CategoryTree extends BaseI18nLoop
|
||||
}
|
||||
|
||||
// changement de rubrique
|
||||
protected function buildCategoryTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult)
|
||||
protected function buildCategoryTree($parent, $visible, $level, $previousLevel, $max_level, $exclude, LoopResult &$loopResult)
|
||||
{
|
||||
if ($level > $max_level) return;
|
||||
|
||||
@@ -87,11 +87,12 @@ class CategoryTree extends BaseI18nLoop
|
||||
->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE'))
|
||||
->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale))
|
||||
->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level)
|
||||
->set('CHILD_COUNT', $result->countChild())->set('PREV_LEVEL', $previousLevel)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
|
||||
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $level, $max_level, $exclude, $loopResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +110,7 @@ class CategoryTree extends BaseI18nLoop
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
$this->buildCategoryTree($id, $visible, 0, $depth, $exclude, $loopResult);
|
||||
$this->buildCategoryTree($id, $visible, 0, 0, $depth, $exclude, $loopResult);
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ class Content extends BaseI18nLoop
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('folder'),
|
||||
Argument::createIntListTypeArgument('folder_default'),
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('current_folder'),
|
||||
Argument::createIntTypeArgument('depth', 1),
|
||||
@@ -97,9 +98,20 @@ class Content extends BaseI18nLoop
|
||||
}
|
||||
|
||||
$folder = $this->getFolder();
|
||||
$folderDefault = $this->getFolderDefault();
|
||||
|
||||
if (!is_null($folder)) {
|
||||
$folders = FolderQuery::create()->filterById($folder, Criteria::IN)->find();
|
||||
if (!is_null($folder) || !is_null($folderDefault)) {
|
||||
|
||||
$foldersIds = array();
|
||||
if (!is_array($folder)) {
|
||||
$folder = array();
|
||||
}
|
||||
if (!is_array($folderDefault)) {
|
||||
$folderDefault = array();
|
||||
}
|
||||
|
||||
$foldersIds = array_merge($foldersIds, $folder, $folderDefault);
|
||||
$folders =FolderQuery::create()->filterById($foldersIds, Criteria::IN)->find();
|
||||
|
||||
$depth = $this->getDepth();
|
||||
|
||||
@@ -164,12 +176,12 @@ class Content extends BaseI18nLoop
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual":
|
||||
if(null === $folder || count($folder) != 1)
|
||||
if(null === $foldersIds || count($foldersIds) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single folder argument');
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
if(null === $folder || count($folder) != 1)
|
||||
if(null === $foldersIds || count($foldersIds) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single folder argument');
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
@@ -222,6 +234,7 @@ class Content extends BaseI18nLoop
|
||||
->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION", $content->getPosition())
|
||||
->set("DEFAULT_FOLDER", $content->getDefaultFolderId())
|
||||
->set("URL", $content->getUrl($locale))
|
||||
;
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class Country extends BaseI18nLoop
|
||||
|
||||
if (true === $withArea) {
|
||||
$search->filterByAreaId(null, Criteria::ISNOTNULL);
|
||||
} elseif (false == $withArea) {
|
||||
} elseif (false === $withArea) {
|
||||
$search->filterByAreaId(null, Criteria::ISNULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,11 @@ use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Model\CouponQuery;
|
||||
use Thelia\Model\Coupon as MCoupon;
|
||||
use Thelia\Model\CouponQuery;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
@@ -63,7 +61,7 @@ class Coupon extends BaseI18nLoop
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createBooleanOrBothTypeArgument('is_enabled', 1)
|
||||
Argument::createBooleanOrBothTypeArgument('is_enabled')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -88,8 +86,8 @@ class Coupon extends BaseI18nLoop
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
if ($isEnabled != BooleanOrBothType::ANY) {
|
||||
$search->filterByIsEnabled($isEnabled ? 1 : 0);
|
||||
if (isset($isEnabled)) {
|
||||
$search->filterByIsEnabled($isEnabled ? true : false);
|
||||
}
|
||||
|
||||
// Perform search
|
||||
|
||||
@@ -22,9 +22,12 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
/**
|
||||
* Class Delivery
|
||||
@@ -50,6 +53,19 @@ class Delivery extends BaseSpecificModule
|
||||
$search = parent::exec($pagination);
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$search->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL);
|
||||
|
||||
$countryId = $this->getCountry();
|
||||
if(null !== $countryId) {
|
||||
$country = CountryQuery::create()->findPk($countryId);
|
||||
if(null === $country) {
|
||||
throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop');
|
||||
}
|
||||
} else {
|
||||
$country = CountryQuery::create()->findOneByByDefault(1);
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$deliveryModules = $this->search($search, $pagination);
|
||||
|
||||
@@ -73,7 +89,7 @@ class Delivery extends BaseSpecificModule
|
||||
->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO'))
|
||||
->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set('PRICE', $moduleInstance->calculate($this->getCountry()))
|
||||
->set('POSTAGE', $moduleInstance->getPostage($country))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
277
core/lib/Thelia/Core/Template/Loop/Document.php
Normal file
277
core/lib/Thelia/Core/Template/Loop/Document.php
Normal file
@@ -0,0 +1,277 @@
|
||||
<?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\Template\Loop;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Event\DocumentEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type\EnumListType;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Type\EnumType;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
/**
|
||||
* The document loop
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class Document extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @var array Possible document sources
|
||||
*/
|
||||
protected $possible_sources = array('category', 'product', 'folder', 'content');
|
||||
|
||||
/**
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
$collection = new ArgumentCollection(
|
||||
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual-reverse', 'random'))
|
||||
),
|
||||
'manual'
|
||||
),
|
||||
Argument::createIntTypeArgument('lang'),
|
||||
|
||||
Argument::createIntTypeArgument('category'),
|
||||
Argument::createIntTypeArgument('product'),
|
||||
Argument::createIntTypeArgument('folder'),
|
||||
Argument::createIntTypeArgument('content'),
|
||||
|
||||
new Argument(
|
||||
'source',
|
||||
new TypeCollection(
|
||||
new EnumType($this->possible_sources)
|
||||
)
|
||||
),
|
||||
Argument::createIntTypeArgument('source_id')
|
||||
);
|
||||
|
||||
// Add possible document sources
|
||||
foreach ($this->possible_sources as $source) {
|
||||
$collection->addArgument(Argument::createIntTypeArgument($source));
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically create the search query, and set the proper filter and order
|
||||
*
|
||||
* @param string $source a valid source identifier (@see $possible_sources)
|
||||
* @param int $object_id the source object ID
|
||||
* @return ModelCriteria the propel Query object
|
||||
*/
|
||||
protected function createSearchQuery($source, $object_id)
|
||||
{
|
||||
$object = ucfirst($source);
|
||||
|
||||
$queryClass = sprintf("\Thelia\Model\%sDocumentQuery", $object);
|
||||
$filterMethod = sprintf("filterBy%sId", $object);
|
||||
|
||||
// xxxDocumentQuery::create()
|
||||
$method = new \ReflectionMethod($queryClass, 'create');
|
||||
$search = $method->invoke(null); // Static !
|
||||
|
||||
// $query->filterByXXX(id)
|
||||
if (! is_null($object_id)) {
|
||||
$method = new \ReflectionMethod($queryClass, $filterMethod);
|
||||
$method->invoke($search, $object_id);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
// Results ordering
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha-reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "manual-reverse":
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
case "manual":
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "random":
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
break(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically create the search query, and set the proper filter and order
|
||||
*
|
||||
* @param string $object_type (returned) the a valid source identifier (@see $possible_sources)
|
||||
* @param string $object_id (returned) the ID of the source object
|
||||
* @return ModelCriteria the propel Query object
|
||||
*/
|
||||
protected function getSearchQuery(&$object_type, &$object_id)
|
||||
{
|
||||
$search = null;
|
||||
|
||||
// Check form source="product" source_id="123" style arguments
|
||||
$source = $this->getSource();
|
||||
|
||||
if (! is_null($source)) {
|
||||
|
||||
$source_id = $this->getSourceId();
|
||||
$id = $this->getId();
|
||||
|
||||
// echo "source = ".$this->getSource().", id=".$source_id." - ".$this->getArg('source_id')->getValue()."<br />";
|
||||
|
||||
if (is_null($source_id) && is_null($id)) {
|
||||
throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified");
|
||||
}
|
||||
|
||||
$search = $this->createSearchQuery($source, $source_id);
|
||||
|
||||
$object_type = $source;
|
||||
$object_id = $source_id;
|
||||
} else {
|
||||
// Check for product="id" folder="id", etc. style arguments
|
||||
foreach ($this->possible_sources as $source) {
|
||||
|
||||
$argValue = intval($this->getArgValue($source));
|
||||
|
||||
if ($argValue > 0) {
|
||||
|
||||
$search = $this->createSearchQuery($source, $argValue);
|
||||
|
||||
$object_type = $source;
|
||||
$object_id = $argValue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($search == null)
|
||||
throw new \InvalidArgumentException(sprintf("Unable to find document source. Valid sources are %s", implode(',', $this->possible_sources)));
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown $pagination
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
// Select the proper query to use, and get the object type
|
||||
$object_type = $object_id = null;
|
||||
|
||||
$search = $this->getSearchQuery($object_type, $object_id);
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (! is_null($id)) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
if (!is_null($exclude))
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
|
||||
// Create document processing event
|
||||
$event = new DocumentEvent($this->request);
|
||||
|
||||
// echo "sql=".$search->toString();
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
// Create document processing event
|
||||
$event = new DocumentEvent($this->request);
|
||||
|
||||
// Put source document file path
|
||||
$source_filepath = sprintf("%s%s/%s/%s",
|
||||
THELIA_ROOT,
|
||||
ConfigQuery::read('documents_library_path', 'local/media/documents'),
|
||||
$object_type,
|
||||
$result->getFile()
|
||||
);
|
||||
|
||||
$event->setSourceFilepath($source_filepath);
|
||||
$event->setCacheSubdirectory($object_type);
|
||||
|
||||
try {
|
||||
// Dispatch document processing event
|
||||
$this->dispatcher->dispatch(TheliaEvents::DOCUMENT_PROCESS, $event);
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $result, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $result->getId())
|
||||
->set("LOCALE" ,$locale)
|
||||
->set("DOCUMENT_URL" , $event->getFileUrl())
|
||||
->set("DOCUMENT_PATH" , $event->getCacheFilepath())
|
||||
->set("ORIGINAL_DOCUMENT_PATH", $source_filepath)
|
||||
->set("TITLE" , $result->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO" , $result->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("POSITION" , $result->getPosition())
|
||||
->set("OBJECT_TYPE" , $object_type)
|
||||
->set("OBJECT_ID" , $object_id)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Ignore the result and log an error
|
||||
Tlog::getInstance()->addError("Failed to process document in document loop: ", $this->args);
|
||||
}
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,12 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\CategoryQuery;
|
||||
use Thelia\Model\Base\ProductCategoryQuery;
|
||||
use Thelia\Model\Base\FeatureQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\FeatureI18nQuery;
|
||||
use Thelia\Model\ProductCategoryQuery;
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
@@ -71,7 +73,8 @@ class Feature extends BaseI18nLoop
|
||||
new Type\EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual_reverse'))
|
||||
),
|
||||
'manual'
|
||||
)
|
||||
),
|
||||
Argument::createAnyTypeArgument('title')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,6 +137,23 @@ class Feature extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
$title = $this->getTitle();
|
||||
|
||||
if (null !== $title) {
|
||||
//find all feture that match exactly this title and find with all locales.
|
||||
$features = FeatureI18nQuery::create()
|
||||
->filterByTitle($title, Criteria::LIKE)
|
||||
->select('id')
|
||||
->find();
|
||||
|
||||
if($features) {
|
||||
$search->filterById(
|
||||
$features,
|
||||
Criteria::IN
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
|
||||
@@ -162,7 +162,8 @@ class Folder extends BaseI18nLoop
|
||||
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $folder->getParent())
|
||||
->set("URL", $folder->getUrl($locale))
|
||||
->set("CONTENT_COUNT", $folder->countChild())
|
||||
->set("CHILD_COUNT", $folder->countChild())
|
||||
->set("CONTENT_COUNT", $folder->countAllContents())
|
||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $folder->getPosition())
|
||||
;
|
||||
|
||||
118
core/lib/Thelia/Core/Template/Loop/FolderTree.php
Normal file
118
core/lib/Thelia/Core/Template/Loop/FolderTree.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?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\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
|
||||
/**
|
||||
*
|
||||
* Folder tree loop, to get a folder tree from a given folder to a given depth.
|
||||
*
|
||||
* - folder is the folder id
|
||||
* - depth is the maximum depth to go, default unlimited
|
||||
* - visible if true or missing, only visible categories will be displayed. If false, all categories (visible or not) are returned.
|
||||
*
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FolderTree extends BaseI18nLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('folder', null, true),
|
||||
Argument::createIntTypeArgument('depth', PHP_INT_MAX),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', true, false),
|
||||
Argument::createIntListTypeArgument('exclude', array())
|
||||
);
|
||||
}
|
||||
|
||||
// changement de rubrique
|
||||
protected function buildFolderTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult)
|
||||
{
|
||||
if ($level > $max_level) return;
|
||||
|
||||
$search = FolderQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search, array(
|
||||
'TITLE'
|
||||
));
|
||||
|
||||
$search->filterByParent($parent);
|
||||
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN);
|
||||
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
|
||||
$results = $search->find();
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE'))
|
||||
->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale))
|
||||
->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
$this->buildFolderTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$id = $this->getFolder();
|
||||
$depth = $this->getDepth();
|
||||
$visible = $this->getVisible();
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
$this->buildFolderTree($id, $visible, 0, $depth, $exclude, $loopResult);
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class Image extends BaseI18nLoop
|
||||
/**
|
||||
* @var array Possible image sources
|
||||
*/
|
||||
protected $possible_sources = array('category', 'product', 'folder', 'content');
|
||||
protected $possible_sources = array('category', 'product', 'folder', 'content', 'module');
|
||||
|
||||
/**
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
@@ -93,7 +93,8 @@ class Image extends BaseI18nLoop
|
||||
new EnumType($this->possible_sources)
|
||||
)
|
||||
),
|
||||
Argument::createIntTypeArgument('source_id')
|
||||
Argument::createIntTypeArgument('source_id'),
|
||||
Argument::createBooleanTypeArgument('force_return', true)
|
||||
);
|
||||
|
||||
// Add possible image sources
|
||||
@@ -123,8 +124,10 @@ class Image extends BaseI18nLoop
|
||||
$search = $method->invoke(null); // Static !
|
||||
|
||||
// $query->filterByXXX(id)
|
||||
if (! is_null($object_id)) {
|
||||
$method = new \ReflectionMethod($queryClass, $filterMethod);
|
||||
$method->invoke($search, $object_id);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
@@ -171,11 +174,12 @@ class Image extends BaseI18nLoop
|
||||
if (! is_null($source)) {
|
||||
|
||||
$source_id = $this->getSourceId();
|
||||
$id = $this->getId();
|
||||
|
||||
// echo "source = ".$this->getSource().", id=".$source_id." - ".$this->getArg('source_id')->getValue()."<br />";
|
||||
//echo "source = ".$this->getSourceId()."source_id=$source_id, id=$id<br />";
|
||||
|
||||
if (is_null($source_id)) {
|
||||
throw new \InvalidArgumentException("'source_id' argument cannot be null if 'source' argument is specified.");
|
||||
if (is_null($source_id) && is_null($id)) {
|
||||
throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified");
|
||||
}
|
||||
|
||||
$search = $this->createSearchQuery($source, $source_id);
|
||||
@@ -211,6 +215,7 @@ class Image extends BaseI18nLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
|
||||
// Select the proper query to use, and get the object type
|
||||
$object_type = $object_id = null;
|
||||
|
||||
@@ -282,7 +287,7 @@ class Image extends BaseI18nLoop
|
||||
// Put source image file path
|
||||
$source_filepath = sprintf("%s%s/%s/%s",
|
||||
THELIA_ROOT,
|
||||
ConfigQuery::read('documents_library_path', 'local/media/images'),
|
||||
ConfigQuery::read('images_library_path', 'local/media/images'),
|
||||
$object_type,
|
||||
$result->getFile()
|
||||
);
|
||||
@@ -313,7 +318,8 @@ class Image extends BaseI18nLoop
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
} catch (\Exception $ex) {
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Ignore the result and log an error
|
||||
Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args);
|
||||
}
|
||||
|
||||
137
core/lib/Thelia/Core/Template/Loop/Module.php
Executable file
137
core/lib/Thelia/Core/Template/Loop/Module.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?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\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* Module loop
|
||||
*
|
||||
*
|
||||
* Class Module
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Module extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
new Argument(
|
||||
'module_type',
|
||||
new Type\TypeCollection(
|
||||
new Type\EnumListType(array(
|
||||
BaseModule::CLASSIC_MODULE_TYPE,
|
||||
BaseModule::DELIVERY_MODULE_TYPE,
|
||||
BaseModule::PAYMENT_MODULE_TYPE,
|
||||
))
|
||||
)
|
||||
),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createBooleanOrBothTypeArgument('active', Type\BooleanOrBothType::ANY)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$moduleType = $this->getModule_type();
|
||||
|
||||
if (null !== $moduleType) {
|
||||
$search->filterByType($moduleType, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$active = $this->getActive();
|
||||
|
||||
if($active !== Type\BooleanOrBothType::ANY) {
|
||||
$search->filterByActivate($active ? 1 : 0, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$search->orderByPosition();
|
||||
|
||||
/* perform search */
|
||||
$modules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($modules);
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $module, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $module->getId())
|
||||
->set("IS_TRANSLATED",$module->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("TITLE",$module->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $module->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $module->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $module->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("CODE", $module->getCode())
|
||||
->set("TYPE", $module->getType())
|
||||
->set("ACTIVE", $module->getActivate())
|
||||
->set("CLASS", $module->getFullNamespace())
|
||||
->set("POSITION", $module->getPosition());
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,16 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
/**
|
||||
*
|
||||
* @package Thelia\Core\Template\Loop
|
||||
@@ -37,19 +41,94 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
*/
|
||||
class Order extends BaseLoop
|
||||
{
|
||||
public $countable = true;
|
||||
public $timestampable = true;
|
||||
public $versionable = false;
|
||||
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
new Argument(
|
||||
'customer',
|
||||
new TypeCollection(
|
||||
new Type\IntType(),
|
||||
new Type\EnumType(array('current'))
|
||||
),
|
||||
'current'
|
||||
),
|
||||
Argument::createIntListTypeArgument('status')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
// TODO : a coder !
|
||||
$search = OrderQuery::create();
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$customer = $this->getCustomer();
|
||||
|
||||
if ($customer === 'current') {
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
} else {
|
||||
$search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL);
|
||||
}
|
||||
} else {
|
||||
$search->filterByCustomerId($customer, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$status = $this->getStatus();
|
||||
|
||||
if (null !== $status) {
|
||||
$search->filterByStatusId($status, Criteria::IN);
|
||||
}
|
||||
|
||||
$orders = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($orders);
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$tax = 0;
|
||||
$amount = $order->getTotalAmount($tax);
|
||||
$loopResultRow = new LoopResultRow($loopResult, $order, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow
|
||||
->set("ID", $order->getId())
|
||||
->set("REF", $order->getRef())
|
||||
->set("CUSTOMER", $order->getCustomerId())
|
||||
->set("DELIVERY_ADDRESS", $order->getDeliveryOrderAddressId())
|
||||
->set("INVOICE_ADDRESS", $order->getInvoiceOrderAddressId())
|
||||
->set("INVOICE_DATE", $order->getInvoiceDate())
|
||||
->set("CURRENCY", $order->getCurrencyId())
|
||||
->set("CURRENCY_RATE", $order->getCurrencyRate())
|
||||
->set("TRANSACTION_REF", $order->getTransactionRef())
|
||||
->set("DELIVERY_REF", $order->getDeliveryRef())
|
||||
->set("INVOICE_REF", $order->getInvoiceRef())
|
||||
->set("POSTAGE", $order->getPostage())
|
||||
->set("PAYMENT_MODULE", $order->getPaymentModuleId())
|
||||
->set("DELIVERY_MODULE", $order->getDeliveryModuleId())
|
||||
->set("STATUS", $order->getStatusId())
|
||||
->set("LANG", $order->getLangId())
|
||||
->set("POSTAGE", $order->getPostage())
|
||||
->set("TOTAL_TAX", $tax)
|
||||
->set("TOTAL_AMOUNT", $amount - $tax)
|
||||
->set("TOTAL_TAXED_AMOUNT", $amount)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
|
||||
84
core/lib/Thelia/Core/Template/Loop/Payment.php
Normal file
84
core/lib/Thelia/Core/Template/Loop/Payment.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
/**
|
||||
* Class Payment
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@gmail.com>
|
||||
*/
|
||||
class Payment extends BaseSpecificModule
|
||||
{
|
||||
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
$collection = parent::getArgDefinitions();
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = parent::exec($pagination);
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$search->filterByType(BaseModule::PAYMENT_MODULE_TYPE, Criteria::EQUAL);
|
||||
|
||||
/* perform search */
|
||||
$paymentModules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($paymentModules);
|
||||
|
||||
foreach ($paymentModules as $paymentModule) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $paymentModule, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
|
||||
throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode()));
|
||||
}
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->setRequest($this->request);
|
||||
$moduleInstance->setDispatcher($this->dispatcher);
|
||||
|
||||
$loopResultRow
|
||||
->set('ID', $paymentModule->getId())
|
||||
->set('TITLE', $paymentModule->getVirtualColumn('i18n_TITLE'))
|
||||
->set('CHAPO', $paymentModule->getVirtualColumn('i18n_CHAPO'))
|
||||
->set('DESCRIPTION', $paymentModule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set('POSTSCRIPTUM', $paymentModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
@@ -73,6 +74,7 @@ class Product extends BaseI18nLoop
|
||||
)
|
||||
),
|
||||
Argument::createIntListTypeArgument('category'),
|
||||
Argument::createIntListTypeArgument('category_default'),
|
||||
Argument::createBooleanTypeArgument('new'),
|
||||
Argument::createBooleanTypeArgument('promo'),
|
||||
Argument::createFloatTypeArgument('min_price'),
|
||||
@@ -88,7 +90,7 @@ class Product extends BaseI18nLoop
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id'))
|
||||
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id'))
|
||||
),
|
||||
'alpha'
|
||||
),
|
||||
@@ -170,9 +172,20 @@ class Product extends BaseI18nLoop
|
||||
}
|
||||
|
||||
$category = $this->getCategory();
|
||||
$categoryDefault = $this->getCategoryDefault();
|
||||
|
||||
if (!is_null($category)) {
|
||||
$categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find();
|
||||
if (!is_null($category) ||!is_null($categoryDefault)) {
|
||||
|
||||
$categoryIds = array();
|
||||
if (!is_array($category)) {
|
||||
$category = array();
|
||||
}
|
||||
if (!is_array($categoryDefault)) {
|
||||
$categoryDefault = array();
|
||||
}
|
||||
|
||||
$categoryIds = array_merge($categoryIds, $category, $categoryDefault);
|
||||
$categories =CategoryQuery::create()->filterById($categoryIds, Criteria::IN)->find();
|
||||
|
||||
$depth = $this->getDepth();
|
||||
|
||||
@@ -527,6 +540,12 @@ class Product extends BaseI18nLoop
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case "id_reverse":
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
@@ -540,12 +559,12 @@ class Product extends BaseI18nLoop
|
||||
$search->addDescendingOrderByColumn('real_lowest_price');
|
||||
break;
|
||||
case "manual":
|
||||
if(null === $category || count($category) != 1)
|
||||
if(null === $categoryIds || count($categoryIds) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
if(null === $category || count($category) != 1)
|
||||
if(null === $categoryIds || count($categoryIds) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
@@ -579,16 +598,43 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$loopResult = new LoopResult($products);
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic
|
||||
|
||||
foreach ($products as $product) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $product->getRealLowestPrice();
|
||||
|
||||
try {
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
$taxCountry
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPrice = null;
|
||||
}
|
||||
|
||||
// Find previous and next product, in the default category.
|
||||
$default_category_id = $product->getDefaultCategoryId();
|
||||
|
||||
$loopResultRow->set("ID", $product->getId())
|
||||
$previous = ProductQuery::create()
|
||||
->joinProductCategory()
|
||||
->where('ProductCategory.category_id = ?', $default_category_id)
|
||||
->filterByPosition($product->getPosition(), Criteria::LESS_THAN)
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$next = ProductQuery::create()
|
||||
->joinProductCategory()
|
||||
->where('ProductCategory.category_id = ?', $default_category_id)
|
||||
->filterByPosition($product->getPosition(), Criteria::GREATER_THAN)
|
||||
->orderByPosition(Criteria::ASC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $product->getId())
|
||||
->set("REF" , $product->getRef())
|
||||
->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
@@ -603,6 +649,13 @@ class Product extends BaseI18nLoop
|
||||
->set("IS_PROMO" , $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW" , $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION" , $product->getPosition())
|
||||
->set("VISIBLE" , $product->getVisible() ? "1" : "0")
|
||||
->set("HAS_PREVIOUS" , $previous != null ? 1 : 0)
|
||||
->set("HAS_NEXT" , $next != null ? 1 : 0)
|
||||
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
->set("DEFAULT_CATEGORY" , $default_category_id)
|
||||
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -31,6 +31,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
@@ -115,7 +116,7 @@ class ProductSaleElements extends BaseLoop
|
||||
|
||||
$currencyId = $this->getCurrency();
|
||||
if (null !== $currencyId) {
|
||||
$currency = CurrencyQuery::create()->findOneById($currencyId);
|
||||
$currency = CurrencyQuery::create()->findPk($currencyId);
|
||||
if (null === $currency) {
|
||||
throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop');
|
||||
}
|
||||
@@ -147,17 +148,27 @@ class ProductSaleElements extends BaseLoop
|
||||
|
||||
$loopResult = new LoopResult($PSEValues);
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic
|
||||
|
||||
foreach ($PSEValues as $PSEValue) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $PSEValue, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $PSEValue->getPrice();
|
||||
try {
|
||||
$taxedPrice = $PSEValue->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
$taxCountry
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPrice = null;
|
||||
}
|
||||
$promoPrice = $PSEValue->getPromoPrice();
|
||||
try {
|
||||
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
$taxCountry
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPromoPrice = null;
|
||||
}
|
||||
|
||||
$loopResultRow->set("ID", $PSEValue->getId())
|
||||
->set("QUANTITY", $PSEValue->getQuantity())
|
||||
|
||||
135
core/lib/Thelia/Core/Template/Loop/TaxRule.php
Normal file
135
core/lib/Thelia/Core/Template/Loop/TaxRule.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?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\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* TaxRule loop
|
||||
*
|
||||
*
|
||||
* Class TaxRule
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class TaxRule extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse'))
|
||||
),
|
||||
'alpha'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = TaxRuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (null !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case "id_reverse":
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$tax_rules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($tax_rules);
|
||||
|
||||
foreach ($tax_rules as $tax_rule) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $tax_rule, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $tax_rule->getId())
|
||||
->set("IS_TRANSLATED" , $tax_rule->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $tax_rule->getVirtualColumn('i18n_TITLE'))
|
||||
->set("DESCRIPTION" , $tax_rule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("IS_DEFAULT" , $tax_rule->getIsDefault() ? '1' : '0')
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
@@ -31,6 +32,7 @@ use Thelia\Core\Template\ParserContext;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\Product;
|
||||
@@ -52,12 +54,16 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
private $securityContext;
|
||||
protected $parserContext;
|
||||
protected $request;
|
||||
protected $dispatcher;
|
||||
|
||||
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext)
|
||||
private static $dataAccessCache = array();
|
||||
|
||||
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext, ContainerAwareEventDispatcher $dispatcher)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
$this->parserContext = $parserContext;
|
||||
$this->request = $request;
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,25 +160,74 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public function countryDataAccess($params, $smarty)
|
||||
{
|
||||
if(array_key_exists('defaultCountry', self::$dataAccessCache)) {
|
||||
$defaultCountry = self::$dataAccessCache['defaultCountry'];
|
||||
} else {
|
||||
$defaultCountry = CountryQuery::create()->findOneByByDefault(1);
|
||||
self::$dataAccessCache['defaultCountry'] = $defaultCountry;
|
||||
}
|
||||
|
||||
switch($params["attr"]) {
|
||||
case "default":
|
||||
return $defaultCountry->getId();
|
||||
}
|
||||
}
|
||||
|
||||
public function cartDataAccess($params, $smarty)
|
||||
{
|
||||
if(array_key_exists('currentCountry', self::$dataAccessCache)) {
|
||||
$currentCountry = self::$dataAccessCache['currentCountry'];
|
||||
} else {
|
||||
$currentCountry = CountryQuery::create()->findOneById(64); // @TODO : make it magic
|
||||
self::$dataAccessCache['currentCountry'] = $currentCountry;
|
||||
}
|
||||
|
||||
$cart = $this->getCart($this->request);
|
||||
$result = "";
|
||||
switch($params["attr"]) {
|
||||
case "count_item":
|
||||
|
||||
$result = $cart->getCartItems()->count();
|
||||
break;
|
||||
case "total_price":
|
||||
$result = $cart->getTotalAmount();
|
||||
break;
|
||||
case "total_taxed_price":
|
||||
$result = $cart->getTaxedAmount($currentCountry);
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function orderDataAccess($params, &$smarty)
|
||||
{
|
||||
$order = $this->request->getSession()->getOrder();
|
||||
$attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr'));
|
||||
switch($attribute) {
|
||||
case 'postage':
|
||||
return $order->getPostage();
|
||||
case 'delivery_address':
|
||||
return $order->chosenDeliveryAddress;
|
||||
case 'invoice_address':
|
||||
return $order->chosenInvoiceAddress;
|
||||
case 'delivery_module':
|
||||
return $order->getDeliveryModuleId();
|
||||
case 'payment_module':
|
||||
return $order->getPaymentModuleId();
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", 'Order', $attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lang global data
|
||||
*
|
||||
* @param $params
|
||||
* @param $smarty
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function langDataAccess($params, $smarty)
|
||||
{
|
||||
@@ -191,6 +246,9 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
*/
|
||||
protected function dataAccessWithI18n($objectLabel, $params, ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID')
|
||||
{
|
||||
if(array_key_exists('data_' . $objectLabel, self::$dataAccessCache)) {
|
||||
$data = self::$dataAccessCache['data_' . $objectLabel];
|
||||
} else {
|
||||
$lang = $this->getNormalizedParam($params, array('lang'));
|
||||
if ($lang === null) {
|
||||
$lang = $this->request->getSession()->getLang()->getId();
|
||||
@@ -209,6 +267,9 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
|
||||
$data = $search->findOne();
|
||||
|
||||
self::$dataAccessCache['data_' . $objectLabel] = $data;
|
||||
}
|
||||
|
||||
$noGetterData = array();
|
||||
foreach ($columns as $column) {
|
||||
$noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column);
|
||||
@@ -271,6 +332,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
|
||||
return array(
|
||||
new SmartyPluginDescriptor('function', 'admin', $this, 'adminDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'customer', $this, 'customerDataAccess'),
|
||||
@@ -279,8 +341,20 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
new SmartyPluginDescriptor('function', 'content', $this, 'contentDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'country', $this, 'countryDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the event dispatcher,
|
||||
*
|
||||
* @return \Symfony\Component\EventDispatcher\EventDispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,18 +23,24 @@
|
||||
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class Security extends AbstractSmartyPlugin
|
||||
{
|
||||
protected $request;
|
||||
private $securityContext;
|
||||
|
||||
public function __construct(SecurityContext $securityContext)
|
||||
public function __construct(Request $request, SecurityContext $securityContext)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +49,7 @@ class Security extends AbstractSmartyPlugin
|
||||
* @param array $params
|
||||
* @param unknown $smarty
|
||||
* @return string no text is returned.
|
||||
* @throws \Thelia\Core\Security\Exception\AuthenticationException
|
||||
*/
|
||||
public function checkAuthFunction($params, &$smarty)
|
||||
{
|
||||
@@ -69,6 +76,31 @@ class Security extends AbstractSmartyPlugin
|
||||
return '';
|
||||
}
|
||||
|
||||
public function checkCartNotEmptyFunction($params, &$smarty)
|
||||
{
|
||||
$cart = $this->request->getSession()->getCart();
|
||||
if($cart===null || $cart->countCartItems() == 0) {
|
||||
throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY, array('empty' => 1));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public function checkValidDeliveryFunction($params, &$smarty)
|
||||
{
|
||||
$order = $this->request->getSession()->getOrder();
|
||||
/* Does address and module still exists ? We assume address owner can't change neither module type */
|
||||
if($order !== null) {
|
||||
$checkAddress = AddressQuery::create()->findPk($order->chosenDeliveryAddress);
|
||||
$checkModule = ModuleQuery::create()->findPk($order->getDeliveryModuleId());
|
||||
}
|
||||
if(null === $order || null == $checkAddress || null === $checkModule) {
|
||||
throw new OrderException('Delivery must be defined', OrderException::UNDEFINED_DELIVERY, array('missing' => 1));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the various smarty plugins handled by this class
|
||||
*
|
||||
@@ -77,7 +109,9 @@ class Security extends AbstractSmartyPlugin
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction')
|
||||
new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction'),
|
||||
new SmartyPluginDescriptor('function', 'check_cart_not_empty', $this, 'checkCartNotEmptyFunction'),
|
||||
new SmartyPluginDescriptor('function', 'check_valid_delivery', $this, 'checkValidDeliveryFunction'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,8 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
|
||||
$loopResults = $loop->exec(self::$pagination[$name]);
|
||||
|
||||
$loopResults->rewind();
|
||||
|
||||
$this->loopstack[$name] = $loopResults;
|
||||
|
||||
// Pas de résultat ? la boucle est terminée, ne pas évaluer le contenu.
|
||||
|
||||
@@ -27,6 +27,7 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class UrlGenerator extends AbstractSmartyPlugin
|
||||
{
|
||||
@@ -47,11 +48,27 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
public function generateUrlFunction($params, &$smarty)
|
||||
{
|
||||
// the path to process
|
||||
$path = $this->getParam($params, 'path');
|
||||
$path = $this->getParam($params, 'path', null);
|
||||
$file = $this->getParam($params, 'file', null);
|
||||
|
||||
if ($file !== null) {
|
||||
$path = $file;
|
||||
$mode = URL::PATH_TO_FILE;
|
||||
}
|
||||
else if ($path !== null) {
|
||||
$mode = URL::WITH_INDEX_PAGE;
|
||||
}
|
||||
else {
|
||||
throw \InvalidArgumentException(Translator::getInstance()->trans("Please specify either 'path' or 'file' parameter in {url} function."));
|
||||
}
|
||||
|
||||
$target = $this->getParam($params, 'target', null);
|
||||
|
||||
$url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
|
||||
$url = URL::getInstance()->absoluteUrl(
|
||||
$path,
|
||||
$this->getArgsFromParam($params, array('path', 'file', 'target')),
|
||||
$mode
|
||||
);
|
||||
|
||||
if ($target != null) $url .= '#'.$target;
|
||||
|
||||
@@ -169,7 +186,8 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
|
||||
protected function getCurrentUrl()
|
||||
{
|
||||
return URL::getInstance()->retrieveCurrent($this->request)->toString();
|
||||
//return URL::getInstance()->retrieveCurrent($this->request)->toString();
|
||||
return $this->request->getUri();
|
||||
}
|
||||
|
||||
protected function getReturnToUrl()
|
||||
|
||||
@@ -86,6 +86,8 @@ class Thelia extends Kernel
|
||||
$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
|
||||
$con->useDebug(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -281,4 +281,14 @@ class CouponBaseAdapter implements CouponAdapterInterface
|
||||
|
||||
return $currencies->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the event dispatcher,
|
||||
*
|
||||
* @return \Symfony\Component\EventDispatcher\EventDispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->container->get('event_dispatcher');
|
||||
}
|
||||
}
|
||||
|
||||
36
core/lib/Thelia/Exception/DocumentException.php
Normal file
36
core/lib/Thelia/Exception/DocumentException.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\Exception;
|
||||
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
class DocumentException extends \RuntimeException
|
||||
{
|
||||
public function __construct($message, $code = null, $previous = null)
|
||||
{
|
||||
Tlog::getInstance()->addError($message);
|
||||
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
39
core/lib/Thelia/Exception/ModuleException.php
Executable file
39
core/lib/Thelia/Exception/ModuleException.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?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\Exception;
|
||||
|
||||
class ModuleException extends \RuntimeException
|
||||
{
|
||||
const UNKNOWN_EXCEPTION = 0;
|
||||
|
||||
const CODE_NOT_FOUND = 404;
|
||||
|
||||
public function __construct($message, $code = null, $previous = null)
|
||||
{
|
||||
if ($code === null) {
|
||||
$code = self::UNKNOWN_EXCEPTION;
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Exception/OrderException.php
Executable file
52
core/lib/Thelia/Exception/OrderException.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?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\Exception;
|
||||
|
||||
class OrderException extends \RuntimeException
|
||||
{
|
||||
/**
|
||||
* @var string The cart template name
|
||||
*/
|
||||
public $cartRoute = "cart.view";
|
||||
public $orderDeliveryRoute = "order.delivery";
|
||||
|
||||
public $arguments = array();
|
||||
|
||||
const UNKNOWN_EXCEPTION = 0;
|
||||
|
||||
const CART_EMPTY = 100;
|
||||
|
||||
const UNDEFINED_DELIVERY = 200;
|
||||
|
||||
public function __construct($message, $code = null, $arguments = array(), $previous = null)
|
||||
{
|
||||
if(is_array($arguments)) {
|
||||
$this->arguments = $arguments;
|
||||
}
|
||||
if ($code === null) {
|
||||
$code = self::UNKNOWN_EXCEPTION;
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ class TaxEngineException extends \RuntimeException
|
||||
const UNDEFINED_TAX_RULES_COLLECTION = 503;
|
||||
const UNDEFINED_REQUIREMENTS = 504;
|
||||
const UNDEFINED_REQUIREMENT_VALUE = 505;
|
||||
const UNDEFINED_TAX_RULE = 506;
|
||||
|
||||
const BAD_AMOUNT_FORMAT = 601;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user