Advertisement
Underworld1337

Untitled

Oct 12th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <?php
  2. class news
  3. {
  4. private $con;
  5. private $data;
  6. private $cnt;
  7.  
  8. public function __construct() {
  9. $this->con = $GLOBALS['DB'];
  10. }
  11.  
  12. public function init(){
  13. $qry = $this->con->prepare("SELECT * FROM news ORDER BY nID DESC LIMIT 7");
  14. if ($qry->execute()){
  15. if ($qry->rowCount() != 0){
  16. $this->cnt = $qry->rowCount();
  17. $arr = $qry->fetchAll(PDO::FETCH_ASSOC);
  18. $this->data = array_combine(range(1, count($arr)), array_values($arr));
  19. return TRUE;
  20. }else
  21. return FALSE;
  22. }else
  23. return FALSE;
  24. }
  25.  
  26. public function icons(){
  27. $ret = "";
  28. for($i=1;$i<=$this->cnt;$i++){
  29. $spc = ($i != 1) ? "style=\"margin-left: 6px;\"" : "";
  30. $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 . ">";
  31. }
  32. return $ret;
  33. }
  34.  
  35. public function news(){
  36. $ret = "";
  37. for($i=1;$i<=$this->cnt;$i++){
  38. $spc = ($i != 1) ? "style=\"display: none;\"" : "";
  39. $ret .= "<div id=\"newsText_" . $this->data[$i]['newsID'] . "\" class=\"newsTextContainer\" " . $spc . "><h3>" . $this->data[$i]['headline'] . "</h3>" . $this->data[$i]['text'] . "</div>";
  40. }
  41. return $ret;
  42. }
  43.  
  44. public function images(){
  45. $ret = "";
  46. for($i=1;$i<=$this->cnt;$i++){
  47. $ret .= "<img id=\"newsImage_" . $this->data[$i]['newsID'] . "\" src=\"./do_img/global/events/" . $this->data[$i]['image'] . "\" class=\"newsImage oldNews\">";
  48. }
  49. return $ret;
  50. }
  51.  
  52. public function jsarray(){
  53. $ret = "";
  54. for($i=1;$i<=$this->cnt;$i++){
  55. $ret .= "newsItemIds.push('" . $this->data[$i]['newsID'] . "');";
  56. }
  57. return $ret;
  58. }
  59.  
  60. public function jsarray2(){
  61. $ret = "uploadedNewsIds.push('" . $this->data[1]['newsID'] . "');";
  62. return $ret;
  63. }
  64. }
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement