Fixed getUrl()

This commit is contained in:
franck
2013-08-31 15:52:42 +02:00
parent 533f18bcec
commit 6d5d0f6606
17 changed files with 214 additions and 131 deletions

16
composer.lock generated
View File

@@ -397,12 +397,12 @@
"source": {
"type": "git",
"url": "https://github.com/simplepie/simplepie.git",
"reference": "f5436d69a8efa9d4ab3a9abc65d17317eb24b7f4"
"reference": "f97c8ef9be655c35e6fecdb608bdf5af05a4374a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/f5436d69a8efa9d4ab3a9abc65d17317eb24b7f4",
"reference": "f5436d69a8efa9d4ab3a9abc65d17317eb24b7f4",
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/f97c8ef9be655c35e6fecdb608bdf5af05a4374a",
"reference": "f97c8ef9be655c35e6fecdb608bdf5af05a4374a",
"shasum": ""
},
"require": {
@@ -443,7 +443,7 @@
"feeds",
"rss"
],
"time": "2013-04-29 06:13:26"
"time": "2013-08-31 01:38:46"
},
{
"name": "smarty/smarty",
@@ -1622,12 +1622,12 @@
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
"reference": "feb6492762a77db946bc13cc44a20a01546be0e6"
"reference": "77a4e394d99a67e7fb611e8b402c2da4b80fa4f8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/feb6492762a77db946bc13cc44a20a01546be0e6",
"reference": "feb6492762a77db946bc13cc44a20a01546be0e6",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/77a4e394d99a67e7fb611e8b402c2da4b80fa4f8",
"reference": "77a4e394d99a67e7fb611e8b402c2da4b80fa4f8",
"shasum": ""
},
"require": {
@@ -1660,7 +1660,7 @@
"faker",
"fixtures"
],
"time": "2013-08-12 10:05:47"
"time": "2013-08-29 19:11:59"
},
{
"name": "phpunit/php-code-coverage",

View File

@@ -77,7 +77,7 @@ class Config extends BaseAction implements EventSubscriberInterface
$search = ConfigQuery::create();
if (null !== $config = $search->findById($event->getConfigId())) {
if (null !== $config = $search->findOneById($event->getConfigId())) {
$config
->setDispatcher($this->getDispatcher())
@@ -98,7 +98,7 @@ class Config extends BaseAction implements EventSubscriberInterface
$search = ConfigQuery::create();
if (null !== $config = ConfigQuery::create()->findById($event->getConfigId())) {
if (null !== $config = ConfigQuery::create()->findOneById($event->getConfigId())) {
$config
->setDispatcher($this->getDispatcher())
@@ -127,10 +127,10 @@ class Config extends BaseAction implements EventSubscriberInterface
{
$this->checkAuth("ADMIN", "admin.configuration.variables.delete");
if (null !== $config = ConfigQuery::create()->findById($event->getConfigId())) {
if (null !== ($config = ConfigQuery::create()->findOneById($event->getConfigId()))) {
if (! $config->getSecured()) {
$config->setDispatcher($this->getDispatcher())->delete();
$config->setDispatcher($this->getDispatcher());
$config->delete();
}
}
}

View File

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

View File

@@ -35,22 +35,22 @@
<default key="_controller">Thelia\Controller\Admin\CategoryController::processAction</default>
</route>
<!-- Routes to the Config controller -->
<!-- Routes to the Config (system variables) controller -->
<route id="admin.config.default" path="/admin/configuration/config">
<default key="_controller">Thelia\Controller\Admin\ConfigController::defaultAction</default>
<route id="admin.configuration.variables.default" path="/admin/configuration/variables">
<default key="_controller">Thelia\Controller\Admin\VariablesController::defaultAction</default>
</route>
<route id="admin.config.create" path="/admin/config/configuration/create">
<default key="_controller">Thelia\Controller\Admin\ConfigController::createAction</default>
<route id="admin.configuration.variables.create" path="/admin/configuration/variables/create">
<default key="_controller">Thelia\Controller\Admin\VariablesController::createAction</default>
</route>
<route id="admin.config.change" path="/admin/config/configuration/change">
<default key="_controller">Thelia\Controller\Admin\ConfigController::changeAction</default>
<route id="admin.configuration.variables.change" path="/admin/configuration/variables/change">
<default key="_controller">Thelia\Controller\Admin\VariablesController::changeAction</default>
</route>
<route id="admin.config.delete" path="/admin/config/configuration/delete">
<default key="_controller">Thelia\Controller\Admin\ConfigController::deleteAction</default>
<route id="admin.configuration.variables.delete" path="/admin/configuration/variables/delete">
<default key="_controller">Thelia\Controller\Admin\VariablesController::deleteAction</default>
</route>

View File

@@ -23,16 +23,24 @@
namespace Thelia\Controller\Admin;
class ConfigController extends BaseAdminController
use Thelia\Core\Event\ConfigDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL;
class VariablesController extends BaseAdminController
{
public function defaultAction() {
$this->render('config');
return $this->render('variables');
}
public function createAction() {
}
public function deleteAction() {
$event = new ConfigDeleteEvent($this->getRequest()->get('id'));
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
$this->redirect(URL::adminViewUrl('variables'));
}
public function updateAction() {

View File

@@ -81,7 +81,7 @@ class CategoryPath extends BaseI18nLoop
$search = CategoryQuery::create();
$this->configureI18nProcessing($search, array('TITLE'));
$locale = $this->configureI18nProcessing($search, array('TITLE'));
$search->filterById($id);
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
@@ -99,7 +99,7 @@ class CategoryPath extends BaseI18nLoop
$loopResultRow
->set("TITLE",$category->getVirtualColumn('i18n_TITLE'))
->set("URL", $category->getUrl())
->set("URL", $category->getUrl($locale))
->set("ID", $category->getId())
;

View File

@@ -22,9 +22,7 @@
/*************************************************************************************/
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;
@@ -34,6 +32,7 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\CategoryQuery;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
use Thelia\Core\Template\Element\BaseI18nLoop;
/**
*
@@ -46,19 +45,17 @@ use Thelia\Type\BooleanOrBothType;
* @package Thelia\Core\Template\Loop
* @author Franck Allimant <franck@cqfdev.fr>
*/
class CategoryTree extends BaseLoop
class CategoryTree extends BaseI18nLoop
{
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('category', null, true),
Argument::createIntTypeArgument('depth', PHP_INT_MAX),
Argument::createBooleanOrBothTypeArgument('visible', true, false),
Argument::createIntListTypeArgument('exclude', array())
);
return new ArgumentCollection(Argument::createIntTypeArgument('category', null, true),
Argument::createIntTypeArgument('depth', PHP_INT_MAX),
Argument::createBooleanOrBothTypeArgument('visible', true, false),
Argument::createIntListTypeArgument('exclude', array()));
}
// changement de rubrique
@@ -66,7 +63,11 @@ class CategoryTree extends BaseLoop
{
if ($level > $max_level) return;
$search = CategoryQuery::create();
$search = CategoryQuery::create();
$locale = $this->configureI18nProcessing($search, array(
'TITLE'
));
$search->filterByParent($parent);
@@ -82,18 +83,15 @@ class CategoryTree extends BaseLoop
$loopResultRow = new LoopResultRow();
$loopResultRow
->set("ID", $result->getId())
->set("TITLE",$result->getTitle())
->set("PARENT", $result->getParent())
->set("URL", $result->getUrl())
->set("VISIBLE", $result->getVisible() ? "1" : "0")
->set("LEVEL", $level)
$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);
$loopResult->addRow($loopResultRow);
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
}
}
@@ -105,7 +103,7 @@ class CategoryTree extends BaseLoop
public function exec(&$pagination)
{
$id = $this->getCategory();
$depth = $this->getDepth();
$depth = $this->getDepth();
$visible = $this->getVisible();
$exclude = $this->getExclude();

View File

@@ -57,7 +57,7 @@ class Config extends BaseI18nLoop
return new ArgumentCollection(
Argument::createIntTypeArgument('id'),
Argument::createIntListTypeArgument('exclude'),
Argument::createAnyTypeArgument('name'),
Argument::createAnyTypeArgument('variable'),
Argument::createBooleanOrBothTypeArgument('hidden'),
Argument::createBooleanOrBothTypeArgument('secured')
);
@@ -71,11 +71,11 @@ class Config extends BaseI18nLoop
public function exec(&$pagination)
{
$id = $this->getId();
$name = $this->getName();
$name = $this->getVariable();
$search = ConfigQuery::create();
$this->configureI18nProcessing($search);
$this->configureI18nProcessing($search);
if (! is_null($id))
$search->filterById($id);
@@ -113,6 +113,7 @@ class Config extends BaseI18nLoop
->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("HIDDEN" , $result->getHidden())
->set("SECURED" , $result->getSecured())
->set("CREATE_DATE" , $result->getCreatedAt())
->set("UPDATE_DATE" , $result->getUpdatedAt())
;

View File

@@ -219,7 +219,7 @@ class SmartyParser extends Smarty implements ParserInterface
$fileName .= ".html";
if (!file_exists($fileName)) {
throw new ResourceNotFoundException(sprintf("%s file (%s) not found in %s template", $file, $fileName, $this->template));
throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template));
}
}

View File

@@ -59,6 +59,8 @@ class Config extends BaseConfig {
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETECONFIG, new ConfigEvent($this));
return true;
}
public function postDelete(ConnectionInterface $con = null)

View File

@@ -102,38 +102,6 @@ class Customer extends BaseCustomer implements UserInterface
}
}
public function preInsert(ConnectionInterface $con = null)
{
$this->setRef($this->generateRef());
$customerEvent = new CustomerEvent($this);
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECUSTOMER, $customerEvent);
return true;
}
public function postInsert(ConnectionInterface $con = null)
{
$customerEvent = new CustomerEvent($this);
$this->dispatchEvent(TheliaEvents::AFTER_CREATECUSTOMER, $customerEvent);
}
public function preUpdate(ConnectionInterface $con = null)
{
$customerEvent = new CustomerEvent($this);
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, $customerEvent);
return true;
}
public function postUpdate(ConnectionInterface $con = null)
{
$customerEvent = new CustomerEvent($this);
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, $customerEvent);
}
protected function generateRef()
{
return uniqid(substr($this->getLastname(), 0, (strlen($this->getLastname()) >= 3) ? 3 : strlen($this->getLastname())), true);
@@ -202,4 +170,57 @@ class Customer extends BaseCustomer implements UserInterface
public function getRoles() {
return array(new Role('CUSTOMER'));
}
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->setRef($this->generateRef());
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECUSTOMER, new CustomerEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postInsert(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CREATECUSTOMER, new CustomerEvent($this));
}
/**
* {@inheritDoc}
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, new CustomerEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, new CustomerEvent($this));
}
/**
* {@inheritDoc}
*/
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETECONFIG, new CustomerEvent($this));
return true;
}
/**
* {@inheritDoc}
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::AFTER_DELETECONFIG, new CustomerEvent($this));
}
}

View File

@@ -40,6 +40,8 @@ trait ModelEventDispatcherTrait {
public function setDispatcher(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
return $this;
}
protected function dispatchEvent($eventName, ActionEvent $event)

View File

@@ -703,9 +703,12 @@ label {
line-height: 30px;
.btn-add-item {
.action-btn {
display: block;
float: right;
margin-left: 10px;
text-transform: none;
}
}
@@ -758,3 +761,13 @@ label {
text-transform: uppercase;
}
}
.table-left-aligned {
th, td {
text-align: left;
}
select, textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {
margin-bottom: 0;
}
}

View File

@@ -32,7 +32,7 @@
{module_include location='category_list_caption'}
{loop type="auth" name="can_create" context="admin" roles="ADMIN" permissions="admin.category.create"}
<a class="btn btn-primary btn-add-item" title="{intl l='Add a new category'}" href="#add_category_dialog" data-toggle="modal">
<a class="btn btn-primary action-btn" title="{intl l='Add a new category'}" href="#add_category_dialog" data-toggle="modal">
<i class="icon-plus-sign icon-white"></i>
</a>
{/loop}
@@ -185,7 +185,7 @@
{module_include location='product_list_caption'}
<a class="btn btn-primary btn-add-item" title="{intl l='Add a new product'}" href="#productAddModal" data-toggle="modal">
<a class="btn btn-primary action-btn" title="{intl l='Add a new product'}" href="#productAddModal" data-toggle="modal">
<i class="icon-plus-sign icon-white"></i>
</a>
</caption>

View File

@@ -1,44 +0,0 @@
{check_auth context="admin" roles="ADMIN" permissions="admin.configuration.variables.view" login_tpl="/admin/login"}
{$page_title={intl l='Configuration'}}
{include file='includes/header.inc.html'}
<div class="configuration">
<div id="wrapper" class="container">
{module_include location='config_top'}
<h2>{intl l="Thelia system variables "}</h2>
<div class="row-fluid">
<div class="span6">
<div class="menu-list-table general-block-decorator">
<table class="table table-striped table-condensed">
<caption>{intl l='Product catalog configuration'}</caption>
{loop name="config" type="config" hidden="0"}
<tr>
<td>{$TITLE}</td>
<td>{$NAME}</td>
<td><input type="text" name="value" value="{$VALUE|htmlspecialchars}" /></td>
<td>
{if ! $secured}
{loop type="auth" name="can_delete" context="admin" roles="ADMIN" permissions="admin.configuration.variables.delete"}
<a class="btn btn-mini config-delete" title="{intl l='Delete this configuration variable'}" href="#delete_category_dialog" data-id="{$ID}" data-toggle="modal"><i class="icon-trash"></i></a>
{/loop}
{/if}
</td>
</tr>
{/loop}
</table>
</div>
</div>
</div>
</div>
</div>
{include file='includes/js.inc.html'}
{include file='includes/footer.inc.html'}

View File

@@ -112,8 +112,8 @@
{loop type="auth" name="pcc2" context="admin" roles="ADMIN" permissions="admin.configuration.variables"}
<tr>
<td><a href="{url path='/admin/configuration/config'}">{intl l='System variables'}</a></td>
<td><a class="btn btn-mini" href="{url path='/admin/configuration/config'}"><i class="icon-edit"></i></a></td>
<td><a href="{url path='/admin/configuration/variables'}">{intl l='System variables'}</a></td>
<td><a class="btn btn-mini" href="{url path='/admin/configuration/variables'}"><i class="icon-edit"></i></a></td>
</tr>
{/loop}

View File

@@ -0,0 +1,77 @@
{check_auth context="admin" roles="ADMIN" permissions="admin.configuration.variables.view" login_tpl="/admin/login"}
{$page_title={intl l='Configuration'}}
{include file='includes/header.inc.html'}
<div class="variables">
<div id="wrapper" class="container">
{module_include location='config_top'}
<h2>{intl l="Thelia system variables configuration"}</h2>
<div class="row-fluid">
<div class="span6">
<form>
<div class="general-block-decorator">
<table class="table table-striped table-condensed table-left-aligned">
<caption>
{intl l='Thelia system variables'}
{loop type="auth" name="can_create" context="admin" roles="ADMIN" permissions="admin.category.create"}
<a class="btn btn-primary action-btn" title="{intl l='Add a new variable'}" href="#">
<i class="icon-plus-sign icon-white"></i>
</a>
<button class="btn btn-primary action-btn" title="{intl l='Save chages'}">{intl l='Save changes'} <i class="icon icon-white icon-ok"></i></button>
{/loop}
</caption>
<tr>
<th>{intl l="Purpose"}</th>
<th>{intl l="Name"}</th>
<th>{intl l="Value"}</th>
<th>&nbsp;</th>
</tr>
{loop name="config" type="config" hidden="0" secured="*" backend_context="1"}
<tr>
<td>{$TITLE}</td>
<td>{$NAME}</td>
<td>
{if $SECURED}
{$VALUE}
{else}
<input type="text" name="value" value="{$VALUE|htmlspecialchars}" />
{/if}
</td>
<td>
{if ! $SECURED}
{loop type="auth" name="can_delete" context="admin" roles="ADMIN" permissions="admin.configuration.variables.delete"}
<a class="btn btn-mini config-delete" title="{intl l='Delete this configuration variable'}" href="{url path='/admin/configuration/variables/delete' id="$ID"}"><i class="icon-trash"></i></a>
{/loop}
{/if}
</td>
</tr>
{/loop}
</table>
</div>
</form>
</div>
</div>
</div>
</div>
{include file='includes/js.inc.html'}
<script>
$(function() {
$('a.config-delete').click(function(ev) {
if (! confirm("{intl l='Do you really want to delete this variable ?'}")) {
ev.preventDefault();
}
}
)})
</script>
{include file='includes/footer.inc.html'}