I may have found a bug in Cookbook:Toggle. I sent the following to the pmwiki-users group today:

In the toggle.php recipe of 2014-02-21, we see the following:

$HTMLFooterFmt['toggle'] = "<script type=\"text/javascript\">document.getElementById(\"{Blog.2014-07-01$id}\").style.display = '{Blog.2014-07-01$style}';</script>";

This should create a simple string that is places into the HTMLFooterFmt hash with the index of "toggle."

How on earth is toggle supposed to function if there is more than one toggle present on the page?

Am I missing something in PHP/PmWiki that would allow this to work?

We don't see anything like this behavior in the older version from 2009-07-23

Perhaps not coincidentally, I have multiple toggles working with the version from 2009-07-23, but not with 2013-02-21

Unless I make the following change:

$HTMLFooterFmt["toggle$id"] = "<script type=\"text/javascript\">document.getElementById(\"{Blog.2014-07-01$id}\").style.display = '{Blog.2014-07-01$style}';</script>";

I do understand there were changes made between 2009 and 2014 (I'm slow in updating) to handle nested divs, but I'm failing to see how that's applicable, here (my targets are nested, for one thing).

UPDATE 2014.07.06: Entirely my mistake. The original download of toggle.php at did NOT have 'toggle as an index passed to $HTMLFooterFmt. I have no idea how it got there, since I believe I only opened the file once I was having an issue. But I must have done it, somehow.....

ToggleEdit and bootstrap icons

My own Cookbook:ToggleEdit recipe creates a wrapper around Toggle, by way of an edit-button.
But the edit-buttons by default are images; as part of bootstrap I've tried to rewrite them using the included css-sprites.
The recipe is not compatible with this format.

the css-sprite gui-icon code (from skin.php):

global $BootButtons;

SDVA($BootButtons, array(
  'em'       => array(100, "''", "''", '$[Emphasized]',
  'strong'   => array(110, "'''", "'''", '$[Strong]',
  /* 'pagelink' => array(200, '[[', ']]', '$[Page link]', */
  /*                 '$GUIButtonDirUrlFmt/pagelink.gif"$[Link to internal page]"'), */
  /* 'extlink'  => array(210, '[[', ']]', 'http:// | $[link text]', */
  /*                 '$GUIButtonDirUrlFmt/extlink.gif"$[Link to external page]"'), */
  'big'      => array(300, "'+", "+'", '$[Big text]',
  /* 'small'    => array(310, "'-", "-'", '$[Small text]', */
  /*                 '$GUIButtonDirUrlFmt/small.gif"$[Small text]"'), */
  'sup'      => array(320, "'^", "^'", '$[Superscript]',
  'sub'      => array(330, "'_", "_'", '$[Subscript]',
  /* 'h2'       => array(400, '\\n!! ', '\\n', '$[Heading]', */
  /*                 '$GUIButtonDirUrlFmt/h.gif"$[Heading]"'), */
  'center'   => array(410, '%center%', '', '',

/* sms($BootButtons); */
sms('after the echo');

Markup('e_bootbuttons', 'directives',
  "Keep(FmtPageName(BootButtonCode(\$pagename), \$pagename))");

function BootButtonCode($pagename) {
  global $BootButtons;
  $cmpfn = create_function('$a,$b', 'return $a[0]-$b[0];');
  sms('inside of BootButtonCode');
  sms('Buttons: '.$BootButtons);
  usort($BootButtons, $cmpfn);
  $out = "<script type='text/javascript'><!--\n";
  foreach ($BootButtons as $k => $g) {
    if (!$g) continue;
    @list($when, $mopen, $mclose, $mtext, $class, $mkey) = $g;
    // I will confess to not completely understanding what was happening, here
    // I replaced "$tag" in the above line with "$class"
    // which better replaced what I'm doing....
    /* if ($tag{0} == '<') { */
    /*     $out .= "document.write(\"$tag\");\n"; */
    /*     continue; */
    /* } */
    /* if (preg_match('/^(.*\\.(gif|jpg|png))("([^"]+)")?$/', $tag, $m)) { */
    /*   $title = (@$m[4] > '') ? "title='{$m[4]}'" : ''; */
    /*   /\* $tag = "<img src='{$m[1]}' $title style='border:0px;' />"; *\/ */
    /*   $tag = "<i class='{$m[1]}'></i>"; */
    /* } */
    ## NOTE: label-inverse is only for darkstrap. And looks awful otherwise....
   $tag = "<span class='label guibutton'><i class='$class'></i></span>";
    $mopen = str_replace(array('\\', "'"), array('\\\\', "\\\\'"), $mopen);
    $mclose = str_replace(array('\\', "'"), array('\\\\', "\\\\'"), $mclose);
    $mtext = str_replace(array('\\', "'"), array('\\\\', "\\\\'"), $mtext);
    $out .=
      "insButton(\"$mopen\", \"$mclose\", '$mtext', \"$tag\", \"$mkey\");\n";
  $out .= '//--></script>';
  return $out;
NOTE: the bootstrap icons are not showing up in the blog edit page, here. They are enabled, since I do see them when editing in the WikiSandbox.

What gives?


Is Cookbook:PageTableOfContents installed, here?

DONE: add to blog template.

See 2014-07-03 for an issue (not imagined, this time!)


Cookbook:SourceBlock is not working.

I have it working on my work-wiki.
Here are the errors:

Warning: include_once(/path/tot/cookbook/geshi/geshi.php): failed to open stream: No such file or directory in /path/to/cookbook/sourceblock.php on line 152

Warning: include_once(): Failed opening '/path/to/cookbook/geshi/geshi.php' for inclusion (include_path='.:/usr/lib/php5.4') in /path/to/cookbook/sourceblock.php on line 152

Fatal error: Class 'GeSHi' not found in /path/to/cookbook/sourceblock.php on line 156


The Geshi source-code has been switched up.
The download from GitHub includes some notes and build-files and a src directory.
It's the contents of the src directory that the recipe expects to find at /cookbook/geshi - particularly geshi.php