Page MenuHomeDevCentral

D29.id60.diff
No OneTemporary

D29.id60.diff

diff --git a/pages/lemonde.php b/pages/lemonde.php
--- a/pages/lemonde.php
+++ b/pages/lemonde.php
@@ -18,11 +18,27 @@
$this->unixtime = mktime(0, 0, 0, $mm, $dd, $yyyy);
$this->date = strftime(LONG_DATE_FORMAT, $this->unixtime);
- //Gets author
+ $this->author = $this->getAuthor();
+ }
+
+ /**
+ * Gets the author of the article
+ *
+ * @return string the article's author
+ */
+ public function getAuthor () {
+ //Gets author field from HTML code
//e.g. <span itemprop="author" class="auteur txt12_120">Stéphanie Le Bars</span>
//TODO: ensure no article has more than one author
$author = self::between('itemprop="author"', '</');
$pos = strpos($author, '">') + 2;
- $this->author = substr($author, $pos);
+ $author = trim(substr($author, $pos));
+
+ if ($author[0] == '<') {
+ $pos = strpos($author, '>') + 1;
+ return substr($author, $pos);
+ }
+
+ return $author;
}
}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 01:40 (8 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2314204
Default Alt Text
D29.id60.diff (1 KB)

Event Timeline