Page MenuHomeDevCentral

No OneTemporary

diff --git a/pages/index.dat b/pages/index.dat
index d378813..ee5aeae 100644
--- a/pages/index.dat
+++ b/pages/index.dat
@@ -1,5 +1,6 @@
http://www.erudit.org/ Erudit
http://www.lalibre.be/ LaLibreBelgique
http://www.lesoir.be/ LeSoir
http://archives.lesoir.be/ LeSoir
http://www.rue89.com/ Rue89
+http://www.tandfonline.com TaylorAndFrancis
diff --git a/pages/taylorandfrancis.php b/pages/taylorandfrancis.php
new file mode 100644
index 0000000..4913c70
--- /dev/null
+++ b/pages/taylorandfrancis.php
@@ -0,0 +1,76 @@
+<?php
+
+//Page analysis for www.tandfonline.com
+class TaylorAndFrancisPage extends Page {
+ /**
+ * Initializes a new TaylorAndFrancisPage instance. If an error occured, you can read it in $this->error.
+ *
+ * @param string $url the page URL
+ */
+ function __construct ($url) {
+ $this->url = $url;
+ $this->data = self::curl_download($url);
+ $this->analyse();
+ }
+
+ function analyse () {
+ parent::analyse();
+ $this->publisher = 'Taylor & Francis';
+
+ //DOI
+ $this->doi = self::between('meta name="dc.Identifier" scheme="doi" content="', '"');
+
+ //Gets the right dc.Identifier (coden scheme)
+ //Expected format: <Issue name>, Vol. <Issue volume>, No. <Issue number>, <Issue date>, pp. <article pages>
+ //e.g. Annals of Science, Vol. 68, No. 3, July 2011, pp. 325–350
+ $identifier = self::between('meta name="dc.Identifier" scheme="coden" content="', '"');
+ $identifier_data = explode(', ', $identifier);
+
+ $pos = strpos($identifier, ", Vol. ");
+ $this->journal = substr($identifier, 0, $pos);
+
+ $this->volume = self::grab($identifier, "Vol. ", ",");
+ $this->issue = self::grab($identifier, "No. ", ",");
+
+ $date = explode(' ', $identifier_data[3]);
+ $this->yyyy = array_pop($date);
+
+ $pos = strpos($identifier, "pp. ");
+ $this->pages = substr($identifier, $pos + 4);
+
+ //Author
+ //TODO: handle several authors
+ $author = trim(self::getMetaTag($this->meta_tags, 'dc.Creator'));
+ $names = explode(' ', $author);
+ if (count($names) == 2) {
+ $this->author = "$names[1], $names[0]";
+ } else {
+ $this->author = $author;
+ }
+ }
+
+ function is_article () {
+ return true;
+ }
+
+ static function curl_download ($url) {
+ $ch = curl_init();
+ $timeout = 5;
+ $cookie_file = tmpfile();
+ $cookie_file = tempnam(sys_get_temp_dir(), "cookie-sourcesgen-");
+ curl_setopt($ch, CURLOPT_COOKIESESSION, true);
+ curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
+ curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+ $data = curl_exec($ch);
+ curl_close($ch);
+ unlink($cookie_file);
+ return $data;
+ }
+
+}
+
+?>
diff --git a/templates/wikipedia-fr/Article.php b/templates/wikipedia-fr/Article.php
index 8fd106a..8856a37 100644
--- a/templates/wikipedia-fr/Article.php
+++ b/templates/wikipedia-fr/Article.php
@@ -1,164 +1,178 @@
<?php
setlocale(LC_TIME, 'fr_FR.UTF-8');
class ArticleTemplate extends Template {
public $lang;
public $title;
public $periodique;
public $year;
public $accessdate;
function __construct () {
$this->name = "Article";
$this->accessdate = trim(strftime(LONG_DATE_FORMAT));
}
static function loadFromPage ($page) {
$template = new self();
$t = $page->meta_tags;
//Language
- $template->lang = page::getMetaTag($t, 'dc_language', 'citation_language');
+ $template->lang = page::getMetaTag($t, 'dc_language', 'citation_language', 'dc.Language');
//Authors
- if ($author = $page->author ?: page::getMetaTag($t, 'author', 'dc_creator', 'citation_authors', 'dc_contributor', 'citation_author')) {
+ if ($author = $page->author ?: page::getMetaTag($t, 'author', 'dc_creator', 'citation_authors', 'dc_contributor', 'citation_author', 'dc.Creator')) {
//TODO: handle Alpha Beta syntax instead Beta, Alpha
$template->authors[] = explode(', ', $author, 2);
}
//Title
if (!$template->title = page::getMetaTag($t, 'dc_title', 'citation_title')) {
$template->title = $page->title;
}
//Journal, publisher
- $template->journal = page::getMetaTag($t, 'prism_publicationname', 'citation_journal_title', 'og:site_name');
+ $template->journal = $page->journal ?: page::getMetaTag($t, 'prism_publicationname', 'citation_journal_title', 'og:site_name');
$template->journalLink = $t['dc_source'];
- $template->publisher = page::getMetaTag($t, 'dc_publisher', 'citation_publisher');
+ $template->publisher = $page->publisher ?: page::getMetaTag($t, 'dc_publisher', 'citation_publisher');
//Issue name, number and volume
- $template->issue = page::getMetaTag($t, 'prism_number', 'citation_issue');
- $template->volume = page::getMetaTag($t, 'citation_volume');
+ $template->issue = $page->issue ?: page::getMetaTag($t, 'prism_number', 'citation_issue');
+ $template->volume = $page->volume ?: page::getMetaTag($t, 'citation_volume');
if (
(!$template->issueName = $t['prism_issuename'])
&&
array_key_exists('dc_relation_ispartof', $t)
) {
$template->issueName = $t['dc_relation_ispartof']
. " <!-- !!! paramètre à nettoyer !!! -->";
}
//Date
if ($page->unixtime) {
$template->yyyy = date('Y', $page->unixtime);
$template->mm = date('m', $page->unixtime);
$template->dd = date('j', $page->unixtime);
} elseif ($date = page::getMetaTag($t, 'prism_publicationdate', 'dc_date', 'citation_date')) {
- $template->yyyy = substr($date, 0, 4);
- $template->mm = substr($date, 5, 2);
- $template->dd = substr($date, 8, 2);
+ if ($date[4] == '/' || $date[4] == '-' || $date[4] == '.') {
+ $template->yyyy = substr($date, 0, 4);
+ $template->mm = substr($date, 5, 2);
+ $template->dd = substr($date, 8, 2);
+ } else {
+ $template->yyyy = substr($date, 6, 4);
+ $template->mm = substr($date, 0, 2);
+ $template->dd = substr($date, 3, 2);
+ }
} else {
- $template->yyyy = page::getMetaTag($t, 'citation_year', 'citation_publication_date');
+ $template->yyyy = $page->yyyy ?: page::getMetaTag($t, 'citation_year', 'citation_publication_date');
}
//Pages
- $template->pageStart = page::getMetaTag($t, 'prism_startingpage', 'citation_firstpage', 'citation_first_page');
- $template->pageEnd = page::getMetaTag($t, 'prism_endingpage', 'citation_lastpage', 'citation_last_page');
+ if ($page->pages) {
+ $template->pageStart = $page->pages;
+ } else {
+ $template->pageStart = page::getMetaTag($t, 'prism_startingpage', 'citation_firstpage', 'citation_first_page');
+ $template->pageEnd = page::getMetaTag($t, 'prism_endingpage', 'citation_lastpage', 'citation_last_page');
+ }
//ISBN, ISSN, URLs
$template->issn = $page->issn ?: page::getMetaTag($t, 'prism_issn', 'citation_issn');
$template->isbn = page::getMetaTag($t, 'citation_isbn');
- $template->doi = page::getMetaTag($t, 'citation_doi');
+ $template->doi = $page->doi ?: page::getMetaTag($t, 'citation_doi');
$template->summary = page::getMetaTag($t, 'citation_abstract_html_url');
$template->url = self::getTextURL($page->url, $t);
return $template;
}
function __toString () {
//Langue
$this->params['langue'] = $this->lang;
//Auteur
- if (count($this->authors)) {
- $k = 1;
- foreach ($this->authors as $author) {
- $this->params["prénom$k"] = $author[1];
- $this->params["nom$k"] = $author[0];
- $this->params["lien auteur$k"] = '';
- $k++;
- }
+ if (!count($this->authors)) {
+ //Per http://fr.wikipedia.org/w/?&diff=93455862, print
+ //one blank set of lines for author when the article
+ //metadata doesn't offer author information.
+ $this->authors = [['', '']];
+ }
+ $k = 1;
+ foreach ($this->authors as $author) {
+ $this->params["prénom$k"] = $author[1];
+ $this->params["nom$k"] = $author[0];
+ $this->params["lien auteur$k"] = '';
+ $k++;
}
//Titre, périodique, éditeur, volume, etc.
$this->params['titre'] = $this->title;
$this->params['périodique'] = $this->journal;
//TODO: vérifier si l'aticle existe sur fr.wikip et contient l'infobox Presse ou est rattaché à une catégorie fille de [[Catégorie:Revue scientifique]]
//$this->params['lien périodique'] = $this->journal;
$this->params['éditeur'] = $this->publisher;
if ($this->volume) $this->params['volume'] = $this->volume;
$this->params['numéro'] = $this->issue;
if ($this->issueName) $this->params['titre numéro'] = $this->issueName;
//Date
if ($this->mm && $this->dd) {
$date = mktime(12, 0, 0, $this->mm, $this->dd, $this->yyyy);
$this->params['jour'] = trim(strftime('%e', $date));
$this->params['mois'] = strftime('%B', $date);
}
$this->params['année'] = $this->yyyy;
//Pages, ISSN, ISBN, DOI, URL, consulté le
$this->params['pages'] = $this->pageEnd ? ($this->pageStart . '-' . $this->pageEnd) : $this->pageStart;
if ($this->issn) $this->params['ISSN'] = $this->issn;
if ($this->isbn) $this->params['ISBN'] = $this->isbn;
if ($this->doi) $this->params['doi'] = $this->doi;
$this->params['url texte'] = $this->url;
if (self::isSummaryPertinent($this->url, $this->summary)) {
$this->params['résumé'] = $this->summary;
}
$this->params['consulté le'] = trim(strftime(LONG_DATE_FORMAT));
return parent::__toString();
}
/**
* Gets article full text URL
*
* @param string $url the article current URL
*
* @return string the article fulltext URL
*/
static function getTextURL ($url, $metatags) {
if (strpos($url, '.revues.org/') > 0) {
//revues.org PDF generation is broken
return $url;
}
if ($text_url = page::getMetaTag($metatags, 'citation_pdf_url', 'citation_fulltext_html_url')) {
return $text_url;
}
return $url;
}
/**
* Determines if a summary is pertinent to include in parameters
*
* @param string $url_article Article URL
* @param string $url_summary Summary URL
*
* @return bool true if the summary URL should be included in templat ; otherwise, false
*/
static function isSummaryPertinent ($url_article, $url_summary) {
//Empty summary or identical to URL are rejected
if ($url_summary == '' || $url_summary == $url_article) return false;
//This site is indexed through /resume.php but gives /article.php as summary URL in metadata
if (substr($url_article, 0, 32) == "http://www.cairn.info/resume.php") return false;
return true;
}
}
?>

File Metadata

Mime Type
text/x-diff
Expires
Fri, Sep 12, 20:53 (22 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2978156
Default Alt Text
(10 KB)

Event Timeline