-
Notifications
You must be signed in to change notification settings - Fork 6
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
Martin
committed
Aug 24, 2015
1 parent
57f216f
commit 281afc3
Showing
15 changed files
with
192 additions
and
10 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mae_event_categories Changelog | ||
============================== | ||
|
||
Version 1.1.0 (2015-08-25) added filter module | ||
Version 1.0.3 (2015-06-02) hotfix model / namespace | ||
Version 1.0.1 (2015-06-01) added model class | ||
Version 1.0.0 stable (2015-04-08) Initial release. |
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
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
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 |
---|---|---|
@@ -1,10 +1,17 @@ | ||
<?php | ||
ClassLoader::addNamespace(array('MaeEventCategories')); | ||
ClassLoader::addNamespace('MaeEventCategories'); | ||
|
||
ClassLoader::addClasses(array | ||
( | ||
'MaeEventCategories\MaeEvent' => 'system/modules/mae_event_categories/classes/MaeEvent.php', | ||
'MaeEventCategories\MaeEventCatModel' => 'system/modules/mae_event_categories/models/MaeEventCatModel.php', | ||
'MaeEventCategories\ModuleFilter' => 'system/modules/mae_event_categories/modules/ModuleFilter.php' | ||
)); | ||
|
||
// Models | ||
'MaeEventCategories\MaeEventCatModel' => 'system/modules/mae_event_categories/models/MaeEventCatModel.php' | ||
/** | ||
* Register the templates | ||
*/ | ||
TemplateLoader::addFiles(array | ||
( | ||
'mod_mae_event_filter' => 'system/modules/mae_event_categories/templates/modules' | ||
)); |
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
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
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
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
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<?php | ||
$GLOBALS['TL_LANG']['tl_module']['event_categories'] = array('Eventkategorien', 'Eine oder mehrere Kategorien auswählen, die in der Liste angezeigt werden sollen, ansonsten werden alle angezeigt.'); | ||
$GLOBALS['TL_LANG']['tl_module']['event_cat_legend'] = 'Eventkategorien'; | ||
$GLOBALS['TL_LANG']['tl_module']['event_cat_legend'] = 'Eventkategorien'; | ||
$GLOBALS['TL_LANG']['tl_module']['mae_event_list'] = array('Eventliste', 'Das Eventlistenmodul, das gefiltert werden soll'); | ||
$GLOBALS['TL_LANG']['tl_module']['mae_setup_legend'] = 'Einstellungen'; |
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
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<?php | ||
$GLOBALS['TL_LANG']['tl_module']['event_categories'] = array('Event categories', 'Select one or more categories to be displayed in the list.'); | ||
$GLOBALS['TL_LANG']['tl_module']['event_cat_legend'] = 'Event categories'; | ||
$GLOBALS['TL_LANG']['tl_module']['event_cat_legend'] = 'Event categories'; | ||
$GLOBALS['TL_LANG']['tl_module']['mae_event_list'] = array('Event list', 'The event list module which has to be filtered'); | ||
$GLOBALS['TL_LANG']['tl_module']['mae_setup_legend'] = 'Setup'; |
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,85 @@ | ||
<?php | ||
|
||
namespace MaeEventCategories; | ||
use Contao\Database; | ||
use Contao\Input; | ||
|
||
|
||
class ModuleFilter extends \Module | ||
{ | ||
/** | ||
* Template | ||
* @var string | ||
*/ | ||
protected $strTemplate = 'mod_mae_event_filter'; | ||
|
||
public function generate() | ||
{ | ||
if (TL_MODE == 'BE') { | ||
$objTemplate = new \BackendTemplate('be_wildcard'); | ||
$objTemplate->wildcard = '### MODULE EVENT FILTER ###'; | ||
$objTemplate->title = $this->headline; | ||
$objTemplate->id = $this->id; | ||
$objTemplate->link = $this->name; | ||
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; | ||
|
||
return $objTemplate->parse(); | ||
} | ||
|
||
return parent::generate(); | ||
} | ||
|
||
/** | ||
* Compile the current element | ||
*/ | ||
protected function compile() | ||
{ | ||
$allowAllCats = false; | ||
$selectedCat = Input::get('category'); | ||
$this->Template->selectedCategory = empty($selectedCat) ? "all" : $selectedCat; | ||
$this->Template->showAllHref = $this->addToUrl('category=all'); | ||
|
||
$items = array(); | ||
$filterCats = empty($this->event_categories) ? array() : unserialize($this->event_categories); | ||
if(count($filterCats) == 0) { | ||
if($this->mae_event_list > 0) { | ||
// take category list from event list, if configured | ||
$objListCats = $this->Database->prepare("SELECT event_categories FROM tl_module WHERE id=?")->execute($this->mae_event_list); | ||
if($objListCats->numRows == 1) { | ||
$listCats = $objListCats->event_categories; | ||
if(!empty($listCats)) { | ||
$filterCats = unserialize($listCats); | ||
} | ||
} | ||
} | ||
if(count($filterCats) == 0) { | ||
// take all categories, because there are no categories defined neither in filter, nore in event list | ||
$allowAllCats = true; | ||
} | ||
} | ||
|
||
if(count($filterCats) > 0 || $allowAllCats) { | ||
if($allowAllCats) { | ||
$sqlSort = "SELECT * FROM tl_mae_event_cat ORDER BY title"; | ||
} | ||
else { | ||
$sqlSort = "SELECT * FROM tl_mae_event_cat WHERE id IN (" . implode(",", $filterCats) . ") ORDER BY title"; | ||
} | ||
$objCats = $this->Database->execute($sqlSort); | ||
while ($item = $objCats->fetchAssoc()) { | ||
if($selectedCat == $item['id']) { | ||
$item['cssClass'] = $item['cssClass'] . " active"; | ||
} | ||
if(!empty($item['cssClass'])) { | ||
$item['cssClass'] = " " . trim($item['cssClass']); | ||
} | ||
if(empty($item['cssId'])) { | ||
$item['cssId'] = "mae_cat_" . $item['id']; | ||
} | ||
$item['href'] = $this->addToUrl('category=' . $item['id']); | ||
$items[] = $item; | ||
} | ||
} // if have categories | ||
$this->Template->items = $items; | ||
} | ||
} |
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,13 @@ | ||
<div class="mod_mae_event_filter block"> | ||
<?php if(!empty($this->headline)) {echo "<" . $this->hl . ">" . $this->headline . "</" . $this->hl . ">";} ?> | ||
<ul> | ||
<li class="category all<?php echo ($this->selectedCategory == "all" ? " active" : ""); ?>"> | ||
<a href="<?php echo $this->showAllHref; ?>" title="{{label::tl_mae_event_cat:all:1}}">{{label::tl_mae_event_cat:all:0}}</a> | ||
</li> | ||
<?php foreach ($this->items as $item) { ?> | ||
<li id="<?php echo $item['cssId']; ?>" class="category<?php echo $item['cssClass']; ?>"> | ||
<a href="<?php echo $item['href']; ?>" title="<?php echo $item['title']; ?>"><?php echo $item['title']; ?></a> | ||
</li> | ||
<?php } // each $item ?> | ||
</ul> | ||
</div> |