/** * This does two things: * -dynamically creates html form based on parameters (author and menutype) * -rebuilds command which is then sent as the bibtex command * * @param unknown $options The arguments * @return multitype:string The output of the bibfilter shortcode */ function bibfilter($options) { // create form with custom types and authors global $post; $selected_author = false; $selected_type = false; $original_authors = Papercite::array_get($options, "author", ""); $original_allow = Papercite::array_get($options, "allow", ""); if (isset($_POST) && papercite::array_get($_POST, "papercite_post_id", 0) == $post->ID) { if (isset($_POST["papercite_author"]) && !empty($_POST["papercite_author"])) { $selected_author = $options["author"] = $_POST["papercite_author"]; } if (isset($_POST["papercite_allow"]) && !empty($_POST["papercite_allow"])) { $selected_type = $options["allow"] = $_POST["papercite_allow"]; } } $result = $this->getEntries($options); ob_start(); ?> <form method="post" accept-charset="UTF-8"> <input type="hidden" name="papercite_post_id" value="<?php echo $post->ID; ?> "> <table style="border-top: solid 1px #eee; border-bottom: solid 1px #eee; width: 100%"> <tr> <td>Authors:</td> <td><select name="papercite_author" id="papercite_author"> <option value="">ALL</option> <?php $authors = preg_split("#\\s*\\|\\s*#", $original_authors); if (Papercite::array_get($options, "sortauthors", 0)) { sort($authors); } foreach ($authors as $author) { print "<option value=\"" . htmlentities($author, ENT_QUOTES, "UTF-8") . "\""; if ($selected_author == $author) { print " selected=\"selected\""; } print ">{$author}</option>"; } ?> </select></td> <td>Type:</td> <td><select name="papercite_allow" id="papercite_type"> <option value="">ALL</option> <?php $types = preg_split("#\\s*,\\s*#", $original_allow); foreach ($types as $type) { print "<option value=\"" . htmlentities($type, ENT_QUOTES, "UTF-8") . "\""; if ($selected_type == $type) { print " selected=\"selected\""; } print ">" . papercite_bibtype2string($type) . "</option>"; } ?> </select></td> <td><input type="submit" value="Filter" /></td> </tr> </table> </form> <?php return ob_get_clean() . $this->showEntries($result, $options, $this->getBib2TplOptions($options), false, $options["bibtex_template"], $options["format"], "bibtex"); }