Skip to content

Commit e1bdae6

Browse files
committed
Add missing function getTailHtml().
1 parent 77e96da commit e1bdae6

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • app/code/community/Kiatng/Shooter/Helper

app/code/community/Kiatng/Shooter/Helper/File.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ public function tail(string $filepath, int $lines = 10)
5757
}
5858
}
5959

60+
/**
61+
* Get the tail of a file as HTML
62+
*
63+
* @param string $filepath Path to the file to read
64+
* @param int $lines Number of lines to read (must be positive)
65+
* @return string Returns the tail of the file as HTML or an empty string if no tail is found
66+
*/
67+
public function getTailHtml(string $filepath, int $lines = 10): string
68+
{
69+
if ($tail = $this->tail($filepath, $lines)) {
70+
$tail = print_r($tail, true);
71+
$dt = Mage::getSingleton('core/date')->date('Y-m-d H:i:s', filemtime($filepath));
72+
return "<h3>$filepath <em>$dt</em></h3><pre>$tail</pre>";
73+
}
74+
75+
return '';
76+
}
77+
6078
/**
6179
* Get the latest file in a directory
6280
*

0 commit comments

Comments
 (0)