diff --git a/src/Resources/contao/dca/tl_module.php b/src/Resources/contao/dca/tl_module.php
index aab54c3..917ece8 100755
--- a/src/Resources/contao/dca/tl_module.php
+++ b/src/Resources/contao/dca/tl_module.php
@@ -148,18 +148,32 @@ public function __construct()
public function checkConfig()
{
- if ((!$GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token']) ||
- (!$GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token_secret']) ||
- (!$GLOBALS['TL_CONFIG']['twitterreader_credentials_user_id']) ||
- (!$GLOBALS['TL_CONFIG']['twitterreader_credentials_screen_name'])
- ) {
+ $oauth_token = "";
+ $oauth_secret = "";
+ $twitter_user_id = "";
+ $twitter_screen_name = "";
+
+ if (array_key_exists('twitterreader_credentials_oauth_token', $GLOBALS['TL_CONFIG'])) {
+ $oauth_token = $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token'];
+ }
+ if (array_key_exists('twitterreader_credentials_oauth_token_secret', $GLOBALS['TL_CONFIG'])) {
+ $oauth_secret = $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token_secret'];
+ }
+ if (array_key_exists('twitterreader_credentials_user_id', $GLOBALS['TL_CONFIG'])) {
+ $twitter_user_id = $GLOBALS['TL_CONFIG']['twitterreader_credentials_user_id'];
+ }
+ if (array_key_exists('twitterreader_credentials_screen_name', $GLOBALS['TL_CONFIG'])) {
+ $twitter_screen_name = $GLOBALS['TL_CONFIG']['twitterreader_credentials_screen_name'];
+ }
+
+ if (strlen($oauth_token) == 0 || strlen($oauth_secret) == 0 || strlen($twitter_user_id) == 0 || strlen($twitter_screen_name) == 0) {
$_SESSION['TL_ERROR'][] = $GLOBALS['TL_LANG']['tl_module']['twitterreader_auth_missing'];
}
}
public function getTwitterTemplates(DataContainer $dc)
{
- return $this->getTemplateGroup('twitterreader_', $dc->activeRecord->pid);
+ return \Controller::getTemplateGroup('twitterreader_');
}
public function purgeCacheData($field, DataContainer $dc)
diff --git a/src/Resources/contao/modules/FrontendTwitterReader.php b/src/Resources/contao/modules/FrontendTwitterReader.php
index 2e4300f..97d8e02 100755
--- a/src/Resources/contao/modules/FrontendTwitterReader.php
+++ b/src/Resources/contao/modules/FrontendTwitterReader.php
@@ -37,7 +37,7 @@ public function generate()
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
- $objTemplate->href = $this->Environment->script.'?do=themes&table=tl_module&act=edit&id='.$this->id;
+ $objTemplate->href = \Environment::script.'?do=themes&table=tl_module&act=edit&id='.$this->id;
return $objTemplate->parse();
}
@@ -63,8 +63,18 @@ protected function compile()
// check only, if last check is longer than 1 minute old.
$actualTime = time();
+ $oauth_token = "";
+ $oauth_secret = "";
+
+ if (array_key_exists('twitterreader_credentials_oauth_token', $GLOBALS['TL_CONFIG'])) {
+ $oauth_token = $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token'];
+ }
+ if (array_key_exists('twitterreader_credentials_oauth_token_secret', $GLOBALS['TL_CONFIG'])) {
+ $oauth_secret = $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token_secret'];
+ }
+
if ((($actualTime - $moduleModel->twitterLastUpdate) > $UpdateRange) || (!\is_array($objFeed))) {
- $oauth = new TwitterOAuth(TwitterUtil::TwitterReaderConsumerKey(), TwitterUtil::TwitterReaderConsumerSecret(), $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token'], $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token_secret']);
+ $oauth = new TwitterOAuth(TwitterUtil::TwitterReaderConsumerKey(), TwitterUtil::TwitterReaderConsumerSecret(), $oauth_token, $oauth_secret);
$arrFeed = [
'include_entities' => true,
'count' => $this->twittercount,
diff --git a/src/Resources/contao/widgets/WidgetTwitterOAuth.php b/src/Resources/contao/widgets/WidgetTwitterOAuth.php
index b53249d..030f31f 100755
--- a/src/Resources/contao/widgets/WidgetTwitterOAuth.php
+++ b/src/Resources/contao/widgets/WidgetTwitterOAuth.php
@@ -112,17 +112,27 @@ public function generate()
} elseif ('TwitterReaderOAuthRevoke' === \Input::get('action')) {
$this->revokeTwitterOAuth();
}
- if (\Input::get('oauth_verifyer')) {
+ if (strlen(\Input::get('oauth_verifier'))) {
$this->verifyTwitterOAuth();
}
- if ($GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token']) {
+ $oauth_token = "";
+ $oauth_secret = "";
+
+ if (array_key_exists('twitterreader_credentials_oauth_token', $GLOBALS['TL_CONFIG'])) {
+ $oauth_token = $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token'];
+ }
+ if (array_key_exists('twitterreader_credentials_oauth_token_secret', $GLOBALS['TL_CONFIG'])) {
+ $oauth_secret = $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token_secret'];
+ }
+
+ $sWizard = '';
+ if (strlen($oauth_token)) {
$connection = new TwitterOAuth(TwitterUtil::TwitterReaderConsumerKey(), TwitterUtil::TwitterReaderConsumerSecret(),
- $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token'],
- $GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token_secret']);
+ $oauth_token,
+ $oauth_secret);
$objAuth = $connection->get('account/verify_credentials');
-
- if ($objAuth->error) {
+ if ($objAuth == null) {
$sWizard .= $objAuth->error.'
';
} else {
$sWizard .= '
'.$GLOBALS['TL_LANG']['tl_settings']['twitterreader_authenticated_as'].':
'; @@ -173,7 +183,7 @@ protected function requestTwitterOAuth() $connection = new TwitterOAuth(TwitterUtil::TwitterReaderConsumerKey(), TwitterUtil::TwitterReaderConsumerSecret()); $urlRequest = preg_replace('/&action=TwitterReaderOAuthCheck/i', '', \Environment::get('request')); - $request_token = $connection->oauth('oauth/request_token', ['oauth_callback' => 'https://www.aurealis.de/contao-twitterreader-redirect.php?redirectUrl='.TwitterUtil::base64url_encode(\Environment::get('base').$urlRequest)]); + $request_token = $connection->oauth('oauth/request_token', ['oauth_callback' => 'https://opensource.nasbrill-soft.de/contao-twitterreader-redirect.php?redirectUrl='.TwitterUtil::base64url_encode(\Environment::get('base').$urlRequest)]); $this->Config->update("\$GLOBALS['TL_CONFIG']['twitterreader_oauth_token']", $request_token['oauth_token']); $this->Config->update("\$GLOBALS['TL_CONFIG']['twitterreader_oauth_token_secret']", $request_token['oauth_token_secret']); @@ -192,14 +202,14 @@ protected function verifyTwitterOAuth() $GLOBALS['TL_CONFIG']['twitterreader_oauth_token'], $GLOBALS['TL_CONFIG']['twitterreader_oauth_token_secret']); - $arrAccessToken = $connection->oauth('oauth/access_token', ['oauth_verifier' => \Input::get('oauth_verifyer')]); + $arrAccessToken = $connection->oauth("oauth/access_token", ["oauth_verifier" => \Input::get('oauth_verifier')]); $this->Config->update("\$GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token']", $arrAccessToken['oauth_token']); $this->Config->update("\$GLOBALS['TL_CONFIG']['twitterreader_credentials_oauth_token_secret']", $arrAccessToken['oauth_token_secret']); $this->Config->update("\$GLOBALS['TL_CONFIG']['twitterreader_credentials_user_id']", $arrAccessToken['user_id']); $this->Config->update("\$GLOBALS['TL_CONFIG']['twitterreader_credentials_screen_name']", $arrAccessToken['screen_name']); - $urlRequest = preg_replace('/(&(amp;)?|\?)oauth_verifyer=[^& ]*/i', '', \Environment::get('request')); + $urlRequest = preg_replace('/(&(amp;)?|\?)oauth_verifier=[^& ]*/i', '', \Environment::get('request')); $urlRequest = preg_replace('/(&(amp;)?|\?)oauth_token=[^& ]*/i', '', $urlRequest); $this->redirect($urlRequest);