# PLUGIN PREVIEW BY TEXTPATTERN.INFO
/*
adi_globals - Global variables
Written by Adi Gilbert
Released under the GNU General Public License
Version history:
0.3 - TXP 4.6 tag registration
0.2 - added thisimage, thissection, thiscategory (thanks bloke)
- removed txpcfg (thanks joebaich)
- disabled debug option if PHP is disallowed in articles
0.1 - initial release
*/
// TXP 4.6 tag registration
if (class_exists('\Textpattern\Tag\Registry')) {
Txp::get('\Textpattern\Tag\Registry')
->register('adi_globals')
;
}
function adi_globals($atts) {
$globals = array('prefs','thispage','thissection','pretext','thisarticle','thisimage','thislink','thisfile','thiscomment','thiscategory');
foreach ($globals as $thisglobal)
global $$thisglobal;
extract(lAtts(array(
'name' => '', // the global variable we're looking for
'quiet' => '0', // don't display value (default = no)
'txpvar' => '1', // set TXP variable or not (default = yes)
'debug' => '0',
), $atts));
if (!$prefs['allow_article_php_scripting']) // no peeking if PHP disallowed in articles
$debug = 0;
if ($name || $debug)
foreach ($globals as $thisglobal)
if (is_array($$thisglobal))
if ($debug) {
echo '<pre>$'.$thisglobal.'</pre>';
dmp($$thisglobal);
}
else
if (array_key_exists($name,$$thisglobal)) { // variable found
if ($txpvar) { // set TXP var
if (!isset($GLOBALS['variable'])) // initialise TXP variables array, if required
$GLOBALS['variable'] = array();
$GLOBALS['variable'][$name] = ${$thisglobal}[$name];
}
if (!$quiet) // shout it out
return ${$thisglobal}[$name];
}
return '';
}