This repository was archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
261 lines (220 loc) · 6.17 KB
/
index.php
File metadata and controls
261 lines (220 loc) · 6.17 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
/**
* moziloCMS Plugin: fbGraph
*
* Reads the facebook graph and returns specific information
*
* PHP version 5
*
* @category PHP
* @package PHP_MoziloPlugins
* @author DEVMOUNT <mail@devmount.de>
* @license GPL v3+
* @version GIT: v0.1.2014-01-12
* @link https://github.com/devmount-mozilo/fbGraph/wiki/Dokumentation
* @see “I have the right to do anything,” you say — but not everything is
* beneficial. “I have the right to do anything” — but I will not be
* mastered by anything.
* - The Bible
*
* Plugin created by DEVMOUNT
* www.devmount.de
*
*/
// only allow moziloCMS environment
if (!defined('IS_CMS')) {
die();
}
/**
* fbGraph Class
*
* @category PHP
* @package PHP_MoziloPlugins
* @author DEVMOUNT <mail@devmount.de>
* @license GPL v3+
* @link https://github.com/devmount/fbGraph
*/
class fbGraph extends Plugin
{
private $_admin_lang;
private $_cms_lang;
// plugin information
const PLUGIN_AUTHOR = 'DEVMOUNT';
const PLUGIN_TITLE = 'fbGraph';
const PLUGIN_VERSION = 'v0.1.2014-01-12';
const MOZILO_VERSION = '2.0';
const PLUGIN_DOCU
= 'https://github.com/devmount-mozilo/fbGraph/wiki/Dokumentation';
private $_plugin_tags = array(
'1' => '{fbGraph|id|tag|after}',
);
/**
* creates plugin content
*
* @param string $value Parameter divided by '|'
*
* @return string HTML output
*/
function getContent($value)
{
global $CMS_CONF;
$this->_cms_lang = new Language(
$this->PLUGIN_SELF_DIR
. 'lang/cms_language_'
. $CMS_CONF->get('cmslanguage')
. '.txt'
);
/**
* get params
* $pid either id as number or name
* $tag the specific information - possible values are:
* about, category, company_overview, founded, description,
* is_published, talking_about_count, username, website,
* were_here_count, id, name, link, likes
* $after text displayed after the information
*/
list($pid, $tag, $after)
= $this->makeUserParaArray($value, false, '|');
$file = 'http://graph.facebook.com/' . $pid;
$graph = json_decode(@file_get_contents($file));
// check url file
if ($graph == '') {
return $this->throwError(
$this->_cms_lang->getLanguageValue('error_file', $pid)
);
}
$info = '';
switch ($tag) {
// fb-page tags
case 'about':
$info = $graph->about;
break;
case 'category':
$info = $graph->category;
break;
case 'company_overview':
$info = $graph->company_overview;
break;
case 'founded':
$info = $graph->founded;
break;
case 'description':
$info = $graph->description;
break;
case 'is_published':
$info = $graph->is_published;
break;
case 'talking_about_count':
$info = $graph->talking_about_count;
break;
case 'username':
$info = $graph->username;
break;
case 'website':
$info = $graph->website;
break;
case 'were_here_count':
$info = $graph->were_here_count;
break;
case 'id':
$info = $graph->id;
break;
case 'name':
$info = $graph->name;
break;
case 'link':
$info = $graph->link;
break;
case 'likes':
$info = $graph->likes;
break;
// fb-profile tags
case 'first_name':
$info = $graph->first_name;
break;
case 'last_name':
$info = $graph->last_name;
break;
case 'gender':
$info = $graph->gender;
break;
case 'locale':
$info = $graph->locale;
break;
// default
default:
return $this->throwError(
$this->_cms_lang->getLanguageValue('error_tag', $tag)
);
break;
}
// build return content
$content = '<div class="fbGraph">' . $info;
if ($after != '') {
$content .= ' ' . $after;
}
$content .= '</div>';
return $content;
}
/**
* sets backend configuration elements and template
*
* @return Array configuration
*/
function getConfig()
{
$config = array();
return $config;
}
/**
* sets backend plugin information
*
* @return Array information
*/
function getInfo()
{
global $ADMIN_CONF;
$this->_admin_lang = new Language(
$this->PLUGIN_SELF_DIR
. 'lang/admin_language_'
. $ADMIN_CONF->get('language')
. '.txt'
);
// build plugin tags
$tags = array();
foreach ($this->_plugin_tags as $key => $tag) {
$tags[$tag] = $this->_admin_lang->getLanguageValue('tag_' . $key);
}
$info = array(
'<b>' . self::PLUGIN_TITLE . '</b> ' . self::PLUGIN_VERSION,
self::MOZILO_VERSION,
$this->_admin_lang->getLanguageValue(
'description',
htmlspecialchars($this->_plugin_tags['1'], ENT_COMPAT, 'UTF-8')
),
self::PLUGIN_AUTHOR,
array(
self::PLUGIN_DOCU,
self::PLUGIN_TITLE . ' '
. $this->_admin_lang->getLanguageValue('on_devmount')
),
$tags
);
return $info;
}
/**
* throws styled error message
*
* @param string $text Content of error message
*
* @return string HTML content
*/
protected function throwError($text)
{
return '<div class="' . self::PLUGIN_TITLE . 'Error">'
. '<div>' . $this->_cms_lang->getLanguageValue('error') . '</div>'
. '<span>' . $text. '</span>'
. '</div>';
}
}
?>