Example #1
0
    /**
     * Constructor 
     *
     */
    public function __construct($url, $dbOptions)
    {
        $user = new CUser($dbOptions);
        $content = new CContent($dbOptions);
        $filter = new CTextFilter();
        $res = $content->getContentByUrl($url);
        if (isset($res[0])) {
            $c = $res[0];
        } else {
            die('Misslyckades: det finns inget innehåll.');
        }
        // Sanitize content before using it.
        $title = htmlentities($c->title, null, 'UTF-8');
        $data = $filter->doFilter(htmlentities($c->data, null, 'UTF-8'), $c->filter);
        // Prepare content and store it all in variables in the Anax container.
        $this->title = $title;
        $editLink = $user->isAuthenticated() ? "<a href='content_edit.php?id={$c->id}'>Uppdatera sidan</a>\n        <a href='content_delete.php?id={$c->id}'>Radera sidan</a>" : null;
        $this->main = <<<EOD
<article>
<header>
<h1>{$title}</h1>
</header>

{$data}

<footer>
<p>(Skriven av {$c->owner}. Publicerad {$c->pubdate})</p>
{$editLink}
</footer
</article>
EOD;
    }
Example #2
0
 /**
  * Get the content of the post.
  *
  * @param object $content to link to.
  * @return string with url to display content.
  */
 public function GetPost($slug = null)
 {
     $posts = parent::GetContent('post', $slug);
     foreach ($posts as $p) {
         // Sanitizing
         $p->title = htmlentities($p->title, null, 'UTF-8');
         $p->data = $this->filter->doFilter(htmlentities($p->data, null, 'UTF-8'), $p->filter);
     }
     return $posts;
 }
Example #3
0
 /**
  * Get the content of the page.
  *
  * @param object $content to link to.
  * @return string with url to display content.
  */
 public function GetPage($url = null)
 {
     $url = is_null($url) ? $this->defaultUrl : $url;
     $res = parent::GetContent('page', $url);
     isset($res[0]) or die('No page to view.');
     $content = (array) $res[0];
     // Sanitizing
     $content['title'] = htmlentities($content['title'], null, 'UTF-8');
     $content['data'] = $this->filter->doFilter(htmlentities($content['data'], null, 'UTF-8'), $content['filter']);
     return $content;
 }
Example #4
0
$title = isset($_POST['title']) ? strip_tags($_POST['title']) : null;
$category = isset($_POST['category']) ? strip_tags($_POST['category']) : null;
$type = isset($_POST['type']) ? strip_tags($_POST['type']) : null;
$pdate = isset($_POST['pdate']) ? $_POST['pdate'] : null;
$acronym = isset($_SESSION['user']) ? $_SESSION['user']->acronym : null;
// if user is NOT authenticated.
if ($acronym == null) {
    echo <<<EOD
<div style=" border: 1px solid #777; border-radius: 3px; padding: 10px 20px;">
    <h2 style="margin-top: 0;">Du måste vara inloggad för att få skapa nytt innehåll...</h2>
    <p><a href="?p=clogin" class="aButton">Logga in</a></p>
</div>
EOD;
} else {
    if ($create) {
        $cont = new CContent($urbax['database']);
        if ($newId = $cont->add($title, $category, $type, $pdate)) {
            echo "Nytt innehåll sparat. <a href='?p=uppdatecontent&amp;id={$newId}' class='aButton'>Editera</a>";
            //use javascritp to redirect - forces the the nav menu to uppdate
            echo "<script> setTimeout(function (){ window.location.href = '?p=contentedit'; }, 2000);</script>";
        }
    } else {
        $today = date("Y-m-d");
        //var_dump($user->isAdmin());
        $disabled = '';
        $info = '';
        if (!$user->isAdmin()) {
            $disabled = "disabled";
            $info = "<p> Du kan inte editera eftersom du inte är administratör.</p>";
        }
        echo <<<MYHTML
Example #5
0
<?php

// get parameters
$id = isset($_GET['id']) ? filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE) : null;
$uppdate = isset($_POST['uppdate']) ? true : false;
$title = isset($_POST['title']) ? strip_tags($_POST['title']) : null;
$type = isset($_POST['type']) ? strip_tags($_POST['type']) : null;
$acronym = isset($_SESSION['user']) ? $_SESSION['user']->acronym : null;
$cont = new CContent($urbax['database']);
if ($acronym == null) {
    echo <<<EOD
<div style=" border: 1px solid #777; border-radius: 3px; padding: 10px 20px;">
    <h2 style="margin-top: 0;">Du måste vara inloggad för att få redigera innehåll...</h2>
    <p><a href="?p=clogin" class="aButton">Logga in</a></p>
</div>
EOD;
} else {
    //Do we have a valid id-value?
    if (!$cont->validContentId($id)) {
        $dbc = new CDatabase($urbax['database']);
        $resultset = $dbc->ExecuteSelectQueryAndFetchAll('SELECT id, title FROM Content WHERE deleted IS NULL');
        echo "<h2>Välj post att redigera:</h2>";
        echo "<table class='table'>";
        echo "<tr><th style='width:100px;'></th><th>Id</th><th>Titel</th></tr>";
        foreach ($resultset as $res) {
            echo "<tr><td><a href='?p=contentedit&amp;id={$res->id}' class='aButton' style='width:50px; margin:0 auto; display:block;'>Editera</a></td><td>{$res->id}</td><td>{$res->title}</td></tr>";
        }
        echo "</table>";
    } else {
        if ($uppdate) {
            // Get parameters
Example #6
0
<?php

/**
 * This is a Branax pagecontroller.
 *
 */
// Include the essential config-file which also creates the $branax variable with its defaults.
include __DIR__ . '/config.php';
$user = new CUser($branax['database']);
$user->isAuthenticated() or die('Check: You must login to edit.');
$content = new CContent($branax['database']);
// Do it and store it all in variables in the Branax container.
$branax['title'] = "Innehåll";
$branax['main'] = <<<EOD
<h1>Administrera innehåll</h1>
{$content->getList()}
EOD;
// Finally, leave it all to the rendering phase of Branax.
include BRANAX_THEME_PATH;
Example #7
0
<?php

include __DIR__ . '/config.php';
/**
 * CMovieSearch constructor.
 * @var CDatabase $db
 */
if (isset($_POST['add'])) {
    $news = new CContent();
    $name = $_POST['name'];
    $title = $_POST['title'];
    $content = $_POST['content'];
    $published = $_POST['pub'];
    $news->addNews($title, $content, $name, $published);
    header('Location: index.php');
} else {
    $Orange['main'] = <<<EOD
    <h1></h1>
    <div class="form">
    <form method=post action="add-news.php">
              <fieldset>
              <legend>ADD NEWS</legend>
              <p><label>Titel:<br/><input type='text' name='title' placeholder="Title...."></label></p>
              <p><label>Text:<br/><textarea name='content' placeholder="Meddelande...."></textarea></label></p>
              <p><label>Namn:<br/><input type='text' name='name' placeholder="Namn...."></label></p>
              <p><label>Published:<br/><input type='date' name='pub' placeholder="Published...."></label></p>
              <div class="add"><input type='submit' name='add' value='Publisera'></div>
              </fieldset>
            </form>
        </fieldset>
</form>
Example #8
0
<?php

include __DIR__ . '/config.php';
/**
 * CMovieSearch constructor.
 * @var CDatabase $db
 */
$Orange['title'] = "Lägg till innehåll";
$get_page = new CContent();
$id = $_GET['p'];
$params = array($id);
$content = $get_page->getPage($params);
if (CUser::isAuthenticated()) {
    if (isset($_POST['update'])) {
        $updatedContent = $_POST['content'];
        $get_page->updatePage($updatedContent, $content[0]->id);
        header('Location: add-content.php');
    }
    //$page = $_POST['page'];
    $item = $content[0]->content;
    $Orange['main'] = <<<EOD

    <div class="form">
    <form method=post action="add-content.php?={$id}">
              <fieldset>
              <legend>Uppdatera innehåll</legend>
              <p><label>Text:<br/><textarea name='content'>{$item}</textarea></label></p>
              <div class="add"><input type='submit' name='update' value='Uppdatera'></div>
              </fieldset>
            </form>
        </fieldset>
Example #9
0
<?php

/**
 * This is a Branax pagecontroller.
 *
 */
// Include the essential config-file which also creates the $branax variable with its defaults.
include __DIR__ . '/config.php';
$user = new CUser($branax['database']);
$user->isAuthenticated() or die('Check: You must login to edit.');
$content = new CContent($branax['database']);
// Do it and store it all in variables in the Anax container.
$branax['title'] = "Lägg till";
$branax['main'] = <<<EOD
<h1>Lägg till nytt innehåll</h1>
{$content->create($user->getAcronym())}
EOD;
// Finally, leave it all to the rendering phase of Anax.
include BRANAX_THEME_PATH;
Example #10
0
<?php

if (CUser::isAuthenticated()) {
    $get_page = new CContent();
    $id = $_GET['p'];
    $params = array($id);
    $content = $get_page->getPage($params);
}
Example #11
0
<?php

/**
 * This is a Orange pagecontroller.
 *
 */
// Include the essential config-file which also creates the $Orange variable with its defaults.
include __DIR__ . '/config.php';
// Do it and store it all in variables in the Orange container.
$Orange['title'] = "Blogg";
$blog = new CContent();
$filter = new CTextFilter();
if (isset($_POST['blog'])) {
    $name = $_POST['name'];
    $content = $_POST['content'];
    //$content   = $filter->doFilter(htmlentities($content, null, 'UTF-8'));
    $published = date("Y-m-d H:i:s");
    $blog->addPost($name, $content, $published);
    header('Location: blog.php');
} else {
    $res = $blog->getBlogContent();
    $items = $blog->drawBlogs($res);
    $Orange['main'] = <<<EOD


<div class="blogg">
<div class="rubrik"><p class="undertext">Bloggposter</p></div>

{$items}

</div>
Example #12
0
<?php

/**
 * This is a Orange pagecontroller.
 *
 */
// Include the essential config-file which also creates the $Orange variable with its defaults.
include __DIR__ . '/config.php';
$get_page = new CContent();
$id = isset($_GET['p']);
if (isset($_GET['p'])) {
    $params = array($id = $_GET['p']);
    $res = $get_page->getPage($params);
    $content = $res[0]->content;
}
// Do it and store it all in variables in the Orange container.
$Orange['title'] = "Galleri";
$Orange['main'] = <<<EOD
<div class="link">
{$content}
</div>
<div class="link"><a href='add-content.php?p={$id}'>Uppdatera</a></div>


EOD;
// Finally, leave it all to the rendering phase of Anax.
include Orange_THEME_PATH;
Example #13
0
 public function __construct($db)
 {
     parent::__construct($db);
 }
Example #14
0
// get parameters
$id = isset($_GET['id']) ? filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE) : null;
$uppdate = isset($_POST['uppdate']) ? true : false;
$title = isset($_POST['title']) ? strip_tags($_POST['title']) : null;
$type = isset($_POST['type']) ? strip_tags($_POST['type']) : null;
$acronym = isset($_SESSION['user']) ? $_SESSION['user']->acronym : null;
if ($acronym == null) {
    echo <<<EOD
<div style=" border: 1px solid #777; border-radius: 3px; padding: 10px 20px;">
    <h2 style="margin-top: 0;">Du måste vara inloggad för att få radera innehåll...</h2>
    <p><a href="?p=clogin" class="aButton">Logga in</a></p>
</div>
EOD;
} else {
    $cont = new CContent($urbax['database']);
    //time to delete a post?
    if ($cont->validContentId($id)) {
        $cont->delete($id);
        //use javascritp to reload - forces the the nav menu to uppdate
        //echo "<script> setTimeout(function (){ window.location.href = '?p=contentdelete'; }, 2000);</script>";
    }
    //var_dump($user->isAdmin());
    $disabled = '';
    $info = '';
    if (!$user->isAdmin()) {
        $disabled = "disabled";
        $info = "<p> Du kan inte radera eftersom du inte är administratör.</p>";
    }
    //show table
    $dbc = new CDatabase($urbax['database']);
Example #15
0
/**
 * This is a Orange pagecontroller.
 *
 */
// Include the essential config-file which also creates the $Orange variable with its defaults.
include __DIR__ . '/config.php';
// Define what to include to make the plugin to work
$Orange['stylesheets'][] = 'css/slideshow.css';
$Orange['javascript_include'][] = 'js/slideshow.js';
// Do it and store it all in variables in the Orange container.
$Orange['title'] = "Startsida";
$calender = new CCalendar();
$calender->getValues();
$calender->generateCalenderData();
$output = $calender->printMiniCalendar();
$content = new CContent();
$res = $content->getBlogContentForFirstPage();
$blog_posts = $content->drawBlogPosts($res);
$news = $content->getNews();
$printNews = $content->drawNews($news);
$slide = <<<EOD
<div id="slideshow" class='slideshow' data-host="" data-path="img/dogs/" data-images='["1.jpg", "2.jpg", "5.jpg", "6.jpg"]'>
<img src='img/dogs/6.jpg' width='962px' height='400px' alt='Me'/>
</div>
EOD;
$Orange['main'] = <<<EOD
{$slide}
<div>
<div class="nyheter">
<div class="rubrik"><p class="undertext">Nyheter</div>
{$printNews}
Example #16
0
/**
 * This is a Hera pagecontroller.
 *
 */
// Include the essential config-file which also creates the $anax variable with its defaults.
include __DIR__ . '/config.php';
// add style for forms
$hera['stylesheets'][] = 'css/forms.css';
$hera['title'] = "Hantera nyheter";
// Database
$db = new CDatabase($hera['database']);
//login-info
$user = new CUser($db);
//content handler
$content = new CContent($db);
if ($user->IsAuthenticated()) {
    if (isset($_GET['new'])) {
        $hera['main'] = $content->printAndPostAdd();
    } elseif (isset($_GET['delete'])) {
        $content->getEntryById($_GET['delete']);
        $hera['main'] = $content->printAndPostDelete();
    } elseif (isset($_GET['id'])) {
        $content->getEntryById($_GET['id']);
        $hera['main'] = $content->printAndPostUpdate();
    } else {
        if (isset($_GET['publish'])) {
            $content->publish($_GET['publish']);
        }
        $list = $content->getAllAsList();
        $new = $user->IsAdmin() ? "<a href='?new' class='as-button'>Skapa ett nytt inlägg</a>" : "<p>För att skapa, radera och ändra inlägg behöver man vara inloggad som admin.</p>";
Example #17
0
<?php

/**
 * This is a Branax pagecontroller.
 *
 */
// Include the essential config-file which also creates the $branax variable with its defaults.
include __DIR__ . '/config.php';
$user = new CUser($branax['database']);
$user->isAuthenticated() or die('Check: You must login first.');
$content = new CContent($branax['database']);
// Do it and store it all in variables in the Branax container.
$branax['title'] = "Återställ";
$branax['main'] = <<<EOD
<h1>Återställ databasen till ursprungligt skick</h1>
{$content->reset()}
EOD;
// Finally, leave it all to the rendering phase of Branax.
include BRANAX_THEME_PATH;
Example #18
0
<?php

/**
 * This is a Branax pagecontroller.
 *
 */
// Include the essential config-file which also creates the $branax variable with its defaults.
include __DIR__ . '/config.php';
$user = new CUser($branax['database']);
$user->isAuthenticated() or die('Check: You must login to delete.');
$content = new CContent($branax['database']);
// Do it and store it all in variables in the Branax container.
$branax['title'] = "Radera";
$branax['main'] = <<<EOD
<h1>Radera innehåll</h1>
{$content->delete()}
EOD;
// Finally, leave it all to the rendering phase of Branax.
include BRANAX_THEME_PATH;
Example #19
0
<h1 class="center">Återställ tabellerna CContent och Cuser</h1>
<p>Genom att klicka på knappen nedan återställer du ovanstående tabeller (i filmdatabasen) till sitt ursprung:</p>

<form method="post">
    <input type="submit" value="Återställ">
    <input type='hidden' name="restore" /> 
</form>


<?php 
if (isset($_POST['restore'])) {
    $cont = new CContent($urbax['database']);
    echo $cont->reset();
}
Example #20
0
<?php

/**
 * This is a Branax pagecontroller.
 *
 */
// Include the essential config-file which also creates the $branax variable with its defaults.
include __DIR__ . '/config.php';
$user = new CUser($branax['database']);
$user->isAuthenticated() or die('Check: You must login to edit.');
$content = new CContent($branax['database']);
// Do it and store it all in variables in the Branax container.
$branax['title'] = "Edit";
$branax['main'] = <<<EOD
<h1>Editera innehåll</h1>
{$content->update()}
EOD;
// Finally, leave it all to the rendering phase of Branax.
include BRANAX_THEME_PATH;