Rajout du module View pour pouvoir afficher dans les menus la liste des marques
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user