Example #1
0
 private function createXML()
 {
     global $Site;
     global $dbPages;
     global $dbPosts;
     global $Url;
     $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
     $xml .= '<rss version="2.0">';
     $xml .= '<channel>';
     $xml .= '<title>' . $Site->title() . '</title>';
     $xml .= '<link>' . $Site->url() . '</link>';
     $xml .= '<description>' . $Site->description() . '</description>';
     $posts = buildPostsForPage(0, 10, true);
     foreach ($posts as $Post) {
         $xml .= '<item>';
         $xml .= '<title>' . $Post->title() . '</title>';
         $xml .= '<link>' . $Post->permalink(true) . '</link>';
         $xml .= '<description>' . $Post->description() . '</description>';
         $xml .= '</item>';
     }
     $xml .= '</channel></rss>';
     // New DOM document
     $doc = new DOMDocument();
     // Friendly XML code
     $doc->formatOutput = true;
     $doc->loadXML($xml);
     $doc->save(PATH_PLUGINS_DATABASES . $this->directoryName . DS . 'rss.xml');
 }
Example #2
0
 private function getAllPosts()
 {
     $posts = buildPostsForPage(0, $this->getDbField('showAllAmount'), true, false);
     $tmp = array();
     foreach ($posts as $Post) {
         array_push($tmp, $Post->json($returnsArray = true));
     }
     return json_encode($tmp);
 }
Example #3
0
 public function siteSidebar()
 {
     // This function is declared in 70.posts.php
     $posts = buildPostsForPage(0, $this->getDbField('amount'), true, false);
     $html = '<div class="plugin plugin-latest-posts">';
     // Print the label if not empty.
     $label = $this->getDbField('label');
     if (!empty($label)) {
         $html .= '<h2 class="plugin-title">' . $label . '</h2>';
     }
     $html .= '<div class="plugin-content">';
     $html .= '<ul>';
     foreach ($posts as $Post) {
         $html .= '<li>';
         $html .= '<a href="' . $Post->permalink() . '">' . $Post->title() . '</a>';
         $html .= '</li>';
     }
     $html .= '</ul>';
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }
Example #4
0
        reIndexTagsPosts();
    }
}
// Execute the scheduler.
if ($dbPosts->scheduler()) {
    // Reindex dbTags.
    reIndexTagsPosts();
}
// Build specific post.
if ($Url->whereAmI() === 'post' && $Url->notFound() === false) {
    $Post = buildPost($Url->slug());
    // The post doesn't exist.
    if ($Post === false) {
        $Url->setNotFound(true);
        unset($Post);
    } elseif (!$Post->published()) {
        $Url->setNotFound(true);
        unset($Post);
    } else {
        $posts[0] = $Post;
    }
} elseif ($Url->whereAmI() === 'tag' && $Url->notFound() === false) {
    $posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true, $Url->slug());
} else {
    // Posts for admin area.
    if ($Url->whereAmI() === 'admin') {
        $posts = buildPostsForPage($Url->pageNumber(), POSTS_PER_PAGE_ADMIN, false);
    } elseif (($Url->whereAmI() === 'home' || $Url->whereAmI() === 'blog') && $Url->notFound() === false) {
        $posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true);
    }
}