Пример #1
0
<?php

$url = Url::getCurrentUrl();
new NewsSelector();
//force class loading for constants
/******************************\
	          LOAD NEWS
	\******************************/
$selected = $url->hasQueryVar('select') ? $url->getQueryVar('select') : NEWSSELECTOR_ALL;
$selector = new NewsSelector($selected, $_SESSION[MODE_H]);
if (Url::getCurrentUrl()->hasQueryVar('showPrepared')) {
    $selector->setPreparedShown(true);
}
$newsList = News::getAllNews($selector);
usort($newsList, array('News', 'timestampSorter'));
/******************************\
	       BUILD VIEWS ACCESS
	\******************************/
$viewMap = array(NEWSSELECTOR_ALL => "Dernières news", NEWSSELECTOR_RELEASES => "Sorties", NEWSSELECTOR_TEAM => "Infos team", NEWSSELECTOR_PARTNERS => "Partenaires", NEWSSELECTOR_DB0COMPANY => "db0 company", NEWSSELECTOR_MISC => "Bonus");
$viewsLinks = new SimpleBlockComponent();
foreach ($viewMap as $id => $name) {
    $url->setQueryVar('select', empty($id) ? null : $id, true);
    $viewsLinks->addComponent(new Link(new Url($url), $name));
}
$views = new HeaderComponent();
$views->setClass("views");
$rssUrl = buildRssUrlIfAvailable();
$title = new Title(null, 2);
$title->addComponent(new RssLink($rssUrl));
$title->addComponent("Vues");
$views->addComponent($title);
Пример #2
0
<?php

define('ROOT', dirname(__FILE__));
require_once ROOT . '/includes/DB_Connection.php';
require_once ROOT . '/includes/News.php';
include "./pages/header.php";
if (isset($_GET['news_id'])) {
    $action = $_GET['news_id'];
    $news = new News();
    $news->getOneNew($action);
} elseif (isset($_GET['author_id'])) {
    $action = $_GET['author_id'];
    $news = new News();
    $news->getNewsOneAuthor($action);
} else {
    $news = new News();
    $news->getAllNews();
}
include "./pages/footer.php";
Пример #3
0
<html>
<head>
    <meta charset="utf-8">
</head>
<body>
<?php 
//include __DIR__."/DataBase.php";
require __DIR__ . "/Article.php";
$news = new News();
$news->deleteArticle(8);
//$sql->insert('Привет', 'Как дела?');
//$sql->update(5,'Заголвок новтси','Как ошибки делаются');
$posts = $news->getAllNews();
foreach ($posts as $key) {
    echo $key['id'] . ' ' . $key['title'] . ' ' . $key['text'] . '<br>';
}
var_dump($posts);
?>

</body>
</html>
Пример #4
0
        $json["status"] = 0;
        $json["statusInfo"] = "fail";
        $json["error"] = "parameter missing";
    } else {
        $usr->makeofflineguest($_REQUEST["guestid"]);
        $json["status"] = 1;
        $json["statusInfo"] = "success";
    }
}
if ($_REQUEST["operation"] == "news") {
    if (!isset($_REQUEST["role"]) || !isset($_REQUEST["appid"]) || !isset($_REQUEST["imported_appid"]) || !isset($_REQUEST["offset"]) || !isset($_REQUEST["userid"])) {
        $json["status"] = 0;
        $json["statusInfo"] = "fail";
        $json["error"] = "parameter missing";
    } else {
        $data = $news->getAllNews($_REQUEST["role"], $_REQUEST["appid"], $_REQUEST["offset"], $_REQUEST["userid"], $_REQUEST["imported_appid"]);
        //$data= $rs; //$news->getRowReal();
        $timezone = date_default_timezone_get();
        if ($data) {
            $usr->updateUnreadNewsCount($_REQUEST["userid"], $_REQUEST["role"]);
            $json["status"] = 1;
            $json["statusInfo"] = "success";
            $json["news"] = $data;
            $json["timezone"] = $timezone;
        } else {
            $json["status"] = 1;
            $json["statusInfo"] = "success";
            $json["news"] = array();
            $json["timezone"] = $timezone;
            //$json["error"]="nodata";
        }
Пример #5
0
 public static function getNews($id)
 {
     foreach (News::getAllNews() as $news) {
         if ($news->getId() == $id) {
             return $news;
         } else {
             continue;
         }
     }
     throw new Exception("{$id} is not a valid news ID");
 }