Skip to content

Commit

Permalink
add theme license description and buy button
Browse files Browse the repository at this point in the history
  • Loading branch information
MDevster committed Dec 6, 2017
1 parent ffd11b0 commit 2db405a
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 1 deletion.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"autoload": {
"psr-4": {
"Pdir\\ThemeHelperBundle\\": "src"
}
},
"classmap": [
"src/Resources/contao/"
]
},
"extra": {
"contao-manager-plugin": "Pdir\\ThemeHelperBundle\\ContaoManager\\Plugin"
Expand Down
87 changes: 87 additions & 0 deletions src/Resources/contao/dca/tl_theme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

/*
* Replace label function
*/
$GLOBALS['TL_DCA']['tl_theme']['list']['label']['label_callback'] = array('tl_theme_extended', 'addPreviewImageAndDesc');

/*
* add fields to pallet
*/
$GLOBALS['TL_DCA']['tl_theme']['palettes']['default'] = str_replace
(
',author',
',author,pdir_th_description,pdir_th_license_domain',
$GLOBALS['TL_DCA']['tl_theme']['palettes']['default']
);

/**
* Add fields to tl_theme
*/
$GLOBALS['TL_DCA']['tl_theme']['fields']['pdir_th_description'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_theme']['pdir_th_description'],
'exclude' => true,
'search' => false,
'sorting' => false,
'inputType' => 'textarea',
'eval' => array('readonly' => false),
'sql' => "mediumtext NULL"
);

$GLOBALS['TL_DCA']['tl_theme']['fields']['pdir_th_license_domain'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_theme']['pdir_th_license_domain'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('tl_class' => 'w50', 'maxlength'=> 128),
'sql' => "varchar(128) NOT NULL default ''"
);

class tl_theme_extended extends tl_theme
{
/**
* Add an image and a description to each record
*
* @param array $row
* @param string $label
*
* @return string
*/
public function addPreviewImageAndDesc($row, $label)
{
// add buy action if needed
if ($row['pdir_th_description'] != '')
{
$label = '<span><img src="bundles/system/modules/theme_installer/assets/img/buy_theme.png" title="' . $GLOBALS['TL_LANG']['tl_theme']['buyTheme'] . '"' .
' onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':768,\'title\':\'' . $GLOBALS['TL_LANG']['MSC']['buyThemeButtonTitle'] . '\',\'url\':\'https://contao-themes.net/buy-mate.html\',\'id\':\'buyTheme\'});return false"' .
' style="position:absolute;margin:10px 0;"></span>' . $label;
}

// add image
$label = $this->addPreviewImage($row, $label);

// add theme and license description
if ($row['pdir_th_description'] != '')
{
// add info icon
$html = '<i class="icon" onmouseover="document.getElementById(\'themeDesc\').style.display = \'block\'"'.
' onmouseout="document.getElementById(\'themeDesc\').style.display = \'none\'"'.
' style="color:#fff;border-radius:50%;font-weight:bold;padding:3px;border:1px solid #649d9a;background:#649d9a;margin-left:5px;">i</i>';

// license status
if($row['pdir_th_license_domain'] != '')
$html .= $GLOBALS['TL_LANG']['tl_theme']['pdir_th_payed_license_text'] . $row['pdir_th_license_domain'] .'<br>';
else
$html .= $GLOBALS['TL_LANG']['tl_theme']['pdir_th_license_text'] . '<br>';

// desc
$html .= '<div id="themeDesc" style="display:none;">';
$html .= \StringUtil::decodeEntities($row['pdir_th_description']);
$html .= '</div>';
$label = $label . $html;
}

return $label;
}
}
15 changes: 15 additions & 0 deletions src/Resources/contao/language/de/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

// theme helper tags
$GLOBALS['TL_LANG']['tl_article']['pdir_th_tag'] = array('Theme Helper Tag', 'Bitte wählen Sie einen Theme Helper Tag um den Inhalt dieses Artikels als Insert Tag zu nutzen.');

// theme desc & license
$GLOBALS['TL_LANG']['tl_theme']['pdir_th_description'] = array('Beschreibung', 'Die Theme Beschreibung wird durch die Theme Einstellungen vorgegeben.');
$GLOBALS['TL_LANG']['tl_theme']['pdir_th_license_domain'] = array('Theme lizensiert für', 'Dieser Theme wurde für diese Domain kostenpflichtig lizensiert.');
$GLOBALS['TL_LANG']['tl_theme']['pdir_th_license_text'] = ' // Copyright-Link darf nicht entfernt werden.';
$GLOBALS['TL_LANG']['tl_theme']['pdir_th_payed_license_text'] = ' // kostenpflichtig registriert für ';

$GLOBALS['TL_LANG']['tl_theme']['buyTheme'] = 'Kostenpflichtige Lizenz kaufen.';
$GLOBALS['TL_LANG']['MSC']['buyThemeConfirm'] = 'Möchten Sie für diesen Theme eine kostenplichtige Lizenz erwerben?';
$GLOBALS['TL_LANG']['MSC']['buyThemeButtonTitle'] = 'Theme Lizenz kaufen';

14 changes: 14 additions & 0 deletions src/Resources/contao/language/en/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

// theme helper tags
$GLOBALS['TL_LANG']['tl_article']['pdir_th_tag'] = array('Theme Helper Tag', 'Please select a theme helper tag to use content of this article as insert tag.');

// theme desc & license
$GLOBALS['TL_LANG']['tl_theme']['pdir_th_description'] = array('Theme description', 'The theme description is provided by theme config.');
$GLOBALS['TL_LANG']['tl_theme']['pdir_th_license_domain'] = array('Theme license for', 'This theme has a paid license for this domain.');
$GLOBALS['TL_LANG']['tl_theme']['pdir_th_license_text'] = ' // leave copyright license';
$GLOBALS['TL_LANG']['tl_theme']['pdir_th_payed_license_text'] = ' // paid license for ';

$GLOBALS['TL_LANG']['tl_theme']['buyTheme'] = 'Buy paid license.';
$GLOBALS['TL_LANG']['MSC']['buyThemeConfirm'] = 'Do you want to buy a paid license for this theme?';
$GLOBALS['TL_LANG']['MSC']['buyThemeButtonTitle'] = 'Buy theme license';
Binary file added src/Resources/public/img/buy_theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2db405a

Please sign in to comment.