コード例 #1
0
<?php

include_once dirname(__FILE__) . "/../configs.php";
if (isset($_GET["id"]) && isset($_GET["cat"])) {
    $id = $_GET["id"];
    $cat = $_GET["cat"];
    try {
        $db = MongoConnection();
        $db_getter = new MongoGetter($db);
        $post_data = $db_getter->getSingleRowById($id);
        if ($post_data !== NULL) {
            //post is found
            $post_cat = in_array($cat, $post_data["category"]) ? $cat : $post_data["category"][0];
            //it is possible the post is no longer part of the given cat so check if it is and if it is not give the post a cat it belongs to
            $post_data["show_id"] = true;
            //make id visable
            $parse_down = new Parsedown();
            $post_views = new PostViews($parse_down);
            $post_template = file_get_contents($GLOBALS['template_dir'] . "/blog_post.txt");
            echo $post_views->makePostHtmlFromData($post_data, $post_cat, $post_template);
        }
    } catch (MongoCursorException $e) {
        //echo "error message: ".$e->getMessage()."\n";
    }
}
コード例 #2
0
ファイル: post.php プロジェクト: duckmin/blogcms
        $post_views = new PostViews(new Parsedown());
        $non_hyphenated_title = $post_views->convertPostTitleHyphensToSpaces($title);
        $single_post_data = $db_getter->getSingleRowFromDate($non_hyphenated_title, $start, $end);
        //NULL if not found
        $page_template = file_get_contents($GLOBALS['template_dir'] . "/base_page.txt");
        $post_template = file_get_contents($GLOBALS['template_dir'] . "/blog_post.txt");
        if ($single_post_data !== NULL) {
            $tmplt_data = array();
            $tmplt_data["title"] = $single_post_data["title"] . " - " . $_SERVER['HTTP_HOST'];
            $tmplt_data["description"] = $single_post_data["description"];
            $tmplt_data["styles"] = "";
            $tmplt_data["scripts"] = "<script src='/scripts/page_actions/post_actions.js' ></script>";
            $tmplt_data["base"] = $base;
            $tmplt_data["header"] = $post_views->getCatHeaderList($cat);
            $tmplt_data["category"] = $cat;
            $tmplt_data["search_placeholder"] = "search {$cat}";
            $tmplt_data["search_value"] = "";
            $tmplt_data["body"] = $post_views->makePostHtmlFromData($single_post_data, $cat, $post_template);
            $full_page = TemplateBinder::bindTemplate($page_template, $tmplt_data);
            echo $full_page;
        } else {
            goTo404();
        }
    } catch (MongoException $e) {
        //echo $e->getMessage();
        //Mongo will throw an error if id does not exist, go to 404 page
        goTo404();
    }
} else {
    goTo404();
}
コード例 #3
0
ファイル: get_post_info.php プロジェクト: duckmin/blogcms
        } else {
            $cursor = $db_getter->getBlogManagePosts($page_num, $cat);
        }
        $posts = iterator_to_array($cursor);
        if (count($posts) > $GLOBALS['amount_on_manger_tab']) {
            array_pop($posts);
            $next = true;
        } else {
            $next = false;
        }
        $parsedown = new Parsedown();
        $post_views = new PostViews($parsedown);
        $modified_array = array();
        $post_template = file_get_contents($GLOBALS['template_dir'] . "/blog_post.txt");
        foreach ($posts as $row) {
            $post_cat = strlen($cat) > 0 ? $cat : $row["category"][0];
            //when viewing all posts/search cat will be empty string so use base cat
            $modified_row = $post_views->generateModifedListingForPostInfo($row, $post_cat);
            $row["show_id"] = true;
            //show_id on template, so manager page JavaScript can identify them
            $post_html = $post_views->makePostHtmlFromData($row, $post_cat, $post_template);
            array_push($modified_array, array("post_data" => $modified_row, "post_html" => $post_html));
        }
        $prev = $page_num > 1 ? true : false;
        $data = array("posts" => $modified_array, "next" => $next, "prev" => $prev);
        header('Content-Type: application/json; charset=utf-8');
        echo json_encode(array("result" => true, "data" => $data));
    } catch (MongoCursorException $e) {
        echo returnMessage(false, 'ERROR:' . $e->getMessage(), null);
    }
}
コード例 #4
0
ファイル: get_preview.php プロジェクト: duckmin/blogcms
<?php

include_once dirname(__FILE__) . "/../configs.php";
$json = json_decode($_POST['json'], true);
$post_view = new PostViews(new Parsedown());
$post_template = file_get_contents($GLOBALS['template_dir'] . "/blog_post.txt");
$single = array();
$single["_id"] = "5428784f7f8b9afe1a779e93";
//just a dummy ID means nothing
$single["lastModified"] = new MongoDate();
$single["title"] = "Preview";
$single["post_data"] = $json;
$single["author"] = $_SESSION['user'];
echo $post_view->makePostHtmlFromData($single, $GLOBALS['post_categories'][0], $post_template);
//post category is just a placeholder the link will not work i the preview it is just a sample