-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- set minimum version to Contao 4.13 - added support for contao/faq-bundle
- Loading branch information
Showing
13 changed files
with
319 additions
and
381 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
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 |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
/** | ||
* Contao Open Source CMS | ||
* | ||
* Copyright (c) 2005-2022 Leo Feyer | ||
* Copyright (c) 2005-2023 Leo Feyer | ||
* | ||
* @package Opengraph3 | ||
* @author Benny Born <[email protected]> | ||
* @author Michael Bösherz <[email protected]> | ||
* @license LGPL | ||
* @copyright 2022 numero2 - Agentur für digitales Marketing GbR | ||
* @copyright 2023 numero2 - Agentur für digitales Marketing GbR | ||
*/ | ||
|
||
|
||
|
@@ -34,12 +34,10 @@ public static function addModuleData( $objModule ): void { | |
$event = CalendarEventsModel::findPublishedByParentAndIdOrAlias((Input::get('auto_item') ?? ''), $calendars); | ||
|
||
// Check if the calendar event could get loaded from the database | ||
if (null === $event) { | ||
return; | ||
} | ||
|
||
OpenGraph3::addProperty('og_type', 'website', $event); | ||
if( null !== $event ) { | ||
|
||
OpenGraph3::addTagsToPage($event); | ||
OpenGraph3::addProperty('og_type', 'website', $event); | ||
OpenGraph3::addTagsToPage($event); | ||
} | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
|
||
/** | ||
* Contao Open Source CMS | ||
* | ||
* Copyright (c) 2005-2023 Leo Feyer | ||
* | ||
* @package Opengraph3 | ||
* @author Benny Born <[email protected]> | ||
* @author Michael Bösherz <[email protected]> | ||
* @license LGPL | ||
* @copyright 2023 numero2 - Agentur für digitales Marketing GbR | ||
*/ | ||
|
||
|
||
namespace numero2\OpenGraph3; | ||
|
||
use Contao\Config; | ||
use Contao\FaqModel; | ||
use Contao\Input; | ||
use Contao\StringUtil; | ||
use DateTime; | ||
|
||
|
||
class OpenGraphFaq { | ||
|
||
|
||
/** | ||
* Appends OpenGraph data from FAQ articles | ||
* | ||
* @param $objModule | ||
*/ | ||
public static function addModuleData( $objModule ): void { | ||
|
||
$faqCategories = []; | ||
$faqCategories = StringUtil::deserialize($objModule->faq_categories); | ||
|
||
$objArticle = null; | ||
$objArticle = FaqModel::findPublishedByParentAndIdOrAlias((Input::get('auto_item') ?? ''), $faqCategories); | ||
|
||
if( null !== $objArticle ) { | ||
|
||
OpenGraph3::addProperty('og_type','article',$objArticle); | ||
|
||
// add modified time | ||
if( $objArticle->tstamp ) { | ||
|
||
$date = new DateTime(); | ||
$date->setTimestamp($objArticle->tstamp); | ||
$date = $date->format(Config::get('datimFormat')); | ||
|
||
OpenGraph3::addProperty('og_article_modified_time',$date,$objArticle); | ||
} | ||
|
||
OpenGraph3::addTagsToPage( $objArticle ); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
/** | ||
* Contao Open Source CMS | ||
* | ||
* Copyright (c) 2005-2021 Leo Feyer | ||
* Copyright (c) 2005-2023 Leo Feyer | ||
* | ||
* @package Opengraph3 | ||
* @author Benny Born <[email protected]> | ||
* @author Michael Bösherz <[email protected]> | ||
* @license LGPL | ||
* @copyright 2021 numero2 - Agentur für digitales Marketing GbR | ||
* @copyright 2023 numero2 - Agentur für digitales Marketing GbR | ||
*/ | ||
|
||
|
||
|
@@ -34,7 +34,7 @@ class OpenGraphIsotope { | |
*/ | ||
public static function addModuleData( $objModule ): void { | ||
|
||
$objProduct = NULL; | ||
$objProduct = null; | ||
$objProduct = Product::findAvailableByIdOrAlias( (Input::get('auto_item') ?? '') ); | ||
|
||
if( null !== $objProduct ) { | ||
|
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 |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
/** | ||
* Contao Open Source CMS | ||
* | ||
* Copyright (c) 2005-2022 Leo Feyer | ||
* Copyright (c) 2005-2023 Leo Feyer | ||
* | ||
* @package Opengraph3 | ||
* @author Benny Born <[email protected]> | ||
* @author Michael Bösherz <[email protected]> | ||
* @license LGPL | ||
* @copyright 2022 numero2 - Agentur für digitales Marketing GbR | ||
* @copyright 2023 numero2 - Agentur für digitales Marketing GbR | ||
*/ | ||
|
||
|
||
|
@@ -19,6 +19,7 @@ | |
use Contao\Input; | ||
use Contao\NewsModel; | ||
use Contao\StringUtil; | ||
use DateTime; | ||
|
||
|
||
class OpenGraphNews { | ||
|
@@ -34,7 +35,7 @@ public static function addModuleData( $objModule ): void { | |
$newsArchives = []; | ||
$newsArchives = StringUtil::deserialize($objModule->news_archives); | ||
|
||
$objArticle = NULL; | ||
$objArticle = null; | ||
$objArticle = NewsModel::findPublishedByParentAndIdOrAlias((Input::get('auto_item') ?? ''), $newsArchives); | ||
|
||
if( null !== $objArticle ) { | ||
|
@@ -44,7 +45,7 @@ public static function addModuleData( $objModule ): void { | |
// add published time | ||
if( $objArticle->time ) { | ||
|
||
$date = new \DateTime(); | ||
$date = new DateTime(); | ||
$date->setTimestamp($objArticle->time); | ||
$date = $date->format(Config::get('datimFormat')); | ||
|
||
|
@@ -54,7 +55,7 @@ public static function addModuleData( $objModule ): void { | |
// add modified time | ||
if( $objArticle->tstamp ) { | ||
|
||
$date = new \DateTime(); | ||
$date = new DateTime(); | ||
$date->setTimestamp($objArticle->tstamp); | ||
$date = $date->format(Config::get('datimFormat')); | ||
|
||
|
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 |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
/** | ||
* Contao Open Source CMS | ||
* | ||
* Copyright (c) 2005-2021 Leo Feyer | ||
* Copyright (c) 2005-2023 Leo Feyer | ||
* | ||
* @package Opengraph3 | ||
* @author Benny Born <[email protected]> | ||
* @author Michael Bösherz <[email protected]> | ||
* @license LGPL | ||
* @copyright 2021 numero2 - Agentur für digitales Marketing GbR | ||
* @copyright 2023 numero2 - Agentur für digitales Marketing GbR | ||
*/ | ||
|
||
|
||
|
@@ -29,10 +29,10 @@ class OpenGraphStoreLocator { | |
*/ | ||
public static function addModuleData( $objModule ): void { | ||
|
||
$alias = NULL; | ||
$alias = null; | ||
$alias = Input::get('auto_item') ? Input::get('auto_item') : Input::get('store'); | ||
|
||
$objStore = NULL; | ||
$objStore = null; | ||
$objStore = StoresModel::findByIdOrAlias( ($alias ?? '') ); | ||
|
||
if( null !== $objStore ) { | ||
|
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* Contao Open Source CMS | ||
* | ||
* Copyright (c) 2005-2023 Leo Feyer | ||
* | ||
* @package Opengraph3 | ||
* @author Benny Born <[email protected]> | ||
* @author Michael Bösherz <[email protected]> | ||
* @license LGPL | ||
* @copyright 2023 numero2 - Agentur für digitales Marketing GbR | ||
*/ | ||
|
||
use Contao\Controller; | ||
use Contao\System; | ||
|
||
|
||
if( !empty($GLOBALS['TL_DCA']['tl_faq']) ) { | ||
|
||
System::loadLanguageFile('opengraph_fields'); | ||
Controller::loadDataContainer('opengraph_fields'); | ||
|
||
/** | ||
* Modify palettes | ||
*/ | ||
$GLOBALS['TL_DCA']['tl_faq']['palettes']['default'] = str_replace( | ||
'{answer_legend' | ||
, $GLOBALS['TL_DCA']['opengraph_fields']['palettes']['default'].'{answer_legend' | ||
, $GLOBALS['TL_DCA']['tl_faq']['palettes']['default'] | ||
); | ||
|
||
/** | ||
* Modify fields | ||
*/ | ||
$GLOBALS['TL_DCA']['tl_faq']['fields'] = array_merge( | ||
$GLOBALS['TL_DCA']['tl_faq']['fields'] | ||
, $GLOBALS['TL_DCA']['opengraph_fields']['fields'] | ||
); | ||
|
||
/** | ||
* Add legends | ||
*/ | ||
array_walk( | ||
$GLOBALS['TL_LANG']['opengraph_fields']['legends'] | ||
, function( $translation, $key ) { | ||
$GLOBALS['TL_LANG']['tl_faq'][$key] = $translation; | ||
} | ||
); | ||
} |
Oops, something went wrong.