Rajout du module View pour pouvoir afficher dans les menus la liste des marques

This commit is contained in:
2023-12-02 15:42:11 +01:00
parent fc6a693f1c
commit 97a75fbf2a
37 changed files with 4471 additions and 5 deletions

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<loops>
<loop name="view" class="View\Loop\View" />
<loop name="frontview" class="View\Loop\FrontView" />
<loop name="frontfiles" class="View\Loop\Frontfiles" />
</loops>
<forms>
<form name="view.create" class="View\Form\ViewForm" />
</forms>
<commands>
<!--
<command class="MyModule\Command\MySuperCommand" />
-->
</commands>
<services>
<service id="view.listener" class="View\Listener\ViewListener">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="module.view.listener" class="View\Listener\ControllerListener">
<tag name="kernel.event_subscriber"/>
</service>
</services>
<hooks>
<hook id="view.hookmanager.hook" class="View\Hook\HookManager">
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfiguration"/>
<tag name="hook.event_listener" event="category.tab-content" type="back" method="onEditModuleTab"/>
<tag name="hook.event_listener" event="content.tab-content" type="back" method="onEditModuleTab"/>
<tag name="hook.event_listener" event="folder.tab-content" type="back" method="onEditModuleTab"/>
<tag name="hook.event_listener" event="product.tab-content" type="back" method="onEditModuleTab"/>
</hook>
</hooks>
</config>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://thelia.net/schema/dic/module"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_1.xsd">
<fullnamespace>View\View</fullnamespace>
<descriptive locale="en_US">
<title>Assign a specific view for any category, product, folder or content</title>
</descriptive>
<descriptive locale="fr_FR">
<title>Utilisez une vue spécifique pour chaque catégorie, produit, dossier ou contenu</title>
</descriptive>
<languages>
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>2.0.2</version>
<author>
<name>Anthony Chevrier / Franck Allimant</name>
<email>anthony@meedle.fr / thelia@cqfdev.fr</email>
</author>
<type>classic</type>
<thelia>2.1.0</thelia>
<stability>other</stability>
</module>

View File

@@ -0,0 +1,11 @@
<?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="view.add" path="/admin/view/add/{source_id}" methods="post">
<default key="_controller">View\Controller\ViewController::createAction</default>
<requirement key="source_id">\d+</requirement>
</route>
</routes>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia" namespace="View\Model">
<!--
See propel documentation on http://propelorm.org for all information about schema file
-->
<table name="view">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
<column name="view" size="255" type="VARCHAR" />
<column name="source" type="CLOB" />
<column name="source_id" type="INTEGER" />
<column name="subtree_view" size="255" type="VARCHAR" default="" />
<column name="children_view" size="255" type="VARCHAR" default="" />
<behavior name="timestampable" />
</table>
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
</database>

View File

@@ -0,0 +1,26 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- view
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `view`;
CREATE TABLE `view`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`view` VARCHAR(255),
`source` LONGTEXT,
`source_id` INTEGER,
`subtree_view` VARCHAR(255) DEFAULT '',
`children_view` VARCHAR(255) DEFAULT '',
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,14 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- view
-- ---------------------------------------------------------------------
ALTER TABLE `view` ADD `subtree_view` VARCHAR(255) AFTER `view`;
ALTER TABLE `view` ADD `children_view` VARCHAR(255) AFTER `view`;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View 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 View\Controller;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Log\Tlog;
use View\Event\ViewEvent;
use View\Form\ViewForm;
/**
* Class ViewController
* @package View\Controller
*/
class ViewController extends BaseAdminController
{
public function createAction($source_id)
{
$form = new ViewForm($this->getRequest());
try {
$viewForm = $this->validateForm($form);
$data = $viewForm->getData();
$event = new ViewEvent(
$data['view'],
$data['source'],
$data['source_id']
);
if ($data['has_subtree'] != 0) {
$event
->setChildrenView($data['children_view'])
->setSubtreeView($data['subtree_view']);
}
$this->dispatch('view.create', $event);
return $this->generateSuccessRedirect($form);
} catch (\Exception $ex) {
$error_message = $ex->getMessage();
Tlog::getInstance()->error("Failed to validate View form: $error_message");
}
$this->setupFormErrorContext(
'Failed to process View form data',
$error_message,
$form
);
$sourceType = $this->getRequest()->get('source_type');
return $this->render(
$sourceType . '-edit',
[
$sourceType . '_id' => $source_id,
'current_tab' => 'modules'
]
);
}
}

View File

@@ -0,0 +1,107 @@
<?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 View\Event;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\HttpFoundation\Request;
use View\Model\View;
/**
* Class FindViewEvent
* @package View\Event
*/
class FindViewEvent extends ActionEvent
{
/** @var int */
protected $objectId;
/** @var int */
protected $objectType;
/** @var string */
protected $view;
/** @var View */
protected $viewObject;
public function __construct($objectId, $objectType)
{
$this->objectId = $objectId;
$this->objectType = $objectType;
}
public function hasView()
{
return ! empty($this->view);
}
/**
* @return mixed
*/
public function getView()
{
return $this->view;
}
/**
* @param mixed $view
* @return $this
*/
public function setView($view)
{
$this->view = $view;
return $this;
}
/**
* @return int
*/
public function getObjectId()
{
return $this->objectId;
}
/**
* @return int
*/
public function getObjectType()
{
return $this->objectType;
}
/**
* @return View
*/
public function getViewObject()
{
return $this->viewObject;
}
/**
* @param View $viewObject
* @return $this
*/
public function setViewObject($viewObject)
{
$this->viewObject = $viewObject;
return $this;
}
}

View 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 View\Event;
use Thelia\Core\Event\ActionEvent;
/**
* Class ViewEvent
* @package View\Event
*/
class ViewEvent extends ActionEvent
{
/** @var string */
protected $view;
/** @var string */
protected $source;
/** @var int */
protected $source_id;
/** @var string */
protected $childrenView = '';
/** @var string */
protected $subtreeView = '';
public function __construct($view, $source, $source_id)
{
$this->view = $view;
$this->source = $source;
$this->source_id = $source_id;
}
public function hasDefinedViews()
{
return ! (empty($this->view) && empty($this->childrenView) && empty($this->subtreeView));
}
/**
* @param string $view the view name
* @return $this
*/
public function setViewName($view)
{
$this->view = $view;
return $this;
}
/**
* @return string
*/
public function getViewName()
{
return $this->view;
}
/**
* @param string $source the source object, one of product, category, content, folder
* @return $this
*/
public function setSource($source)
{
$this->source = $source;
return $this;
}
/**
* @return string
*/
public function getSource()
{
return $this->source;
}
/**
* @param int $source_id
* @return $this
*/
public function setSourceId($source_id)
{
$this->source_id = $source_id;
return $this;
}
/**
* @return int
*/
public function getSourceId()
{
return $this->source_id;
}
/**
* @return string
*/
public function getChildrenView()
{
return $this->childrenView;
}
/**
* @param string $childrenView
* @return $this
*/
public function setChildrenView($childrenView)
{
$this->childrenView = $childrenView;
return $this;
}
/**
* @return string
*/
public function getSubtreeView()
{
return $this->subtreeView;
}
/**
* @param string $subtreeView
* @return $this
*/
public function setSubtreeView($subtreeView)
{
$this->subtreeView = $subtreeView;
return $this;
}
}

View File

@@ -0,0 +1,125 @@
<?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 View\Form;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
use Thelia\Core\Translation\Translator;
use View\View;
/**
* Class ViewForm
* @package View\Form
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class ViewForm extends BaseForm
{
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
* $this->formBuilder->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new \Symfony\Component\Validator\Constraints\NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
*/
protected function buildForm()
{
$this->formBuilder
->add('view', 'text', array(
'label' => Translator::getInstance()->trans('View name', [], View::DOMAIN),
'label_attr' => array(
'for' => 'view_view'
)
))
->add('has_subtree', 'integer', array(
'constraints' => array(
new NotBlank()
),
'label' => Translator::getInstance()->trans('Object with subtree', [], View::DOMAIN),
'label_attr' => array(
'for' => 'view_has_subtree'
)
))
->add('subtree_view', 'text', array(
'required' => false,
'label' => Translator::getInstance()->trans('Sub-tree view name', [], View::DOMAIN),
'label_attr' => array(
'for' => 'view_subtree_view'
)
))
->add('children_view', 'text', array(
'required' => false,
'label' => Translator::getInstance()->trans('Children view name', [], View::DOMAIN),
'label_attr' => array(
'for' => 'view_children_view'
)
))
->add('source', 'text', array(
'constraints' => array(
new NotBlank()
),
'label' => Translator::getInstance()->trans('Source type', [], View::DOMAIN),
'label_attr' => array(
'for' => 'view_source'
)
))
->add('source_id', 'integer', array(
'constraints' => array(
new NotBlank(),
new GreaterThan([ 'value' => 0])
),
'label' => Translator::getInstance()->trans('Source object ID', [], View::DOMAIN),
'label_attr' => array(
'for' => 'view_source_id'
)
))
;
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "view_form";
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Created by PhpStorm.
* User: nicolasbarbey
* Date: 27/08/2019
* Time: 13:41
*/
namespace View\Hook;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
class HookManager extends BaseHook
{
public function onModuleConfiguration(HookRenderEvent $event)
{
$event->add(
$this->render("ViewConfiguration.html")
);
}
public function onEditModuleTab(HookRenderEvent $event)
{
$view = $event->getArgument('view');
$event->add(
$this->render("View-".$view.".html")
);
}
}

View File

@@ -0,0 +1,28 @@
<?php
return array(
'<strong>%view</strong> (définie dans %title)' => '<strong>%view</strong> (defined by %title)',
'Choisissez une vue :' => 'Please select a view :',
'Enregistrer' => 'Save',
'La vue actuellement utilisée par %label est %view.' => 'The current view for %label is %view.',
'List of all specific views' => 'List of all specific views',
'Utiliser la vue par défaut' => 'Use the default view',
'Vue à utiliser par les %label' => 'View used by %label',
'Vue à utiliser pour %label' => 'View used by %label',
'la vue par défaut' => 'the default view',
'Aucune vue spécifique trouvée.' => 'No specific view was found',
'Categories' => 'Categories',
'Contents' => 'Contents',
'Default view' => 'Default view',
'Folders' => 'Folders',
'List of specific views' => 'List of specific views',
'Products' => 'Products',
'ce contenu' => 'this content',
'ce dossier' => 'this folder',
'ce produit' => 'this product',
'cette catégorie' => 'this category',
'contenus' => 'contents',
'produits' => 'products',
'sous-catégories' => 'sub-categories',
'sous-dossiers' => 'sub-folders',
);

View File

@@ -0,0 +1,28 @@
<?php
return array(
'<strong>%view</strong> (définie dans %title)' => '<strong>%view</strong> (définie dans %title)',
'Choisissez une vue :' => 'Choisissez une vue :',
'Enregistrer' => 'Enregistrer',
'La vue actuellement utilisée par %label est %view.' => 'La vue actuellement utilisée par %label est %view.',
'List of all specific views' => 'Voir toutes les vues spcécifiques',
'Utiliser la vue par défaut' => 'Utiliser la vue par défaut',
'Vue à utiliser par les %label' => 'Vue à utiliser par les %label',
'Vue à utiliser pour %label' => 'Vue à utiliser pour %label',
'la vue par défaut' => 'la vue par défaut',
'Aucune vue spécifique trouvée.' => 'Aucune vue spécifique trouvée.',
'Categories' => 'Catégories',
'Contents' => 'Contenus',
'Default view' => 'Vue par défaut',
'Folders' => 'Dossiers',
'List of specific views' => 'Liste des vues spécifiques',
'Products' => 'Produits',
'ce contenu' => 'ce contenu',
'ce dossier' => 'ce dossier',
'ce produit' => 'ce produit',
'cette catégorie' => 'cette catégorie',
'contenus' => 'contenus',
'produits' => 'produits',
'sous-catégories' => 'sous-catégories',
'sous-dossiers' => 'sous-dossiers',
);

View File

@@ -0,0 +1,10 @@
<?php
return array(
'Children view name' => 'Children view name',
'Object with subtree' => 'Object with subtree',
'Source object ID' => 'Source object ID',
'Source type' => 'Source type',
'Sub-tree view name' => 'Sub-tree view name',
'View name' => 'View name',
);

View File

@@ -0,0 +1,9 @@
<?php
return array(
'Children view name' => 'Vue pour les objets enfants',
'Object with subtree' => 'Objet avec descendance',
'Source object ID' => 'ID de l\'object source',
'Source type' => 'Type de source',
'Sub-tree view name' => 'Vue pour les objets descendants',
'View name' => 'Nom de la vue',
);

View File

@@ -0,0 +1,55 @@
<?php
/**
* Created by PhpStorm.
* User: chevrier_meedle
* Date: 22/05/2014
* Time: 18:46
*/
namespace View\Listener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use View\Event\FindViewEvent;
class ControllerListener implements EventSubscriberInterface
{
public function controllerListener(FilterControllerEvent $event)
{
static $possibleMatches = [
'product_id' => 'product',
'category_id' => 'category',
'content_id' => 'content',
'folder_id' => 'folder'
];
$request = $event->getRequest();
$currentView = $event->getRequest()->attributes->get('_view');
// Try to find a direct match. A view is defined for the object.
foreach ($possibleMatches as $parameter => $objectType) {
// Search for a view when the parameter is present in the request, and
// the current view is the default one (fix for https://github.com/AnthonyMeedle/thelia-modules-View/issues/6)
if ($currentView == $objectType && (null !== $objectId = $request->query->get($parameter))) {
$findEvent = new FindViewEvent($objectId, $objectType);
$event->getDispatcher()->dispatch('view.find', $findEvent);
if ($findEvent->hasView()) {
$event->getRequest()->query->set('view', $findEvent->getView());
}
return;
}
}
}
public static function getSubscribedEvents()
{
return [
KernelEvents::CONTROLLER => ["controllerListener", 128]
];
}
}

View File

@@ -0,0 +1,146 @@
<?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 View\Listener;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Action\BaseAction;
use Thelia\Model\CategoryQuery;
use Thelia\Model\ContentQuery;
use Thelia\Model\FolderQuery;
use Thelia\Model\ProductQuery;
use View\Event\FindViewEvent;
use View\Event\ViewEvent;
use View\Model\View;
use View\Model\ViewQuery;
/**
* Class View
* @package View\Listener
*/
class ViewListener extends BaseAction implements EventSubscriberInterface
{
public function create(ViewEvent $event)
{
if (null === $view = ViewQuery::create()->filterBySourceId($event->getSourceId())->findOneBySource($event->getSource())) {
$view = new View();
}
if ($event->hasDefinedViews()) {
$view
->setView($event->getViewName())
->setSource($event->getSource())
->setSourceId($event->getSourceId())
->setSubtreeView($event->getSubtreeView())
->setChildrenView($event->getChildrenView())
->save();
} else {
$view->delete();
}
}
public function find(FindViewEvent $event)
{
$objectType = $event->getObjectType();
$objectId = $event->getObjectId();
// Try to find a direct match. A view is defined for the object.
if (null !== $viewObj = ViewQuery::create()
->filterBySourceId($objectId)
->findOneBySource($objectType)
) {
$viewName = $viewObj->getView();
if (! empty($viewName)) {
$event->setView($viewName)->setViewObject($viewObj);
return;
}
}
$foundView = $sourceView = null;
if ($objectType == 'category') {
$foundView = $this->searchInParents($objectId, $objectType, CategoryQuery::create(), false, $sourceView);
} elseif ($objectType == 'folder') {
$foundView = $this->searchInParents($objectId, $objectType, FolderQuery::create(), false, $sourceView);
} elseif ($objectType == 'product') {
if (null !== $product = ProductQuery::create()->findPk($objectId)) {
$foundView = $this->searchInParents($product->getDefaultCategoryId(), 'category', CategoryQuery::create(), true, $sourceView);
}
} elseif ($objectType == 'content') {
if (null !== $content = ContentQuery::create()->findPk($objectId)) {
$foundView = $this->searchInParents($content->getDefaultFolderId(), 'folder', FolderQuery::create(), true, $sourceView);
}
}
$event->setView($foundView)->setViewObject($sourceView);
}
/**
* Try to find the custom template in the object parent.
*
* @param $objectId int the object id
* @param $objectType string the object type
* @param $objectQuery ModelCriteria the object query to use
* @param $forLeaf bool seach for a leaf (product, content) or node (category, folder)
* @param $sourceView ModelCriteria the model of the found View, returned ti the caller.
*
* @return bool
*/
protected function searchInParents($objectId, $objectType, $objectQuery, $forLeaf, &$sourceView)
{
// For a folder or a category, search template in the object's parent instead of getting object's one.
// To do this, we will ignore the first loop iteration.
$ignoreIteration = ! $forLeaf;
while (null !== $object = $objectQuery->findPk($objectId)) {
if (! $ignoreIteration) {
if (null !== $viewObj = ViewQuery::create()->filterBySourceId($object->getId())->findOneBySource($objectType)) {
$viewName = $forLeaf ? $viewObj->getChildrenView() : $viewObj->getSubtreeView();
if (!empty($viewName)) {
$sourceView = $viewObj;
return $viewName;
}
}
}
$ignoreIteration = false;
// Not found. Try to find the view in the parent object.
$objectId = $object->getParent();
}
return false;
}
public static function getSubscribedEvents()
{
return array(
'view.create' => array('create', 128),
'view.find' => array('find', 128)
);
}
}

View File

@@ -0,0 +1,81 @@
<?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 View\Loop;
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use View\Event\FindViewEvent;
/**
* Class FrontView
* @package View\Loop
*/
class FrontView extends BaseLoop implements ArraySearchLoopInterface
{
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createAnyTypeArgument('source'),
Argument::createIntTypeArgument('source_id')
);
}
public function buildArray()
{
$findEvent = new FindViewEvent($this->getSourceId(), $this->getSource());
$this->dispatcher->dispatch('view.find', $findEvent);
return $findEvent->hasView() ? [ [
'name' => $findEvent->getView(),
'id' => $findEvent->getViewObject()->getId()
] ] : [];
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
foreach ($loopResult->getResultDataCollection() as $view) {
$loopResultRow = new LoopResultRow($view);
$loopResultRow
->set('FRONT_VIEW', $view['name'])
->set('VIEW_ID', $view['id'])
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -0,0 +1,103 @@
<?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 View\Loop;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\TheliaTemplateHelper;
use Thelia\Type;
/**
* Class Commentaire
* @package Commentaire\Loop
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class Frontfiles extends BaseLoop implements ArraySearchLoopInterface
{
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createAnyTypeArgument('templates-active')
);
}
public function buildArray()
{
try {
/** @var TheliaTemplateHelper $templateHelper */
$templateHelper = $this->container->get('thelia.template_helper');
} catch (\Exception $ex) {
$templateHelper = TemplateHelper::getInstance();
}
$frontTemplatePath = $templateHelper->getActiveFrontTemplate()->getAbsolutePath();
$list = [];
$finder = Finder::create()
->files()
->in($frontTemplatePath)
// Do not enter in bower and node directories
->exclude(['bower_components', 'node_modules'])
// Ignore VCS related directories
->ignoreVCS(true)
->ignoreDotFiles(true)
->sortByName()
->name("*.html");
foreach ($finder as $file) {
$list[] = $file;
}
return $list;
}
public function parseResults(LoopResult $loopResult)
{
/** @var SplFileInfo $template */
foreach ($loopResult->getResultDataCollection() as $template) {
$loopResultRow = new LoopResultRow($template);
$loopResultRow
->set("NAME", str_replace('.html', '', $template->getFilename()))
->set("FILE", $template->getFilename())
->set("RELATIVE_PATH", $template->getRelativePath())
->set("ABSOLUTE_PATH", $template->getPath())
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -0,0 +1,140 @@
<?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 View\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\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use View\Model\ViewQuery;
/**
* Class Commentaire
* @package Commentaire\Loop
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class View extends BaseLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
/**
*
* define all args used in your loop
*
*
* example :
*
* public function getArgDefinitions()
* {
* return new ArgumentCollection(
* Argument::createIntListTypeArgument('id'),
* new Argument(
* 'ref',
* new TypeCollection(
* new Type\AlphaNumStringListType()
* )
* ),
* Argument::createIntListTypeArgument('category'),
* Argument::createBooleanTypeArgument('new'),
* Argument::createBooleanTypeArgument('promo'),
* Argument::createFloatTypeArgument('min_price'),
* Argument::createFloatTypeArgument('max_price'),
* Argument::createIntTypeArgument('min_stock'),
* Argument::createFloatTypeArgument('min_weight'),
* Argument::createFloatTypeArgument('max_weight'),
* Argument::createBooleanTypeArgument('current'),
*
* );
* }
*
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
Argument::createAnyTypeArgument('view'),
Argument::createAnyTypeArgument('source'),
Argument::createIntTypeArgument('source_id')
);
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$search = ViewQuery::create();
if (null !== $id = $this->getId()) {
$search->filterById($id, Criteria::IN);
}
if (null !== $view = $this->getView()) {
$search->filterByView($view, Criteria::IN);
}
if (null !== $source = $this->getSource()) {
$search->filterBySource($source, Criteria::IN);
}
if (null !== $source_id = $this->getSourceId()) {
$search->filterBySourceId($source_id, Criteria::IN);
}
return $search;
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \View\Model\View $view */
foreach ($loopResult->getResultDataCollection() as $view) {
$loopResultRow = new LoopResultRow($view);
$loopResultRow
->set('ID', $view->getId())
->set('SOURCE_ID', $view->getSourceId())
->set('SOURCE', $view->getSource())
->set('VIEW', $view->getView())
->set('SUBTREE_VIEW', $view->getSubtreeView())
->set('CHILDREN_VIEW', $view->getChildrenView())
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,681 @@
<?php
namespace View\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use View\Model\View as ChildView;
use View\Model\ViewQuery as ChildViewQuery;
use View\Model\Map\ViewTableMap;
/**
* Base class that represents a query for the 'view' table.
*
*
*
* @method ChildViewQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildViewQuery orderByView($order = Criteria::ASC) Order by the view column
* @method ChildViewQuery orderBySource($order = Criteria::ASC) Order by the source column
* @method ChildViewQuery orderBySourceId($order = Criteria::ASC) Order by the source_id column
* @method ChildViewQuery orderBySubtreeView($order = Criteria::ASC) Order by the subtree_view column
* @method ChildViewQuery orderByChildrenView($order = Criteria::ASC) Order by the children_view column
* @method ChildViewQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildViewQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildViewQuery groupById() Group by the id column
* @method ChildViewQuery groupByView() Group by the view column
* @method ChildViewQuery groupBySource() Group by the source column
* @method ChildViewQuery groupBySourceId() Group by the source_id column
* @method ChildViewQuery groupBySubtreeView() Group by the subtree_view column
* @method ChildViewQuery groupByChildrenView() Group by the children_view column
* @method ChildViewQuery groupByCreatedAt() Group by the created_at column
* @method ChildViewQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildViewQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildViewQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildViewQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildView findOne(ConnectionInterface $con = null) Return the first ChildView matching the query
* @method ChildView findOneOrCreate(ConnectionInterface $con = null) Return the first ChildView matching the query, or a new ChildView object populated from the query conditions when no match is found
*
* @method ChildView findOneById(int $id) Return the first ChildView filtered by the id column
* @method ChildView findOneByView(string $view) Return the first ChildView filtered by the view column
* @method ChildView findOneBySource(string $source) Return the first ChildView filtered by the source column
* @method ChildView findOneBySourceId(int $source_id) Return the first ChildView filtered by the source_id column
* @method ChildView findOneBySubtreeView(string $subtree_view) Return the first ChildView filtered by the subtree_view column
* @method ChildView findOneByChildrenView(string $children_view) Return the first ChildView filtered by the children_view column
* @method ChildView findOneByCreatedAt(string $created_at) Return the first ChildView filtered by the created_at column
* @method ChildView findOneByUpdatedAt(string $updated_at) Return the first ChildView filtered by the updated_at column
*
* @method array findById(int $id) Return ChildView objects filtered by the id column
* @method array findByView(string $view) Return ChildView objects filtered by the view column
* @method array findBySource(string $source) Return ChildView objects filtered by the source column
* @method array findBySourceId(int $source_id) Return ChildView objects filtered by the source_id column
* @method array findBySubtreeView(string $subtree_view) Return ChildView objects filtered by the subtree_view column
* @method array findByChildrenView(string $children_view) Return ChildView objects filtered by the children_view column
* @method array findByCreatedAt(string $created_at) Return ChildView objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildView objects filtered by the updated_at column
*
*/
abstract class ViewQuery extends ModelCriteria
{
/**
* Initializes internal state of \View\Model\Base\ViewQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\View\\Model\\View', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildViewQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildViewQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \View\Model\ViewQuery) {
return $criteria;
}
$query = new \View\Model\ViewQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildView|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = ViewTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(ViewTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildView A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, VIEW, SOURCE, SOURCE_ID, SUBTREE_VIEW, CHILDREN_VIEW, CREATED_AT, UPDATED_AT FROM view WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildView();
$obj->hydrate($row);
ViewTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildView|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(ViewTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(ViewTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(ViewTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(ViewTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ViewTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the view column
*
* Example usage:
* <code>
* $query->filterByView('fooValue'); // WHERE view = 'fooValue'
* $query->filterByView('%fooValue%'); // WHERE view LIKE '%fooValue%'
* </code>
*
* @param string $view The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterByView($view = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($view)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $view)) {
$view = str_replace('*', '%', $view);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(ViewTableMap::VIEW, $view, $comparison);
}
/**
* Filter the query on the source column
*
* Example usage:
* <code>
* $query->filterBySource('fooValue'); // WHERE source = 'fooValue'
* $query->filterBySource('%fooValue%'); // WHERE source LIKE '%fooValue%'
* </code>
*
* @param string $source The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterBySource($source = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($source)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $source)) {
$source = str_replace('*', '%', $source);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(ViewTableMap::SOURCE, $source, $comparison);
}
/**
* Filter the query on the source_id column
*
* Example usage:
* <code>
* $query->filterBySourceId(1234); // WHERE source_id = 1234
* $query->filterBySourceId(array(12, 34)); // WHERE source_id IN (12, 34)
* $query->filterBySourceId(array('min' => 12)); // WHERE source_id > 12
* </code>
*
* @param mixed $sourceId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterBySourceId($sourceId = null, $comparison = null)
{
if (is_array($sourceId)) {
$useMinMax = false;
if (isset($sourceId['min'])) {
$this->addUsingAlias(ViewTableMap::SOURCE_ID, $sourceId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($sourceId['max'])) {
$this->addUsingAlias(ViewTableMap::SOURCE_ID, $sourceId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ViewTableMap::SOURCE_ID, $sourceId, $comparison);
}
/**
* Filter the query on the subtree_view column
*
* Example usage:
* <code>
* $query->filterBySubtreeView('fooValue'); // WHERE subtree_view = 'fooValue'
* $query->filterBySubtreeView('%fooValue%'); // WHERE subtree_view LIKE '%fooValue%'
* </code>
*
* @param string $subtreeView The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterBySubtreeView($subtreeView = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($subtreeView)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $subtreeView)) {
$subtreeView = str_replace('*', '%', $subtreeView);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(ViewTableMap::SUBTREE_VIEW, $subtreeView, $comparison);
}
/**
* Filter the query on the children_view column
*
* Example usage:
* <code>
* $query->filterByChildrenView('fooValue'); // WHERE children_view = 'fooValue'
* $query->filterByChildrenView('%fooValue%'); // WHERE children_view LIKE '%fooValue%'
* </code>
*
* @param string $childrenView The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterByChildrenView($childrenView = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($childrenView)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $childrenView)) {
$childrenView = str_replace('*', '%', $childrenView);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(ViewTableMap::CHILDREN_VIEW, $childrenView, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(ViewTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(ViewTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ViewTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(ViewTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(ViewTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(ViewTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Exclude object from result
*
* @param ChildView $view Object to remove from the list of results
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function prune($view = null)
{
if ($view) {
$this->addUsingAlias(ViewTableMap::ID, $view->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the view table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ViewTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
ViewTableMap::clearInstancePool();
ViewTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildView or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildView object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ViewTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(ViewTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
ViewTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
ViewTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(ViewTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(ViewTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(ViewTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(ViewTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(ViewTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildViewQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(ViewTableMap::CREATED_AT);
}
} // ViewQuery

View File

@@ -0,0 +1,471 @@
<?php
namespace View\Model\Map;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
use View\Model\View;
use View\Model\ViewQuery;
/**
* This class defines the structure of the 'view' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class ViewTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'View.Model.Map.ViewTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'view';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\View\\Model\\View';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'View.Model.View';
/**
* The total number of columns
*/
const NUM_COLUMNS = 8;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 8;
/**
* the column name for the ID field
*/
const ID = 'view.ID';
/**
* the column name for the VIEW field
*/
const VIEW = 'view.VIEW';
/**
* the column name for the SOURCE field
*/
const SOURCE = 'view.SOURCE';
/**
* the column name for the SOURCE_ID field
*/
const SOURCE_ID = 'view.SOURCE_ID';
/**
* the column name for the SUBTREE_VIEW field
*/
const SUBTREE_VIEW = 'view.SUBTREE_VIEW';
/**
* the column name for the CHILDREN_VIEW field
*/
const CHILDREN_VIEW = 'view.CHILDREN_VIEW';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'view.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'view.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'View', 'Source', 'SourceId', 'SubtreeView', 'ChildrenView', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'view', 'source', 'sourceId', 'subtreeView', 'childrenView', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(ViewTableMap::ID, ViewTableMap::VIEW, ViewTableMap::SOURCE, ViewTableMap::SOURCE_ID, ViewTableMap::SUBTREE_VIEW, ViewTableMap::CHILDREN_VIEW, ViewTableMap::CREATED_AT, ViewTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'VIEW', 'SOURCE', 'SOURCE_ID', 'SUBTREE_VIEW', 'CHILDREN_VIEW', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'view', 'source', 'source_id', 'subtree_view', 'children_view', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'View' => 1, 'Source' => 2, 'SourceId' => 3, 'SubtreeView' => 4, 'ChildrenView' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'view' => 1, 'source' => 2, 'sourceId' => 3, 'subtreeView' => 4, 'childrenView' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
self::TYPE_COLNAME => array(ViewTableMap::ID => 0, ViewTableMap::VIEW => 1, ViewTableMap::SOURCE => 2, ViewTableMap::SOURCE_ID => 3, ViewTableMap::SUBTREE_VIEW => 4, ViewTableMap::CHILDREN_VIEW => 5, ViewTableMap::CREATED_AT => 6, ViewTableMap::UPDATED_AT => 7, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'VIEW' => 1, 'SOURCE' => 2, 'SOURCE_ID' => 3, 'SUBTREE_VIEW' => 4, 'CHILDREN_VIEW' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
self::TYPE_FIELDNAME => array('id' => 0, 'view' => 1, 'source' => 2, 'source_id' => 3, 'subtree_view' => 4, 'children_view' => 5, 'created_at' => 6, 'updated_at' => 7, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('view');
$this->setPhpName('View');
$this->setClassName('\\View\\Model\\View');
$this->setPackage('View.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('VIEW', 'View', 'VARCHAR', false, 255, null);
$this->addColumn('SOURCE', 'Source', 'CLOB', false, null, null);
$this->addColumn('SOURCE_ID', 'SourceId', 'INTEGER', false, null, null);
$this->addColumn('SUBTREE_VIEW', 'SubtreeView', 'VARCHAR', false, 255, '');
$this->addColumn('CHILDREN_VIEW', 'ChildrenView', 'VARCHAR', false, 255, '');
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? ViewTableMap::CLASS_DEFAULT : ViewTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (View object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = ViewTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = ViewTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + ViewTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = ViewTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
ViewTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = ViewTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = ViewTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
ViewTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(ViewTableMap::ID);
$criteria->addSelectColumn(ViewTableMap::VIEW);
$criteria->addSelectColumn(ViewTableMap::SOURCE);
$criteria->addSelectColumn(ViewTableMap::SOURCE_ID);
$criteria->addSelectColumn(ViewTableMap::SUBTREE_VIEW);
$criteria->addSelectColumn(ViewTableMap::CHILDREN_VIEW);
$criteria->addSelectColumn(ViewTableMap::CREATED_AT);
$criteria->addSelectColumn(ViewTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.VIEW');
$criteria->addSelectColumn($alias . '.SOURCE');
$criteria->addSelectColumn($alias . '.SOURCE_ID');
$criteria->addSelectColumn($alias . '.SUBTREE_VIEW');
$criteria->addSelectColumn($alias . '.CHILDREN_VIEW');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(ViewTableMap::DATABASE_NAME)->getTable(ViewTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(ViewTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(ViewTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new ViewTableMap());
}
}
/**
* Performs a DELETE on the database, given a View or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or View object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ViewTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \View\Model\View) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(ViewTableMap::DATABASE_NAME);
$criteria->add(ViewTableMap::ID, (array) $values, Criteria::IN);
}
$query = ViewQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { ViewTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { ViewTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the view table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return ViewQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a View or Criteria object.
*
* @param mixed $criteria Criteria or View object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ViewTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from View object
}
if ($criteria->containsKey(ViewTableMap::ID) && $criteria->keyContainsValue(ViewTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.ViewTableMap::ID.')');
}
// Set the correct dbName
$query = ViewQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // ViewTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
ViewTableMap::buildTableMap();

View File

@@ -0,0 +1,10 @@
<?php
namespace View\Model;
use View\Model\Base\View as BaseView;
class View extends BaseView
{
}

View File

@@ -0,0 +1,23 @@
<?php
namespace View\Model;
use View\Model\Base\ViewQuery as BaseViewQuery;
use Propel\Runtime\Propel;
use View\Model\Map\ViewTableMap;
use \PDO;
use View\Model\View as ChildView;
/**
* Skeleton subclass for performing query and update operations on the 'view' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class ViewQuery extends BaseViewQuery
{
} // ViewQuery

View File

@@ -0,0 +1,92 @@
View module
===========
Using this module, you can select a specific view for any category, product, folder or content.
## Installation
```
composer require thelia/view-module:~2.0.1
```
Activate the module and go to the "Modules" tab of any category, product, folder or content configuration page.
## The loop view
Get the specific view of an object and the specific views of its sub-elements.
### Parameters
|Argument |Description |
|--- |--- |
|**id** | The ID of the specific view |
|**view** | The Name of the specific view |
|**source** | The type of the source associated. The possible values are `category`, `product`, `folder` or `content` |
|**source_id** | The ID of the source associated |
### Output variables
|Variables |Description |
|--- |--- |
|$ID | The Id of the specific view |
|$SOURCE_ID | The ID of the source associated |
|$SOURCE | The source associated (`category`, `product`, `folder` or `content`)|
|$VIEW | The name of the specific view |
|$SUBTREE_VIEW | The name of the specific view associated with the sub-element (sub-category or sub-folder) of the source |
|$CHILDREN_VIEW | The name of the specific view associated with the children (products or contents) of the source|
### Example
```
{loop type="view" name="my-specific-view" source="content" source_id=11}...{/loop}
```
## The loop frontfiles
Return all the front office templates and their path.
### Parameters
This loop have no parameters
### Output variables
|Variables |Description |
|--- |--- |
|$NAME | The template name |
|$FILE | The file name |
|$RELATIVE_PATH | The relative path of the template |
|$ABSOLUTE_PATH | The absolute path of the template |
### Example
```
{loop type="frontfile" name="my-fo-template"}...{/loop}
```
## The loop frontview
Return view of an object if the object have a specific view.
### Parameters
|Argument |Description |
|--- |--- |
|**source** | The source of the object (`category`, `product`, `folder` or `content`) |
|**source_id** | The ID of the object |
### Output variables
|Variables |Description |
|--- |--- |
|FRONT_VIEW | The name of the view |
|VIEW_ID | The id of the view in the view table |
### Example
```
{loop type="frontview" name="my-frontview-loop" source="category" source_id=11 }...{/loop}
```

View File

@@ -0,0 +1,34 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace View;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Install\Database;
use Thelia\Module\BaseModule;
class View extends BaseModule
{
const DOMAIN = 'view';
public function postActivation(ConnectionInterface $con = null)
{
$database = new Database($con->getWrappedConnection());
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
}
public function update($currentVersion, $newVersion, ConnectionInterface $con = null)
{
$database = new Database($con->getWrappedConnection());
$database->insertSql(null, array(__DIR__ . '/Config/update.sql'));
}
}

View File

@@ -0,0 +1,11 @@
{
"name": "thelia/view-module",
"license": "LGPL-3.0+",
"type": "thelia-module",
"require": {
"thelia/installer": "~1.1"
},
"extra": {
"installer-name": "View"
}
}

View File

@@ -0,0 +1,12 @@
{include
file="view-includes/generic-view-selector.html"
sourceType = 'category'
sourceId = $category_id
successUrl = {url path="/admin/categories/update?category_id=$category_id&current_tab=modules"}
hasSubTree = 1
objectLabel = {intl d='view.bo.default' l='cette catégorie'}
subTreeObjectLabel = {intl d='view.bo.default' l='sous-catégories'}
childrenObjectLabel = {intl d='view.bo.default' l='produits'}
childrenSourceType = 'product'
}

View File

@@ -0,0 +1,8 @@
{include
file="view-includes/generic-view-selector.html"
sourceType = 'content'
sourceId = $content_id
successUrl = {url path="/admin/content/update/$content_id?current_tab=modules"}
hasSubTree = 0
objectLabel = {intl d='view.bo.default' l='ce contenu'}
}

View File

@@ -0,0 +1,12 @@
{include
file="view-includes/generic-view-selector.html"
sourceType = 'folder'
sourceId = $folder_id
successUrl = {url path="/admin/folders/update/$folder_id?current_tab=modules"}
hasSubTree = 1
objectLabel = {intl d='view.bo.default' l='ce dossier'}
subTreeObjectLabel = {intl d='view.bo.default' l='sous-dossiers'}
childrenObjectLabel = {intl d='view.bo.default' l='contenus'}
childrenSourceType = 'content'
}

View File

@@ -0,0 +1,8 @@
{include
file="view-includes/generic-view-selector.html"
sourceType = 'product'
sourceId = $product_id
successUrl = {url path="/admin/products/update?product_id=$product_id&current_tab=modules"}
hasSubTree = 0
objectLabel = {intl d='view.bo.default' l='ce produit'}
}

View File

@@ -0,0 +1,174 @@
{$useDefault = "<span class=\"text-muted\">{intl l='Default view' d='view.bo.default'}</span>"}
<div class="row">
<div class="col-md-12 general-block-decorator">
<div class="title title-without-tabs">
{intl d='view.bo.default' l="List of specific views"}
</div>
<div class="general-block-decorator">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">{intl l="Categories" d="view.bo.default"}</caption>
{ifloop rel="views"}
<thead>
<tr>
<th>ID</th>-
<th>Title</th>
<th>This category view</th>
<th>Children categories view</th>
<th>Products view</th>
</tr>
</thead>
<tbody>
{loop name="views" type="view" source="category"}
{ifloop rel="info"}
<tr>
{loop name="info" type="category" id=$SOURCE_ID}
<td><a href="{url path="/admin/categories/update" category_id=$ID current_tab='modules'}">{$ID}</a></td>
<td><a href="{url path="/admin/categories/update" category_id=$ID current_tab='modules'}">{$TITLE}</a></td>
{/loop}
<td>{$VIEW|default:$useDefault nofilter}</td>
<td>{$SUBTREE_VIEW|default:$useDefault nofilter}</td>
<td>{$CHILDREN_VIEW|default:$useDefault nofilter}</td>
</tr>
{/ifloop}
{/loop}
</tbody>
{/ifloop}
{elseloop rel="views"}
<thead>
<tr>
<td>
<div class="alert alert-info">{intl l="Aucune vue spécifique trouvée." d="view.bo.default"}</div>
</td>
</tr>
</thead>
{/elseloop}
</table>
</div>
<div class="general-block-decorator">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">{intl l="Products" d="view.bo.default"}</caption>
{ifloop rel="views"}
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>This product view</th>
</tr>
</thead>
<tbody>
{loop name="views" type="view" source="product"}
{ifloop rel="info"}
<tr>
{loop name="info" type="product" id=$SOURCE_ID}
<td><a href="{url path="/admin/products/update" product_id=$ID current_tab='modules'}">{$ID}</a></td>
<td><a href="{url path="/admin/products/update" product_id=$ID current_tab='modules'}">{$TITLE}</a></td>
{/loop}
<td>{$VIEW|default:$useDefault nofilter}</td>
</tr>
{/ifloop}
{/loop}
</tbody>
{/ifloop}
{elseloop rel="views"}
<thead>
<tr>
<td>
<div class="alert alert-info">{intl l="Aucune vue spécifique trouvée." d="view.bo.default"}</div>
</td>
</tr>
</thead>
{/elseloop}
</table>
</div>
<div class="general-block-decorator">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">{intl l="Folders" d="view.bo.default"}</caption>
{ifloop rel="views"}
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>This folder view</th>
<th>Children folders view</th>
<th>Contents view</th>
</tr>
</thead>
<tbody>
{loop name="views" type="view" source="folder"}
{ifloop rel="info"}
<tr>
{loop name="info" type="folder" id=$SOURCE_ID}
<td><a href="{url path="/admin/folders/update/$ID" current_tab='modules'}">{$ID}</a></td>
<td><a href="{url path="/admin/folders/update/$ID" current_tab='modules'}">{$TITLE}</a></td>
{/loop}
<td>{$VIEW|default:$useDefault nofilter}</td>
<td>{$SUBTREE_VIEW|default:$useDefault nofilter}</td>
<td>{$CHILDREN_VIEW|default:$useDefault nofilter}</td>
</tr>
{/ifloop}
{/loop}
</tbody>
{/ifloop}
{elseloop rel="views"}
<thead>
<tr>
<td>
<div class="alert alert-info">{intl l="Aucune vue spécifique trouvée." d="view.bo.default"}</div>
</td>
</tr>
</thead>
{/elseloop}
</table>
</div>
<div class="general-block-decorator">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">{intl l="Contents" d="view.bo.default"}</caption>
{ifloop rel="views"}
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>This content view</th>
</tr>
</thead>
<tbody>
{loop name="views" type="view" source="content"}
{ifloop rel="info"}
<tr>
{loop name="info" type="content" id=$SOURCE_ID}
<td><a href="{url path="/admin/content/update/$ID" current_tab='modules'}">{$ID}</a></td>
<td><a href="{url path="/admin/content/update/$ID" current_tab='modules'}">{$TITLE}</a></td>
{/loop}
<td>{$VIEW|default:$useDefault nofilter}</td>
</tr>
{/ifloop}
{/loop}
</tbody>
{/ifloop}
{elseloop rel="views"}
<thead>
<tr>
<td>
<div class="alert alert-info">{intl l="Aucune vue spécifique trouvée." d="view.bo.default"}</div>
</td>
</tr>
</thead>
{/elseloop}
</table>
</div>
</div>
</div>

View File

@@ -0,0 +1,133 @@
{*
$sourceType : la source de la vue: folder, product, cateogry, product
$sourceId : identifiant de la source de la vue
$successUrl : the form success url
*}
<div class="general-block-decorator">
<div class="row">
<div class="col-md-12">
<p class="title title-without-tabs">{intl d="view.bo.default" l="Vue à utiliser pour %label" label=$objectLabel}</p>{form name="view.create"}
{loop type="frontview" name="front_view" source=$sourceType source_id=$sourceId}
{loop type="view" name="view" id=$VIEW_ID}
{loop type=$SOURCE name="obj_title" id=$SOURCE_ID}
{$frontView = {intl d="view.bo.default" l='<strong>%view</strong> (définie dans %title)' view=$FRONT_VIEW title=$TITLE}}
{/loop}
{/loop}
{/loop}
{if empty($frontView)}
{$frontView = {intl d="view.bo.default" l="la vue par défaut"}}
{/if}
<p>{intl d="view.bo.default" l="La vue actuellement utilisée par %label est %view." label=$objectLabel view=$frontView}</p>
<form action="{url path="/admin/view/add/$sourceId"}" method="POST" {form_enctype form=$form}>
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{* Pour gérer les erreurs *}
<input type="hidden" name="source_type" value="{$sourceType}">
{form_hidden_fields form=$form}
{form_field form=$form field="success_url"}
<input type="hidden" name="{$name}" value="{$successUrl}">
{/form_field}
{form_field form=$form field="view"}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">
{intl d="view.bo.default" l="Choisissez une vue :"}
</label>
{loop type="view" name="viewselected" source=$sourceType source_id=$sourceId}
{$viewSelected = $VIEW}
{/loop}
<select id="{$label_attr.for}" name="{$name}" class="submit-on-change form-control">
<option value="">{intl d="view.bo.default" l='Utiliser la vue par défaut' view=$sourceType}</option>
{loop type="frontfiles" name="translate-fo-templates"}
<option value="{$NAME}"{if $NAME == $viewSelected} selected="selected"{/if}>{$FILE}</option>
{/loop}
</select>
</div>
{/form_field}
{form_field form=$form field="has_subtree"}
<input type="hidden" name="{$name}" value="{$hasSubTree}">
{/form_field}
{if $hasSubTree}
<div class="row">
<div class="col-md-6">
<p class="title title-without-tabs">{intl d="view.bo.default" l="Vue à utiliser par les %label" label=$subTreeObjectLabel}</p>
{form_field form=$form field="subtree_view"}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">
{intl d="view.bo.default" l="Choisissez une vue :"}
</label>
{loop type="view" name="viewselected" source=$sourceType source_id=$sourceId}
{$viewSelected = $SUBTREE_VIEW}
{/loop}
<select id="{$label_attr.for}" name="{$name}" class="submit-on-change form-control">
<option value="">{intl d="view.bo.default" l='Utiliser la vue par défaut' view=$sourceType}</option>
{loop type="frontfiles" name="translate-fo-templates"}
<option value="{$NAME}"{if $NAME == $viewSelected} selected="selected"{/if}>{$FILE}</option>
{/loop}
</select>
</div>
{/form_field}
</div>
<div class="col-md-6">
<p class="title title-without-tabs">{intl d="view.bo.default" l="Vue à utiliser par les %label" label=$childrenObjectLabel}</p>
{form_field form=$form field="children_view"}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">
{intl d="view.bo.default" l="Choisissez une vue :"}
</label>
{loop type="view" name="viewselected" source=$sourceType source_id=$sourceId}
{$viewSelected = $CHILDREN_VIEW}
{/loop}
<select id="{$label_attr.for}" name="{$name}" class="submit-on-change form-control">
<option value="">{intl d="view.bo.default" l='Utiliser la vue par défaut' view=$childrenSourceType}</option>
{loop type="frontfiles" name="translate-fo-templates"}
<option value="{$NAME}"{if $NAME == $viewSelected} selected="selected"{/if}>{$FILE}</option>
{/loop}
</select>
</div>
{/form_field}
</div>
</div>
{/if}
{form_field form=$form field="source"}
<input type="hidden" name="{$name}" value="{$sourceType}">
{/form_field}
{form_field form=$form field="source_id"}
<input type="hidden" name="{$name}" value="{$sourceId}">
{/form_field}
<div class="form-group">
<p class="form-control-static pull-left">
<a href="{url path="/admin/module/View"}">
<span class="glyphicon glyphicon-eye-open"></span>
{intl d="view.bo.default" l="List of all specific views"}
</a>
</p>
<button type="submit" name="save_mode" value="stay" class="form-submit-button btn btn-success pull-right">
{intl d="view.bo.default" l='Enregistrer'} <span class="glyphicon glyphicon-ok"></span>
</button>
</div>
</form>
{/form}
</div>
</div>
</div>

View File

@@ -0,0 +1,29 @@
{extends file="layout.tpl"}
{block name="main-content"}
<section id="our-brands">
<div class="brands-heading">
<h2 class="block-title">{intl l="Our brands" d="brandsonhome"}</h2>
</div>
<div id="brands">
<div class="brands-content">
<ul class="list-unstyled row" style="text-align: center">
{loop type="brand" name="brand_list"}
{loop type="image" name="brand_images" brand={$ID} width=100}
<li class="item col-xs-6 col-sm-4 col-md-2">
<article class="row" itemscope itemtype="http://schema.org/Product">
<img src="{$IMAGE_URL}" alt="{$TITLE}" />
</article>
</li>
{/loop}
{/loop}
</ul>
</div>
</div>
</section>
{/block}
{block name="stylesheet"}
{hook name="brand.stylesheet"}
{/block}

View File

@@ -1,3 +1,3 @@
<?php
define('RS_CI_DEV_MODE', false);
define('RS_CI_LOGS', 0);
define('RS_CI_LOGS', 1);

View File

@@ -94,8 +94,7 @@ class RevSliderFront extends RevSliderBaseFront{
?>
<script>
jQuery(document).ready(function() {
if (jQuery('#wp-admin-bar-revslider-default').length>0 && jQuery('.rev_slider_wrapper').length>0) {
if (jQuery('#wp-admin-bar-revslider-default').length>0 && jQuery('.rev_slider_wrapper').length>0) {
var aliases = new Array();
jQuery('.rev_slider_wrapper').each(function() {
aliases.push(jQuery(this).data('alias'));
@@ -405,6 +404,8 @@ class RevSliderFront extends RevSliderBaseFront{
public static function add_setREVStartSize(){
$script = '<script type="text/javascript">';
$script .= 'function setREVStartSize(e){
if ( typeof window.jQuery === "undefined" ) { return; }
try{ e.c=jQuery(e.c);var i=jQuery(window).width(),t=9999,r=0,n=0,l=0,f=0,s=0,h=0;
if(e.responsiveLevels&&(jQuery.each(e.responsiveLevels,function(e,f){f>i&&(t=r=f,l=e),i>f&&f>r&&(r=f,n=e)}),t>r&&(l=n)),f=e.gridheight[l]||e.gridheight[0]||e.gridheight,s=e.gridwidth[l]||e.gridwidth[0]||e.gridwidth,h=i/s,h=h>1?1:h,f=Math.round(h*f),"fullscreen"==e.sliderLayout){var u=(e.c.width(),jQuery(window).height());if(void 0!=e.fullScreenOffsetContainer){var c=e.fullScreenOffsetContainer.split(",");if (c) jQuery.each(c,function(e,i){u=jQuery(i).length>0?u-jQuery(i).outerHeight(!0):u}),e.fullScreenOffset.split("%").length>1&&void 0!=e.fullScreenOffset&&e.fullScreenOffset.length>0?u-=jQuery(window).height()*parseInt(e.fullScreenOffset,0)/100:void 0!=e.fullScreenOffset&&e.fullScreenOffset.length>0&&(u-=parseInt(e.fullScreenOffset,0))}f=u}else void 0!=e.minHeight&&f<e.minHeight&&(f=e.minHeight);e.c.closest(".rev_slider_wrapper").css({height:f})
}catch(d){console.log("Failure at Presize of Slider:"+d)}