Exemple #1
0
 /**
  * Main entry point: Handles a match in the post
  */
 function _process(&$matches)
 {
     global $wpdb, $papercite_table_name;
     $debug = false;
     $post = null;
     // --- Initialisation ---
     // Includes once the bibtex parser
     require_once dirname(__FILE__) . "/lib/BibTex_" . $this->options["bibtex_parser"] . ".php";
     // Includes once the converter
     require_once "bib2tpl/bibtex_converter.php";
     // Get the options
     $command = $matches[1];
     // Get all the options pairs and store them
     // in the $options array
     $options_pairs = array();
     preg_match_all("/\\s*([\\w-:_]+)=(?:([^\"]\\S*)|\"([^\"]+)\")(?:\\s+|\$)/", sizeof($matches) > 2 ? $matches[2] : "", $options_pairs, PREG_SET_ORDER);
     // print "<pre>";
     // print htmlentities(print_r($options_pairs,true));
     // print "</pre>";
     // ---Set preferences
     // by order of increasing priority
     // (0) Set in the shortcode
     // (1) From the preferences
     // (2) From the custom fields
     // (3) From the general options
     // $this->options has already processed the steps 0-2
     $options = $this->options;
     $options["filters"] = array();
     foreach ($options_pairs as $x) {
         $value = $x[2] . (sizeof($x) > 3 ? $x[3] : "");
         if ($x[1] == "template") {
             // Special case of template: should overwrite the corresponding command template
             $options["{$command}_{$x['1']}"] = $value;
         } else {
             if (Papercite::startsWith($x[1], "filter:")) {
                 $options["filters"][substr($x[1], 7)] = $value;
             } else {
                 $options[$x[1]] = $value;
             }
         }
     }
     // --- Compatibility issues: handling old syntax
     if (array_key_exists("groupByYear", $options) && strtoupper($options["groupByYear"]) == "TRUE") {
         $options["group"] = "year";
         $options["group_order"] = "desc";
     }
     $data = null;
     return $this->processCommand($command, $options);
 }