-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
2,784 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "oveleon/contao-recommendation-bundle", | ||
"type": "contao-bundle", | ||
"description": "Recommendation integration for Contao 4 Open Source CMS", | ||
"keywords": ["contao","recommendation-bundle"], | ||
"homepage": "https://www.oveleon.de/", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Oveleon", | ||
"homepage": "https://oveleon.de/", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php":"^5.6 || ^7.0", | ||
"contao/core-bundle":"^4.4" | ||
}, | ||
"require-dev": { | ||
"contao/manager-plugin": "^2.0" | ||
}, | ||
"conflict": { | ||
"contao/core": "*", | ||
"contao/manager-plugin": "<2.0 || >=3.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Oveleon\\ContaoRecommendationBundle\\": "src/" | ||
}, | ||
"classmap": [ | ||
"src/Resources/contao/" | ||
], | ||
"exclude-from-classmap": [ | ||
"src/Resources/contao/config/", | ||
"src/Resources/contao/dca/", | ||
"src/Resources/contao/languages/", | ||
"src/Resources/contao/templates/" | ||
] | ||
}, | ||
"extra": { | ||
"contao-manager-plugin": "Oveleon\\ContaoRecommendationBundle\\ContaoManager\\Plugin" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Oveleon Recommendation Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoRecommendationBundle\ContaoManager; | ||
|
||
use Contao\CoreBundle\ContaoCoreBundle; | ||
use Contao\ManagerPlugin\Bundle\BundlePluginInterface; | ||
use Contao\ManagerPlugin\Bundle\Config\BundleConfig; | ||
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; | ||
use Oveleon\ContaoRecommendationBundle\ContaoRecommendationBundle; | ||
|
||
/** | ||
* Plugin for the Contao Manager. | ||
* | ||
* @author Fabian Ekert <[email protected]> | ||
*/ | ||
class Plugin implements BundlePluginInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBundles(ParserInterface $parser) | ||
{ | ||
return [ | ||
BundleConfig::create(ContaoRecommendationBundle::class) | ||
->setLoadAfter([ContaoCoreBundle::class]) | ||
->setReplace(['recommendation']), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Oveleon Recommendation Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoRecommendationBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
/** | ||
* Configures the Contao recommendation bundle. | ||
* | ||
* @author Fabian Ekert <[email protected]> | ||
*/ | ||
class ContaoRecommendationBundle extends Bundle | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
// Back end modules | ||
array_insert($GLOBALS['BE_MOD']['content'], 5, array | ||
( | ||
'recommendation' => array | ||
( | ||
'tables' => array('tl_recommendation_archive', 'tl_recommendation') | ||
) | ||
)); | ||
|
||
// Front end modules | ||
array_insert($GLOBALS['FE_MOD'], 2, array | ||
( | ||
'recommendation' => array | ||
( | ||
'recommendationlist' => '\\Oveleon\\ContaoRecommendationBundle\\ModuleRecommendationList', | ||
'recommendationreader' => '\\Oveleon\\ContaoRecommendationBundle\\ModuleRecommendationReader', | ||
) | ||
)); | ||
|
||
// Models | ||
$GLOBALS['TL_MODELS']['tl_recommendation'] = '\\Oveleon\\ContaoRecommendationBundle\\RecommendationModel'; | ||
$GLOBALS['TL_MODELS']['tl_recommendation_archive'] = '\\Oveleon\\ContaoRecommendationBundle\\RecommendationArchiveModel'; | ||
|
||
// Add permissions | ||
$GLOBALS['TL_PERMISSIONS'][] = 'recommendations'; | ||
$GLOBALS['TL_PERMISSIONS'][] = 'recommendationp'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Oveleon Recommendation Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
// Add palettes to tl_module | ||
$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationlist'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives,numberOfItems,recommendation_featured,perPage,skipFirst;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; | ||
$GLOBALS['TL_DCA']['tl_module']['palettes']['recommendationreader'] = '{title_legend},name,headline,type;{config_legend},recommendation_archives;{template_legend:hide},recommendation_metaFields,recommendation_template,customTpl;{image_legend:hide},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; | ||
|
||
// Add fields to tl_module | ||
$GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_archives'] = array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_module']['recommendation_archives'], | ||
'exclude' => true, | ||
'inputType' => 'checkbox', | ||
'options_callback' => array('tl_module_recommendation', 'getRecommendationArchives'), | ||
'eval' => array('multiple'=>true, 'mandatory'=>true), | ||
'sql' => "blob NULL" | ||
); | ||
|
||
$GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_featured'] = array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_module']['recommendation_featured'], | ||
'default' => 'all_items', | ||
'exclude' => true, | ||
'inputType' => 'select', | ||
'options' => array('all_items', 'featured', 'unfeatured'), | ||
'reference' => &$GLOBALS['TL_LANG']['tl_module'], | ||
'eval' => array('tl_class'=>'w50'), | ||
'sql' => "varchar(16) NOT NULL default ''" | ||
); | ||
|
||
$GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_metaFields'] = array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_module']['recommendation_metaFields'], | ||
'default' => array('date', 'author'), | ||
'exclude' => true, | ||
'inputType' => 'checkbox', | ||
'options' => array('date', 'author', 'rating'), | ||
'reference' => &$GLOBALS['TL_LANG']['MSC'], | ||
'eval' => array('multiple'=>true), | ||
'sql' => "varchar(255) NOT NULL default ''" | ||
); | ||
|
||
$GLOBALS['TL_DCA']['tl_module']['fields']['recommendation_template'] = array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_module']['recommendation_template'], | ||
'default' => 'recommendation_latest', | ||
'exclude' => true, | ||
'inputType' => 'select', | ||
'options_callback' => array('tl_module_recommendation', 'getRecommendationTemplates'), | ||
'eval' => array('tl_class'=>'w50'), | ||
'sql' => "varchar(64) NOT NULL default ''" | ||
); | ||
|
||
|
||
/** | ||
* Provide miscellaneous methods that are used by the data configuration array. | ||
* | ||
* @author Fabian Ekert <[email protected]> | ||
*/ | ||
class tl_module_recommendation extends Backend | ||
{ | ||
|
||
/** | ||
* Import the back end user object | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->import('BackendUser', 'User'); | ||
} | ||
|
||
/** | ||
* Get all recommendation archives and return them as array | ||
* | ||
* @return array | ||
*/ | ||
public function getRecommendationArchives() | ||
{ | ||
if (!$this->User->isAdmin && !\is_array($this->User->recommendations)) | ||
{ | ||
return array(); | ||
} | ||
|
||
$arrArchives = array(); | ||
$objArchives = $this->Database->execute("SELECT id, title FROM tl_recommendation_archive ORDER BY title"); | ||
|
||
while ($objArchives->next()) | ||
{ | ||
if ($this->User->hasAccess($objArchives->id, 'recommendations')) | ||
{ | ||
$arrArchives[$objArchives->id] = $objArchives->title; | ||
} | ||
} | ||
|
||
return $arrArchives; | ||
} | ||
|
||
/** | ||
* Return all recommendation templates as array | ||
* | ||
* @return array | ||
*/ | ||
public function getRecommendationTemplates() | ||
{ | ||
return $this->getTemplateGroup('recommendation_'); | ||
} | ||
} |
Oops, something went wrong.