Changeset 700339
- Timestamp:
- 04/19/2013 02:30:05 PM (11 years ago)
- Location:
- pubmed-publist/trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pubmed-publist/trunk/includes/admin.php
r700299 r700339 4 4 **/ 5 5 6 6 7 //TODO: Add Purge cache buttons / functions. 7 8 //TODO: Add cache settings 8 9 //TODO: Add PMID exclude setting. 9 10 11 12 10 13 /* settings link in plugin management screen */ 11 14 function pm_pubmed_settings_link( $links ) { … … 132 135 if(isset($key)) { 133 136 $val = trim(wp_kses($val, '')); 137 134 138 } // end if 135 139 } // end foreach … … 139 143 update_option('pm_publist_settings', $input); 140 144 } 145 146 147 148 149 150 151 152 153 154 141 155 return $input; 142 156 } … … 149 163 } 150 164 public function pm_publist_create_searchString_field($int){ 165 151 166 $options = get_option('pm_publist_settings'); 152 167 ?><textarea style="width:100%;" rows="5" id="searchString<?php echo $int;?>" name="array_key[searchString<?php echo $int;?>]"><?php echo $options['searchString'.$int];?></textarea><?php 168 169 170 153 171 } 154 172 public function pm_publist_use_info(){ -
pubmed-publist/trunk/includes/core.php
r700299 r700339 29 29 $total = $show+$extra; 30 30 31 31 32 $transient = 'pm_pubmedlist'.$show.$extra.$class.$layout; 33 34 35 32 36 $pubs = get_transient( $transient ); 33 37 if ( false === $pubs ) { … … 170 174 171 175 $xmlCache = pm_publist_DIR.'pm_cache.xml'; 176 172 177 //TODO: Sort caching out. Remove age chack from pubmedrequest.php and ue just this??? 173 178 //Easier to get var from settings here. 179 180 174 181 $xmlcache_time = 60*60; // 1 hour 175 182 $timedif = @(time() - filemtime($xmlCache)); … … 193 200 return false; 194 201 } else { 202 195 203 $strings = get_option('pm_publist_settings'); 204 205 206 207 208 209 210 211 212 213 196 214 $data = http_build_query($strings); 197 215 … … 224 242 ////Create page 225 243 $pubs = '<ul class="pm_publist '.$class.'">'.implode($lmbpubs[0]).'</ul>'; 244 226 245 global $show; 227 246 global $total; 228 247 if($show != $total) { 248 249 250 229 251 //TODO: Add CSS / JS / Shortcode for this: 230 252 //$pubs .= do_shortcode('[toggle title="More papers"]<ul class="'.$class.'>'.implode($lmbpubs[1]).'</ul>[/toggle]'); … … 232 254 }; 233 255 256 234 257 //for next time write transient cache file. 235 258 //but only if no error (basic check using length) … … 237 260 if (strlen($pubs) > 500){ 238 261 set_transient($transient, $pubs, 60*30); 262 263 264 265 266 267 268 269 239 270 } 240 271 } -
pubmed-publist/trunk/pm_publist.php
r700299 r700339 3 3 Plugin Name: PubMed Publist 4 4 Description: Shortcodes to display a list of publications from PubMed 5 5 6 Version: 0.9.1 7 8 9 6 10 Author: Phil Banks 7 11 */ -
pubmed-publist/trunk/pm_pubmedrequest.php
r700299 r700339 2 2 ////If Cache is good - use it 3 3 //define some variables. 4 4 5 //TODO: Use options to set this cache time 5 6 //TODO: Check there isn't a WP function for writing to disk. Problems on some hosts??? 7 8 6 9 $cache_time = 60*60*2; // 2 hours 7 10 $cache_file = dirname(__FILE__).'/pm_cache.xml'; … … 14 17 else { 15 18 $nodes = array(); 19 16 20 if(isset($_POST["searchString1"])) { 17 21 $search1 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["searchString1"].'&report=xml'; … … 40 44 41 45 //get PubMed data as XML using parallel cURL requests for speed. 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 42 77 $node_count = count($nodes); 43 78 $curl_arr = array(); … … 59 94 60 95 96 97 98 99 61 100 //function to clean PubMed data so it is valid XML. 62 101 function cleanPubmed($dirtyPubmed) { … … 71 110 $query = array(); 72 111 foreach ($xml1->PubmedArticle as $paper) { 73 112 $query[] = sprintf('(MedlineCitation/PMID != %s)',$paper->MedlineCitation->PMID); 74 113 } 75 114 $query = implode('and', $query); … … 77 116 $xmlClean = '<Document>'; 78 117 foreach ($xml2->xpath(sprintf('PubmedArticle[%s]', $query)) as $paper) { 79 118 $xmlClean .= $paper->asXML(); 80 119 } 81 120 $xmlClean .= '</Document>'; … … 103 142 104 143 144 105 145 //Loop through set nodes and clean/convert 146 147 148 106 149 for($i = 0; $i < $node_count; $i++) { 107 150 $num = $i+1; … … 111 154 ${"xml$num"} = new SimpleXMLElement(${"search$num"}); 112 155 } 156 113 157 //Loop through nodes and dedupe/merge 158 159 160 114 161 $output = $xml1; 115 162 if ($node_count > 1) { 116 163 for($i = 0; $i < $node_count-1; $i++) { 117 164 $num = $i+2; 165 166 167 168 169 118 170 ${"xml$num.clean"} = dedupeXML($output,${"xml$num"}); 119 171 $output = mergeXML($output,${"xml$num.clean"}); -
pubmed-publist/trunk/readme.txt
r700299 r700339 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 10 11 11 12 Simple shortcode to get and display latest publications from PubMed using a PubMed search URL(s). 12 13 13 14 15 16 17 18 14 19 == Description == 15 20 … … 18 23 The shortcode accepts arguments to set how many papers are displayed, apply classes for custom styling, and choose from two layout options. 19 24 25 26 27 28 29 30 20 31 21 32 = Roadmap = … … 26 37 * Add JS for show/hide extra results on front-end 27 38 39 28 40 41 42 29 43 == Installation == 30 44 … … 35 49 1. Or use `<?php do_shortcode('recentpublications'); ?>` in your templates 36 50 51 37 52 53 54 38 55 == Frequently Asked Questions == 39 56 … … 44 61 = Can I contribute to the plugin / suggest a change? = 45 62 63 46 64 Please do! [The project is hosted on GitHub here](http://github.com/emirpprime/PubMedPublist). 47 65 66 67 68 48 69 49 70 == Screenshots == … … 54 75 1. Settings screen 55 76 77 56 78 57 79 == Changelog == … … 62 84 63 85 = 0.9 = 86 87 88 89 90 91 64 92 * Initial Beta Release
Note: See TracChangeset
for help on using the changeset viewer.