Code

Project: jvfeatures

jvtypes.h      jvfeatures.h      chessSeg.cpp      jvtypes.cpp      jvtest.cpp      jvfeatures.cpp     

Project: Other

migrateMailbox.scpt.txt     

Project: Infinite HMM Tutorial

run.m      iHMM_tutorial.zip      HDP_HMM.m      README.txt      ConditionalProbabilityTable.m      HDP.m      HMMProblem.m      HMM.m     

Project: RRT

RRT.h      plot_output.py      RRT.tgz      rrt_test.cpp      RRT.cpp      BidirectionalRRT.cpp      AbstractRRT.cpp     

Project: Box2D_friction_mod

WheelConstraint.h      test_TopDownCar.py      b2FrictionJoint.h      python_friction_joint.patch      test_TopDownFrictionJoint.py      TestEntries.cpp      TopDownCar.h      b2FrictionJoint.cpp      box2d_friction_joint.patch     

Project: Dirichlet Process Mixture Tutorial

EM_GM.m      DP_Demo.m      DPMM.m      DP_Tutorial.zip      DirichletProcess.m      gaussian_EM.m     

Project: Arduino_Code

plot_ardunio_data.sh      Arduino_Code.zip      convert_range2D.py      arduino-serial.c      oscilloscope.sh      oscilloscope.pde      motordriver.pde      helicopter_controller.pde      accelerometer_test.pde      ranger_plane_sweep.pde      clodbuster_controller.pde      pwm_manual.pde      ranger_test.pde      servo_test.pde     

Project: ArduCom

arducom.py      setup.py     

Project: support

geshi.php      Protector.php     

Project: Cogent

CodePane.php      NotesPane.php      PicsPane.php      Cogent.php      PubsTable.php     
Click here to download "resources/site-code/Cogent/PubsTable.php"

resources/site-code/Cogent/PubsTable.php

<?php
require("Cogent.php");
/**
* PubsTable
* A class for generating HTML tables of publication PDFs by scanning directories
* containing folders of PDF files.  For each directory found, PubsTable
* will add an album (top-level div) with a heading of that name.
*
* Outline:
* PicsPane("<directory name>")
* PicsPane->run();      // generates HTML output for all images found, organized by album
*
* Author: Jonathan Scholz
* 2/3/2010
*/


class PubsTable extends Cogent
{
        /**
        * Like the list_content() function in the base class, except fancier.  Instead
        * of just returning the filtered list of files found, this function creates a
        * dictionary of fields for information from the filename, and returns an array
        * containing both the raw filename and the dictionary of parsed information as a
        * tuple (array)
        * Both arrays within this tuple are sorted by the date field of the parsed filenames
        */

public function list_and_parse($dir) {
        // The delimiters for parsing filenames
        $tokens = "()";

        $hndl = opendir($dir);
        if ($hndl == false) {
                print "Could not find directory $dir";
                exit;
        } else {
                while (false !== ($item = readdir($hndl))) {
                        // Get file extension
                        $ext = substr(strrchr($item, '.'), 1);

                        // Match against filter
                        if (Cogent::in_arrayi($ext, $this->filters)) {
                                // Extract tokens (hard coded tokens for now)
                                $items_toks[] = array("author" => strtok($item, $tokens),
                                        "date" => strtok($tokens),
                                        "title" => strtok($tokens),
                                        "journal" => strtok($tokens));
                                $items[] = $item;
                        }
                }
                closedir($hndl); // close directory

                // Now sort both arrays by the "date" key
                if (isset($items) && count($items)!=0) {
                        foreach ($items_toks as $key => $row) {
                                // Create an array of dates, in the order they appear originally
                                $dates[$key] = $row['date'];
                        }
                        // Sort the full names (items) and the tokenized array by ascending $dates elements
                        array_multisort($dates,SORT_DESC,$items_toks,$items);
                        return array($items, $items_toks);
                }
        }
        return;
}

/**
* Generates HTML for a table of publications organized by category
*/

protected function generate($dir, $files){
        print '<table class="pubs">'."\n\n";
        // Fetch PDFs & parse
        $all_PDF_info = $this->list_and_parse($this->rootdir."/".$dir);


        // Write out the section heading
        print '<tr><td class="pubs_section">'.$dir.'</td>';
        print '<td style="text-align: center;">download</td></tr>';
        if (count($all_PDF_info[0])==0) {
                print '<tr><td class="pubs_entry_disc">Working on it...</td>';
                print '<td class="pubs_entry_link"></td></tr>'."\n\n"; // print second cell
        }
        else {
                for ($paper=0; $paper < count($all_PDF_info[0]); $paper++) {
                        // write the table row and start the text column:
                        print '<tr><td class="pubs_entry_disc">';

                        // write the authors:
                        print $all_PDF_info[1][$paper]['author'];

                        // write the date:
                        print "(".$all_PDF_info[1][$paper]['date'].")";

                        //write the title (in bold):
                        print "<strong>".$all_PDF_info[1][$paper]['title']."</strong>";

                        //write the journal (in parens):
                        print "<i>".$all_PDF_info[1][$paper]['journal']."</i>";
                        //close td:
                        print '</td>'."\n";

                        // Write the link to the actual file, which is the 1st element of the main info array
                        print '<td class="pubs_entry_link"><a href="'.
                        $this->rootdir."/".$dir."/".$all_PDF_info[0][$paper].'" '.              //  set target
                        'onClick="_gaq.push([\'_trackEvent\', \'Publication\', \'Downloaded\', \''.$all_PDF_info[0][$paper].'\']);">'. // install tracker
                        '<img src="resources/icons/pdf-icon.jpg" /></a></td></tr>'."\n\n";
                }
        }
        print '</table>'."\n";
        }
} // End: class PubsTable


?>

About me

Pic of me