Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
leycommediasolutions authored Oct 2, 2019
1 parent 6ad14a7 commit fffea7b
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 35 deletions.
59 changes: 57 additions & 2 deletions src/Resources/contao/classes/Element_End.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,37 @@ class Element_End extends \ContentElement
* Template
* @var string
*/
protected $strTemplate = 'ce_elementset_end';
protected $strTemplate = 'ce_elementset_end';

public function generate()
{
$resultelementset_id = $this->Database->prepare("SELECT elementset_id FROM tl_content WHERE id=? ")
->limit(1)
->execute($this->id);

if($resultelementset_id->numRows > 0){
foreach($resultelementset_id->row() as $k=>$v)
{
$resultelementset_id_new = $this->Database->prepare("SELECT customTplEnde FROM tl_elementsets WHERE id=? AND addWrapper=1")
->limit(1)
->execute($v);

if($resultelementset_id_new->numRows > 0){

$result_array = $resultelementset_id_new->row();
if($result_array["customTplEnde"]){
$this->strTemplate = $result_array["customTplEnde"];
if($this->customTpl){
$this->strTemplate = $this->customTpl;
}
}
}
}
}
return parent::generate();
}


/**
* Compile the content element
*/
Expand Down Expand Up @@ -38,7 +68,32 @@ private function genBeOutput()
*/
private function genFeOutput()
{
$this->Template;
$this->Template->elementset_class = "ce_elementset";
$this->Template->addWrapper = "";

$resultelementset_id = $this->Database->prepare("SELECT elementset_id FROM tl_content WHERE id=? ")
->limit(1)
->execute($this->id);

if($resultelementset_id->numRows > 0){
foreach($resultelementset_id->row() as $k=>$v)
{
$resultelementset_id_new = $this->Database->prepare("SELECT elementset_class, addWrapper FROM tl_elementsets WHERE id=? ")
->limit(1)
->execute($v);

if($resultelementset_id_new->numRows > 0){

$result_array = $resultelementset_id_new->row();
if($result_array["elementset_class"] && $result_array["addWrapper"]){
$this->Template->elementset_class = 'ce_elementset '. $result_array["elementset_class"];
}
if($result_array["addWrapper"]){
$this->Template->addWrapper = $result_array["addWrapper"];
}
}
}
}
}
}
class_alias(Element_End::class, 'Element_End');
79 changes: 52 additions & 27 deletions src/Resources/contao/classes/Element_Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@
namespace leycommediasolutions\contao_elementsets\Resources\contao\classes;
class Element_Start extends \ContentElement
{
/**
* Template
* @var string
*/
protected $strTemplate = 'ce_elementset_start';
/**
* Compile the content element
*/
protected $strTemplate = "ce_elementset_start";

public function generate()
{
$resultelementset_id = $this->Database->prepare("SELECT elementset_id FROM tl_content WHERE id=? ")
->limit(1)
->execute($this->id);

if($resultelementset_id->numRows > 0){
foreach($resultelementset_id->row() as $k=>$v)
{
$resultelementset_id_new = $this->Database->prepare("SELECT customTplStart FROM tl_elementsets WHERE id=? AND addWrapper=1")
->limit(1)
->execute($v);

if($resultelementset_id_new->numRows > 0){

$result_array = $resultelementset_id_new->row();
if($result_array["customTplStart"]){
$this->strTemplate = $result_array["customTplStart"];
if($this->customTpl){
$this->strTemplate = $this->customTpl;
}
}
}
}
}
return parent::generate();
}

protected function compile()
{
if (TL_MODE == 'BE') {
Expand All @@ -18,9 +40,6 @@ protected function compile()
$this->genFeOutput();
}
}
/**
* @return string
*/
private function genBeOutput()
{
$resultelementset_id = $this->Database->prepare("SELECT elementset_id FROM tl_content WHERE id=? ")
Expand All @@ -33,28 +52,34 @@ private function genBeOutput()
$this->Template->wildcard = "### ". $GLOBALS['TL_LANG']['FFL']['elementset_start'][0] . $v. " ###";
}
}
/**
* @return string
*/
private function genFeOutput()
{
$this->Template->elementset_class = "ce_elementset";
$this->Template->addWrapper = "";

$resultelementset_id = $this->Database->prepare("SELECT elementset_id FROM tl_content WHERE id=? ")
->execute($this->id);
foreach($resultelementset_id->row() as $k=>$v)
{
$resultelementset_id_new = $this->Database->prepare("SELECT elementset_class FROM tl_elementsets WHERE id=? ")
->execute($v);
foreach($resultelementset_id_new->row() as $kk=>$vv)
->limit(1)
->execute($this->id);

if($resultelementset_id->numRows > 0){
foreach($resultelementset_id->row() as $k=>$v)
{
if ($v != '') {
$this->Template->elementset_class = 'ce_elementset '. $vv;
}
else
{
$this->Template->elementset_class = 'ce_elementset';
$resultelementset_id_new = $this->Database->prepare("SELECT elementset_class, addWrapper FROM tl_elementsets WHERE id=? ")
->limit(1)
->execute($v);

if($resultelementset_id_new->numRows > 0){

$result_array = $resultelementset_id_new->row();
if($result_array["elementset_class"] && $result_array["addWrapper"]){
$this->Template->elementset_class = 'ce_elementset '. $result_array["elementset_class"];
}
if($result_array["addWrapper"]){
$this->Template->addWrapper = $result_array["addWrapper"];
}
}
}
}
}
}
}
class_alias(Element_Start::class, 'Element_Start');
40 changes: 37 additions & 3 deletions src/Resources/contao/dca/tl_elementsets.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,15 @@
// Palettes
'palettes' => array
(
'default' => '{title_legend},title,preview_image,elementset_class,category'
'__selector__' => array('addWrapper'),
'default' => '{title_legend},title,category,preview_image,addWrapper',
),

// Subpalettes
'subpalettes' => array
(
'addWrapper' => 'elementset_class,customTplStart,customTplEnde',
),

// Fields
'fields' => array
Expand Down Expand Up @@ -165,6 +172,35 @@
),
'sql' => "text NULL"
),
'addWrapper' => array
(
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('submitOnChange'=>true),
'sql' => "char(1) NOT NULL default '1'"
),
'customTplStart' => array
(
'exclude' => true,
'inputType' => 'select',
'options_callback' => static function (\Contao\DataContainer $dc)
{
return \Contao\Controller::getTemplateGroup('ce_elementset_start_');
},
'eval' => array('includeBlankOption'=>true, 'chosen'=>true, 'tl_class'=>'w50 clr'),
'sql' => "varchar(64) NOT NULL default ''"
),
'customTplEnde' => array
(
'exclude' => true,
'inputType' => 'select',
'options_callback' => static function (\Contao\DataContainer $dc)
{
return \Contao\Controller::getTemplateGroup('ce_elementset_end_');
},
'eval' => array('includeBlankOption'=>true, 'chosen'=>true, 'tl_class'=>'w50'),
'sql' => "varchar(64) NOT NULL default ''"
),
)
);
class tl_elementsets extends Backend
Expand All @@ -177,8 +213,6 @@ public function __construct()
{
parent::__construct();
$this->import('BackendUser', 'User');
/* $set = array('pid' => '13', 'ptable' => 'tl_elementsets');
$objInsert = $this->Database->prepare("INSERT INTO tl_content %s")->set($set)->execute();*/
}

/**
Expand Down
18 changes: 18 additions & 0 deletions src/Resources/contao/languages/de/tl_elementsets.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@
<trans-unit id="tl_elementsets.newcategory.1">
<source>Erstellen Sie eine Kategorie.</source>
</trans-unit>
<trans-unit id="tl_elementsets.addWrapper.0">
<source>Wrapper einfügen</source>
</trans-unit>
<trans-unit id="tl_elementsets.addWrapper.1">
<source>Hier können Sie auswählen ob ein Wrapper eingefügt werden soll.</source>
</trans-unit>
<trans-unit id="tl_elementsets.customTplStart.0">
<source>Individuelles Template (Start)</source>
</trans-unit>
<trans-unit id="tl_elementsets.customTplStart.1">
<source>Hier können Sie das Standard-Template für den Wrapper überschreiben.</source>
</trans-unit>
<trans-unit id="tl_elementsets.customTplEnde.0">
<source>Individuelles Template (Ende)</source>
</trans-unit>
<trans-unit id="tl_elementsets.customTplEnde.1">
<source>Hier können Sie das Standard-Template für den Wrapper überschreiben.</source>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

</div>
<?php if($this->addWrapper): ?>
</div>
<?php endif;?>
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<div <?php echo $this->cssID ?> class="<?php echo $this->class;?> <?php echo $this->elementset_class;?>">
<?php if($this->addWrapper): ?>
<div <?php echo $this->cssID ?> class="<?php echo $this->class;?> <?php echo $this->elementset_class;?>">
<?php endif;?>

0 comments on commit fffea7b

Please sign in to comment.