<?php
include ( ROOT. '/components/Db.php' ) ;
class News {
public static function getNewsItemById( $id ) {
if ( $id ) {
$db = Db:: getConnection ( ) ;
$result = $db -> query ( 'SELECT * FROM news WHERE id=' . $id ) ;
$newItem = $result -> fetch ( ) ;
return $newItem ;
}
}
public static function getNewsList( ) {
$db = Db:: getConnection ( ) ;
$result = $db -> query ( 'SELECT * FROM news' ) ;
$i = 0 ;
while ( $row = $result -> fetch ( ) ) {
$newsList [ $i ] [ 'id' ] = $row [ 'id' ] ;
$newsList [ $i ] [ 'title' ] = $row [ 'title' ] ;
$newsList [ $i ] [ 'short_content' ] = $row [ 'short_content' ] ;
$newsList [ $i ] [ 'content' ] = $row [ 'Content' ] ;
$i ++;
}
return $newsList ;
}
}
Cgo8P3BocAoKaW5jbHVkZShST09ULicvY29tcG9uZW50cy9EYi5waHAnKTsKY2xhc3MgTmV3cyB7CgogICAgcHVibGljIHN0YXRpYyBmdW5jdGlvbiBnZXROZXdzSXRlbUJ5SWQoJGlkKXsKICAgICAgICAkaWQgPSBpbnR2YWwoJGlkKTsKCiAgICAgICAgaWYoJGlkKXsKCiAgICAgICAgICAgICRkYiA9IERiOjpnZXRDb25uZWN0aW9uKCk7CgogICAgICAgICAgICAkcmVzdWx0ID0gJGRiLT5xdWVyeSgnU0VMRUNUICogRlJPTSBuZXdzIFdIRVJFICBpZD0nLiRpZCk7CgogICAgICAgICAgICAkbmV3SXRlbSA9ICRyZXN1bHQtPmZldGNoKCk7CgogICAgICAgICAgICByZXR1cm4gJG5ld0l0ZW07CiAgICAgICAgfQoKCiAgICB9CgogICAgcHVibGljIHN0YXRpYyAgZnVuY3Rpb24gZ2V0TmV3c0xpc3QoKXsKICAgICAgICAkZGIgPSBEYjo6Z2V0Q29ubmVjdGlvbigpOwoKICAgICAgICAkbmV3c0xpc3QgPSBhcnJheSgpOwogICAgICAgICRyZXN1bHQgPSAkZGItPnF1ZXJ5KCdTRUxFQ1QgKiBGUk9NIG5ld3MnKTsKCgogICAgICAgICRpID0gMDsKICAgICAgICB3aGlsZSgkcm93ID0gJHJlc3VsdC0+ZmV0Y2goKSl7CgogICAgICAgICAgICAkbmV3c0xpc3RbJGldWydpZCddID0gJHJvd1snaWQnXTsKICAgICAgICAgICAgJG5ld3NMaXN0WyRpXVsndGl0bGUnXSA9ICRyb3dbJ3RpdGxlJ107CiAgICAgICAgICAgICRuZXdzTGlzdFskaV1bJ3Nob3J0X2NvbnRlbnQnXSA9ICRyb3dbJ3Nob3J0X2NvbnRlbnQnXTsKICAgICAgICAgICAgJG5ld3NMaXN0WyRpXVsnY29udGVudCddID0gJHJvd1snQ29udGVudCddOwogICAgICAgICAgICAkaSsrOwogICAgICAgIH0KCiAgICAgICAgcmV0dXJuICRuZXdzTGlzdDsKICAgIH0KfQo=