1) { $key = $param[1]; } else { $key = ""; } // Key must be names followed by a year and possibly a lower case letter if(!preg_match("/^[A-Z][A-Za-z]+[1-2][0-9][0-9][0-9][a-z]?$/", $key)) { $key = ""; } $refs = db_readTable("refs"); if($key == "") { // list all refs in alpha order printHead("List of References"); printSmallMasthead($currentyear); //echo "
"; echo "
"; echo "

List of References

\n"; //echo ""; for($i = 1; $i < count($refs); $i++) { $ref = $refs[$i]; $reflist[$ref["key"]] = $ref; } ksort($reflist); echo "
    "; foreach ($reflist as $key => $ref) { echo "
  • "; printRef($ref); echo "
  • "; } echo "
"; echo "
"; printMenu(); } else { $ref = db_get_first($refs, "key", $key); if($ref != null) { printRef($ref); } else { echo "

Reference not found.

"; } } } function formatRef($key) { $refs = db_readTable("refs"); $ref = db_get_first($refs, "key", $key); $text = $ref["author"] . " (" . $ref["year"] . ") " . $ref["title"] . ". " . $ref["details"] . "."; $myHtml = SmartyPants(markdown($text)); return $myHtml; } function printRef($ref) { $text = $ref["author"] . " (" . $ref["year"] . ") " . $ref["title"] . ". " . $ref["details"] . "."; $myHtml = SmartyPants(markdown($text)); echo $myHtml; } if($param[0] == "toc") { // ------------------------------------- TOC $matched = true; printHead("Table of Contents"); printSmallMasthead($currentyear); echo "
"; printTOC($year); echo "
"; printMenu(); } if($param[0] == "board") { // ------------------------------------- BOARD $matched = true; include_once "php/markdown.php"; include_once "php/smartypants.php"; printHead("Editorial Board"); printSmallMasthead($currentyear); $text = file_get_contents("ELR.data/board.md"); $myHtml = SmartyPants(markdown($text)); echo '
'; echo $myHtml; echo "
"; printMenu(); } if($param[0] == "news") { // ------------------------------------- NEWS $matched = true; include_once "php/markdown.php"; include_once "php/smartypants.php"; printHead("ELR Journal - News and Updates"); printSmallMasthead($currentyear); $text = file_get_contents("ELR.data/news.md"); $myHtml = SmartyPants(markdown($text)); echo '
'; echo $myHtml; echo "
"; printMenu(); } if($param[0] == "call") { // ------------------------------------- CALL $matched = true; include_once "php/markdown.php"; include_once "php/smartypants.php"; printHead("Call for Papers"); printSmallMasthead($currentyear); $text = file_get_contents("ELR.data/call.md"); $myHtml = SmartyPants(markdown($text)); echo '
'; echo $myHtml; echo "
"; printMenu(); } if($param[0] == "styleguide") { // ---------------------------- STYLEGUIDE $matched = true; include_once "php/markdown.php"; include_once "php/smartypants.php"; printHead("Guidelines for Authors"); printSmallMasthead($currentyear); $text = file_get_contents("ELR.data/styleguide.md"); $myHtml = SmartyPants(markdown($text)); echo '
'; echo $myHtml; echo "
"; printMenu(); } if($param[0] == "article") { // ------------------------------------- ARTICLE $matched = true; include_once "php/markdown.php"; include_once "php/smartypants.php"; printHead("Article"); if(count($param) > 1) { if(preg_match("/^20[0-9][0-9]$/", $param[1])) $year = $param[1]; else $year = $currentyear; } printSmallMasthead($year); if(count($param) > 2) { if(preg_match("/^[0-9]+$/", $param[2])) $number = $param[2]; else $number = ""; } //echo "

year = $year

"; //echo "

number = $number

"; if($year == "" || $number == "") { echo "
"; printTOC($year); echo "
"; printMenu(); exit; } $published = db_readTable("articles"); $pubyear = db_get_all($published,"year", $year); $pubnum = db_get_first($pubyear,"number", $number); if($pubnum == null || ($pubnum["status"] != "published" && $pubnum["status"] != "draft")) { echo "
"; echo "

The requested article ($number/$year) does not exist.

"; echo "
"; printMenu(); exit; } $cachedpath = "ELR.data/" . $cachedir . "/" . $year . "_" . $number . ".html"; //echo "

cachedpath = $cachedpath

"; if(file_exists($cachedpath)) { $time = filemtime($cachedpath); } else { $time = 0; } $path="ELR.data/" . $year . "/" . $number . "/" . "article.md"; $refpath="ELR.data/" . $year . "/" . $number . "/" . "refs"; //echo "

path = $path

"; if(file_exists($path)) { echo '
'; $orgtime = filemtime($path); if($time <= $orgtime) { // cache copy is out of date $text = file_get_contents($path); $bib = ""; if(file_exists($refpath)) { // are there references? $refs = file($refpath); ksort($refs); $bib = "
    "; for($i = 0; $i < count($refs); $i++) { $ref = trim($refs[$i]); $text = $text . "\n[" . $ref . "]: http://ejournals.org.uk/ELR/reference/" . $ref; $bib = $bib . "
  • " . formatRef($ref) . "
  • \n"; } $bib = $bib . "
"; } $myHtml = SmartyPants(markdown($text)); if(file_exists($refpath)) { $myHtml = $myHtml . "

References

\n" . $bib; } $handle = fopen($cachedpath, "w"); if(!$handle) { //echo $header; echo $myHtml; //echo $footer; exit; } else { //fwrite($handle, $header); fwrite($handle, $myHtml); //fwrite($handle, $footer); fclose($handle); } } include($cachedpath); # # Show bibliographical reference at bottom of paper # $articles = db_readTable("articles"); for($i = 1; $i < count($articles); $i++) { $article = $articles[$i]; if($article["year"] == $year && $article["number"] == $number) { echo "


"; echo $article["author"] . " (" . $article["year"] . ") "; echo "“" . $article["title"] . "”," ; echo " ELR Journal, "; echo ($article["year"] - 2006) . " (" . $article["number"]; echo ")."; } } echo '
'; } else { echo "

Article does not exist.

"; echo "Back to main page."; exit; } printMenu(); } // ---------- END OF ARTICLE ------------ if(!$matched) { //------------------------------------ DEFAULT HOME PAGE include_once "php/markdown.php"; include_once "php/smartypants.php"; printHead("Home Page"); date_default_timezone_set('GMT'); printSmallMasthead(date("o")); echo "
"; printTOC(""); echo "
"; printMenu(); } function printHead($title) { global $FONT_FAMILY; echo "\n"; echo "\n"; echo "\n"; echo "ELR Journal - $title\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo "\n"; } function printSmallMasthead($year) { echo ""; echo "
\n"; echo "ELR Journal\n"; echo "
\n"; echo "\n"; echo "\n"; $vol = $year - 2006; echo "\n"; echo "\n"; echo "
Empirical Language Research
vol $vol
ISSN 1746-6830
\n"; echo "
\n"; echo "
\n"; } function printMenu() { global $root; echo "
"; echo "\n"; printTracker(); printAds(); echo "
\n"; echo "\n"; echo "\n"; } function printTOC($year) { global $root; $table = db_readTable("articles"); $published = db_get_all($table, "status", "published"); if($year == "") { $pubyear = $published; } else { $pubyear = db_get_all($published, "year", $year); } if(is_array($pubyear)) { foreach($pubyear as $key => $row) { $yr[$key] = $row["year"]; $no[$key] = $row["number"]; } array_multisort($yr, SORT_ASC, $no, SORT_ASC, $pubyear); $year = 0; foreach($pubyear as $key => $row) { if($row["year"] != $year) { $year = $row["year"]; $vol = $year - 2006; echo "Vol. $vol ($year)\n"; echo "
"; } echo "
"; echo "" . $row["author"] . "\n"; echo "   "; echo "" . $row["title"] . "\n"; echo "(Nr " . $row["number"] . ")"; echo "
"; echo "
"; } } } function printAtomFeed() { header("Content-Type: application/atom+xml; charset=utf-8"); echo ""; echo ""; echo "ELR Journal"; echo "Empirical Language Research"; echo ""; //echo "2003-12-13T18:30:02Z"; echo "http://ejournals.org.uk/ELR"; $articles = db_readTable("articles"); for($i = 1; $i < count($articles); $i++) { $article = $articles[$i]; if($article["status"] == "published") { echo "\n"; echo ""; echo $article["author"] . ": “" . $article["title"] . "”"; echo "\n"; echo "http://ejournals.org.uk/ELR/article/" . $article["year"]; echo "/" . $article["number"] . "\n"; echo "http://ejournals.org.uk/ELR/article/" . $article["year"]; echo "/" . $article["number"] . "\n"; echo "" . $article["date"] . "\n"; echo "
" . $article["abstract"] . "
\n"; echo "
\n"; } } echo "
"; } function printRSSFeed() { header("Content-Type: application/rss+xml; charset=utf-8"); echo ""; echo ''; echo ''; echo 'ELR Journal'; echo ''; echo 'This feed contains information about the articles published'; echo 'in the on-line journal Empirical Language Research.'; echo ''; echo 'http://ejournals.org.uk/ELR/'; $articles = db_readTable("articles"); for($i = 1; $i < count($articles); $i++) { $article = $articles[$i]; if($article["status"] == "published") { echo "\n"; echo ""; echo $article["author"] . ": “" . $article["title"] . "”"; echo "\n"; echo "" . $article["abstract"] . "\n"; echo "" . $article["date"] . "\n"; echo "http://ejournals.org.uk/ELR/article/" . $article["year"]; echo "/" . $article["number"] . "\n"; echo "http://ejournals.org.uk/ELR/article/" . $article["year"]; echo "/" . $article["number"] . "\n"; echo "\n"; } } echo ''; echo ''; } function printTracker() { echo ''; echo ''; } function printAds() { return; echo ""; echo ""; } ?>