Explorar o código

Add machine-readable dates in views (#3106)

This will allow to make some transformations on dates when needed.
See #3103 and #853
Alexis Degrugillier %!s(int64=5) %!d(string=hai) anos
pai
achega
8d8211b2a5

+ 4 - 2
app/Models/Entry.php

@@ -87,9 +87,11 @@ class FreshRSS_Entry extends Minz_Model {
 	public function date($raw = false) {
 		if ($raw) {
 			return $this->date;
-		} else {
-			return timestamptodate($this->date);
 		}
+		return timestamptodate($this->date);
+	}
+	public function machineReadableDate() {
+		return @date (DATE_ATOM, $this->date);
 	}
 	public function dateAdded($raw = false, $microsecond = false) {
 		if ($raw) {

+ 1 - 1
app/views/helpers/index/normal/entry_bottom.phtml

@@ -107,7 +107,7 @@
 		<?php } ?>
 	</li><?php
 	if ($bottomline_date) {
-		?><li class="item date"><?= $this->entry->date() ?></li><?php
+		?><li class="item date"><time datetime="<?= $this->entry->machineReadableDate() ?>"><?= $this->entry->date() ?></time>&nbsp;</li><?php
 	}
 	if ($bottomline_link) {
 		?><li class="item link"><a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>"><?= _i('link') ?></a></li><?php

+ 1 - 1
app/views/helpers/index/normal/entry_header.phtml

@@ -44,6 +44,6 @@
 			?></span><?php
 		endif;
 	?></a></li>
-	<?php if ($topline_date) { ?><li class="item date"><?= $this->entry->date() ?> </li><?php } ?>
+	<?php if ($topline_date) { ?><li class="item date"><time datetime="<?= $this->entry->machineReadableDate() ?>"><?= $this->entry->date() ?></time>&nbsp;</li><?php } ?>
 	<?php if ($topline_link) { ?><li class="item link"><a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>"><?= _i('link') ?></a></li><?php } ?>
 </ul>

+ 1 - 2
app/views/index/reader.phtml

@@ -62,8 +62,7 @@ $content_width = FreshRSS_Context::$user_conf->content_width;
 						endforeach;
 						echo ' — ';
 					endif;
-					echo $item->date();
-				?></div><div class="text">
+				?><time datetime="<?= $item->machineReadableDate() ?>"><?= $item->date() ?></time></div><div class="text">
 				<?= $item->content() ?>
 			</div></div>
 		</div>