Exemplo n.º 1
0
$eventVenueUrl = "";
$eventAddress = "";
$eventTicketLink = "";
$eventTicketsatdoor = "";
$eventFacebookUrl = "";
$eventCoverImage = "./img/default.jpg";
$eventPreview = "";
$eventBody = "";
$eventGalleryImages = NULL;
$editingEvent = false;
//check whether editing blogpost
if (isset($_GET['editingPost']) && isset($_GET['id'])) {
    $editingPost = true;
    $editedID = $_GET['id'];
    $blogpost = new Blogpost(FALSE);
    $blogpost->updateParameters($_GET['id']);
    $postTitle = $blogpost->title;
    $postTags = $blogpost->tagsOriginal;
    $postSortdate = $blogpost->sortdateArray["day"] . "/" . $blogpost->sortdateArray["month"] . "/" . $blogpost->sortdateArray["year"];
    $youtubeCover = $blogpost->youtubeCover;
    $postCoverImage = $blogpost->coverimage != NULL ? "./img/medium/" . $blogpost->coverimage : $postCoverImage;
    $postBody = $blogpost->body;
}
//check whether editing event
if (isset($_GET['editingEvent']) && isset($_GET['id'])) {
    $editingEvent = true;
    $editedID = $_GET['id'];
    $event = new Event(FALSE);
    $event->updateParameters($_GET['id']);
    $eventTitle = $event->title;
    $eventTags = $event->tagsOriginal;
Exemplo n.º 2
0
/**
 * Print Latest newsItems 
 *	
 * @param int $offset 
 * @param int $numberOfPosts
 * @return
 */
function retrievePostsWithTag($tag, $offset, $numberOfPosts)
{
    include_once 'blogpost.inc.php';
    include_once 'event.inc.php';
    include_once 'db.inc.php';
    //Open a database connection and store it
    $db = new PDO(DB_INFO, DB_USER, DB_PASS);
    //initialize array to store retrieved ids
    $results = array();
    //search blogposts
    $sql = "SELECT id, sortdate, created\n\t\t\tFROM blogposts \n\t\t\tWHERE tags LIKE '%" . $tag . "%'";
    //LIMIT ".$numberOfPosts . " OFFSET " . $offset;
    $stmt = $db->prepare($sql);
    $stmt->execute();
    //add results to results array
    while ($row = $stmt->fetch()) {
        array_push($results, array("id" => $row['id'], "created" => $row['created'], "sortdate" => $row['sortdate'], "posttype" => "blogpost"));
        flush();
    }
    $stmt->closeCursor();
    //search events
    $sql = "SELECT id, sortdate, created\n\t\t\tFROM events \n\t\t\tWHERE tags LIKE '%" . $tag . "%'";
    //LIMIT ".$numberOfPosts . " OFFSET " . $offset;
    $stmt = $db->prepare($sql);
    $stmt->execute();
    //add results to results array
    while ($row = $stmt->fetch()) {
        array_push($results, array("id" => $row['id'], "created" => $row['created'], "sortdate" => $row['sortdate'], "posttype" => "event"));
        flush();
    }
    $stmt->closeCursor();
    //if we found results, print them
    if (count($results) > 0) {
        //sort the results array by sortdate and created
        foreach ($results as $key => $row) {
            // Obtain a list of columns
            $sortdate[$key] = $row['sortdate'];
            $created[$key] = $row['created'];
        }
        array_multisort($sortdate, SORT_DESC, $created, SORT_DESC, $results);
        //echo posts
        foreach ($results as $result) {
            switch ($result['posttype']) {
                case 'blogpost':
                    $blogpost = new Blogpost(FALSE);
                    $blogpost->updateParameters($result['id']);
                    echo $blogpost->formatNewspage();
                    flush();
                    break;
                case 'event':
                    $event = new Event(FALSE);
                    $event->updateParameters($result['id']);
                    echo $event->formatEventpage();
                    flush();
                    break;
            }
        }
    } else {
        echo "<h4>Sorry, we found no news articles or events with this tag</h4><br>\n\t\t<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><!-- sorry, I was lazy -->";
    }
}