diff --git a/cli-header.php b/cli-header.php new file mode 100644 index 0000000..cd97e19 --- /dev/null +++ b/cli-header.php @@ -0,0 +1,27 @@ +
'; + +$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.= ""; + $bg.= "
".pll_translate_string($chall, 'en')." Hall
"; + } + + + + $bg .= ''; + $bg .= ''; + + $en .= ''; + $en .= ''; + /* + + + + + */ + + } + $bg.= "
Зала ".pll_translate_string($chall,'bg')."
'.$row->start.' - '.$row->end.''.htmlentities($row->title).'
'; + $bg .= ''.htmlentities($row->spname).'
'; + $bg .= ''.$row->tname.''; + $bg .= '
'.htmlentities($row->abstract).'
'.$row->start.' - '.$row->end.''.htmlentities($row->title).'
'; + $en .= ''.htmlentities($row->spname).'
'; + $en .= ''.$row->tname.''; + $en .= '
'.htmlentities($row->abstract).'
10:15 – 11:00Open-source hardware от България + Цветан Узунов +
Какво е OSHW (Open Source Hardware)? + Какви са приликите и разликите между OSHW и FOSS? + Може ли да се прави бизнес с OSHW? + Кога да правим и кога да не правим OSHW? + OLinuXino boards roadmap. + Olimex's Arduino boards roadmap.
\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'); + }*/ + diff --git a/load-program.php b/load-program.php new file mode 100644 index 0000000..e70417d --- /dev/null +++ b/load-program.php @@ -0,0 +1,188 @@ + '; + $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 + 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 + 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){ + $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); + + diff --git a/load-speakers.php b/load-speakers.php new file mode 100644 index 0000000..b40a6bd --- /dev/null +++ b/load-speakers.php @@ -0,0 +1,68 @@ + 'speakers','lang' => $lang, 'nopaging' => 'true'); + $speakers = new WP_Query( $speakers_args ); + + $result = $speakers->get_posts(); + # var_dump($result); + + foreach ($result as $k=>$v) { + $args = array( + 'post_parent' => $v->id, + 'post_type' => 'attachment', + 'posts_per_page' => -1, + 'post_status' => 'any' ); + + $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)); + } + var_dump(wp_delete_post($v->ID, true)); + } + } + + $spk = pg_query("select + distinct sp.user_id, sp.id, sp.first_name, sp.last_name, e.language, picture, biography, github, twitter + from + speaker_profiles sp join events_speaker_profiles esp on sp.id=esp.speaker_profile_id + join events e on esp.event_id=e.id + where e.state=1 + order by sp.first_name, sp.last_name; +"); + + while ($row = pg_fetch_object($spk)) { + $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_bg_".$row->user_id); + preg_match("%src='(http://[^']*)'%", $att, $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'); + + $postid_en=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_en, "photo_spk_en_".$row->user_id); + preg_match("%src='(http://[^']*)'%", $att, $matches); + $wpurl = $matches[1]; + $attid = pn_get_attachment_id_from_url($wpurl); + add_post_meta($postid_en, '_thumbnail_id', $attid); + pll_set_post_language($postid_en, 'en'); + + pll_save_post_translations(array($postid => 'bg', $postid_en => '$en')); + + } + diff --git a/pgconn.dist.php b/pgconn.dist.php new file mode 100644 index 0000000..a23af79 --- /dev/null +++ b/pgconn.dist.php @@ -0,0 +1,6 @@ +