Changeset 2111833
- Timestamp:
- 06/25/2019 04:17:56 AM (7 years ago)
- Location:
- wp-pubmed-reflist/trunk
- Files:
-
- 1 added
- 5 edited
-
class.wpPubMedRefList.php (modified) (1 diff)
-
class.wpPubMedRefListSettings.php (modified) (8 diffs)
-
class.wpPubMedRefListViews.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
settings/api_form.php (added)
-
settings/query_form.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-pubmed-reflist/trunk/class.wpPubMedRefList.php
r1830696 r2111833 190 190 191 191 function fetchXML($url){ 192 $delay = 400000; # 0.4 seconds in microseconds 193 $apikey = trim(get_option('wp_pubmed_reflist_api')); 194 if(isset($apikey) && $apikey != ''){ 195 $delay = 100000; # 0.1 seconds in microseconds 196 $url .= "&api_key=$apikey"; 197 } 198 #trigger_error("url:$url"); 199 usleep($delay); 192 200 switch($this->remote_method){ 193 201 case 'allow_url_fopen': -
wp-pubmed-reflist/trunk/class.wpPubMedRefListSettings.php
r1822314 r2111833 72 72 73 73 function admin_init(){ 74 global $new_whitelist_options;75 74 $this->options = get_option('wp_pubmed_reflist'); 76 75 $this->formats = get_option('wp_pubmed_reflist_styles'); 76 $this->apikey = get_option('wp_pubmed_reflist_api'); 77 77 # stylelist will be empty on first install or upgrade from < 0.9; initialize to squelch warning in set_default_styles 78 78 # if the styles don't exist set the default ones here so they are available even if the user never hits the styles tab. … … 96 96 # add new section for adding keys 97 97 add_settings_section( 98 'wp_pubmed_reflist_faclist', 99 'New key', 100 'wpPubMedReflistViews::faclist_text', 101 'wp_pubmed_reflist' 98 'wp_pubmed_reflist_faclist', # id 99 'New key', # title 100 'wpPubMedReflistViews::faclist_text', # callback 101 'wp_pubmed_reflist' # page 102 102 ); 103 103 add_settings_field( 104 104 'wp_pubmed_reflist_faclist', 105 '', array($this, 'faclist_form'), 105 '', 106 array($this, 'faclist_form'), 106 107 'wp_pubmed_reflist', 107 108 'wp_pubmed_reflist_faclist' … … 197 198 'wp_pubmed_bolds' # section 198 199 ); 200 /* 201 Registry for NCBI api key managment tab 202 */ 203 204 register_setting( 205 'pubmed_ref_api', # option group 206 'wp_pubmed_reflist_api', # option name 207 array($this, 'pubmed_formats_validate') # sanitize callback 208 ); 209 add_settings_section( 210 'wp_pubmed_reflist_apikey', # id 211 'Add NCBI API key', # title 212 'wpPubMedReflistViews::api_key_form_text', # callback 213 'wp_pubmed_reflist_api' # page 214 ); 215 add_settings_field( 216 'wp_pubmed_reflist_api', # id 217 '', # title 218 array($this, 'api_form'), # callback 219 'wp_pubmed_reflist_api', # page 220 'wp_pubmed_reflist_apikey' # section 221 ); 199 222 } 200 223 … … 212 235 */ 213 236 function options_page(){ 214 global $new_whitelist_options;215 237 echo "<h2>PubMed Reflist</h2> 216 238 Manage PubMed queries for use with the [pmid-refs key=<key> limit=<number>] shorttag."; … … 240 262 $active_tab = $_GET[ 'tab' ]; 241 263 } // end if 242 $query_tab_class = $format_tab_class = $ help_tab_class = 'nav-tab';264 $query_tab_class = $format_tab_class = $api_tab_class = $help_tab_class = 'nav-tab'; 243 265 $active_tab_class = $active_tab.'_tab_class'; 244 266 # commented out until I can figure out weird reordering and layout behavior of the tabs … … 247 269 <a href='?page=wp_pubmed_reflist&tab=query' class='$query_tab_class'>Queries</a> 248 270 <a href='?page=wp_pubmed_reflist&tab=format' class='$format_tab_class'>Reference Styles</a> 271 <a href='?page=wp_pubmed_reflist&tab=api' class='$api_tab_class'>NCBI API key</a> 249 272 <a href='?page=wp_pubmed_reflist&tab=help' class='$help_tab_class'>Help</a> 250 273 </h2>"; … … 259 282 submit_button('Save Changes','submit', true, array('tab'=>'format')); 260 283 break; 284 case 'api': 285 settings_fields('pubmed_ref_api'); 286 do_settings_sections('wp_pubmed_reflist_api'); # param is a page name, not a section id 287 submit_button('Save Changes','submit', true, array('tab'=>'api')); 288 break; 261 289 case 'query': 262 290 default: 263 settings_fields('pubmed_refs_options');264 do_settings_sections('wp_pubmed_reflist');291 settings_fields('pubmed_refs_options'); 292 do_settings_sections('wp_pubmed_reflist'); 265 293 submit_button('Save Changes','submit', true, array('tab'=>'query')); 266 294 } … … 274 302 function query_form(){ 275 303 require_once(__DIR__."/settings/query_form.php"); 304 } 305 306 function api_form(){ 307 require_once(__DIR__."/settings/api_form.php"); 276 308 } 277 309 -
wp-pubmed-reflist/trunk/class.wpPubMedRefListViews.php
r1822314 r2111833 39 39 echo "List of items that should be get the html <strong>strong</strong> tag in article author lists (e.g. author names). Enter one item per line"; 40 40 } 41 42 public static function api_key_form_text(){ 43 echo " 44 <h2>Setting an NCBI API key</h2> 45 <p>After May 1, 2018. NCBI began throttling anonymous queries to the E-utilities API, which is what WP Pubmed Reflist uses to do queries and fetch results. Anonymous requests are limited to 3/second while those with an API key can do 10/sec. The anonymous number may be enough for users of WP Pubmed Reflist, but if you want faster performance, get an API key for your NCBI account as described <a href='https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/'>here</a> and enter it below: </p> 46 "; 47 } 48 41 49 42 50 public static function noFetchMethod(){ … … 82 90 if($extra != '') $reflist[] = $extra; 83 91 } 84 if ($limit < 0){ 92 if ($limit < 0){ 85 93 $limit = abs($limit) - 1; 86 94 if(count($reflist) < $limit) $limit = count($reflist); … … 151 159 $text = "$prefix<a href='http://www.ncbi.nlm.nih.gov/pmc/articles/$pmcid'>$pmcid</a>"; 152 160 } 153 break; 161 break; 154 162 case '_TitleL': 155 163 if(isset($ref['PMID'])){ … … 189 197 return $text; 190 198 } 191 199 192 200 /* 193 201 Display the help tab -
wp-pubmed-reflist/trunk/readme.txt
r1830696 r2111833 3 3 Tags: shortcodes, pubmed, references 4 4 Requires at least: 3.0 5 Tested up to: 4.9.45 Tested up to: 5.2.2 6 6 Donate link:http://biochemistry.tamu.edu/index.php/alum/giving/ 7 Stable tag: 1. 27 Stable tag: 1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 63 63 * input validation for the admin page 64 64 * jquery datatables for settings view 65 = 1.3 = 66 * Change handling of disallowed characters in query keys in hopes of dealing with a mysterious problem where on some installations keys are showing illegal chars when the chars are all legal. 67 * Add support for NCBI API keys (optional) 68 65 69 = 1.2 = 66 70 * Preprocess ArticleTitle and AbstractText wrap them in CDATA sections. This preserves HTML inside the Titles and Abstracts, such as superscripts. -
wp-pubmed-reflist/trunk/settings/query_form.php
r1822314 r2111833 8 8 $facprops = @$this->options['facprops']; 9 9 #echo "<pre>options: \nfaclist\n"; var_dump($faclist);echo "facprops\n";var_dump($facprops);echo "</pre>"; 10 echo "<table><tr><th>Search Key</th><th>Query</th><th>Extras</th><th>Delete?</th></tr>"; 10 $hiddens = ''; 11 $formTable = "<table><tr><th>Search Key</th><th>Query</th><th>Extras</th><th>Delete?</th></tr>"; 11 12 if($faclist){ 12 13 sort($faclist); 13 14 foreach($faclist as $name){ 14 15 # sanitize the faclist name 15 $sanitizedName = preg_replace('/[^a-zA-Z0-9\s-_\(\)]/', '', $name); 16 $name = trim($name); 17 $sanitizedName = preg_replace('/[^a-zA-Z0-9\s-_\(\)]/', '_', $name); 16 18 if($sanitizedName != $name){ 17 echo "$name contains characters not allowed in the key"; 19 $name = $sanitizedName; 20 /* echo "$name contains characters not allowed in the key<br />"; 18 21 # delete it if it is already in the db. 19 22 if(($key = array_search($name, $this->options['faclist'])) !== false) { … … 24 27 unset ($facprops[$name]['query']); 25 28 } 26 continue; 29 continue; */ 27 30 } 28 31 if ($name == '' || (isset($facprops[$name]['delete']) && $facprops[$name]['delete'] == 'on')) continue; 29 $name = strtolower($name);32 #$name = strtolower($name); 30 33 $val = $extras = ""; 31 echo"<tr><td>$name</td>";34 $formTable .= "<tr><td>$name</td>"; 32 35 # query 33 36 if(isset($facprops[$name]['query'])) $val = $facprops[$name]['query']; 34 echo"<td><textarea id='wp_pubmed_reflist_qlist' ".37 $formTable .= "<td><textarea id='wp_pubmed_reflist_qlist' ". 35 38 "name='wp_pubmed_reflist[facprops][$name][query]' 36 39 cols='60' rows='2' >$val</textarea></td>"; 37 40 # extra citations not in pubmed 38 41 if(isset($facprops[$name]['extras'])) $extras = $facprops[$name]['extras']; 39 echo"<td><textarea id='wp_pubmed_reflist_qlist' ".42 $formTable .= "<td><textarea id='wp_pubmed_reflist_qlist' ". 40 43 "name='wp_pubmed_reflist[facprops][$name][extras]' 41 44 cols='60' rows='2' >$extras</textarea></td>"; 42 45 # delete? 43 echo"<td><input type='checkbox' id='wp_pubmed_reflist_qlist' ".46 $formTable .= "<td><input type='checkbox' id='wp_pubmed_reflist_qlist' ". 44 47 "name='wp_pubmed_reflist[facprops][$name][delete]' /></td> 45 48 <tr>"; 46 49 47 echo "<input id='wp_pubmed_reflist_faclist' name='wp_pubmed_reflist[facprops][$name][last_update]' type='hidden' value='0' />";50 $hiddens .= "<input id='wp_pubmed_reflist_faclist' name='wp_pubmed_reflist[facprops][$name][last_update]' type='hidden' value='0' />\n"; 48 51 49 52 } 50 53 } 51 echo "</table>"; 54 $formTable .= "</table>"; 55 echo $formTable.$hiddens;
Note: See TracChangeset
for help on using the changeset viewer.