Initial Commit
This commit is contained in:
42
local/modules/SliderRevolution/Config/config.xml
Normal file
42
local/modules/SliderRevolution/Config/config.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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="slider-revolution.slider" class="SliderRevolution\Loop\SliderLoop"/>
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<form name="sliderrevolution.form.configure" class="SliderRevolution\Form\ConfigurationForm" />
|
||||
</forms>
|
||||
|
||||
<services>
|
||||
<service id="sliderrevolution.smarty.plugin.get_countdown" class="SliderRevolution\Smarty\CountdownDate" >
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
</service>
|
||||
|
||||
<service id="sliderrevolution.event_listener" class="SliderRevolution\EventListener\EventManager">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<hooks>
|
||||
<hook id="sliderrevolution.front_hook" class="SliderRevolution\Hook\FrontHookManager">
|
||||
<tag name="hook.event_listener" event="main.content-top" type="front" method="onMainContentTop" />
|
||||
<tag name="hook.event_listener" event="main.stylesheet" type="front" method="onMainStylesheet" />
|
||||
<tag name="hook.event_listener" event="main.javascript-initialization" method="onMainJavascriptInitialization" />
|
||||
</hook>
|
||||
|
||||
<hook id="sliderrevolution.back_hook" class="SliderRevolution\Hook\BackHookManager">
|
||||
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfigure" />
|
||||
|
||||
<tag name="hook.event_listener" event="category.modification.form-right.bottom" type="back" method="onCategoryEditRightColumnBottom" />
|
||||
<tag name="hook.event_listener" event="product.modification.form-right.bottom" type="back" method="onProductEditRightColumnBottom" />
|
||||
<tag name="hook.event_listener" event="folder.modification.form-right.bottom" type="back" method="onFolderEditRightColumnBottom" />
|
||||
<tag name="hook.event_listener" event="content.modification.form-right.bottom" type="back" method="onContentEditRightColumnBottom" />
|
||||
<tag name="hook.event_listener" event="brand.modification.form-right.bottom" type="back" method="onBrandEditRightColumnBottom" />
|
||||
</hook>
|
||||
</hooks>
|
||||
</config>
|
||||
24
local/modules/SliderRevolution/Config/module.xml
Normal file
24
local/modules/SliderRevolution/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_2.xsd">
|
||||
<fullnamespace>SliderRevolution\SliderRevolution</fullnamespace>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Intégration du slider Slider Revolution</title>
|
||||
</descriptive>
|
||||
<languages>
|
||||
<language>fr_FR</language>
|
||||
</languages>
|
||||
<version>1.0.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Franck Allimant</name>
|
||||
<company>CQFDev</company>
|
||||
<email>thelia@cqfdev.fr</email>
|
||||
<website>www.cqfdev.fr</website>
|
||||
</author>
|
||||
</authors>
|
||||
<type>classic</type>
|
||||
<thelia>2.3.0</thelia>
|
||||
<stability>prod</stability>
|
||||
</module>
|
||||
10
local/modules/SliderRevolution/Config/routing.xml
Normal file
10
local/modules/SliderRevolution/Config/routing.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?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="sliderrevolution.configure" path="/admin/module/sliderrevolution/configure" methods="post">
|
||||
<default key="_controller">SliderRevolution\Controller\ConfigurationController::configure</default>
|
||||
</route>
|
||||
</routes>
|
||||
15
local/modules/SliderRevolution/Config/schema.xml
Normal file
15
local/modules/SliderRevolution/Config/schema.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../core/vendor/propel/propel/resources/xsd/database.xsd" >
|
||||
|
||||
<table name="slider_association" namespace="SliderRevolution\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
|
||||
<column name="slider_alias" size="255" type="VARCHAR" />
|
||||
<column name="object_id" type="integer" required="true" />
|
||||
<column name="object_type" type="varchar" required="true" size="10"/>
|
||||
</table>
|
||||
|
||||
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
|
||||
</database>
|
||||
2
local/modules/SliderRevolution/Config/sqldb.map
Normal file
2
local/modules/SliderRevolution/Config/sqldb.map
Normal file
@@ -0,0 +1,2 @@
|
||||
# Sqlfile -> Database map
|
||||
thelia.sql=thelia
|
||||
22
local/modules/SliderRevolution/Config/thelia.sql
Normal file
22
local/modules/SliderRevolution/Config/thelia.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
# 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;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- slider_association
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `slider_association`;
|
||||
|
||||
CREATE TABLE `slider_association`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`slider_alias` VARCHAR(255),
|
||||
`object_id` INTEGER NOT NULL,
|
||||
`object_type` VARCHAR(10) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
# This restores the fkey checks, after having unset them earlier
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Copyright (c) CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SliderRevolution\Controller;
|
||||
|
||||
use SliderRevolution\SliderRevolution;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class ConfigurationController extends BaseAdminController
|
||||
{
|
||||
public function configure()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'SliderRevolution', AccessManager::UPDATE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$configurationForm = $this->createForm('sliderrevolution.form.configure');
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($configurationForm, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
foreach ($data as $name => $value) {
|
||||
if (is_array($value)) {
|
||||
$value = implode(';', $value);
|
||||
}
|
||||
|
||||
SliderRevolution::setConfigValue($name, $value);
|
||||
}
|
||||
|
||||
$this->adminLogAppend(
|
||||
"sliderrevolution.configuration.message",
|
||||
AccessManager::UPDATE,
|
||||
sprintf("Configuration du franco mise à jour")
|
||||
);
|
||||
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
// If we have to stay on the same page, redisplay the configuration page/
|
||||
$url = '/admin/module/SliderRevolution';
|
||||
} else {
|
||||
// If we have to close the page, go back to the module back-office page.
|
||||
$url = '/admin/modules';
|
||||
}
|
||||
|
||||
return $this->generateRedirect(URL::getInstance()->absoluteUrl($url));
|
||||
} catch (FormValidationException $ex) {
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("Configuration du franco", [], SliderRevolution::DOMAIN_NAME),
|
||||
$error_msg,
|
||||
$configurationForm,
|
||||
$ex
|
||||
);
|
||||
|
||||
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/module/SliderRevolution'));
|
||||
}
|
||||
}
|
||||
161
local/modules/SliderRevolution/EventListener/EventManager.php
Normal file
161
local/modules/SliderRevolution/EventListener/EventManager.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
/**
|
||||
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
|
||||
* Date: 28/03/2019 17:22
|
||||
*/
|
||||
namespace SliderRevolution\EventListener;
|
||||
|
||||
use SliderRevolution\Model\SliderAssociation;
|
||||
use SliderRevolution\Model\SliderAssociationQuery;
|
||||
use SliderRevolution\SliderRevolution;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Brand\BrandEvent;
|
||||
use Thelia\Core\Event\Category\CategoryEvent;
|
||||
use Thelia\Core\Event\Content\ContentEvent;
|
||||
use Thelia\Core\Event\Folder\FolderEvent;
|
||||
use Thelia\Core\Event\Product\ProductEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\TheliaFormEvent;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class EventManager implements EventSubscriberInterface
|
||||
{
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
TheliaEvents::FORM_BEFORE_BUILD . ".thelia_product_modification" => ['addSliderSelectorToForm', 128],
|
||||
TheliaEvents::FORM_BEFORE_BUILD . ".thelia_category_modification" => ['addSliderSelectorToForm', 128],
|
||||
TheliaEvents::FORM_BEFORE_BUILD . ".thelia_content_modification" => ['addSliderSelectorToForm', 128],
|
||||
TheliaEvents::FORM_BEFORE_BUILD . ".thelia_folder_modification" => ['addSliderSelectorToForm', 128],
|
||||
TheliaEvents::FORM_BEFORE_BUILD . ".thelia_brand_modification" => ['addSliderSelectorToForm', 128],
|
||||
|
||||
TheliaEvents::CATEGORY_UPDATE => ['processCategorySelectedSlider', 100],
|
||||
TheliaEvents::PRODUCT_UPDATE => ['processProductSelectedSlider', 100],
|
||||
TheliaEvents::CONTENT_UPDATE => ['processContentSelectedSlider', 100],
|
||||
TheliaEvents::FOLDER_UPDATE => ['processFolderSelectedSlider', 100],
|
||||
TheliaEvents::BRAND_UPDATE => ['processBrandSelectedSlider', 100],
|
||||
];
|
||||
}
|
||||
|
||||
public function addSliderSelectorToForm(TheliaFormEvent $event)
|
||||
{
|
||||
$event->getForm()->getFormBuilder()->add(
|
||||
'slider_id',
|
||||
'text',
|
||||
[
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans(
|
||||
'Slider associé',
|
||||
[],
|
||||
SliderRevolution::DOMAIN_NAME
|
||||
),
|
||||
'label_attr' => [
|
||||
'help' => Translator::getInstance()->trans(
|
||||
'Choisissez ici le slider à associer à cet élément.',
|
||||
[ ],
|
||||
SliderRevolution::DOMAIN_NAME
|
||||
)
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryEvent $event
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
public function processCategorySelectedSlider(CategoryEvent $event)
|
||||
{
|
||||
// Utilise le principe NON DOCUMENTE qui dit que si une form bindée à un event trouve
|
||||
// un champ absent de l'event, elle le rend accessible à travers une méthode magique.
|
||||
// (cf. ActionEvent::bindForm())
|
||||
$sliderId = trim($event->slider_id);
|
||||
|
||||
$this->processSelectedSlider($sliderId, 'category', $event->getCategory()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryEvent $event
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
public function processProductSelectedSlider(ProductEvent $event)
|
||||
{
|
||||
// Utilise le principe NON DOCUMENTE qui dit que si une form bindée à un event trouve
|
||||
// un champ absent de l'event, elle le rend accessible à travers une méthode magique.
|
||||
// (cf. ActionEvent::bindForm())
|
||||
$sliderId = trim($event->slider_id);
|
||||
|
||||
$this->processSelectedSlider($sliderId, 'product', $event->getProduct()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryEvent $event
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
public function processContentSelectedSlider(ContentEvent $event)
|
||||
{
|
||||
// Utilise le principe NON DOCUMENTE qui dit que si une form bindée à un event trouve
|
||||
// un champ absent de l'event, elle le rend accessible à travers une méthode magique.
|
||||
// (cf. ActionEvent::bindForm())
|
||||
$sliderId = trim($event->slider_id);
|
||||
|
||||
$this->processSelectedSlider($sliderId, 'content', $event->getContent()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryEvent $event
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
public function processFolderSelectedSlider(FolderEvent $event)
|
||||
{
|
||||
// Utilise le principe NON DOCUMENTE qui dit que si une form bindée à un event trouve
|
||||
// un champ absent de l'event, elle le rend accessible à travers une méthode magique.
|
||||
// (cf. ActionEvent::bindForm())
|
||||
$sliderId = trim($event->slider_id);
|
||||
|
||||
$this->processSelectedSlider($sliderId, 'folder', $event->getFolder()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryEvent $event
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
public function processBrandSelectedSlider(BrandEvent $event)
|
||||
{
|
||||
// Utilise le principe NON DOCUMENTE qui dit que si une form bindée à un event trouve
|
||||
// un champ absent de l'event, elle le rend accessible à travers une méthode magique.
|
||||
// (cf. ActionEvent::bindForm())
|
||||
$sliderId = trim($event->slider_id);
|
||||
|
||||
$this->processSelectedSlider($sliderId, 'brand', $event->getBrand()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sliderId
|
||||
* @param $objectId
|
||||
* @param $objectType
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
protected function processSelectedSlider($sliderId, $objectType, $objectId)
|
||||
{
|
||||
if (null === $sliderAssoc = SliderAssociationQuery::create()->filterByObjectId($objectId)->filterByObjectType($objectType)->findOne()) {
|
||||
$sliderAssoc = (new SliderAssociation())
|
||||
->setObjectId($objectId)
|
||||
->setObjectType($objectType);
|
||||
}
|
||||
|
||||
$sliderAssoc
|
||||
->setSliderAlias($sliderId)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
59
local/modules/SliderRevolution/Form/ConfigurationForm.php
Normal file
59
local/modules/SliderRevolution/Form/ConfigurationForm.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia 2 FrancoDePort payment module */
|
||||
/* */
|
||||
/* Copyright (c) CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace SliderRevolution\Form;
|
||||
|
||||
use SliderRevolution\SliderRevolution;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
/**
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class ConfigurationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add(
|
||||
SliderRevolution::SLIDER_ID,
|
||||
'text',
|
||||
[
|
||||
'constraints' => [new NotBlank()],
|
||||
'label' => $this->translator->trans('Identifiant du slider à afficher', [], SliderRevolution::DOMAIN_NAME),
|
||||
'data' => SliderRevolution::getConfigValue(SliderRevolution::SLIDER_ID),
|
||||
]
|
||||
)
|
||||
->add(
|
||||
SliderRevolution::FIN_COMPTE_A_REBOURS,
|
||||
'text',
|
||||
[
|
||||
'required' => false,
|
||||
'constraints' => [new Callback([ "methods" => [[ $this, "checkDate" ]]]),],
|
||||
'label' => $this->translator->trans('Date de fin de compte à rebours (format JJ/MM/AAAA HH:MM:SS)', [], SliderRevolution::DOMAIN_NAME),
|
||||
'data' => SliderRevolution::getConfigValue(SliderRevolution::FIN_COMPTE_A_REBOURS, ''),
|
||||
'label_attr' => [
|
||||
'help' => $this->translator->trans("Si une date est indiquée, un compte à rebours sera affiché sur les sliders qui ont les layer texte requises (ID t_days, t_hours, t_minutes et t_seconds), cf https://www.themepunch.com/revsliderjquery-doc/countdown", [], SliderRevolution::DOMAIN_NAME)
|
||||
]
|
||||
]
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function checkDate($value, ExecutionContextInterface $context)
|
||||
{
|
||||
if (! empty($value) && false === \DateTime::createFromFormat('d/m/Y H:i:s', $value)) {
|
||||
$context->addViolation("Merci d'indiquer une date au format JJ/MM/AAAA HH:MM:SS, par exemple 17/11/2018 12:30:00");
|
||||
}
|
||||
}
|
||||
}
|
||||
88
local/modules/SliderRevolution/Hook/BackHookManager.php
Normal file
88
local/modules/SliderRevolution/Hook/BackHookManager.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
/**
|
||||
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
|
||||
* Date: 05/03/2016 18:11
|
||||
*/
|
||||
|
||||
namespace SliderRevolution\Hook;
|
||||
|
||||
use SliderRevolution\Model\SliderAssociationQuery;
|
||||
use SliderRevolution\SliderRevolution;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Model\ModuleConfig;
|
||||
use Thelia\Model\ModuleConfigQuery;
|
||||
|
||||
class BackHookManager extends BaseHook
|
||||
{
|
||||
public function onModuleConfigure(HookRenderEvent $event)
|
||||
{
|
||||
$vars = [];
|
||||
|
||||
if (null !== $params = ModuleConfigQuery::create()->findByModuleId(SliderRevolution::getModuleId())) {
|
||||
/** @var ModuleConfig $param */
|
||||
foreach ($params as $param) {
|
||||
$vars[ $param->getName() ] = $param->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
$event->add(
|
||||
$this->render('sliderrevolution/module-configuration.html', $vars)
|
||||
);
|
||||
}
|
||||
|
||||
public function onCategoryEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'category', $event->getArgument('category_id'));
|
||||
}
|
||||
|
||||
public function onContentEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'content', $event->getArgument('content_id'));
|
||||
}
|
||||
|
||||
public function onFolderEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'folder', $event->getArgument('folder_id'));
|
||||
}
|
||||
|
||||
public function onBrandEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'brand', $event->getArgument('brand_id'));
|
||||
}
|
||||
|
||||
public function onProductEditRightColumnBottom(HookRenderEvent $event)
|
||||
{
|
||||
return $this->renderSliderAssocSelector($event, 'product', $event->getArgument('product_id'));
|
||||
}
|
||||
|
||||
protected function renderSliderAssocSelector(HookRenderEvent $event, $objectType, $objectId)
|
||||
{
|
||||
if (null !== $sliderAssoc = SliderAssociationQuery::create()
|
||||
->filterByObjectType($objectType)
|
||||
->filterByObjectId($objectId)
|
||||
->findOne()) {
|
||||
$sliderAlias = $sliderAssoc->getSliderAlias();
|
||||
} else {
|
||||
$sliderAlias = '';
|
||||
}
|
||||
|
||||
$event->add(
|
||||
$this->render(
|
||||
"sliderrevolution/slider-selector.html",
|
||||
[
|
||||
'slider_alias' => $sliderAlias
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
85
local/modules/SliderRevolution/Hook/FrontHookManager.php
Normal file
85
local/modules/SliderRevolution/Hook/FrontHookManager.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
/**
|
||||
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
|
||||
* Date: 05/03/2016 18:11
|
||||
*/
|
||||
|
||||
namespace SliderRevolution\Hook;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use SliderRevolution\Model\SliderAssociationQuery;
|
||||
use SliderRevolution\SliderRevolution;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
|
||||
require_once __DIR__ . "/../../../../web/revslider/embed_thelia.php";
|
||||
|
||||
class FrontHookManager extends BaseHook
|
||||
{
|
||||
private $jsCode = '';
|
||||
|
||||
public function onMainStylesheet(HookRenderEvent $event)
|
||||
{
|
||||
if (null !== SliderRevolution::getConfigValue(SliderRevolution::SLIDER_ID)) {
|
||||
$event->add(
|
||||
\RevSliderEmbedder::cssIncludes(false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function onMainJavascriptInitialization(HookRenderEvent $event)
|
||||
{
|
||||
if (null !== SliderRevolution::getConfigValue(SliderRevolution::SLIDER_ID)) {
|
||||
$event->add(
|
||||
\RevSliderEmbedder::jsIncludes(false, false) . $this->jsCode
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function onMainContentTop(HookRenderEvent $event)
|
||||
{
|
||||
$view = $this->getView();
|
||||
|
||||
if ($this->isAcceptedView($view)) {
|
||||
if ($view === "index") {
|
||||
if (null !== $slider = SliderRevolution::getConfigValue(SliderRevolution::SLIDER_ID)) {
|
||||
$event->add(
|
||||
\RevSliderEmbedder::putRevSlider($slider, '', $this->jsCode)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (null !== $sliderAssoc = SliderAssociationQuery::create()
|
||||
->filterByObjectType($view)
|
||||
->filterByObjectId( $this->getRequest()->get($view . '_id'))
|
||||
->filterBySliderAlias('', Criteria::NOT_EQUAL)
|
||||
->findOne()) {
|
||||
$event->add(
|
||||
\RevSliderEmbedder::putRevSlider($sliderAssoc->getSliderAlias(), '', $this->jsCode)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function isAcceptedView($view)
|
||||
{
|
||||
$acceptedViews = [
|
||||
'category',
|
||||
'product',
|
||||
'folder',
|
||||
'content',
|
||||
'brand',
|
||||
'index'
|
||||
];
|
||||
|
||||
return in_array($view, $acceptedViews);
|
||||
}
|
||||
}
|
||||
4
local/modules/SliderRevolution/I18n/en_US.php
Normal file
4
local/modules/SliderRevolution/I18n/en_US.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return array(
|
||||
// 'an english string' => 'The displayed english string',
|
||||
);
|
||||
4
local/modules/SliderRevolution/I18n/fr_FR.php
Normal file
4
local/modules/SliderRevolution/I18n/fr_FR.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return array(
|
||||
// 'an english string' => 'La traduction française de la chaine',
|
||||
);
|
||||
71
local/modules/SliderRevolution/Loop/SliderLoop.php
Normal file
71
local/modules/SliderRevolution/Loop/SliderLoop.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Copyright (c) Franck Allimant, CQFDev */
|
||||
/* email : thelia@cqfdev.fr */
|
||||
/* web : http://www.cqfdev.fr */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
/**
|
||||
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
|
||||
* Date: 25/04/2019 18:57
|
||||
*/
|
||||
namespace SliderRevolution\Loop;
|
||||
|
||||
use Propel\Runtime\Connection\PropelPDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ServiceContainer\ServiceContainerInterface;
|
||||
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\ArgumentCollection;
|
||||
|
||||
class SliderLoop extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
public function buildArray()
|
||||
{
|
||||
$query = "select id,alias,title from revslider_sliders where type = ''";
|
||||
|
||||
/** @var PropelPDO $connection */
|
||||
$connection = Propel::getConnection('thelia');
|
||||
|
||||
$statement = $connection->query($query);
|
||||
|
||||
$result = [];
|
||||
|
||||
while ($statement && $row = $statement->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$result[] = [
|
||||
'id' => $row['id'],
|
||||
'alias' => $row['alias'],
|
||||
'title' => $row['title']
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $data) {
|
||||
$loopResultRow = new LoopResultRow($data);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $data['id'])
|
||||
->set("ALIAS", $data['alias'])
|
||||
->set("TITLE", $data['title'])
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
}
|
||||
}
|
||||
1226
local/modules/SliderRevolution/Model/Base/SliderAssociation.php
Normal file
1226
local/modules/SliderRevolution/Model/Base/SliderAssociation.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,455 @@
|
||||
<?php
|
||||
|
||||
namespace SliderRevolution\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 SliderRevolution\Model\SliderAssociation as ChildSliderAssociation;
|
||||
use SliderRevolution\Model\SliderAssociationQuery as ChildSliderAssociationQuery;
|
||||
use SliderRevolution\Model\Map\SliderAssociationTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'slider_association' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildSliderAssociationQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildSliderAssociationQuery orderBySliderAlias($order = Criteria::ASC) Order by the slider_alias column
|
||||
* @method ChildSliderAssociationQuery orderByObjectId($order = Criteria::ASC) Order by the object_id column
|
||||
* @method ChildSliderAssociationQuery orderByObjectType($order = Criteria::ASC) Order by the object_type column
|
||||
*
|
||||
* @method ChildSliderAssociationQuery groupById() Group by the id column
|
||||
* @method ChildSliderAssociationQuery groupBySliderAlias() Group by the slider_alias column
|
||||
* @method ChildSliderAssociationQuery groupByObjectId() Group by the object_id column
|
||||
* @method ChildSliderAssociationQuery groupByObjectType() Group by the object_type column
|
||||
*
|
||||
* @method ChildSliderAssociationQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildSliderAssociationQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildSliderAssociationQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildSliderAssociation findOne(ConnectionInterface $con = null) Return the first ChildSliderAssociation matching the query
|
||||
* @method ChildSliderAssociation findOneOrCreate(ConnectionInterface $con = null) Return the first ChildSliderAssociation matching the query, or a new ChildSliderAssociation object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildSliderAssociation findOneById(int $id) Return the first ChildSliderAssociation filtered by the id column
|
||||
* @method ChildSliderAssociation findOneBySliderAlias(string $slider_alias) Return the first ChildSliderAssociation filtered by the slider_alias column
|
||||
* @method ChildSliderAssociation findOneByObjectId(int $object_id) Return the first ChildSliderAssociation filtered by the object_id column
|
||||
* @method ChildSliderAssociation findOneByObjectType(string $object_type) Return the first ChildSliderAssociation filtered by the object_type column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildSliderAssociation objects filtered by the id column
|
||||
* @method array findBySliderAlias(string $slider_alias) Return ChildSliderAssociation objects filtered by the slider_alias column
|
||||
* @method array findByObjectId(int $object_id) Return ChildSliderAssociation objects filtered by the object_id column
|
||||
* @method array findByObjectType(string $object_type) Return ChildSliderAssociation objects filtered by the object_type column
|
||||
*
|
||||
*/
|
||||
abstract class SliderAssociationQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \SliderRevolution\Model\Base\SliderAssociationQuery 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 = '\\SliderRevolution\\Model\\SliderAssociation', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildSliderAssociationQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildSliderAssociationQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \SliderRevolution\Model\SliderAssociationQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \SliderRevolution\Model\SliderAssociationQuery();
|
||||
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 ChildSliderAssociation|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = SliderAssociationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(SliderAssociationTableMap::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 ChildSliderAssociation A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, SLIDER_ALIAS, OBJECT_ID, OBJECT_TYPE FROM slider_association 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 ChildSliderAssociation();
|
||||
$obj->hydrate($row);
|
||||
SliderAssociationTableMap::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 ChildSliderAssociation|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 ChildSliderAssociationQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(SliderAssociationTableMap::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 ChildSliderAssociationQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(SliderAssociationTableMap::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 ChildSliderAssociationQuery 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(SliderAssociationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($id['max'])) {
|
||||
$this->addUsingAlias(SliderAssociationTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(SliderAssociationTableMap::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the slider_alias column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterBySliderAlias('fooValue'); // WHERE slider_alias = 'fooValue'
|
||||
* $query->filterBySliderAlias('%fooValue%'); // WHERE slider_alias LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $sliderAlias 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 ChildSliderAssociationQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterBySliderAlias($sliderAlias = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($sliderAlias)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $sliderAlias)) {
|
||||
$sliderAlias = str_replace('*', '%', $sliderAlias);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(SliderAssociationTableMap::SLIDER_ALIAS, $sliderAlias, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the object_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByObjectId(1234); // WHERE object_id = 1234
|
||||
* $query->filterByObjectId(array(12, 34)); // WHERE object_id IN (12, 34)
|
||||
* $query->filterByObjectId(array('min' => 12)); // WHERE object_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $objectId 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 ChildSliderAssociationQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByObjectId($objectId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($objectId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($objectId['min'])) {
|
||||
$this->addUsingAlias(SliderAssociationTableMap::OBJECT_ID, $objectId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($objectId['max'])) {
|
||||
$this->addUsingAlias(SliderAssociationTableMap::OBJECT_ID, $objectId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(SliderAssociationTableMap::OBJECT_ID, $objectId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the object_type column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByObjectType('fooValue'); // WHERE object_type = 'fooValue'
|
||||
* $query->filterByObjectType('%fooValue%'); // WHERE object_type LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $objectType 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 ChildSliderAssociationQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByObjectType($objectType = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($objectType)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $objectType)) {
|
||||
$objectType = str_replace('*', '%', $objectType);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(SliderAssociationTableMap::OBJECT_TYPE, $objectType, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildSliderAssociation $sliderAssociation Object to remove from the list of results
|
||||
*
|
||||
* @return ChildSliderAssociationQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($sliderAssociation = null)
|
||||
{
|
||||
if ($sliderAssociation) {
|
||||
$this->addUsingAlias(SliderAssociationTableMap::ID, $sliderAssociation->getId(), Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the slider_association 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(SliderAssociationTableMap::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).
|
||||
SliderAssociationTableMap::clearInstancePool();
|
||||
SliderAssociationTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildSliderAssociation or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildSliderAssociation 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(SliderAssociationTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(SliderAssociationTableMap::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();
|
||||
|
||||
|
||||
SliderAssociationTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
SliderAssociationTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // SliderAssociationQuery
|
||||
@@ -0,0 +1,426 @@
|
||||
<?php
|
||||
|
||||
namespace SliderRevolution\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 SliderRevolution\Model\SliderAssociation;
|
||||
use SliderRevolution\Model\SliderAssociationQuery;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'slider_association' 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 SliderAssociationTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'SliderRevolution.Model.Map.SliderAssociationTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'slider_association';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\SliderRevolution\\Model\\SliderAssociation';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'SliderRevolution.Model.SliderAssociation';
|
||||
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 4;
|
||||
|
||||
/**
|
||||
* 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 = 4;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
*/
|
||||
const ID = 'slider_association.ID';
|
||||
|
||||
/**
|
||||
* the column name for the SLIDER_ALIAS field
|
||||
*/
|
||||
const SLIDER_ALIAS = 'slider_association.SLIDER_ALIAS';
|
||||
|
||||
/**
|
||||
* the column name for the OBJECT_ID field
|
||||
*/
|
||||
const OBJECT_ID = 'slider_association.OBJECT_ID';
|
||||
|
||||
/**
|
||||
* the column name for the OBJECT_TYPE field
|
||||
*/
|
||||
const OBJECT_TYPE = 'slider_association.OBJECT_TYPE';
|
||||
|
||||
/**
|
||||
* 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', 'SliderAlias', 'ObjectId', 'ObjectType', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'sliderAlias', 'objectId', 'objectType', ),
|
||||
self::TYPE_COLNAME => array(SliderAssociationTableMap::ID, SliderAssociationTableMap::SLIDER_ALIAS, SliderAssociationTableMap::OBJECT_ID, SliderAssociationTableMap::OBJECT_TYPE, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'SLIDER_ALIAS', 'OBJECT_ID', 'OBJECT_TYPE', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'slider_alias', 'object_id', 'object_type', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
/**
|
||||
* 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, 'SliderAlias' => 1, 'ObjectId' => 2, 'ObjectType' => 3, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'sliderAlias' => 1, 'objectId' => 2, 'objectType' => 3, ),
|
||||
self::TYPE_COLNAME => array(SliderAssociationTableMap::ID => 0, SliderAssociationTableMap::SLIDER_ALIAS => 1, SliderAssociationTableMap::OBJECT_ID => 2, SliderAssociationTableMap::OBJECT_TYPE => 3, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'SLIDER_ALIAS' => 1, 'OBJECT_ID' => 2, 'OBJECT_TYPE' => 3, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'slider_alias' => 1, 'object_id' => 2, 'object_type' => 3, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
/**
|
||||
* 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('slider_association');
|
||||
$this->setPhpName('SliderAssociation');
|
||||
$this->setClassName('\\SliderRevolution\\Model\\SliderAssociation');
|
||||
$this->setPackage('SliderRevolution.Model');
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('SLIDER_ALIAS', 'SliderAlias', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('OBJECT_ID', 'ObjectId', 'INTEGER', true, null, null);
|
||||
$this->addColumn('OBJECT_TYPE', 'ObjectType', 'VARCHAR', true, 10, null);
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
* 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 ? SliderAssociationTableMap::CLASS_DEFAULT : SliderAssociationTableMap::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 (SliderAssociation object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = SliderAssociationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = SliderAssociationTableMap::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 + SliderAssociationTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = SliderAssociationTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
SliderAssociationTableMap::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 = SliderAssociationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = SliderAssociationTableMap::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;
|
||||
SliderAssociationTableMap::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(SliderAssociationTableMap::ID);
|
||||
$criteria->addSelectColumn(SliderAssociationTableMap::SLIDER_ALIAS);
|
||||
$criteria->addSelectColumn(SliderAssociationTableMap::OBJECT_ID);
|
||||
$criteria->addSelectColumn(SliderAssociationTableMap::OBJECT_TYPE);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.SLIDER_ALIAS');
|
||||
$criteria->addSelectColumn($alias . '.OBJECT_ID');
|
||||
$criteria->addSelectColumn($alias . '.OBJECT_TYPE');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(SliderAssociationTableMap::DATABASE_NAME)->getTable(SliderAssociationTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(SliderAssociationTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(SliderAssociationTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new SliderAssociationTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a SliderAssociation or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or SliderAssociation 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(SliderAssociationTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \SliderRevolution\Model\SliderAssociation) { // 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(SliderAssociationTableMap::DATABASE_NAME);
|
||||
$criteria->add(SliderAssociationTableMap::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
$query = SliderAssociationQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { SliderAssociationTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { SliderAssociationTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the slider_association 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 SliderAssociationQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a SliderAssociation or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or SliderAssociation 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(SliderAssociationTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from SliderAssociation object
|
||||
}
|
||||
|
||||
if ($criteria->containsKey(SliderAssociationTableMap::ID) && $criteria->keyContainsValue(SliderAssociationTableMap::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.SliderAssociationTableMap::ID.')');
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = SliderAssociationQuery::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;
|
||||
}
|
||||
|
||||
} // SliderAssociationTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
SliderAssociationTableMap::buildTableMap();
|
||||
10
local/modules/SliderRevolution/Model/SliderAssociation.php
Normal file
10
local/modules/SliderRevolution/Model/SliderAssociation.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SliderRevolution\Model;
|
||||
|
||||
use SliderRevolution\Model\Base\SliderAssociation as BaseSliderAssociation;
|
||||
|
||||
class SliderAssociation extends BaseSliderAssociation
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace SliderRevolution\Model;
|
||||
|
||||
use SliderRevolution\Model\Base\SliderAssociationQuery as BaseSliderAssociationQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'slider_association' 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 SliderAssociationQuery extends BaseSliderAssociationQuery
|
||||
{
|
||||
|
||||
} // SliderAssociationQuery
|
||||
55
local/modules/SliderRevolution/Readme.md
Normal file
55
local/modules/SliderRevolution/Readme.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Slider Revolution
|
||||
|
||||
Add a short description here. You can also add a screenshot if needed.
|
||||
|
||||
## Installation
|
||||
|
||||
### Manually
|
||||
|
||||
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is SliderRevolution.
|
||||
* Activate it in your thelia administration panel
|
||||
|
||||
### Composer
|
||||
|
||||
Add it in your main thelia composer.json file
|
||||
|
||||
```
|
||||
composer require your-vendor/slider-revolution-module:~1.0
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Explain here how to use your module, how to configure it, etc.
|
||||
|
||||
## Hook
|
||||
|
||||
If your module use one or more hook, fill this part. Explain which hooks are used.
|
||||
|
||||
|
||||
## Loop
|
||||
|
||||
If your module declare one or more loop, describe them here like this :
|
||||
|
||||
[loop name]
|
||||
|
||||
### Input arguments
|
||||
|
||||
|Argument |Description |
|
||||
|--- |--- |
|
||||
|**arg1** | describe arg1 with an exemple. |
|
||||
|**arg2** | describe arg2 with an exemple. |
|
||||
|
||||
### Output arguments
|
||||
|
||||
|Variable |Description |
|
||||
|--- |--- |
|
||||
|$VAR1 | describe $VAR1 variable |
|
||||
|$VAR2 | describe $VAR2 variable |
|
||||
|
||||
### Exemple
|
||||
|
||||
Add a complete exemple of your loop
|
||||
|
||||
## Other ?
|
||||
|
||||
If you have other think to put, feel free to complete your readme as you want.
|
||||
40
local/modules/SliderRevolution/SliderRevolution.php
Normal file
40
local/modules/SliderRevolution/SliderRevolution.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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 SliderRevolution;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use SliderRevolution\Model\SliderAssociationQuery;
|
||||
use Thelia\Install\Database;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class SliderRevolution extends BaseModule
|
||||
{
|
||||
/** @var string */
|
||||
const DOMAIN_NAME = 'sliderrevolution';
|
||||
|
||||
const SLIDER_ID = 'slider_id';
|
||||
const FIN_COMPTE_A_REBOURS = 'countdown_end';
|
||||
|
||||
|
||||
public function postActivation(ConnectionInterface $con = null)
|
||||
{
|
||||
// Creer la table si elle n'existe pas déjà
|
||||
try {
|
||||
SliderAssociationQuery::create()->findOne();
|
||||
} catch (\Exception $ex) {
|
||||
$database = new Database($con);
|
||||
|
||||
$database->insertSql(null, [__DIR__ . '/Config/thelia.sql']);
|
||||
}
|
||||
}
|
||||
}
|
||||
64
local/modules/SliderRevolution/Smarty/CountdownDate.php
Normal file
64
local/modules/SliderRevolution/Smarty/CountdownDate.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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 SliderRevolution\Smarty;
|
||||
|
||||
use SliderRevolution\SliderRevolution;
|
||||
use TheliaSmarty\Template\AbstractSmartyPlugin;
|
||||
use TheliaSmarty\Template\SmartyPluginDescriptor;
|
||||
|
||||
/**
|
||||
* Class CartPostage
|
||||
* @package Thelia\Core\Template\Smarty\Plugins
|
||||
*/
|
||||
class CountdownDate extends AbstractSmartyPlugin
|
||||
{
|
||||
/**
|
||||
* Get postage amount for cart
|
||||
*
|
||||
* @param array $params Block parameters
|
||||
* @param mixed $content Block content
|
||||
* @param \Smarty_Internal_Template $template Template
|
||||
* @param bool $repeat Control how many times
|
||||
* the block is displayed
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCountdownDate($params, /** @noinspection PhpUnusedParameterInspection */ $template)
|
||||
{
|
||||
$countdown = SliderRevolution::getConfigValue(SliderRevolution::FIN_COMPTE_A_REBOURS);
|
||||
|
||||
if (! empty($countdown)) {
|
||||
if (false !== $date = \DateTime::createFromFormat("d/m/Y H:i:s", $countdown)) {
|
||||
$today = new \DateTime();
|
||||
|
||||
if ($date > $today) {
|
||||
return $date->getTimestamp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the various smarty plugins handled by this class
|
||||
*
|
||||
* @return \TheliaSmarty\Template\SmartyPluginDescriptor[] smarty plugin descriptors
|
||||
*/
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor('function', 'slider_revolution_countdown', $this, 'getCountdownDate')
|
||||
);
|
||||
}
|
||||
}
|
||||
11
local/modules/SliderRevolution/composer.json
Normal file
11
local/modules/SliderRevolution/composer.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "your-vendor/slider-revolution-module",
|
||||
"license": "LGPL-3.0+",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.1"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "SliderRevolution"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<div class="row">
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl d='sliderrevolution.bo.default' l="Configuration Slider Revolution"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{form name="sliderrevolution.form.configure"}
|
||||
|
||||
<form action="{url path="/admin/module/sliderrevolution/configure"}" method="post">
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{include file = "includes/inner-form-toolbar.html"
|
||||
hide_flags = true
|
||||
page_url = "{url path='/admin/module/sliderrevolution'}"
|
||||
close_url = "{url path='/admin/modules'}"
|
||||
}
|
||||
|
||||
{if $form_error}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-danger">{$form_error_message}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="col-md-6">
|
||||
{custom_render_form_field field='slider_id'}
|
||||
<select {form_field_attributes field='slider_id'}>
|
||||
<option value="">Aucun slider</option>
|
||||
{loop type="slider-revolution.slider" name="slider"}
|
||||
<option {if $value == $ALIAS}selected {/if}value="{$ALIAS}">{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{/custom_render_form_field}
|
||||
{render_form_field field='countdown_end'}
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 text-right clearfix">
|
||||
<a class="btn btn-primary text-right" href="/revslider/?c=account" target="_blank">{intl d='sliderrevolution.bo.default' l="Accéder à l'éditeur du slider"}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
{custom_render_form_field field='slider_id'}
|
||||
<select {form_field_attributes field='slider_id'}>
|
||||
<option value="">Aucun slider</option>
|
||||
{loop type="slider-revolution.slider" name="slider"}
|
||||
<option {if $slider_alias == $ALIAS}selected {/if}value="{$ALIAS}">{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{/custom_render_form_field}
|
||||
Reference in New Issue
Block a user