";
}
return $value;
}
function parseHeader($block)
{
return 'data->level.'>'. $block->data->text .'data->level.'>';
}
function parseCode($block)
{
return '
'.$block->data->code .'
';
}
function parseParagraph($block)
{
return ''.$block->data->text .'
';
}
function parseTable($block)
{
unset($return, $line, $cell);
$return = '
';
foreach ($block->data->content as $line) {
$return .= '';
foreach ($line as $cell) {
$return .= '';
$return .= $cell;
$return .= ' | ';
}
$return .= '
';
}
$return .= '
';
return $return;
}
function parseList($block)
{
unset($tag, $return, $item);
if ($block->data->style == 'ordered'){
$tag = 'ol';
}elseif ($block->data->style == 'unordered'){
$tag = 'ul';
}
$return = '<'.$tag.'>';
foreach ($block->data->items as $item) {
$return .= ''.$item.'';
}
$return .= ''.$tag.'>';
return $return;
}
function parseImage($block)
{
unset($captiontitle, $captionalt);
if ($block->data->caption){
$captiontitle = ''.$block->data->caption.'
';
$captionalt = $block->data->caption;
}
return '

'.$captiontitle.'
';
}
function echofeeddata($resultfeedmysqli, $returnfirstupdated){
unset($return, $publishing_date);
$author_id = $resultfeedmysqli['author_id'];
$sqlfeed_author = mysqli_query($conn, "SELECT `fullname` FROM `authors` WHERE `id` = '.$author_id.'");
$resultfeed_author = mysqli_fetch_assoc($sqlfeed_author);
//date
$publishing_date = date("r", strtotime($resultfeedmysqli['publishing_date']));
//date
if ($returnfirstupdated === true){
$return .= ''.$publishing_date.'';
}
$return .= '
'.valueToXML($resultfeedmysqli['article_title']).'
https://'.$_SERVER[HTTP_HOST].'/'.$resultfeedmysqli['nameaddress'].'';
if ($resultfeed_author['fullname']){
$return .= '
'.valueToXML($resultfeed_author['fullname']).'
';
}
$content_array_feed = json_decode($resultfeedmysqli['content']);
if (is_object($content_array_feed)){
foreach ($content_array_feed->blocks as $block) {
switch ($block->type) {
case 'code':
$content_feed .= parseCode($block);
break;
case 'paragraph':
$content_feed .= parseParagraph($block);
break;
case 'header':
$content_feed .= parseHeader($block);
break;
case 'image':
$content_feed .= parseImage($block);
break;
case 'list':
$content_feed .= parseList($block);
break;
case 'table':
$content_feed .= parseTable($block);
break;
default:
// code...
break;
}
}
}
$content_feed = html_entity_decode($content_feed);
$return .= '
'.valueToXML($content_feed).'
'.$publishing_date.'
';
return $return;
}
echo '
https://'.$_SERVER[HTTP_HOST].'/feed
'; ?>
0){
$resultfeed_posts = mysqli_fetch_assoc($sqlfeed_posts);
echo echofeeddata($resultfeed_posts, true);
while($resultfeed_posts = mysqli_fetch_assoc($sqlfeed_posts)){
echo echofeeddata($resultfeed_posts, false);
}
}
}
?>