Plugin Directory

Changeset 700339

Timestamp:
04/19/2013 02:30:05 PM (11 years ago)
Author:
emirpprime
Message:

Initial Commit

Location:
pubmed-publist/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • pubmed-publist/trunk/includes/admin.php

    r700299 r700339  
    44 **/
    55
     6
    67//TODO: Add Purge cache buttons / functions.
    78//TODO: Add cache settings
    89//TODO: Add PMID exclude setting.
    910
     11
     12
    1013/* settings link in plugin management screen */
    1114function pm_pubmed_settings_link( $links ) {
     
    132135            if(isset($key)) {
    133136                $val = trim(wp_kses($val, ''));
     137
    134138            } // end if
    135139        } // end foreach
     
    139143            update_option('pm_publist_settings', $input);
    140144        }
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
    141155        return $input;
    142156    }
     
    149163    }
    150164    public function pm_publist_create_searchString_field($int){
     165
    151166        $options = get_option('pm_publist_settings');
    152167        ?><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
    153171    }
    154172    public function pm_publist_use_info(){
  • pubmed-publist/trunk/includes/core.php

    r700299 r700339  
    2929    $total = $show+$extra;
    3030
     31
    3132    $transient = 'pm_pubmedlist'.$show.$extra.$class.$layout;
     33
     34
     35
    3236    $pubs = get_transient( $transient );
    3337    if ( false === $pubs ) {
     
    170174
    171175            $xmlCache = pm_publist_DIR.'pm_cache.xml';
     176
    172177            //TODO: Sort caching out. Remove age chack from pubmedrequest.php and ue just this???
    173178            //Easier to get var from settings here.
     179
     180
    174181            $xmlcache_time = 60*60; // 1 hour
    175182            $timedif = @(time() - filemtime($xmlCache));
     
    193200                        return false;
    194201                    } else {
     202
    195203                        $strings = get_option('pm_publist_settings');
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
    196214                        $data = http_build_query($strings);
    197215
     
    224242        ////Create page
    225243        $pubs = '<ul class="pm_publist '.$class.'">'.implode($lmbpubs[0]).'</ul>';
     244
    226245        global $show;
    227246        global $total;
    228247        if($show != $total) {
     248
     249
     250
    229251            //TODO: Add CSS / JS / Shortcode for this:
    230252            //$pubs .= do_shortcode('[toggle title="More papers"]<ul class="'.$class.'>'.implode($lmbpubs[1]).'</ul>[/toggle]');
     
    232254        };
    233255
     256
    234257        //for next time write transient cache file.
    235258        //but only if no error (basic check using length)
     
    237260        if (strlen($pubs) > 500){
    238261            set_transient($transient, $pubs, 60*30);
     262
     263
     264
     265
     266
     267
     268
     269
    239270        }
    240271    }
  • pubmed-publist/trunk/pm_publist.php

    r700299 r700339  
    33Plugin Name: PubMed Publist
    44Description: Shortcodes to display a list of publications from PubMed
     5
    56Version: 0.9.1
     7
     8
     9
    610Author: Phil Banks
    711*/
  • pubmed-publist/trunk/pm_pubmedrequest.php

    r700299 r700339  
    22////If Cache is good - use it
    33//define some variables.
     4
    45//TODO: Use options to set this cache time
    56//TODO: Check there isn't a WP function for writing to disk. Problems on some hosts???
     7
     8
    69$cache_time = 60*60*2; // 2 hours
    710$cache_file = dirname(__FILE__).'/pm_cache.xml';
     
    1417else {
    1518        $nodes = array();
     19
    1620        if(isset($_POST["searchString1"])) {
    1721            $search1 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["searchString1"].'&report=xml';
     
    4044
    4145        //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
    4277        $node_count = count($nodes);
    4378        $curl_arr = array();
     
    5994
    6095
     96
     97
     98
     99
    61100        //function to clean PubMed data so it is valid XML.
    62101        function cleanPubmed($dirtyPubmed) {
     
    71110            $query = array();
    72111            foreach ($xml1->PubmedArticle as $paper) {
    73                 $query[] = sprintf('(MedlineCitation/PMID != %s)',$paper->MedlineCitation->PMID);
     112            $query[] = sprintf('(MedlineCitation/PMID != %s)',$paper->MedlineCitation->PMID);
    74113            }
    75114            $query = implode('and', $query);
     
    77116            $xmlClean = '<Document>';
    78117            foreach ($xml2->xpath(sprintf('PubmedArticle[%s]', $query)) as $paper) {
    79                 $xmlClean .= $paper->asXML();
     118            $xmlClean .= $paper->asXML();
    80119            }
    81120            $xmlClean .= '</Document>';
     
    103142
    104143
     144
    105145        //Loop through set nodes and clean/convert
     146
     147
     148
    106149        for($i = 0; $i < $node_count; $i++) {
    107150            $num = $i+1;
     
    111154            ${"xml$num"} = new SimpleXMLElement(${"search$num"});
    112155        }
     156
    113157        //Loop through nodes and dedupe/merge
     158
     159
     160
    114161        $output = $xml1;
    115162        if ($node_count > 1) {
    116163            for($i = 0; $i < $node_count-1; $i++) {
    117164                $num = $i+2;
     165
     166
     167
     168
     169
    118170                ${"xml$num.clean"} = dedupeXML($output,${"xml$num"});
    119171                $output = mergeXML($output,${"xml$num.clean"});
  • pubmed-publist/trunk/readme.txt

    r700299 r700339  
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
     10
    1011
    1112Simple shortcode to get and display latest publications from PubMed using a PubMed search URL(s).
    1213
    1314
     15
     16
     17
     18
    1419== Description ==
    1520
     
    1823The shortcode accepts arguments to set how many papers are displayed, apply classes for custom styling, and choose from two layout options.
    1924
     25
     26
     27
     28
     29
     30
    2031
    2132= Roadmap =
     
    2637* Add JS for show/hide extra results on front-end
    2738
     39
    2840
     41
     42
    2943== Installation ==
    3044
     
    35491. Or use `<?php do_shortcode('recentpublications'); ?>` in your templates
    3650
     51
    3752
     53
     54
    3855== Frequently Asked Questions ==
    3956
     
    4461= Can I contribute to the plugin / suggest a change? =
    4562
     63
    4664Please do! [The project is hosted on GitHub here](http://github.com/emirpprime/PubMedPublist).
    4765
     66
     67
     68
    4869
    4970== Screenshots ==
     
    54751. Settings screen
    5576
     77
    5678
    5779== Changelog ==
     
    6284
    6385= 0.9 =
     86
     87
     88
     89
     90
     91
    6492* Initial Beta Release
Note: See TracChangeset for help on using the changeset viewer.