]> git.bts.cx Git - cx.git/blobdiff - cx/lib/posts.php
Admin fixes
[cx.git] / cx / lib / posts.php
index 8ce6e6bf6a9ad923fe879f4cfac6e45807c56b34..e46aa28cd6816f79a5827f5c7fe17a6f8fecd198 100644 (file)
@@ -135,6 +135,7 @@ function cx_posts_get(int $limit = 0, int $offset = 0, bool $include_drafts = fa
                post_id,
                post_slug,
                post_date,
+               post_is_page,
                post_is_draft,
                post_title,
                post_data
@@ -188,6 +189,7 @@ function cx_posts_find_post($post_id) {
                post_id,
                post_slug,
                post_date,
+               post_is_page,
                post_is_draft,
                post_title,
                post_data
@@ -235,18 +237,25 @@ function cx_posts_find_page_id($post_slug) {
        return null;
 }
 
-function cx_pages_get() {
+function cx_pages_get(bool $include_drafts = false) {
        $sql = 'SELECT
                post_id,
                post_slug,
                post_date,
+               post_is_page,
                post_is_draft,
                post_title,
                post_data
                FROM posts
-               WHERE post_is_page == TRUE
-               AND post_is_draft == FALSE
-               ORDER BY post_creation_time ASC;';
+               WHERE post_is_page == TRUE';
+
+       if ($include_drafts == false) {
+               $sql .= ' AND post_is_draft == FALSE';
+       }
+
+       $sql .= ' ORDER BY post_date ASC';
+
+       $sql .= ';';
 
        foreach (cx_db_query($sql) as $post) {
                $p = new Post($post);