Module Recettes : on avance petit à petit
This commit is contained in:
@@ -6,12 +6,13 @@
|
||||
|
||||
<forms>
|
||||
<form name="recette_create_form" class="Recettes\Form\RecetteCreateForm" />
|
||||
<form name="recette_update_form" class="Recettes\Form\RecetteUpdateForm" />
|
||||
</forms>
|
||||
|
||||
<hooks>
|
||||
<hook id="recettes.hook" class="Recettes\Hook\HookManager">
|
||||
<tag name="hook.event_listener" event="content.tab" type="back" method="onEditTab" />
|
||||
</hook>
|
||||
|
||||
</hooks>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -8,4 +8,5 @@
|
||||
<default key="_controller">Recettes\Controller\MainController::saveRecipe</default>
|
||||
</route>
|
||||
|
||||
|
||||
</routes>
|
||||
|
||||
@@ -22,7 +22,14 @@ use Thelia\Tools\URL;
|
||||
class MainController extends BaseAdminController
|
||||
{
|
||||
|
||||
public function saveRecipe(Request $request)
|
||||
public function viewAction(Request $request)
|
||||
{
|
||||
$id = $request->get("content_id");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function saveRecipe(Request $request)
|
||||
{
|
||||
$productsList = [];
|
||||
|
||||
|
||||
@@ -54,8 +54,13 @@ class RecetteCreateForm extends BaseForm
|
||||
)
|
||||
->add(
|
||||
"difficulty",
|
||||
"integer",
|
||||
"choice",
|
||||
[
|
||||
"choices" => array(
|
||||
"Facile",
|
||||
"Moyen",
|
||||
"Difficile"
|
||||
),
|
||||
"label" => $this->trans("Difficulty"),
|
||||
"label_attr" => [
|
||||
"for" => "attr-difficulty"
|
||||
@@ -106,7 +111,7 @@ class RecetteCreateForm extends BaseForm
|
||||
)
|
||||
->add(
|
||||
"steps",
|
||||
"text",
|
||||
"textarea",
|
||||
[
|
||||
"label" => $this->trans("Steps"),
|
||||
"label_attr" => [
|
||||
|
||||
30
local/modules/Recettes/Form/RecetteUpdateForm.php
Normal file
30
local/modules/Recettes/Form/RecetteUpdateForm.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Recettes\Form;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
* Class RecetteUpdateForm
|
||||
* @package Recettes\Form
|
||||
*/
|
||||
class RecetteUpdateForm extends RecetteCreateForm
|
||||
{
|
||||
/** @var Translator $translator */
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'recette_update_form';
|
||||
}
|
||||
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Recettes\Hook;
|
||||
|
||||
use Recettes\Recettes;
|
||||
use Thelia\Core\Event\Hook\HookRenderBlockEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Model\ContentFolderQuery;
|
||||
use Thelia\Model\FolderI18nQuery;
|
||||
|
||||
/**
|
||||
* Class BackHook
|
||||
@@ -15,14 +16,21 @@ class HookManager extends baseHook
|
||||
|
||||
public function onEditTab(HookRenderBlockEvent $event)
|
||||
{
|
||||
$event->add(
|
||||
[
|
||||
"id" => 'admin-comment',
|
||||
"title" => 'Recette',
|
||||
"content" => ($this->render('recette.html'))
|
||||
]
|
||||
);
|
||||
$contentId = $event->getArgument('id');
|
||||
$parentFolderId = ContentFolderQuery::create()->findOneByContentId($contentId)->getFolderId();
|
||||
$parentFolder = FolderI18nQuery::create()->findOneById($parentFolderId)->getTitle();
|
||||
|
||||
if (0 != strpos($parentFolder, 'recette')) {
|
||||
$event->add(
|
||||
[
|
||||
"id" => 'admin-content-recipe',
|
||||
"title" => 'Recette',
|
||||
"content" => ($this->render('recette-tab.html',
|
||||
[ "people" => "2" ]
|
||||
))
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@
|
||||
{intl l=$label d='recettes'}
|
||||
{if $required}<span class="required">*</span>{/if}
|
||||
</label>
|
||||
<input type="text" id="{$label_attr.for}" class="form-control etroit" name="{$name}" value="" {if $required}required{/if} /> 
|
||||
<input type="text" id="{$label_attr.for}" class="form-control etroit" name="{$name}" value="{$people}" {if $required}required{/if} /> 
|
||||
</div>
|
||||
{form_error form=$form field="people"}{$message}{/form_error}
|
||||
{/form_field}
|
||||
43
local/modules/View/Config/config.xml
Normal file
43
local/modules/View/Config/config.xml
Normal 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>
|
||||
24
local/modules/View/Config/module.xml
Normal file
24
local/modules/View/Config/module.xml
Normal 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>
|
||||
11
local/modules/View/Config/routing.xml
Normal file
11
local/modules/View/Config/routing.xml
Normal 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>
|
||||
17
local/modules/View/Config/schema.xml
Normal file
17
local/modules/View/Config/schema.xml
Normal 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>
|
||||
26
local/modules/View/Config/thelia.sql
Normal file
26
local/modules/View/Config/thelia.sql
Normal 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;
|
||||
14
local/modules/View/Config/update.sql
Normal file
14
local/modules/View/Config/update.sql
Normal 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;
|
||||
84
local/modules/View/Controller/ViewController.php
Normal file
84
local/modules/View/Controller/ViewController.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace 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'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
107
local/modules/View/Event/FindViewEvent.php
Normal file
107
local/modules/View/Event/FindViewEvent.php
Normal 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;
|
||||
}
|
||||
}
|
||||
150
local/modules/View/Event/ViewEvent.php
Normal file
150
local/modules/View/Event/ViewEvent.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace 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;
|
||||
}
|
||||
}
|
||||
125
local/modules/View/Form/ViewForm.php
Normal file
125
local/modules/View/Form/ViewForm.php
Normal 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";
|
||||
}
|
||||
}
|
||||
31
local/modules/View/Hook/HookManager.php
Normal file
31
local/modules/View/Hook/HookManager.php
Normal 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")
|
||||
);
|
||||
}
|
||||
}
|
||||
28
local/modules/View/I18n/backOffice/default/en_US.php
Normal file
28
local/modules/View/I18n/backOffice/default/en_US.php
Normal 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',
|
||||
);
|
||||
28
local/modules/View/I18n/backOffice/default/fr_FR.php
Normal file
28
local/modules/View/I18n/backOffice/default/fr_FR.php
Normal 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',
|
||||
);
|
||||
10
local/modules/View/I18n/en_US.php
Normal file
10
local/modules/View/I18n/en_US.php
Normal 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',
|
||||
);
|
||||
9
local/modules/View/I18n/fr_FR.php
Normal file
9
local/modules/View/I18n/fr_FR.php
Normal 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',
|
||||
);
|
||||
55
local/modules/View/Listener/ControllerListener.php
Normal file
55
local/modules/View/Listener/ControllerListener.php
Normal 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]
|
||||
];
|
||||
}
|
||||
}
|
||||
146
local/modules/View/Listener/ViewListener.php
Normal file
146
local/modules/View/Listener/ViewListener.php
Normal 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)
|
||||
);
|
||||
}
|
||||
}
|
||||
81
local/modules/View/Loop/FrontView.php
Normal file
81
local/modules/View/Loop/FrontView.php
Normal 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;
|
||||
}
|
||||
}
|
||||
103
local/modules/View/Loop/Frontfiles.php
Normal file
103
local/modules/View/Loop/Frontfiles.php
Normal 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;
|
||||
}
|
||||
}
|
||||
140
local/modules/View/Loop/View.php
Normal file
140
local/modules/View/Loop/View.php
Normal 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;
|
||||
}
|
||||
}
|
||||
1535
local/modules/View/Model/Base/View.php
Normal file
1535
local/modules/View/Model/Base/View.php
Normal file
File diff suppressed because it is too large
Load Diff
681
local/modules/View/Model/Base/ViewQuery.php
Normal file
681
local/modules/View/Model/Base/ViewQuery.php
Normal 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
|
||||
471
local/modules/View/Model/Map/ViewTableMap.php
Normal file
471
local/modules/View/Model/Map/ViewTableMap.php
Normal 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();
|
||||
10
local/modules/View/Model/View.php
Normal file
10
local/modules/View/Model/View.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace View\Model;
|
||||
|
||||
use View\Model\Base\View as BaseView;
|
||||
|
||||
class View extends BaseView
|
||||
{
|
||||
|
||||
}
|
||||
23
local/modules/View/Model/ViewQuery.php
Normal file
23
local/modules/View/Model/ViewQuery.php
Normal 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
|
||||
92
local/modules/View/README.md
Normal file
92
local/modules/View/README.md
Normal 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}
|
||||
```
|
||||
34
local/modules/View/View.php
Normal file
34
local/modules/View/View.php
Normal 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'));
|
||||
}
|
||||
}
|
||||
11
local/modules/View/composer.json
Normal file
11
local/modules/View/composer.json
Normal 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"
|
||||
}
|
||||
}
|
||||
@@ -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¤t_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'
|
||||
}
|
||||
@@ -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'}
|
||||
}
|
||||
@@ -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'
|
||||
}
|
||||
@@ -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¤t_tab=modules"}
|
||||
hasSubTree = 0
|
||||
objectLabel = {intl d='view.bo.default' l='ce produit'}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -1,339 +0,0 @@
|
||||
{extends file="admin-layout.tpl"}
|
||||
|
||||
{block name="no-return-functions"}
|
||||
{$admin_current_location = 'folder'}
|
||||
{/block}
|
||||
|
||||
{block name="check-resource"}admin.content{/block}
|
||||
{block name="check-access"}view{/block}
|
||||
|
||||
{block name="page-title"}{intl l='Edit content'}{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="content edit-content">
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{include file="includes/folder-breadcrumb.html" editing_content="true"}
|
||||
|
||||
{hook name="content-edit.top" content_id=$content_id}
|
||||
|
||||
<div class="row">
|
||||
{loop name="content_edit" type="content" visible="*" id="{$content_id}" backend_context="1" lang="$edit_language_id" with_prev_next_info="true"}
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<div class="row">
|
||||
<div class="col-md-7 title">
|
||||
{intl l='Edit content %title' title={$TITLE}}
|
||||
</div>
|
||||
|
||||
<div class="col-md-5 actions">
|
||||
|
||||
{if $HAS_PREVIOUS != 0}
|
||||
<a href="{url path="/admin/content/update/%previous" previous=$PREVIOUS}" class="btn btn-default" title="{intl l='Edit previous content'}"><span class="glyphicon glyphicon-arrow-left"></span></a>
|
||||
{else}
|
||||
<a href="#" disabled="disabled" class="btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span></a>
|
||||
{/if}
|
||||
|
||||
<a href="{$URL nofilter}" target="_blank" class="btn btn-default" title="{intl l='Preview content page'}"><span class="glyphicon glyphicon-eye-open"></span></a>
|
||||
|
||||
{if $HAS_NEXT != 0}
|
||||
<a href="{url path="/admin/content/update/%next" next=$NEXT}" class="btn btn-default" title="{intl l='Edit next content'}"><span class="glyphicon glyphicon-arrow-right"></span></a>
|
||||
{else}
|
||||
<a href="#" disabled="disabled" class="btn btn-default"><span class="glyphicon glyphicon-arrow-right"></span></a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
{hookblock name="content.tab" id="{$content_id}" fields="id,title,href,content"}
|
||||
|
||||
{capture "content_tab_tab"}
|
||||
{forhook rel="content.tab"}
|
||||
<li>
|
||||
<a href="#{$id}"
|
||||
{if $href}data-href="{$href}"{/if}
|
||||
data-toggle="tab">{$title}
|
||||
</a>
|
||||
</li>
|
||||
{/forhook}
|
||||
{/capture}
|
||||
|
||||
{capture "content_tab_content"}
|
||||
{forhook rel="content.tab"}
|
||||
<div class="tab-pane fade" id="{$id}">
|
||||
{if $href}
|
||||
{* ajax *}
|
||||
<div class="text-center"><span class="loading">{intl l="Please wait, loading"}</span></div>
|
||||
{else}
|
||||
{$content nofilter}
|
||||
{/if}
|
||||
</div>
|
||||
{/forhook}
|
||||
{/capture}
|
||||
|
||||
{/hookblock}
|
||||
|
||||
<ul class="nav nav-tabs" id="tabbed-menu">
|
||||
<li class="active">
|
||||
<a href="#general" data-toggle="tab">{intl l="General description"}</a></li>
|
||||
<li><a href="#seo" data-toggle="tab">{intl l="SEO"}</a></li>
|
||||
<li><a href="#association" data-toggle="tab">{intl l="Associations"}</a></li>
|
||||
<li><a href="#images" data-toggle="tab">{intl l="Images"}</a></li>
|
||||
<li><a href="#documents" data-toggle="tab">{intl l="Documents"}</a></li>
|
||||
{$smarty.capture.content_tab_tab nofilter}
|
||||
<li><a href="#modules" data-toggle="tab">{intl l="Modules"}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
|
||||
<div class="tab-pane fade active in" id="general">
|
||||
|
||||
<div class="form-container">
|
||||
|
||||
{form name="thelia.admin.content.modification"}
|
||||
<form method="POST" action="{url path='/admin/content/save'}" {form_enctype} class="clearfix">
|
||||
|
||||
{include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/folders' parent=$DEFAULT_FOLDER}"}
|
||||
|
||||
{* Be sure to get the folder ID, even if the form could not be validated *}
|
||||
<input type="hidden" name="content_id" value="{$content_id}"/>
|
||||
|
||||
<input type="hidden" name="current_tab" value="general"/>
|
||||
|
||||
{form_hidden_fields}
|
||||
|
||||
{form_field field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/content/update/%id" id=$ID}"/>
|
||||
{/form_field}
|
||||
|
||||
{form_field field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}"/>
|
||||
{/form_field}
|
||||
|
||||
{if $form_error}
|
||||
<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{include file="includes/standard-description-form-fields.html"}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
|
||||
{hook name="content.modification.form-right.top" content_id=$content_id}
|
||||
|
||||
{form_field field='default_folder'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
|
||||
<label for="{$label_attr.for}" class="control-label">
|
||||
{$label} :
|
||||
</label>
|
||||
|
||||
<select id="{$label_attr.for}" required="required" name="{$name}" class="form-control">
|
||||
<option value="0" disabled>{intl l="Top level"}</option>
|
||||
|
||||
{$myparent=$DEFAULT_FOLDER}
|
||||
{loop name="fold-parent" type="folder-tree" visible="*" folder="0"}
|
||||
<option value="{$ID}" {if $myparent == $ID}selected="selected"{/if}>{option_offset l=$LEVEL+1 label={$TITLE}}</option>
|
||||
{/loop}
|
||||
|
||||
</select>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field field='visible'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l='Visibility'}</label>
|
||||
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
|
||||
{$label}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{hook name="content.modification.form-right.bottom" content_id=$content_id}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{include
|
||||
file="includes/inner-form-toolbar.html"
|
||||
hide_submit_buttons = false
|
||||
hide_flags = true
|
||||
|
||||
close_url="{url path='/admin/folders' parent=$DEFAULT_FOLDER}"
|
||||
}
|
||||
|
||||
<small>{intl l='Folder created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</small>
|
||||
|
||||
</form>
|
||||
{/form}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="seo">
|
||||
{include file="includes/seo-tab.html"
|
||||
formAction = "{url path='/admin/content/seo/save'}"
|
||||
pageUrl = "{url path='/admin/content/update'}/$content_id"
|
||||
closeUrl = "{url path='/admin/folders' parent=$DEFAULT_FOLDER}"
|
||||
success_url = "{url path='/admin/folders' parent=$DEFAULT_FOLDER}"
|
||||
current_id = $content_id
|
||||
seoType = 'content'
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="association">
|
||||
{include file="includes/content-folder-management.html"}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="images">
|
||||
{include file='includes/image-upload-form.html' imageType='content' parentId=$content_id resource="admin.content"}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="documents">
|
||||
{include file='includes/document-upload-form.html' documentType='content' parentId=$content_id resource="admin.content"}
|
||||
</div>
|
||||
|
||||
{$smarty.capture.content_tab_content nofilter}
|
||||
|
||||
<div class="tab-pane fade" id="modules">
|
||||
<div class="form-container">
|
||||
{include
|
||||
file = "includes/inner-form-toolbar.html"
|
||||
hide_submit_buttons = true
|
||||
page_url = {$pageUrl}
|
||||
close_url = {$closeUrl}
|
||||
current_tab = "modules"
|
||||
}
|
||||
</div>
|
||||
{* ugly fix : {hook name="content.tab-content" id="{$content_id}" view="content"} *}
|
||||
{include file="includes/module-tab-content.html" hook="content.tab-content" location="content-edit" id="{$content_id}" view="content"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/loop}
|
||||
</div>
|
||||
|
||||
{hook name="content-edit.bottom" content_id=$content_id}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{* Delete category confirmation dialog *}
|
||||
|
||||
{capture "delete_folder_dialog"}
|
||||
<input type="hidden" name="content_id" value="{$content_id}"/>
|
||||
<input type="hidden" name="additional_folder_id" id="additional_folder_delete_id" value=""/>
|
||||
<input type="hidden" name="current_tab" value="association"/>
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-confirm-dialog.html"
|
||||
|
||||
dialog_id = "delete_folder_dialog"
|
||||
dialog_title = {intl l="Remove associated folder"}
|
||||
dialog_message = {intl l="Do you really want to remove the content from this folder ?"}
|
||||
|
||||
form_action = {token_url path='/admin/content/folder/delete'}
|
||||
form_content = {$smarty.capture.delete_folder_dialog nofilter}
|
||||
}
|
||||
{/block}
|
||||
|
||||
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
{javascripts file='assets/js/dropzone.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
{javascripts file='assets/js/image-upload.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
{javascripts file='assets/js/document-upload.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
{javascripts file='assets/js/jquery-ui-1.10.3.custom.min.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
<script>
|
||||
$(function() {
|
||||
// Atomatic ajax tab load, if data-href is defined.
|
||||
$('.nav-tabs a[data-href]').on('shown.bs.tab', function(ev) {
|
||||
var $this = $(this);
|
||||
$($this.attr('href')).load($this.data('href'), function(ev) {
|
||||
if($this.data('callback')) {
|
||||
eval($this.data('callback') + '();');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Load active tab
|
||||
|
||||
$.imageUploadManager.initImageDropZone();
|
||||
$.documentUploadManager.initDocumentDropZone();
|
||||
|
||||
$('.use_default_rewriten_url').click(function(ev) {
|
||||
alert("Not functionnal");
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
// Show proper tab, if defined
|
||||
{if ! empty($current_tab)}
|
||||
$('.nav-tabs a[href="#{$current_tab}"]').trigger("click");
|
||||
{/if}
|
||||
|
||||
$('a.delete-folder').click(function(e) {
|
||||
$('#additional_folder_delete_id').val($(this).data('id'));
|
||||
});
|
||||
|
||||
// Set proper content ID in delete content from
|
||||
$('a.delete-content').click(function(ev) {
|
||||
$('#content_delete_id').val($(this).data('id'));
|
||||
$('#folder_delete_id').val($('#folder_id').val());
|
||||
});
|
||||
|
||||
// Load content on folder selection
|
||||
$('#folder_id').change(function(event) {
|
||||
$.ajax({
|
||||
url: '{url path="/admin/folder/%id/available-related-content/" id=$folder_id}' + $(this).val() + '.xml',
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
$('#content_id :not(:first-child)').remove();
|
||||
|
||||
var have_content = false;
|
||||
|
||||
$.each(json, function(idx, value) {
|
||||
$('#content_id').append($('<option>').text(value.title).attr('value', value.id));
|
||||
|
||||
have_content = true; // Lame...
|
||||
});
|
||||
|
||||
if (have_content)
|
||||
$('#content_selector').removeClass('hide');
|
||||
else
|
||||
$('#content_selector').addClass('hide');
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Initialize folder select value
|
||||
{if $folder_id != 0}
|
||||
$('#folder_id').val("{$folder_id}").change();
|
||||
{/if}
|
||||
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
{block name="javascript-last-call"}
|
||||
{hook name="content.edit-js" location="content-edit-js" content_id={$content_id} }
|
||||
|
||||
{hook name="wysiwyg.js" location="wysiwyg-content-edit-js" }
|
||||
{/block}
|
||||
@@ -1 +1 @@
|
||||
@font-face{font-family:sofia_prolight;src:url(../fonts/sofiapro/sofiapro-light-webfont.woff2) format('woff2'),url(../fonts/sofiapro/sofiapro-light-webfont.woff) format('woff');font-weight:400;font-style:normal}#product-details .product-info .sku,aside.col-left,div.product-options,footer.footer-info,section.category-description,ul.pager{display:none}html{font-family:sofia_prolight,sans-serif!important}#products-new .overlay:after,#products-offer .overlay:after,#products-upsell .overlay:after,body{font-family:sofia_prolight,'Open Sans',sans-serif!important}div.container{width:90%!important}@media (min-width:992px){.header__main{width:90%}}@media (min-width:768px){.header__content{flex-direction:column}}.header__content{display:flex}.header__main{align-items:center;display:flex;flex-direction:row;justify-content:space-between}.header__secondary{display:inline-flex}.overlay:before{background-color:rgba(128,189,138,.4)}.navbar-default{background-color:transparent}.navbar li>a.home:before{display:none}.navbar li{font-size:1.72rem}.nav>li{text-transform:uppercase}.navbar-customer{display:flex;flex-direction:column;text-align:center}.navbar-customer>li>a{text-transform:none}.header__content .container-fluid{padding-left:0;padding-right:0}.navbar-form .form-control{width:150px}.navbar-form{margin:auto}.logo-boutique{width:160px}.navbar{margin-bottom:0}.glyphicon,a{color:#95c11e}.btn{border-radius:5px;border-color:#95c11e;border-left:1px solid #95c11e}.btn-default{color:#3c3c3b;background-color:#fff}.btn-default:active,.btn-default:focus,.btn-default:hover{color:#fff;background-color:#3c3c3b;text-decoration:none}.btn-primary{background-color:#95c11e;color:#fff}.btn-primary:active,.btn-primary:focus,.btn-primary:hover{background-color:#fff;border-color:#95c11e;color:#95c11e}.btn-primary[disabled]:focus,.btn-primary[disabled]:hover{background-color:#95c11e;border-color:#95c11e;color:#fff}.btn-link:focus,.btn-link:hover{color:#95c11e}.navbar-default .navbar-nav>li>a{color:#3c3c3b}.nav>li>a:focus,.nav>li>a:hover,.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:focus,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>li>a:focus,.navbar-default .navbar-nav>li>a:hover{background-color:#95c11e;color:#fff}.breadcrumb{text-align:center;font-size:large;margin-bottom:30px}.checkout-progress .btn-step.active{background:#95c11e}.toolbar .amount{color:#95c11e}.grid #category-products .item>article .product-info .name{height:1.5em}.product-title,.product-title:active,.product-title:hover{text-decoration:none;color:#3c3c3b}.price,.table-cart tbody td.subprice .price,.table-cart thead th.subprice,.table-order tbody td.subprice .price,.table-order thead th.subprice{color:#95c11e}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{background-color:#95c11e;border-color:#95c11e}.products-heading{text-transform:uppercase;text-align:center}.products-heading>h2{color:#3c3c3b;font-weight:900}.fa-cart-plus,.fa-user,.glyphicon-search{font-size:2rem!important}#search-button{padding-top:6px}#search-button>input[type=search]{display:none}#search-button:hover>input[type=search]{display:inline-flex}.footer-container .footer-block{background-color:rgba(128,189,138,.08)}.block.block-contact .block-content ul>li:before{color:#95c11e}.block .block-title{color:#3c3c3b}.block .block-content .block-subtitle,.block-default .block-content li:before{color:#95c11e}
|
||||
.btn,.tag-produit{border-radius:5px}@font-face{font-family:sofia_prolight;src:url(../fonts/sofiapro/sofiapro-light-webfont.woff2) format('woff2'),url(../fonts/sofiapro/sofiapro-light-webfont.woff) format('woff');font-weight:400;font-style:normal}#product-details .product-info .sku,aside.col-left,div.product-options,footer.footer-info,section.category-description,ul.pager{display:none}html{font-family:sofia_prolight,sans-serif!important}#products-new .overlay:after,#products-offer .overlay:after,#products-upsell .overlay:after,body{font-family:sofia_prolight,'Open Sans',sans-serif!important}div.container{width:90%!important}@media (min-width:992px){.header__main{width:90%}}@media (min-width:768px){.header__content{flex-direction:column}}.header__content{display:flex}.header__main{align-items:center;display:flex;flex-direction:row;justify-content:space-between}.header__secondary{display:inline-flex}.overlay:before{background-color:rgba(128,189,138,.4)}.navbar-default{background-color:transparent}.navbar li>a.home:before{display:none}.navbar li{font-size:1.72rem}.nav>li{text-transform:uppercase}.navbar-customer{display:flex;flex-direction:column;text-align:center}.navbar-customer>li>a{text-transform:none}.header__content .container-fluid{padding-left:0;padding-right:0}.navbar-form .form-control{width:150px}.navbar-form{margin:auto}.logo-boutique{width:160px}.navbar{margin-bottom:0}.glyphicon,a{color:#95c11e}.btn{border-color:#95c11e;border-left:1px solid #95c11e}.btn-default{color:#3c3c3b;background-color:#fff}.btn-default:active,.btn-default:focus,.btn-default:hover{color:#fff;background-color:#3c3c3b;text-decoration:none}.btn-primary{background-color:#95c11e;color:#fff}.btn-primary:active,.btn-primary:focus,.btn-primary:hover{background-color:#fff;border-color:#95c11e;color:#95c11e}.btn-primary[disabled]:focus,.btn-primary[disabled]:hover{background-color:#95c11e;border-color:#95c11e;color:#fff}.btn-link:focus,.btn-link:hover{color:#95c11e}.navbar-default .navbar-nav>li>a{color:#3c3c3b}.nav>li>a:focus,.nav>li>a:hover,.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:focus,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>li>a:focus,.navbar-default .navbar-nav>li>a:hover{background-color:#95c11e;color:#fff}.breadcrumb{text-align:center;font-size:large;margin-bottom:30px}.checkout-progress .btn-step.active{background:#95c11e}.toolbar .amount{color:#95c11e}.grid #category-products .item>article .product-info .name{height:1.5em}.product-title,.product-title:active,.product-title:hover{text-decoration:none;color:#3c3c3b}.price,.table-cart tbody td.subprice .price,.table-cart thead th.subprice,.table-order tbody td.subprice .price,.table-order thead th.subprice{color:#95c11e}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{background-color:#95c11e;border-color:#95c11e}.products-heading{text-transform:uppercase;text-align:center}.products-heading>h2{color:#3c3c3b;font-weight:900}.fa-cart-plus,.fa-user,.glyphicon-search{font-size:2rem!important}#search-button{padding-top:6px}#search-button>input[type=search]{display:none}#search-button:hover>input[type=search]{display:inline-flex}.footer-container .footer-block{background-color:rgba(128,189,138,.08)}.block.block-contact .block-content ul>li:before{color:#95c11e}.block .block-title{color:#3c3c3b}.block .block-content .block-subtitle,.block-default .block-content li:before{color:#95c11e}.boutons-plusmoins{display:inline-grid!important;margin-right:20px}.bouton-moins,.bouton-plus{font-family:FontAwesome;content:"f067"}.tag-produit{transform:rotate(-10deg);padding:0 5px;text-align:center;position:absolute;z-index:300;bottom:5px;right:10px}.tag-bio{background-color:#95c11e;color:#fff}.tag-local{background-color:red;color:#fff}
|
||||
@@ -228,4 +228,36 @@ div.container {
|
||||
}
|
||||
.block-default .block-content li:before {
|
||||
color: #95c11e;
|
||||
}
|
||||
|
||||
.boutons-plusmoins {
|
||||
display: inline-grid !important;
|
||||
margin-right: 20px;
|
||||
}
|
||||
.bouton-plus {
|
||||
font-family: FontAwesome;
|
||||
content: "f067";
|
||||
}
|
||||
.bouton-moins {
|
||||
font-family: FontAwesome;
|
||||
content: "f067";
|
||||
}
|
||||
|
||||
.tag-produit {
|
||||
transform: rotate(-10deg);
|
||||
padding: 0 5px;
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
z-index: 300;
|
||||
bottom: 5px;
|
||||
right: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.tag-bio {
|
||||
background-color: #95c11e;
|
||||
color: white;
|
||||
}
|
||||
.tag-local {
|
||||
background-color: red;
|
||||
color: white;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
(function($) {
|
||||
|
||||
|
||||
// $("i#bouton-plus").click(function () {
|
||||
// $("#quantity").val().add(1);
|
||||
// });
|
||||
|
||||
})(jQuery);
|
||||
@@ -8,6 +8,17 @@
|
||||
{if not $product_id}
|
||||
{assign var="product_id" value=$ID}
|
||||
{/if}
|
||||
|
||||
{assign var="IS_BIO" value=false}
|
||||
{assign var="IS_LOCAL" value=false}
|
||||
{loop name="features-list" type="feature" product=$product_id}
|
||||
{if $TITLE|strstr:"Locaux"}{assign var="IS_LOCAL" value=true}{/if}
|
||||
{loop name="feature-values-list" type="feature_value" product=$product_id feature={$ID}}
|
||||
{if $TITLE|strstr:"Bio"}{assign var="IS_BIO" value=true}{/if}
|
||||
{/loop}
|
||||
{/loop}
|
||||
|
||||
|
||||
<article class="row" itemscope itemtype="http://schema.org/Product">
|
||||
{hook name="singleproduct.top" product="{$product_id}"}
|
||||
|
||||
@@ -26,6 +37,14 @@
|
||||
<p>{$DESCRIPTION nofilter}</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if $IS_BIO}
|
||||
<span class="tag-produit tag-bio">{intl l="Produit bio"}</span>
|
||||
{/if}
|
||||
{if $IS_LOCAL}
|
||||
<span class="tag-produit tag-local">{intl l="Produit local"}</span>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
|
||||
{* Stock *}
|
||||
@@ -100,7 +119,6 @@
|
||||
{/loop}
|
||||
{/ifloop}
|
||||
{elseloop rel="dp"}
|
||||
|
||||
{loop type="product_sale_elements" name="pse" default=1 product=$product_id}
|
||||
<span class="regular-price col-xs-12"><span itemprop="price" class="price" content="{$TAXED_PRICE}">{format_money number=$TAXED_PRICE}
|
||||
{if $LOOP_COUNT = 1}
|
||||
|
||||
@@ -306,8 +306,8 @@ GNU General Public License : http://www.gnu.org/licenses/
|
||||
</script>
|
||||
|
||||
<!-- Custom scripts -->
|
||||
<script src="{javascript file='assets/dist/js/thelia.min.js'}"></script>
|
||||
<script src="{javascript file='assets/src/js/customJS.js'}"></script>
|
||||
<script src="{javascript file='assets/dist/js/thelia.min.js'}"></script>
|
||||
|
||||
{hook name="main.body-bottom"}
|
||||
</body>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<article class="col-main" role="main" aria-labelledby="main-label">
|
||||
|
||||
<h1 id="main-label" class="page-header">{intl l="Create New Account"}</h1>
|
||||
{hook name="register.top"}
|
||||
{hook name="register.top"}q
|
||||
{form name="thelia.front.customer.create"}
|
||||
<form id="form-register" class="form-horizontal" action="{url path='/register'}" method="post">
|
||||
{form_field field='success_url'}
|
||||
|
||||
Reference in New Issue
Block a user