Plugin Directory

Changeset 700299

Timestamp:
04/19/2013 01:13:18 PM (11 years ago)
Author:
emirpprime
Message:

v0.9.1

Clean up PHP errors
Migrate to Options array
Housekeeping

Location:
pubmed-publist/trunk
Files:
5 edited

Legend:

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

    r700297 r700299  
    33 * Admin functions PubMed Publist plugin
    44 **/
     5
     6
     7
     8
    59
    610/* settings link in plugin management screen */
     
    128132            if(isset($key)) {
    129133                $val = trim(wp_kses($val, ''));
    130 
    131                 if(get_option('pm_publist_'.$key) === FALSE){
    132                     add_option('pm_publist_'.$key, $val);
    133                 }else{
    134                     update_option('pm_publist_'.$key, $val);
    135                 }
    136134            } // end if
    137135        } // end foreach
     136
     137
     138
     139
     140
    138141        return $input;
    139142    }
     
    146149    }
    147150    public function pm_publist_create_searchString_field($int){
    148         ?><textarea style="width:100%;" rows="5" id="searchString<?php echo $int;?>" name="array_key[searchString<?php echo $int;?>]"><?php echo get_option('pm_publist_searchString'.$int);?></textarea><?php
     151        $options = get_option('pm_publist_settings');
     152        ?><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
    149153    }
    150154    public function pm_publist_use_info(){
  • pubmed-publist/trunk/includes/core.php

    r700297 r700299  
    2929    $total = $show+$extra;
    3030
    31     if ($layout) : $transient = 'pm_pubmedlist'.$show.$total.$class.$layout; else : $transient = 'pm_pubmedlist'.$show.$total.$class.$layout; endif;
     31    ;
    3232    $pubs = get_transient( $transient );
    3333    if ( false === $pubs ) {
     
    170170
    171171            $xmlCache = pm_publist_DIR.'pm_cache.xml';
     172
     173
    172174            $xmlcache_time = 60*60; // 1 hour
    173175            $timedif = @(time() - filemtime($xmlCache));
     
    191193                        return false;
    192194                    } else {
    193                         //TODO: must be a better way of handling this.
    194                         $strings = array();
    195                         if (get_option('test_searchString1')) { array_push($strings,get_option('test_searchString1')); };
    196                         if (get_option('test_searchString2')) { array_push($strings,get_option('test_searchString2')); };
    197                         if (get_option('test_searchString3')) { array_push($strings,get_option('test_searchString3')); };
    198                         if (get_option('test_searchString4')) { array_push($strings,get_option('test_searchString4')); };
    199                         if (get_option('test_searchString5')) { array_push($strings,get_option('test_searchString5')); };
    200                         if (get_option('test_searchString6')) { array_push($strings,get_option('test_searchString6')); };
     195                        $strings = get_option('pm_publist_settings');
    201196                        $data = http_build_query($strings);
    202197
     
    229224        ////Create page
    230225        $pubs = '<ul class="pm_publist '.$class.'">'.implode($lmbpubs[0]).'</ul>';
    231         if($lmbpubs[1]) {
     226        global $show;
     227        global $total;
     228        if($show != $total) {
    232229            //TODO: Add CSS / JS / Shortcode for this:
    233230            //$pubs .= do_shortcode('[toggle title="More papers"]<ul class="'.$class.'>'.implode($lmbpubs[1]).'</ul>[/toggle]');
     
    235232        };
    236233
    237         //for next time
    238         //write transient cache file.
     234        //for next time write transient cache file.
    239235        //but only if no error (basic check using length)
     236
    240237        if (strlen($pubs) > 500){
    241             //set_transient($transient, $pubs, 60*30);
    242             set_transient($transient, $pubs, 30);
     238            set_transient($transient, $pubs, 60*30);
    243239        }
    244240    }
  • pubmed-publist/trunk/pm_publist.php

    r700297 r700299  
    33Plugin Name: PubMed Publist
    44Description: Shortcodes to display a list of publications from PubMed
    5 Version: 0.9
     5Version: 0.9
    66Author: Phil Banks
    77*/
  • pubmed-publist/trunk/pm_pubmedrequest.php

    r700297 r700299  
    22////If Cache is good - use it
    33//define some variables.
     4
     5
    46$cache_time = 60*60*2; // 2 hours
    57$cache_file = dirname(__FILE__).'/pm_cache.xml';
     
    1214else {
    1315        $nodes = array();
    14         //TODO: Make multi string compatible. Work out how to test how many then do appropriate for that many.
    15         if(isset($_POST["0"])) {
    16             $search1 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["0"].'&report=xml';
     16        if(isset($_POST["searchString1"])) {
     17            $search1 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["searchString1"].'&report=xml';
    1718            array_push($nodes, $search1);
    1819        }
    19         if(isset($_POST["1"])) {
    20             $search2 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["1"].'&report=xml';
     20        if(isset($_POST[""])) {
     21            $search2 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST[""].'&report=xml';
    2122            array_push($nodes, $search2);
    2223        }
    23         if(isset($_POST["2"])) {
    24             $search3 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["2"].'&report=xml';
     24        if(isset($_POST[""])) {
     25            $search3 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST[""].'&report=xml';
    2526            array_push($nodes, $search3);
    2627        }
    27         if(isset($_POST["3"])) {
    28             $search4 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["3"].'&report=xml';
     28        if(isset($_POST[""])) {
     29            $search4 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST[""].'&report=xml';
    2930            array_push($nodes, $search4);
    3031        }
    31         if(isset($_POST["4"])) {
    32             $search5 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["4"].'&report=xml';
     32        if(isset($_POST[""])) {
     33            $search5 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST[""].'&report=xml';
    3334            array_push($nodes, $search5);
    3435        }
    35         if(isset($_POST["5"])) {
    36             $search6 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST["5"].'&report=xml';
     36        if(isset($_POST[""])) {
     37            $search6 = 'http://www.ncbi.nlm.nih.gov/pubmed?term='.$_POST[""].'&report=xml';
    3738            array_push($nodes, $search6);
    3839        }
    3940
    40 
    4141        //get PubMed data as XML using parallel cURL requests for speed.
    42         ////$nodes = array($search1, $search2, $search3, $search4, $search5, $search6);
    4342        $node_count = count($nodes);
    4443        $curl_arr = array();
     
    5857            ${"search$num"} = curl_multi_getcontent  ( $curl_arr[$i]  );
    5958        }
    60 
    6159
    6260
     
    105103
    106104
    107         //Loop through set nodes and process them
     105        //Loop through set nodes and
    108106        for($i = 0; $i < $node_count; $i++) {
    109107            $num = $i+1;
     
    113111            ${"xml$num"} = new SimpleXMLElement(${"search$num"});
    114112        }
    115 
     113        //Loop through nodes and dedupe/merge
    116114        $output = $xml1;
    117115        if ($node_count > 1) {
    118116            for($i = 0; $i < $node_count-1; $i++) {
    119117                $num = $i+2;
    120                 error_log($num);
    121 
    122118                ${"xml$num.clean"} = dedupeXML($output,${"xml$num"});
    123119                $output = mergeXML($output,${"xml$num.clean"});
  • pubmed-publist/trunk/readme.txt

    r700298 r700299  
    5757== Changelog ==
    5858
     59
     60
     61
     62
    5963= 0.9 =
    60 
    6164* Initial Beta Release
Note: See TracChangeset for help on using the changeset viewer.