>id=divisionname<<
text can be hidden/shown
>><<
Necessary parameters: (:toggle div=divisionname:)
Optional parameters:
init=hide hides the division initially (default is show)
lshow=labelname label of button when div is hidden (default is Show)
lhide=labelname label of button when div is shown (default is Hide)
*/
# Version date
$RecipeInfo['ToggleLink']['Version'] = '2009-02-16';
# declare $ToggleLink for (:if enabled $ToggleLink:) recipe installation check
global $ToggelLink; $ToggleLink = 1;
SDVA($ToggleLinkConfig, array(
'init' => 'show', //show div
'lshow' => XL("Show"), //link text 'Show'
'lhide' => XL("Hide"), //link text 'Hide'
'set' => false, //set no cookie to remeber toggle state
'div' => '', //no default div name
'div2' => '', //no default div2 name
'set' => false, //set no cookie to remeber toggle state
'printhidden' => true, // hidden divs get printed
));
Markup('toggle', 'directives',
'/\\(:toggle\\s*(.*?):\\)/ei',
"ToggleLink(\$pagename, PSS('$1'))");
# all in one function
function ToggleLink($pagename,$opt) {
# javascript for toggling and cookie setting
global $HTMLFooterFmt, $ToggleLinkConfig;
$HTMLFooterFmt['toggleobj'] = "
";
$opt = array_merge($ToggleLinkConfig, ParseArgs($opt));
if($opt['init']=='show') $tog = 'show';
if($opt['init']=='hide') $tog = 'hide';
$opt['lshow'] = str_replace("'","’",$opt['lshow']);
$opt['lhide'] = str_replace("'","’",$opt['lhide']);
# check cookie if set=1
if($opt['set']==1) {
global $CookiePrefix, $SkinName;
$Cookie = $CookiePrefix.$SkinName.'_set'.$opt['div'];
if (isset($_COOKIE[$Cookie])) $tog = $_COOKIE[$Cookie];
}
# toggle state
if($tog=='show') {
$label = $opt['lhide'];
$tog = 'hide';
}
elseif($tog=='hide') {
$label = $opt['lshow'];
$tog = 'show';
}
# initial toggle link (later link is build with javascript)
$out = "{$label}";
if($tog=='show') {
$out.= "";
}
if($tog=='show' && $opt['printhidden']==1) {
$out.= "";
}
if($tog=='hide' && $opt['div2']) {
$out.= "";
}
if($tog=='hide' && $opt['div2'] && $opt['printhidden']==1) {
$out.= "";
}
return Keep($out);
}
# end of ToggleLink function