application/Controllers/AjaxControllers/Write.php
/**
     * Return list of articles requested asynchronously
     * Format title, tagline, content
     * Format datetypes to correct format
     * Get all articles of id < lastId
     * Default last_id = 0
     * 
     * @route true
     * @param int $lastId - Last article id recieved by user
     */
Return list of articles requested asynchronously
Format title, tagline, content
Format datetypes to correct format
Get all articles of id < lastId
Default last_id = 0

@route true
@param int $lastId - Last article id recieved by user
Return list of articles requested asynchronously Format title tagline content Format datetypes to correct format Get all articles of id < lastId Default last_id = 0 @route true @param int $lastId - Last article id recieved by user
public function loadArticles(int $lastId) {
        $data = [];
        $data['articles'] = $this->writeModel->fetchArticles($this->articlesOnPage, $lastId);
        $data['status'] = 500;
        $data['last_id'] = 0;
        foreach($data['articles'] as $article) {
            $data['status'] = 200;
            $data['last_id'] = $article->id;
            $article->title = Str::stripNewLines($article->title);
            $article->tagline = Str::stripNewLines($article->tagline);
            $article->content = Html::getChars($article->content);
            $article->created_at = Str::formatEpoch(strtotime($article->created_at), "d/m H:i");
            $article->last_edited = Str::formatEpoch(strtotime($article->last_updated), "d/m H:i");
        }
        echo json_encode($data);
    }
public function loadArticles ( int $ lastId ) { $ data = [ ] ; $ data [ 'articles' ] = $ this -> writeModel -> fetchArticles ( $ this -> articlesOnPage , $ lastId ) ; $ data [ 'status' ] = 500 ; $ data [ 'last_id' ] = 0 ; foreach ( $ data [ 'articles' ] as $ article ) { $ data [ 'status' ] = 200 ; $ data [ 'last_id' ] = $ article -> id ; $ article -> title = Str :: stripNewLines ( $ article -> title ) ; $ article -> tagline = Str :: stripNewLines ( $ article -> tagline ) ; $ article -> content = Html :: getChars ( $ article -> content ) ; $ article -> created_at = Str :: formatEpoch ( strtotime ( $ article -> created_at ) , " d/m H:i " ) ; $ article -> last_edited = Str :: formatEpoch ( strtotime ( $ article -> last_updated ) , " d/m H:i " ) ; } echo json_encode ( $ data ) ; }
Return list of articles requested asynchronously
 Format title, tagline, content
 Format datetypes to correct format
 Get all articles of id < lastId
 Default last_id = 0
Return list of articles requested asynchronously Format title tagline content Format datetypes to correct format Get all articles of id < lastId Default last_id = 0