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 Jan 7, 2021
1 parent cbd47f8 commit 54225ea
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 37 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type":"contao-bundle",
"homepage":"https://www.leycom.de/",
"license":"MIT",
"version":"1.0",
"require":{
"php":">=5.5",
"contao/core-bundle":"^4.3"
Expand Down
77 changes: 68 additions & 9 deletions src/FrontendHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function outputFrontendTemplateHook($content, $template)

$GLOBALS['TL_JAVASCRIPT'][] = $assetsDir . '/js/main.js';
$GLOBALS['TL_JAVASCRIPT'][] = $assetsDir . '/js/functions.js';
$GLOBALS['TL_CSS'][] = $assetsDir . '/css/main.css';
$GLOBALS['TL_CSS'][] = $assetsDir . '/css/main.min.css';

return static::insertData($content, $data);
}
Expand Down Expand Up @@ -277,6 +277,11 @@ protected static function getBackendURL($do, $table, $id, $act = 'edit', array $
* @param string $kk
* @return string
*/

// if (class_exists(\leycommediasolutions\contao_elementsets\ElementSets::class)) {
// }


public function createSelect($frontenddata, $frontendElement,$v){
foreach (array_keys($v) as $kk)
{
Expand Down Expand Up @@ -348,7 +353,7 @@ public function createSelect($frontenddata, $frontendElement,$v){


$output .=
'<div class="fbly_select_item draggable_item tooltip" data-value='.$kk.' draggable="true" ondragstart="event.dataTransfer.setData(\'text/plain\',null)" '.$tooltip.'>
'<div class="fbly_select_item draggable_item tooltip" data-value="'.$kk.'" draggable="true" ondragstart="event.dataTransfer.setData(\'text/plain\',null)" '.$tooltip.'>
<div class="headline matchHeight"><span>'.$headline.'</span></div>
<figure class="image_container"><img src="'.$icon.'" alt="'.$alt.'" draggable="false"></figure>
</div>'; // <div class="description" class="tooltip" title="This is my images tooltip message!">'.$description.'</div>
Expand All @@ -367,7 +372,6 @@ public function createDataSidebar(){
return "";
}


//FEHLER
\System::loadLanguageFile('default');
\System::loadLanguageFile('CTE');
Expand All @@ -389,6 +393,11 @@ public function createDataSidebar(){
$frontenddata[$frontendtext->item] = $frontendtext->row();
}






foreach ($GLOBALS['TL_CTE'] as $k=>$v)
{
if(array_keys($v)){
Expand All @@ -399,12 +408,62 @@ public function createDataSidebar(){
$label_group = $k;
}

if($content_select = FrontendHooks::createSelect($frontenddata, $frontendElement,$v)){
$output .= '<div class="fbly_select_itemHolder fbly_select_close_'. preg_replace('/\s/', '_', $k) .'"><h3><span>'. $label_group .'</span></h3>';
$output .= '<div class="inside_fbly_select_itemHolder">';
$output .= $content_select;
$output .= '</div>';
$output .= '</div>';
$pre = array('/\s/', '/\//', '/\*/', '/\+/', '/\#/', '/\~/', '/\"/', '/\§/', '/\$/', '/\!/', '/\%/', '/\&/', '/\(/', '/\)/', '/\=/', '/\?/', '/\´/', '/\{/', '/\[/', '/\]/', '/\}/', '/\>/', '/\</', '/\|/', '/\:/', '/\./', '/\,/', '/\;/');

if(class_exists(\leycommediasolutions\contao_elementsets\ElementSets::class) && $k == 'elementset' ){
if($content_select = FrontendHooks::createSelect($frontenddata, $frontendElement,$v)){
$output .= '<div class="fbly_select_itemHolder fbly_select_close_'. preg_replace($pre, '_', $k) .'"><h3><span>'. $label_group .'</span></h3>';
$output .= '<div class="inside_fbly_select_itemHolder">';
$output .= $content_select;
$output .= '</div>';

$database = \Database::getInstance();

$elementsets = $database->prepare("SELECT * FROM tl_elementsets")->execute();

if($elementsets->numRows > 0){
while($elementsets->next())
{
$array_elementset[$elementsets->category][] = $elementsets->row();
}
}

foreach ($array_elementset as $name => $attr ){
$output .= '<div class="fbly_select_itemHolder fbly_select_close_'. preg_replace($pre, '_', $k) .'_'.preg_replace($pre, '_',strtolower($name)) . '"><h3><span>'. $name .'</span></h3>';
$output .= '<div class="inside_fbly_select_itemHolder">';
foreach($attr as $attr_detail){
$icon = \FilesModel::findByUuid($attr_detail["preview_image"])->path;
$output .=
'<div class="fbly_select_item draggable_item" data-value="elementset" data-elementset="'.$attr_detail["id"].'" draggable="true" ondragstart="event.dataTransfer.setData(\'text/plain\',null)">
<div class="headline matchHeight"><span>'.$attr_detail["title"].'</span></div>
<figure class="image_container"><img src="'.$icon.'" alt="'.$attr_detail["title"].'" draggable="false"></figure>
</div>';
}
$output .= '</div>';
$output .= '</div>';
}
$output .= '</div>';
}
}

if(class_exists(\leycommediasolutions\contao_elementsets\ElementSets::class) && $k != 'elementset'){
if($content_select = FrontendHooks::createSelect($frontenddata, $frontendElement,$v)){
$output .= '<div class="fbly_select_itemHolder fbly_select_close_'. preg_replace($pre, '_', $k) .'"><h3><span>'. $label_group .'</span></h3>';
$output .= '<div class="inside_fbly_select_itemHolder">';
$output .= $content_select;
$output .= '</div>';
$output .= '</div>';
}
}

if(!class_exists(\leycommediasolutions\contao_elementsets\ElementSets::class)){
if($content_select = FrontendHooks::createSelect($frontenddata, $frontendElement,$v)){
$output .= '<div class="fbly_select_itemHolder fbly_select_close_'. preg_replace('/\s/', '_', $k) .'"><h3><span>'. $label_group .'</span></h3>';
$output .= '<div class="inside_fbly_select_itemHolder">';
$output .= $content_select;
$output .= '</div>';
$output .= '</div>';
}
}
}
}
Expand Down
28 changes: 26 additions & 2 deletions src/Resources/contao/dca/tl_frontendbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
),
'label' => array
(
'fields' => array('headline'),
'format' => '%s',
'fields' => array('icon', 'headline', 'item', 'description'),
'showColumns' => true,
'label_callback' => array('tl_frontendbuilder', 'addIcon')
),
'global_operations' => array
(
Expand Down Expand Up @@ -168,4 +169,27 @@ public function getItem(DataContainer $dc)
}
return $groups;
}
/**
* Add an image to each record
*
* @param array $row
* @param string $label
* @param DataContainer $dc
* @param array $args
*
* @return array
*/
public function addIcon($row, $label, DataContainer $dc, $args)
{
if ($args[0] != '')
{
$objFile = FilesModel::findByUuid($args[0]);

if ($objFile !== null)
{
$args[0] = Image::getHtml(\System::getContainer()->get('contao.image.image_factory')->create(TL_ROOT . '/' . $objFile->path, array(100, 75, 'center_top'))->getUrl(TL_ROOT), '', 'class="theme_preview titel_elementsets"');
}
}
return $args;
}
}
Loading

0 comments on commit 54225ea

Please sign in to comment.