Init du module DHL (sur la base du module Colissimo)
This commit is contained in:
100
local/modules/DHL/Loop/CheckRightsLoop.php
Normal file
100
local/modules/DHL/Loop/CheckRightsLoop.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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 DHL\Loop;
|
||||
|
||||
use DHL\DHL;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
* Class CheckRightsLoop
|
||||
* @package DHL\Looop
|
||||
* @author Thelia <info@thelia.net>
|
||||
*/
|
||||
class CheckRightsLoop extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
}
|
||||
|
||||
public function buildArray()
|
||||
{
|
||||
$ret = array();
|
||||
$dir = __DIR__."/../Config/";
|
||||
if (!is_readable($dir)) {
|
||||
|
||||
$ret[] = array(
|
||||
"ERRMES"=>Translator::getInstance()->trans(
|
||||
"Can't read Config directory",
|
||||
[],
|
||||
DHL::DOMAIN_NAME
|
||||
),
|
||||
"ERRFILE"=>""
|
||||
);
|
||||
}
|
||||
if (!is_writable($dir)) {
|
||||
$ret[] = array(
|
||||
"ERRMES"=>Translator::getInstance()->trans(
|
||||
"Can't write Config directory",
|
||||
[],
|
||||
DHL::DOMAIN_NAME
|
||||
),
|
||||
"ERRFILE"=>""
|
||||
);
|
||||
|
||||
}
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (strlen($file) > 5 && substr($file, -5) === ".json") {
|
||||
if (!is_readable($dir.$file)) {
|
||||
|
||||
$ret[] = array(
|
||||
"ERRMES"=>Translator::getInstance()->trans(
|
||||
"Can't read file",
|
||||
[],
|
||||
DHL::DOMAIN_NAME
|
||||
),
|
||||
"ERRFILE"=>"DHL/Config/".$file
|
||||
);
|
||||
}
|
||||
if (!is_writable($dir.$file)) {
|
||||
$ret[] = array(
|
||||
"ERRMES"=>Translator::getInstance()->trans(
|
||||
"Can't write file",
|
||||
[],
|
||||
DHL::DOMAIN_NAME
|
||||
),
|
||||
"ERRFILE"=>"DHL/Config/".$file
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $arr) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("ERRMES", $arr["ERRMES"])
|
||||
->set("ERRFILE", $arr["ERRFILE"]);
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
74
local/modules/DHL/Loop/NotSendLoop.php
Normal file
74
local/modules/DHL/Loop/NotSendLoop.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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 DHL\Loop;
|
||||
|
||||
use DHL\Model\DHLQuery;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
use Thelia\Core\Template\Loop\Order;
|
||||
|
||||
/**
|
||||
* Class NotSendLoop
|
||||
* @package DHL\Loop
|
||||
* @author Manuel Raynaud <manu@raynaud.io>
|
||||
*/
|
||||
class NotSendLoop extends Order
|
||||
{
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(Argument::createBooleanTypeArgument('with_prev_next_info', false));
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
return DHLQuery::getOrders();
|
||||
}
|
||||
}
|
||||
73
local/modules/DHL/Loop/Price.php
Normal file
73
local/modules/DHL/Loop/Price.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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 DHL\Loop;
|
||||
|
||||
use DHL\DHL;
|
||||
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;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
/**
|
||||
*
|
||||
* Price loop
|
||||
*
|
||||
*
|
||||
* Class Price
|
||||
* @package DHL\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Price extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
/* set countable to false since we need to preserve keys */
|
||||
protected $countable = false;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('area', null, true)
|
||||
);
|
||||
}
|
||||
|
||||
public function buildArray()
|
||||
{
|
||||
$area = $this->getArea();
|
||||
$prices = DHL::getPrices();
|
||||
|
||||
if (!isset($prices[$area]) || !isset($prices[$area]["slices"])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$areaPrices = $prices[$area]["slices"];
|
||||
ksort($areaPrices);
|
||||
|
||||
return $areaPrices;
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach ($loopResult->getResultDataCollection() as $maxWeight => $price) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow->set("MAX_WEIGHT", $maxWeight)
|
||||
->set("PRICE", $price);
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user