Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3937589
D29.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D29.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 19:21 (16 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2314204
Default Alt Text
D29.diff (1 KB)
Attached To
Mode
D29: Extract author from Le Monde article
Attached
Detach File
Event Timeline
Log In to Comment