'; $en = '
 
 Зала СофияЗала ВарнаЗала G1
'; $tracks=array(8 => 'open-biz', 9 => 'open-art', 2 => 'technical', 6 => 'civic', 5 => 'social', 3 => 'advanced-technical'); $prg = pg_query("select h.name as hallname,h.id as hallid, to_char(starts_at, 'DD FMMonth - FMDay') as dt, to_char(s.starts_at,'HH24:MI')|| ' - ' || to_char(s.ends_at,'HH24:MI') as slot, e.title, e.subtitle, e.language, e.id as eventid, e.abstract, e.description, t.name as tname,t.id as trackid, array_agg(sp.first_name || ' ' || sp.last_name)::text 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 left join events_speaker_profiles esp on esp.event_id=e.id left join speaker_profiles sp on esp.speaker_profile_id=sp.id where not s.event_id is null and h.id in (1,2,3) group by h.name, h.id, starts_at, ends_at, t.id, e.title, e.subtitle, e.language, e.id, s.hall_id order by date(s.starts_at),s.starts_at, s.hall_id; "); $dtrans = array('01 November - Saturday' => '01 ноември - събота', '02 November - Sunday' => '02 ноември - неделя'); $p = array(); while ($row = pg_fetch_object($prg)) { $p[$row->dt][$row->slot][$row->hallname]=$row; } $bgpost = array(); $enpost = array(); $bgpost['ID'] = $sched_bg; $enpost['ID'] = $sched_en; $bgpost['post_title'] = "Програма"; $enpost['post_title'] = "Schedule"; $bgpost['post_name'] = "programa"; $enpost['post_name'] = "schedule"; $bgpost['post_author'] = 2; $enpost['post_author'] = 2; $bgpost['post_date'] = "2014-10-13 00:01:02"; $enpost['post_date'] = "2014-10-13 00:01:02"; $cdate=''; $chall=''; $clearsmb=array('{', '}', '"'); $events = array(); foreach ($p as $day => $dayv) { $bg .=''."\n"; $en .=''."\n"; foreach ($dayv as $slot => $slotv) { $bg .= ''."\n"; $en .= ''."\n"; $h=0; foreach ($slotv as $hall => $event){ $h++; while ($h < $event->hallid) { $h++; $bg .= "\n"; $en .= "\n"; } $spkarr = explode(',', str_replace($clearsmb, '' ,$event->spname)); $spkbgarr = array(); $spkenarr = array(); foreach ($spkarr as $val){ if ($val == "NULL") continue; $spkbgarr[] = ''.htmlentities($val).''; $spkenarr[] = ''.htmlentities($val).''; } $spkbg = implode(", ", $spkbgarr); $spken = implode(", ", $spkenarr); $event->spken = $spken; $event->spkbg = $spkbg; $events[] = $event; $bg .= ''."\n"; $en .= ''."\n"; #var_dump($event); } while ($h < 3) { $h++; $bg .= "\n"; $en .= "\n"; } $bg .= ''."\n"; $en .= ''."\n"; } } $bg .= '
 Sofia HallVarna HallHall G1
'.$dtrans[$day].'
'.$day.'
'.$slot.'
'.$slot.''.htmlentities($event->title).''; $bg .='
'.$spkbg.'
'.htmlentities($event->title).''; $en .='
'.$spken.'
'; $en .= ''; $legend = '
Technical
Advanced technical
Social
Open art
Open biz
Civic hacking
Misc
English
Български
'; $bg .= $legend; $en .= $legend; $bg .= '
'; $en .= '
'; foreach ($events as $k => $event) { $bg .= '
'; $bg .= '

'.$event->title.' ('.$event->spkbg.')

'; if (strlen($event->subtitle)>2) $bg .= '

'.htmlentities($event->subtitle).'

'; $bg .= '

'.htmlentities($event->abstract).'

'; # $bg .= '

'.htmlentities($event->description).'

'; $bg .= "
"; $bg .= '
'; $en .= '
'; $en .= '

'.$event->title.' ('.$event->spken.')

'; if (strlen($event->subtitle)>2) $en .= '

'.htmlentities($event->subtitle).'

'; $en .= '

'.htmlentities($event->abstract).'

'; # $en .= '

'.htmlentities($event->description).'

'; $en .= "
"; $en .= '
'; }; $bg .= ''; $en .= ''; $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);