This repository was archived by the owner on Jul 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmod_tweetdisplayback.php
More file actions
96 lines (82 loc) · 3.06 KB
/
mod_tweetdisplayback.php
File metadata and controls
96 lines (82 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Tweet Display Back Module for Joomla!
*
* @copyright Copyright (C) 2010-2016 Michael Babker. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
defined('_JEXEC') or die;
// Include the helper
JLoader::register('ModTweetDisplayBackHelper', __DIR__ . '/helper.php');
/**
* Module variables
* -----------------
* @var object $module A module object
* @var array $attribs An array of attributes for the module (probably from the XML)
* @var array $chrome The loaded module chrome files
* @var JApplicationCms $app The active application singleton
* @var string $scope The application scope before the module was included
* @var \Joomla\Registry\Registry $params Module parameters
* @var string $template The active template
* @var string $path The path to this module file
* @var JLanguage $lang The active JLanguage singleton
* @var string $content Module output content
*/
// Set the template variables
$headerAlign = $params->get('headerAvatarAlignment');
$tweetAlign = $params->get('tweetAlignment');
$headerClassSfx = htmlspecialchars($params->get('headerclasssfx'));
$tweetClassSfx = htmlspecialchars($params->get('tweetclasssfx'));
$flist = ModTweetDisplayBackHelper::toAscii($params->get('twitterList', ''));
$count = $params->get('twitterCount', '3') - 1;
try
{
$helper = new ModTweetDisplayBackHelper($params);
}
catch (RuntimeException $e)
{
// No HTTP adapters are available on this system
$errorMsg = JText::_('MOD_TWEETDISPLAYBACK_ERROR_NO_CONNECTORS');
require JModuleHelper::getLayoutPath('mod_tweetdisplayback', '_error');
return;
}
$helper->moduleId = $module->id;
// Check if caching is enabled
if ($helper->hasCaching)
{
// Check if cache data exists for the tweets to determine our path
if ($helper->getCache()->get($helper->getCacheId('tweet'), 'mod_tweetdisplayback'))
{
// Render from the cached data
$twitter = $helper->compileFromCache();
}
else
{
// Do a request to the Twitter API for new data
$twitter = $helper->compileData();
}
}
else
{
// Do a request to the Twitter API for new data
$twitter = $helper->compileData();
}
// Check to see if processing finished
if (!$helper->isProcessed)
{
// If we have cache data still, try to render from that
if ($helper->getCache()->get($helper->getCacheId('tweet'), 'mod_tweetdisplayback'))
{
// Render from the cached data
$twitter = $helper->compileFromCache();
}
// Check for error objects if processing did not finish
if (!$helper->isProcessed && (!$twitter) || (isset($twitter['error'])))
{
$errorMsg = JText::_('MOD_TWEETDISPLAYBACK_ERROR_UNABLETOLOAD');
require JModuleHelper::getLayoutPath('mod_tweetdisplayback', '_error');
return;
}
}
// Build the output
require JModuleHelper::getLayoutPath('mod_tweetdisplayback', $params->get('layout', 'default'));