start to create first loop
This commit is contained in:
@@ -59,6 +59,9 @@ class DatabaseConfiguration implements ConfigurationInterface
|
||||
->scalarNode("dsn")
|
||||
->cannotBeEmpty()
|
||||
->end()
|
||||
->scalarNode("classname")
|
||||
->defaultValue("PropelPDO")
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
||||
@@ -50,7 +50,8 @@ class DefinePropel {
|
||||
array(
|
||||
"dsn" => $connection["dsn"],
|
||||
"user" => $connection["user"],
|
||||
"password" => $connection["password"]
|
||||
"password" => $connection["password"],
|
||||
"classname" => $connection["classname"]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<loops>
|
||||
<loop name="foo" class="Foo\Bar"/>
|
||||
<loop name="fooz" class="Foo\Barz"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Category" name="category"/>
|
||||
</loops>
|
||||
|
||||
<services>
|
||||
|
||||
131
core/lib/Thelia/Core/Template/Loop/Category.php
Normal file
131
core/lib/Thelia/Core/Template/Loop/Category.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?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\Log\Tlog;
|
||||
use Thelia\Tpex\Element\Loop\BaseLoop;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
|
||||
class Category extends BaseLoop {
|
||||
|
||||
public $id;
|
||||
public $parent;
|
||||
public $current;
|
||||
public $not_empty;
|
||||
public $visible;
|
||||
public $link;
|
||||
public $order;
|
||||
public $random;
|
||||
public $exclude;
|
||||
public $start;
|
||||
public $offset;
|
||||
|
||||
public function defineArgs()
|
||||
{
|
||||
return array(
|
||||
"id" => "optional",
|
||||
"parent" => "optional",
|
||||
"current" => "optional",
|
||||
"not_empty" => 0,
|
||||
"visible" => 1,
|
||||
"link" => "optional",
|
||||
"order" => "optional",
|
||||
"random" => 0,
|
||||
"exclude" => "optional",
|
||||
"limit" => 10,
|
||||
"offset" => 0,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function exec($text)
|
||||
{
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
if (!is_null($this->id)) {
|
||||
$search->filterById($this->id);
|
||||
}
|
||||
|
||||
if(!is_null($this->parent)) {
|
||||
$search->filterByParent($this->parent);
|
||||
}
|
||||
|
||||
if($this->current == 1) {
|
||||
$search->filterById($this->request->get("category_id"));
|
||||
} else if ($this->current == 0) {
|
||||
$search->filterById($this->request->get("category_id"), \Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
if (!is_null($this->exclude)) {
|
||||
$search->filterById(explode(",", $this->exclude), \Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
if (!is_null($this->link)) {
|
||||
$search->filterByLink($this->link);
|
||||
}
|
||||
|
||||
if($this->limit > -1) {
|
||||
$search->limit($this->limit);
|
||||
}
|
||||
$search->offset($this->offset);
|
||||
|
||||
switch($this->order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE);
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE);
|
||||
break;
|
||||
case "reverse":
|
||||
$search->orderByPosition(\Criteria::DESC);
|
||||
break;
|
||||
default:
|
||||
$search->orderByPosition();
|
||||
break;
|
||||
}
|
||||
|
||||
if($this->random == 1) {
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
}
|
||||
$search->joinWithI18n('en_US');
|
||||
|
||||
$categories = $search->find();
|
||||
|
||||
$res = "";
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$temp = str_replace("#TITLE", $category->getTitle(), $text);
|
||||
$temp = str_replace("#CHAPO", $category->getChapo(), $temp);
|
||||
$temp = str_replace("#ID", $category->getId(), $temp);
|
||||
$res .= $temp;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,10 +84,17 @@ class Thelia extends Kernel
|
||||
if ($this->isDebug()) {
|
||||
Propel::setLogger(Tlog::getInstance());
|
||||
$config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
|
||||
$config->setParameter('debugpdo.logging.details.method.enabled', true);
|
||||
$config->setParameter('debugpdo.logging.details.time.enabled', true);
|
||||
$config->setParameter('debugpdo.logging.details.mem.enabled', true);
|
||||
|
||||
$config->setParameter('debugpdo.logging.methods', array(
|
||||
'PropelPDO::exec',
|
||||
'PropelPDO::query',
|
||||
'PropelPDO::prepare',
|
||||
'DebugPDOStatement::execute',
|
||||
), false);
|
||||
$config->setParameter('debugpdo.logging.details', array(
|
||||
'time' => array('enabled' => true),
|
||||
'mem' => array('enabled' => true),
|
||||
'connection' => array('enabled' => true),
|
||||
));
|
||||
$con = Propel::getConnection("thelia");
|
||||
$con->useDebug(true);
|
||||
}
|
||||
|
||||
Submodule core/lib/Thelia/Tpex updated: a6ab89790f...8c4ab84562
@@ -68,7 +68,7 @@ try {
|
||||
|
||||
$con->commit();
|
||||
} catch (Exception $e) {
|
||||
echo "error : ".$e->getMessage();
|
||||
echo "error : ".$e->getMessage()."\n";
|
||||
$con->rollBack();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,19 @@ use Thelia\Model\ProductQuery;
|
||||
|
||||
class Doobitch extends BaseLoop {
|
||||
|
||||
public function exec($text, $args)
|
||||
public function defineArgs()
|
||||
{
|
||||
return array(
|
||||
"param1",
|
||||
"param2" => array("default" => "foo")
|
||||
);
|
||||
}
|
||||
|
||||
public function exec($text)
|
||||
{
|
||||
|
||||
$param1 = Tools::extractValueParam("param1", $args);
|
||||
|
||||
$res = "";
|
||||
if($param1 == 2 || $param1 == 3) {
|
||||
if($this->param1 == 2 || $this->param1 == 3) {
|
||||
for($i = 0; $i < 4; $i++) {
|
||||
$tmp = str_replace("#ALFRED", "foo".$i, $text);
|
||||
if($i%2){
|
||||
@@ -35,6 +41,8 @@ class Doobitch extends BaseLoop {
|
||||
}
|
||||
}
|
||||
|
||||
echo $this->param2;
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,12 @@ use Thelia\Tpex\Element\Loop\BaseLoop;
|
||||
|
||||
class Foo extends BaseLoop {
|
||||
|
||||
public function exec($text, $args)
|
||||
public function defineArgs()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function exec($text)
|
||||
{
|
||||
$res = "";
|
||||
for($i = 0; $i < 4; $i++) {
|
||||
|
||||
@@ -5,21 +5,17 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div>TODO write content #SET{toto, 4} toto vaut #GET{toto} zeafazefaze azef azef azef azef <br />
|
||||
<THELIA_FOO type="foo" id="loop1" param1="#GET{toto}">
|
||||
toto : #TOTO <br />
|
||||
count : #__COUNT__ <br /><br />
|
||||
<THELIA_FU type="doobitch" param1="#__COUNT__" param2="#TUTU">
|
||||
#ALFRED azd azd azed azd <br />
|
||||
<T:CHAPO>#CHAPO n'est pas vide</T:CHAPO>le chapo est vide<//T:CHAPO> <br />
|
||||
</THELIA_FU>
|
||||
</THELIA_FOO>
|
||||
<div>TODO write content<br />
|
||||
|
||||
<TEST_equel test="equal" variable="3" value="1">
|
||||
<THELIA_cat type="category" order="alpha_reverse">
|
||||
#__COUNT__ - #TITLE <br />
|
||||
</THELIA_cat>
|
||||
|
||||
<TEST_equal test="equal" variable="3" value="1">
|
||||
test vrai
|
||||
</TEST_equel>
|
||||
</TEST_equal>
|
||||
test faux
|
||||
<//TEST_equel>
|
||||
<//TEST_equal>
|
||||
<br />
|
||||
<REPEAT_loopy start="6" end="12" increment="1">
|
||||
Compteur = #INDEX<br />
|
||||
|
||||
Reference in New Issue
Block a user