';
$prg = pg_query("select
h.name as hallname,
to_char(starts_at, 'DD FMMonth - FMDay') as dt,
to_char(s.starts_at,'HH24:MI') as start, to_char(s.ends_at,'HH24:MI') as end,
e.title, e.language,
e.abstract,
t.name as tname, t.color as tcolor,
sp.first_name || ' ' || sp.last_name as spname
from
slots s join halls h on h.id=s.hall_id
join events e on s.event_id = e.id
join tracks t on t.id=e.track_id
join users u on u.id=e.user_id
join speaker_profiles sp on sp.user_id=u.id
where
not s.event_id is null
order by date(s.starts_at),s.hall_id, s.starts_at
");
$bgpost = array();
$enpost = array();
$bgpost['ID'] = $sched_bg;
$enpost['ID'] = $sched_en;
$bgpost['post_title'] = "Програма";
$enpost['post_title'] = "Schedule";
$bgpost['post_name'] = "schedule";
$enpost['post_name'] = "schedule";
$cdate='';
$chall='';
while ($row = pg_fetch_object($prg)) {
if ($chall!=$row->hallname && strlen($chall)>1) {
$bg.= "\n";
$en.= "\n";
}
if ($cdate!=$row->dt) {
$cdate = $row->dt;
$bg.= "
$cdate
\n";
$en.= "
$cdate
\n";
}
if ($chall!=$row->hallname) {
$chall = $row->hallname;
echo pll_translate_string($chall, 'en_US')."\n";
$en.= "
".pll_translate_string($chall, 'en')." Hall";
$bg.= "\n";
$en.= "
\n";
$bgpost['post_content'] = $bg;
$enpost['post_content'] = $en;
$bgpost['post_content_filtered'] = $bg;
$enpost['post_content_filtered'] = $en;
$bgpost['post_status'] = 'publish';
$enpost['post_status'] = 'publish';
$bgpost['post_type'] = 'page';
$enpost['post_type'] = 'page';
$bgpost['filter'] = true;
$enpost['filter'] = true;
kses_remove_filters();
wp_insert_post($bgpost);
wp_insert_post($enpost);
/*
$newpost = array();
$newpost['post_type'] = 'speakers';
$newpost['post_status'] = 'publish';
$newpost['post_title'] = $row->first_name." ".$row->last_name;
$newpost['post_content'] = $row->biography;
$newpost['post_excerpt'] = $row->biography;
$postid=wp_insert_post($newpost);
$url = 'https://cfp.openfest.org/uploads/speaker_profile/picture/'.$row->id.'/schedule_'.$row->picture;
echo $url."\n";
$att = media_sideload_image($url, $postid, "photo_spk_".$row->user_id);
preg_match("%src='(http://[^']*)'%", $att, $matches);
var_dump($matches);
$wpurl = $matches[1];
$attid = pn_get_attachment_id_from_url($wpurl);
add_post_meta($postid, '_thumbnail_id', $attid);
pll_set_post_language($postid, 'bg');
}*/