Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class news
- {
- private $con;
- private $data;
- private $cnt;
- public function __construct() {
- $this->con = $GLOBALS['DB'];
- }
- public function init(){
- $qry = $this->con->prepare("SELECT * FROM news ORDER BY nID DESC LIMIT 7");
- if ($qry->execute()){
- if ($qry->rowCount() != 0){
- $this->cnt = $qry->rowCount();
- $arr = $qry->fetchAll(PDO::FETCH_ASSOC);
- $this->data = array_combine(range(1, count($arr)), array_values($arr));
- return TRUE;
- }else
- return FALSE;
- }else
- return FALSE;
- }
- public function icons(){
- $ret = "";
- for($i=1;$i<=$this->cnt;$i++){
- $spc = ($i != 1) ? "style=\"margin-left: 6px;\"" : "";
- $ret .= "<img id=\"newsIcon_" . $this->data[$i]['newsID'] . "\" class=\"breakingNewsIcon\" src=\"./do_img/global/events/icons/" . $this->data[$i]['icon'] . "\" width=\"21\" height=\"21\" " . $spc . ">";
- }
- return $ret;
- }
- public function news(){
- $ret = "";
- for($i=1;$i<=$this->cnt;$i++){
- $spc = ($i != 1) ? "style=\"display: none;\"" : "";
- $ret .= "<div id=\"newsText_" . $this->data[$i]['newsID'] . "\" class=\"newsTextContainer\" " . $spc . "><h3>" . $this->data[$i]['headline'] . "</h3>" . $this->data[$i]['text'] . "</div>";
- }
- return $ret;
- }
- public function images(){
- $ret = "";
- for($i=1;$i<=$this->cnt;$i++){
- $ret .= "<img id=\"newsImage_" . $this->data[$i]['newsID'] . "\" src=\"./do_img/global/events/" . $this->data[$i]['image'] . "\" class=\"newsImage oldNews\">";
- }
- return $ret;
- }
- public function jsarray(){
- $ret = "";
- for($i=1;$i<=$this->cnt;$i++){
- $ret .= "newsItemIds.push('" . $this->data[$i]['newsID'] . "');";
- }
- return $ret;
- }
- public function jsarray2(){
- $ret = "uploadedNewsIds.push('" . $this->data[1]['newsID'] . "');";
- return $ret;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement