BlogNav.php 602 B

1234567891011121314151617181920212223242526
  1. <?php
  2. class BlogNav implements INavigationController{
  3. private $_uri;
  4. public function __construct() {
  5. $this->_uri=new URI("Blog","/blog","/images/blog.svg");
  6. }
  7. public function GetItems() {
  8. $repo=new BlogPostRepository();
  9. $posts=$repo->GetLatest(5);
  10. $links=array();
  11. foreach ($posts as $post){
  12. $title=$post->PostTitle;
  13. if (strlen($title)>50)
  14. $title=substr($title,0,47).'...';
  15. $links[]=new URI($title, "view/".$post->PostUrl);
  16. }
  17. $links[]=new URI("<i>View all</i>","");
  18. return $links;
  19. }
  20. public function GetURI() {
  21. return $this->_uri;
  22. }
  23. }