From 92cee81ad302fede42e287eb12ad9e2eec14a345 Mon Sep 17 00:00:00 2001 From: Vasil Kolev Date: Thu, 16 Oct 2014 19:29:43 +0300 Subject: [PATCH] add workshops page --- load-speakers.php | 4 +- load-workshops.php | 188 +++++++++++++++++++++++++++++++++++++++++++++ page.php | 2 +- 3 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 load-workshops.php diff --git a/load-speakers.php b/load-speakers.php index 56be74d..51ca2c1 100644 --- a/load-speakers.php +++ b/load-speakers.php @@ -19,9 +19,9 @@ $chld = get_children($args); foreach ($chld as $k => $att) { if (preg_match('/^photo_spk/', $att->post_name)) - var_dump(wp_delete_post($att->ID, true)); + wp_delete_post($att->ID, true); } - var_dump(wp_delete_post($v->ID, true)); + wp_delete_post($v->ID, true); } } diff --git a/load-workshops.php b/load-workshops.php new file mode 100644 index 0000000..91817ef --- /dev/null +++ b/load-workshops.php @@ -0,0 +1,188 @@ + '; + $en = '
 
 Зала ПловдивЗала Бургас
'; + + $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 + join events_speaker_profiles esp on esp.event_id=e.id + join speaker_profiles sp on esp.speaker_profile_id=sp.id + where + not s.event_id is null and h.id in (4,5) + 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'] = "Workshop-и"; + $enpost['post_title'] = "Workshops"; + + $bgpost['post_name'] = "workshopsbg"; + $enpost['post_name'] = "workshops"; + + $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+3 < $event->hallid) { + $h++; + $bg .= "\n"; + $en .= "\n"; + } + + $spkarr = explode(',', str_replace($clearsmb, '' ,$event->spname)); + $spkbgarr = array(); + $spkenarr = array(); + foreach ($spkarr as $val){ + $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 < 2) { + $h++; + $bg .= "\n"; + $en .= "\n"; + } + $bg .= ''."\n"; + $en .= ''."\n"; + } + } + + $bg .= '
 Plovdiv HallBurgas Hall
'.$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); + + diff --git a/page.php b/page.php index 56da11d..36732fa 100644 --- a/page.php +++ b/page.php @@ -6,7 +6,7 @@ if ( preg_match('/^(about|ideas-and-recommendations|feedback|team|history|volunt wp_nav_menu( array( 'theme_location' => 'subnav-menu', 'container_class' => 'content subnav cf' ) ); } -if ( preg_match('/^(schedule|programa|speakers|halls)/', $pagename) ) { +if ( preg_match('/^(schedule|programa|speakers|halls|workshop)/', $pagename) ) { wp_nav_menu( array( 'theme_location' => 'footer-schedule', 'container_class' => 'content subnav cf' ) ); }