Example #1
0
use BloggerCMS\Category;
use BloggerCMS\Tag;
use BloggerCMS\Image;
// dashboard
$app->get('/', function () use($app) {
    set_time_limit(0);
    $post = new Post();
    $page = new Page();
    $category = new Category();
    $tag = new Tag();
    $image = new Image();
    $data['totalPosts'] = $post->getTotalPostsCount();
    $data['totalPostsPublished'] = $post->getTotalPostsCountPublished();
    $data['totalPostsDrafts'] = $post->getTotalPostsCountDrafts();
    $data['totalPages'] = $page->getTotalPagesCount();
    $data['totalCategories'] = $category->getTotalCategoriesCount();
    $data['totalTags'] = $tag->getTotalTagsCount();
    $data['totalImages'] = $image->getTotalImagesCount();
    // latest posts/updates from offical BloggerCMS blog
    try {
        $feedUrl = 'https://bloggercms.github.io/rss.xml';
        $feeds = file_get_contents($feedUrl);
        $xml = new SimpleXmlElement($feeds);
        $articles = array();
        foreach ($xml->channel->item as $item) {
            $item = (array) $item;
            $articles[] = array('title' => $item['title'], 'link' => $item['link']);
        }
        $data['articles'] = array_slice($articles, 0, 7);
    } catch (Exception $e) {
    }