diff --git a/core/lib/Thelia/Config/DatabaseConfiguration.php b/core/lib/Thelia/Config/DatabaseConfiguration.php index 753b19d46..d1c1f09d8 100644 --- a/core/lib/Thelia/Config/DatabaseConfiguration.php +++ b/core/lib/Thelia/Config/DatabaseConfiguration.php @@ -59,6 +59,9 @@ class DatabaseConfiguration implements ConfigurationInterface ->scalarNode("dsn") ->cannotBeEmpty() ->end() + ->scalarNode("classname") + ->defaultValue("PropelPDO") + ->end() ->end() ->end() ->end() diff --git a/core/lib/Thelia/Config/DefinePropel.php b/core/lib/Thelia/Config/DefinePropel.php index 02dc8e26b..800fa53ac 100644 --- a/core/lib/Thelia/Config/DefinePropel.php +++ b/core/lib/Thelia/Config/DefinePropel.php @@ -50,7 +50,8 @@ class DefinePropel { array( "dsn" => $connection["dsn"], "user" => $connection["user"], - "password" => $connection["password"] + "password" => $connection["password"], + "classname" => $connection["classname"] ) ) ) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 7fe23edc9..12086193d 100644 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -11,6 +11,7 @@ + diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php new file mode 100644 index 000000000..faba2f288 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -0,0 +1,131 @@ +. */ +/* */ +/*************************************************************************************/ + + +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; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 69e3515f5..076d66e5c 100644 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -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); } diff --git a/core/lib/Thelia/Tpex b/core/lib/Thelia/Tpex index a6ab89790..8c4ab8456 160000 --- a/core/lib/Thelia/Tpex +++ b/core/lib/Thelia/Tpex @@ -1 +1 @@ -Subproject commit a6ab89790f4273df79cf731405158c417098764d +Subproject commit 8c4ab845625ce9d5bd9d9106ced66b434daa7261 diff --git a/install/faker.php b/install/faker.php index 3981e3ebf..28cdb5da1 100644 --- a/install/faker.php +++ b/install/faker.php @@ -68,7 +68,7 @@ try { $con->commit(); } catch (Exception $e) { - echo "error : ".$e->getMessage(); + echo "error : ".$e->getMessage()."\n"; $con->rollBack(); } diff --git a/local/plugins/Test/Loop/Doobitch.php b/local/plugins/Test/Loop/Doobitch.php index d88780510..12cebe7ef 100644 --- a/local/plugins/Test/Loop/Doobitch.php +++ b/local/plugins/Test/Loop/Doobitch.php @@ -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; } } \ No newline at end of file diff --git a/local/plugins/Test/Loop/Foo.php b/local/plugins/Test/Loop/Foo.php index 580d9f6bb..aa161b72a 100644 --- a/local/plugins/Test/Loop/Foo.php +++ b/local/plugins/Test/Loop/Foo.php @@ -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++) { diff --git a/templates/default/index.html b/templates/default/index.html index f3d090ce0..6a844d33f 100644 --- a/templates/default/index.html +++ b/templates/default/index.html @@ -5,21 +5,17 @@ -
TODO write content #SET{toto, 4} toto vaut #GET{toto} zeafazefaze azef azef azef azef
- - toto : #TOTO
- count : #__COUNT__

- - #ALFRED azd azd azed azd
- #CHAPO n'est pas videle chapo est vide
-
-
+
TODO write content
- + + #__COUNT__ - #TITLE
+
+ + test vrai -
+ test faux - +
Compteur = #INDEX