diff --git a/css/styles.css b/css/styles.css index 7de0ea7..d440b9a 100644 --- a/css/styles.css +++ b/css/styles.css @@ -168,134 +168,138 @@ } body { - width: 100%; - height: 100%; - margin: 0; - padding: 0; - font-size: 16px; - font-family: 'Arimo', sans-serif; + width: 100%; + height: 100%; + margin: 0; + padding: 0; + font-size: 16px; + font-family: 'Arimo', sans-serif; } @media all and (max-width: 400px) { - body { - font-size: 14px; - } + body { + font-size: 14px; + } } .content { - max-width: 960px; - margin: 0 auto; - position: relative; + max-width: 960px; + margin: 0 auto; + position: relative; } p { - margin: 0 0 1em 0; - padding: 0; + margin: 0 0 1em 0; + padding: 0; line-height: 1.5em; font-weight: 300; } h1.big { - font-size: 2.4em; - margin-top: 0; - margin-bottom: 0.6em; - padding-top: 0; + font-size: 2.4em; + margin-top: 0; + margin-bottom: 0.6em; + padding-top: 0; } a { - color: #000; + color: #000; } a:hover { - color: #7789b5; + color: #7789b5; } a img { - border: none; + border: none; } h3 small { - font-size: 0.65em; + font-size: 0.65em; } .tac { - text-align: center; + text-align: center; } @media all and (max-width: 960px) { - .content { - padding: 0 1em; - } + .content { + padding: 0 1em; + } } .left { float: left; } .right { float: right; } .cf::after, .cf::before { - content: " "; - clear: both; - display: block; + content: " "; + clear: both; + display: block; } /* Navigation */ nav { - position: relative; - height: 84px; - background: url("../img/navbg.jpg") repeat-x; + position: relative; + height: 84px; + background: url("../img/navbg.jpg") repeat-x; } nav ul { - float: right; - list-style: none; - margin: 0; - padding: 0; + float: right; + list-style: none; + margin: 0; + padding: 0; } nav ul li { - position: relative; + position: relative; } nav .menu > li { - float: left; - margin: 0; - padding: 0; + float: left; + margin: 0; + padding: 0; } nav .menu > li { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - transition: border-top 200ms; - -webkit-transition: border-top 200ms; - border-top: 0 solid #FFF; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + transition: border-top 200ms; + -webkit-transition: border-top 200ms; + border-top: 0 solid #FFF; } nav .menu > li:hover { - border-top: 0.4em solid #A8D6FF; + border-top: 0.4em solid #A8D6FF; } .menu li.fa::before { - display: block; - padding: 30px 4px 0 4px; + display: block; + padding: 30px 4px 0 4px; } .menu li.fa a { - position: absolute; - display: block; - top: 0; - left: 0; - height: 52px; - width: 10px; - text-indent: -9999px; + position: absolute; + display: block; + top: 0; + left: 0; + height: 52px; + width: 10px; + text-indent: -9999px; +} + +nav > .content { + max-width: 1080px; } nav ul a { - color: #000; - text-decoration: none; - display: block; - padding: 1.9em 0.4em 1.5em 0.4em; + color: #000; + text-decoration: none; + display: block; + padding: 1.9em 0.4em 1.5em 0.4em; } nav ul .sub-menu { - display: none; - position: absolute; - background: #fff; - width: 200px; - left: 50%; - margin-left: -100px; - box-shadow: 0 3px 5px -3px #000 + display: none; + position: absolute; + background: #fff; + width: 200px; + left: 50%; + margin-left: -100px; + box-shadow: 0 3px 5px -3px #000 } nav ul li:hover .sub-menu { - display: block; - position: absolute; + display: block; + position: absolute; } nav ul .sub-menu li, @@ -306,51 +310,51 @@ nav ul .sub-menu li a { padding: 1em 0; text-align: center; } nav ul .sub-menu li { border-bottom: 1px solid #ccc; } nav ul .separator { - display: block; - width: 0.05em; - background: #B7B7B7; - height: 2em; - margin: 1.1em 0.4em 0 0.4em; + display: block; + width: 0.05em; + background: #B7B7B7; + height: 2em; + margin: 1.1em 0.4em 0 0.4em; } nav .logo { - display: block; - position: absolute; - top: 0; - left: 0; + display: block; + position: absolute; + top: 0; + left: 0; } nav .selected { - font-weight: bold; + font-weight: bold; } @media all and (max-width: 840px) { - nav .logo { - display: none; - } - nav .logo img { - display: block; - max-height: 100%; - } - nav { - height: auto; - background: none; - padding: 0.4em 0; - border-bottom: 0.2em solid #d7ecff; - } - nav ul { - float: none; - } - nav ul a { - padding: 0.2em; - } - nav ul .separator { - display: block; - width: 0.05em; - background: #B7B7B7; - height: 1em; - margin: 0.2em 0.2em 0 0.2em; - } - nav ul a:hover { - border-top: 0 solid #A8D6FF; - } + nav .logo { + display: none; + } + nav .logo img { + display: block; + max-height: 100%; + } + nav { + height: auto; + background: none; + padding: 0.4em 0; + border-bottom: 0.2em solid #d7ecff; + } + nav ul { + float: none; + } + nav ul a { + padding: 0.2em; + } + nav ul .separator { + display: block; + width: 0.05em; + background: #B7B7B7; + height: 1em; + margin: 0.2em 0.2em 0 0.2em; + } + nav ul a:hover { + border-top: 0 solid #A8D6FF; + } nav .fa-twitter, nav .fa-facebook, nav .fa-rss { display: none; } @@ -359,145 +363,144 @@ nav .selected { /* Banner */ .banner { - height: 258px; - background: url("../img/banner.jpg") no-repeat; - background-size: cover; - padding: 0.2em 0 0 0; + height: 258px; + background: url("../img/banner.jpg") no-repeat; + background-size: cover; + padding: 0.2em 0 0 0; } .banner img { - display: block; - max-width: 100%; - height: 247px; - margin: 0 auto; + display: block; + max-width: 100%; + height: 247px; + margin: 0 auto; } @media all and (max-width: 840px) { - .banner { display: none; } + .banner { display: none; } } /* Grid */ .grid { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 100%; } .grid::after { - content: " "; - clear: both; - display: block; + content: " "; + clear: both; + display: block; } .grid .col2 { - width: 50%; - float: left; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + width: 50%; + float: left; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } .grid .col2+.col2, .grid .col3+.col3, .grid .col4+.col4 { - padding: 0 0 0 1em; + padding: 0 0 0 1em; } .grid .col3 { - width: 33%; - float: left; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + width: 33%; + float: left; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } .grid .col3:nth-child(3n + 1) { - clear: both; - padding: 0; + clear: both; + padding: 0; } .grid .col4 { - width: 25%; - float: left; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + width: 25%; + float: left; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } .grid .col4:nth-child(4n + 1) { - clear: both; - padding: 0; + clear: both; + padding: 0; } .grid .col-left { - width: 70%; - float: left; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - padding: 0 1.6em 0 0; + width: 70%; + float: left; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 0 1.6em 0 0; } .grid .col-right { - width: 30%; - float: left; + width: 30%; + float: left; margin-bottom: 2em; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } .grid .col-right .content { width: 100%; } @media all and (max-width: 600px) { - .grid .col2, .grid .col3, .grid .col4, .grid .col-left, .grid .col-right { - width: 100%; - float: none; - padding: 0 0 1em 0; - } - .grid .col2+.col2, .grid .col3+.col3, .grid .col4+.col4 { - padding: 0; - } + .grid .col2, .grid .col3, .grid .col4, .grid .col-left, .grid .col-right { + width: 100%; + float: none; + padding: 0 0 1em 0; + } + .grid .col2+.col2, .grid .col3+.col3, .grid .col4+.col4 { + padding: 0; + } } /* Separator */ .separator { - width: 100%; - margin: 1.8em 0; - height: 0.1em; - background: #7789b5; + width: 100%; + margin: 1.8em 0; + height: 0.1em; + background: #7789b5; } /* News */ h4 { - margin: 1em 0 0 0; - padding: 0; - height: 70px; + margin: 1em 0 0.4em 0; + padding: 0; } p.info + p { - height: 240px; + height: 240px; overflow: hidden; } .entry-content { - padding: 0 0 2em 0; + padding: 0 0 2em 0; } .info { - color: #8F8F8F; - font-size: 0.6em; - margin: 0 0 1em 0; + color: #8F8F8F; + font-size: 0.6em; + margin: 0 0 1em 0; } .button { - display: inline-block; - padding: 0.4em 0.6em; - border-radius: 0.4em; - background: #DEDEDE; - font-size: 0.8em; - margin: 1em 0 1em 0; - text-decoration: none; - border-bottom: 0.15em solid #999; + display: inline-block; + padding: 0.4em 0.6em; + border-radius: 0.4em; + background: #DEDEDE; + font-size: 0.8em; + margin: 1em 0 1em 0; + text-decoration: none; + border-bottom: 0.15em solid #999; } /* Footer */ footer { - margin: -0.3em 0 0; - padding-top: 1em; - padding-bottom: 1em; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - background: #ddd; + margin: -0.3em 0 0; + padding-top: 1em; + padding-bottom: 1em; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + background: #ddd; } footer h3 { @@ -528,82 +531,86 @@ footer .content li a { /* Sub navigation */ .subnav { - margin-top: 1.6em; - list-style: none; - padding-left: 0; + margin-top: 1.6em; + list-style: none; + padding-left: 0; } .subnav .menu { margin-left: -2.2em; } .subnav li { - float: left; - padding: 0; - margin: 0 1em 0 0; + float: left; + padding: 0; + margin: 0 1em 0 0; list-style: none outside; } .subnav li.selected { - font-weight: bold; + font-weight: bold; } .subnav a { - text-decoration: none; + text-decoration: none; } @media all and (max-width: 960px) { - .subnav { - padding: 0 1em; - } + .subnav { + padding: 0 1em; + } } /* Speaker */ .speaker { - position: relative; - margin: 0 0 2em 0; + position: relative; + margin: 0 0 2em 0; } .speaker::after { - content: " "; - clear: both; - display: block; + content: " "; + clear: both; + display: block; } .speaker > img { /* width: 100px; */ - float: left; - padding: 0.3em; - background: #FFF; - -moz-box-shadow: 0px 0px 1px 1px #999; - -webkit-box-shadow: 0px 0px 1px 1px #999; - box-shadow: 0px 0px 1px 1px #999; - margin: 0 1em 2em 0; + float: left; + padding: 0.3em; + background: #FFF; + -moz-box-shadow: 0px 0px 1px 1px #999; + -webkit-box-shadow: 0px 0px 1px 1px #999; + box-shadow: 0px 0px 1px 1px #999; + margin: 0 1em 2em 0; } .speaker .icons { - text-align: center; - display: inline-block; - margin: 0 0 0 0.1em; + text-align: center; + display: inline-block; + margin: 0 0 0 0.1em; } .speaker .icons a { - display: inline-block; - margin: 0 0.3em 0 0; + display: inline-block; + margin: 0 0.3em 0 0; } .speaker h3 { - margin: 0 0 0.4em 0; - padding: 0; + margin: 0 0 0.4em 0; + padding: 0; } /* Sponsors */ .sponsors-item { - padding: 0 0 2em 0; + padding: 0 0 2em 0; } .sponsors-item .col2 > img { - display: inline-block; - margin: 0 0 2em 0; + display: inline-block; + margin: 0 0 2em 0; } .sponsors-frontpage a { - display: inline-block; - padding: 0 2.2em 1em 0; + display: inline-block; + padding: 0 2.2em 1em 0; +} +.sponsors-frontpage p a { + display: inline; + padding: 0; } /* Plugins */ .gmp_map_opts { - float: none !important; + float: none !important; margin-top: 2em !important; } @@ -657,30 +664,30 @@ a.button:hover { opacity: 0.8; } *********************************************/ .members { - margin: 0 0 2em 0; + margin: 0 0 2em 0; } .member { - margin: 0 0 1em 0; + margin: 0 0 1em 0; } .member a { - display: block; + display: block; } .member a > img { width: 100px; max-width: 100%; - padding: 0.3em; - background: #FFF; - -moz-box-shadow: 0px 0px 1px 1px #999; - -webkit-box-shadow: 0px 0px 1px 1px #999; - box-shadow: 0px 0px 1px 1px #999; + padding: 0.3em; + background: #FFF; + -moz-box-shadow: 0px 0px 1px 1px #999; + -webkit-box-shadow: 0px 0px 1px 1px #999; + box-shadow: 0px 0px 1px 1px #999; } .member span { - display: block; + display: block; } .member .icons a { - display: inline-block; - margin: 0 0.3em 0 0; + display: inline-block; + margin: 0 0.3em 0 0; } /* from the old site */ @@ -700,7 +707,7 @@ a.button:hover { opacity: 0.8; } } .program table td.time { width: 130px; - vertical-align: baseline; + vertical-align: baseline; } .program table caption { font-size: 120%; @@ -713,103 +720,177 @@ a.button:hover { opacity: 0.8; } * Team members *********************************************/ .schedule { - width: 100%; - font-size: 0.8em; - margin: 0 0 3em 0; - clear: both; + width: 100%; + font-size: 0.8em; + margin: 0 0 3em 0; + clear: both; } .schedule-legend { - width: 300px; + width: 300px; } .schedule th, .schedule td { - border-bottom: 1px solid #000; - border-right: 1px dotted #999; - padding: 0.6em 0.4em; - text-align: center; - vertical-align: middle; + border-bottom: 1px solid #000; + border-right: 1px dotted #999; + padding: 0.6em 0.4em; + text-align: center; + vertical-align: middle; + box-shadow: 0px 1px 2px #999; } .schedule-legend td { - padding: 0.4em; + padding: 0.4em; } .schedule a { - border-bottom: dotted 1px #000; - color: #000; + border-bottom: dotted 1px #999; + color: #000; + font-weight: bold; } .schedule a:hover { - border-bottom: none; + border-bottom: none; } .schedule tr td:first-child { - min-width: 82px; + min-width: 82px; } .schedule-day { - font-weight: bold; + font-weight: bold; } .schedule-empty { - background: #FFF; + background: #FFF; } -.schedule-social { - background: #EDD7A7; + +/* Color definitions */ + +/* Open-biz track 2015 */ +.schedule-open-biz { + background: #75d3b3; + color: #000; } +.schedule-open-biz a { + color: #000; +} +.schedule-10 { + background: #75d3b3; + color: #000; +} +.schedule-10 a { + color: #000; +} + +/* OpenArt track 2015*/ +.schedule-open-art { + background: #F0A388; +} +.schedule-11 { + background: #F0A388; +} + +/* Technical track 2015 */ .schedule-technical { - background: #A4D183; + background: #e9d765; + color: #000; } +.schedule-technical a { + color: #000; +} +.schedule-12 { + background: #e9d765; + color: #000; +} +.schedule-12 a { + color: #000; +} + +/* Civic hacking track 2015 */ +.schedule-civic { + background: #DAEBBB; + color: #000; +} +.schedule-civic a { + color: #000; +} +.schedule-13 { + background: #DAEBBB; + color: #000; +} +.schedule-13 a { + color: #000; +} + +/* Social track 2015 */ +.schedule-social { + background: #a6b4de; +} +.schedule-14 { + background: #; +} + +/* Advanced technical track 2015 */ +.schedule-advanced-technical { + background: #DF9959; + color: #000; +} +.schedule-advanced-technical a { + color: #000; +} +.schedule-15 { + background: #DF9959; + color: #000; +} +.schedule-15 a { + color: #000; +} + +/* Misc track 2015 */ +.schedule-misc { + background: #fff; +} +.schedule-16 { + background: #fff; +} + +/* Workshop 2015 */ .schedule-workshop { - background: #E2E0E9; + background: #E2E0E9; } + .schedule-en::after { - content: " "; - background: url('../img/en_US.png'); - width: 16px; - height: 11px; - display: block; - margin: 0.3em auto 0.3em auto; + content: " "; + background: url('../img/en_US.png'); + width: 16px; + height: 11px; + display: block; + margin: 0.3em auto 0.3em auto; } .schedule-bg::after { - content: " "; - background: url('../img/bg_BG.png'); - width: 16px; - height: 11px; - display: block; - margin: 0.3em auto 0.3em auto; -} -.schedule-civic { - background: #E8AAAB; -} -.schedule-advanced-technical { - background: #91C4DF; -} -.schedule-open-biz { - background: #DECDCB; -} -.schedule-misc { - background: #B0E9EC; -} -.schedule-open-art { - background: #ED9134; + content: " "; + background: url('../img/bg_BG.png'); + width: 16px; + height: 11px; + display: block; + margin: 0.3em auto 0.3em auto; } .schedule-avatar { - float: left; - padding: 0.3em; - background: #FFF; - -moz-box-shadow: 0px 0px 1px 1px #999; - -webkit-box-shadow: 0px 0px 1px 1px #999; - box-shadow: 0px 0px 1px 1px #999; - margin: 0 1em 2em 0; + float: left; + padding: 0.3em; + background: #FFF; + -moz-box-shadow: 0px 0px 1px 1px #999; + -webkit-box-shadow: 0px 0px 1px 1px #999; + box-shadow: 0px 0px 1px 1px #999; + margin: 0 1em 2em 0; } p img { - max-width: 100%; + max-width: 100%; } .front-page-sponsors { - text-align: center; + text-align: center; } .front-page-big-title h1 { - font-size: 1.4em; - text-align: center; + font-size: 1.4em; + text-align: center; } .content.front-page-big-title { - padding: 1em 0 0 0; + padding: 1em 0 0 0; } section.entry-meta { diff --git a/front-page.php b/front-page.php index abb23f3..c614c26 100644 --- a/front-page.php +++ b/front-page.php @@ -1,4 +1,257 @@ + + + + + + +
+

Streaming |

+

+

+

+ +

+

+ RTMP | HLS +

+

+

+
+ + +
+ +
diff --git a/functions.php b/functions.php index c3c2a7c..4cc3b5a 100644 --- a/functions.php +++ b/functions.php @@ -335,4 +335,11 @@ if (function_exists("pll_register_string")) { pll_register_string('hall3','G1'); pll_register_string('hall4','Пловдив'); pll_register_string('hall5','Бургас'); + pll_register_string('bulgaria_hall','BULGARIA_HALL'); + pll_register_string('chamber_hall','CHAMBER_HALL'); + pll_register_string('music_hall','MUSIC_HALL'); + pll_register_string('low_quality','LOW_QUALITY'); + pll_register_string('normal_quality','NORMAL_QUALITY'); + pll_register_string('high_quality','HIGH_QUALITY'); + pll_register_string('all_streams','ALL_STREAMS'); } diff --git a/img/banner-bg-2015.png b/img/banner-bg-2015.png index 093979f..296cf6b 100644 Binary files a/img/banner-bg-2015.png and b/img/banner-bg-2015.png differ diff --git a/img/banner-en-2015.png b/img/banner-en-2015.png index d7179b7..0bf36e9 100644 Binary files a/img/banner-en-2015.png and b/img/banner-en-2015.png differ diff --git a/page-schedule.php b/page-schedule.php new file mode 100644 index 0000000..77f5cda --- /dev/null +++ b/page-schedule.php @@ -0,0 +1,58 @@ + 'footer-schedule', 'container_class' => 'content subnav cf' ) ); + +require("schedule-config.php"); + +$content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARATOR . 'parse.php'; +//var_dump($data); +?> +
+
+

+ + + + + + + + + + + + + + +
 
+
+ + + + +
+ +
+ +
+ + + + diff --git a/page-speakers.php b/page-speakers.php index c84fa41..d4deb25 100644 --- a/page-speakers.php +++ b/page-speakers.php @@ -1,90 +1,34 @@ 'footer-schedule', 'container_class' => 'content subnav cf' ) ); -get_header(); - -if ( preg_match('/^(schedule|programa|speakers|halls)/', $pagename) ) { - wp_nav_menu( array( 'theme_location' => 'footer-schedule', 'container_class' => 'content subnav cf' ) ); -} +require("schedule-config.php"); +$content = require __DIR__ . DIRECTORY_SEPARATOR . 'schedule' . DIRECTORY_SEPARATOR . 'parse.php'; +//var_dump($data); ?> -
-
-

+
+

-
- 'speakers', 'nopaging' => 'true', 'order' => 'ASC' ); - $speakers = new WP_Query( $speakers_args ); - - if ( $speakers->have_posts() ) : - while ( $speakers->have_posts() ) : $speakers->the_post(); - ?> - - - -
-
- 'speakers', 'nopaging' => 'true', 'order' => 'ASC' ); - $speakers = new WP_Query( $speakers_args ); - - if ( $speakers->have_posts() ) : - while ( $speakers->have_posts() ) : $speakers->the_post(); - ?> -
- - - -

-
- '; - if (!empty($custom['github'])) echo ''; - if (!empty($custom['public_email'])) echo ''; -?> -
- - -
-
- + + foreach ($content['gspk'] as $line) { + echo $line, PHP_EOL; + } + +?> +
+ +
+
+ + diff --git a/schedule-config.php b/schedule-config.php new file mode 100644 index 0000000..0034ff9 --- /dev/null +++ b/schedule-config.php @@ -0,0 +1,58 @@ + array('lectures' => array(1, 2, 3), 'workshops' => array(4, 5), 'all' => array(1, 2, 3, 4, 5) ), + '2015' => array('lectures' => array(6, 7, 8), 'workshops' => array(9), 'all' => array(6, 7, 8, 9) ) +); + +/* clarion conference ids */ +$confids = array('2014' => 1, '2015' => 2); + + +/* get stuff from WP and parse */ +$siteurl = get_option('siteurl'); +$year = preg_replace('%.*/([0-9]*)$%', '\1', $siteurl); + +$CF['confid'] = $confids[$year]; + +/* TODO make this read the ids from the proper place, as this breaks other years*/ +if ( preg_match('/^workshop/', $pagename) ) { + $CF['allowedhallids'] = $hall_defs[$year]['workshops']; +} else if (preg_match('/^(speakers|lektori)/', $pagename) ) { + $CF['allowedhallids'] = $hall_defs[$year]['all']; +} else { + $CF['allowedhallids'] = $hall_defs[$year]['lectures']; +} + +/* + * There is no better way to get where the speakers are + */ + +if ('en' === $CF['lang']) { + $CF['s_slug'] = 'speakers'; +} else { + $CF['s_slug'] = 'lektori'; +} + +$args = array( + 'name' => $CF['s_slug'], + 'post_type' => 'page', + 'numberposts' => 1 +); + +$speakers_url = ''; + +$my_posts = get_posts($args); +if( $my_posts ) { + $CF['speakers_url'] = get_permalink( $my_posts[0]->ID ); +} + + +?> diff --git a/schedule/.gitignore b/schedule/.gitignore new file mode 100644 index 0000000..f3917d2 --- /dev/null +++ b/schedule/.gitignore @@ -0,0 +1,2 @@ +cache +cache.json diff --git a/schedule/class.SmartCurl.php b/schedule/class.SmartCurl.php new file mode 100644 index 0000000..b963a31 --- /dev/null +++ b/schedule/class.SmartCurl.php @@ -0,0 +1,137 @@ +cache_dir = __DIR__ . DIRECTORY_SEPARATOR . $cache_dir; + } + + if (!file_exists($this->cache_dir)) { + mkdir($this->cache_dir); + } + + $this->cache_index = $this->cache_dir . '.json'; + + $cache = file_exists($this->cache_index) ? file_get_contents($this->cache_index) : false; + + if ($cache !== false) { + $cache = json_decode($cache, true); + } + + if ($cache !== false) { + static::importEtags($cache); + } + + if (!is_null($url_root)) { + $this->url_root = $url_root; + } + + $ch = curl_init(); + + if ($ch === false) { + throw new Exception('curl init failed'); + } + + $this->ch = $ch; + + if (curl_setopt_array($ch, [ + CURLOPT_FAILONERROR => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HEADER => true, + //CURLINFO_HEADER_OUT => true, + ]) === false) { + throw new Exception('curl setopt failed'); + } + } + + public function __destruct() { + curl_close($this->ch); + file_put_contents($this->cache_index, json_encode(static::exportEtags())); + } + + public static function importEtags(array $etags) { + static::$etags = array_merge(static::$etags, $etags); + } + + public static function exportEtags() { + return static::$etags; + } + + public function getUrl($filename) { + if (is_null($this->url_root)) { + $url = $filename; + } + else { + $url = $this->url_root . $filename; + } + + if (curl_setopt($this->ch, CURLOPT_URL, $url) === false) { + throw new Exception('set url failed'); + } + + $cache_file = $this->cache_dir . DIRECTORY_SEPARATOR . $filename; + + $etag = array_key_exists($url, static::$etags) && file_exists($cache_file) ? static::$etags[$url] : null; + + if (curl_setopt($this->ch, CURLOPT_HTTPHEADER, [ + 'If-None-Match:' . (is_null($etag) ? '' : ' ' . $etag), + ]) === false) { + throw new Exception('set etag failed'); + } + + $response = curl_exec($this->ch); + + if ($response === false) { + return false; + } + + //var_dump(curl_getinfo($this->ch, CURLINFO_HEADER_OUT)); + //var_dump($response); + + $header_size = curl_getinfo($this->ch, CURLINFO_HEADER_SIZE); + $header = substr($response, 0, $header_size); + $headers = array_filter(explode("\r\n", $header)); + + foreach ($headers as $header_line) { + if (stripos($header_line, 'etag:') === 0) { + static::$etags[$url] = trim(substr($header_line, strlen('etag:'))); + } + } + + $http_code = curl_getinfo($this->ch, CURLINFO_HTTP_CODE); + + if ($http_code === 304 && !is_null($this->url_root)) { + // use cache + + if (file_exists($cache_file)) { + return file_get_contents($cache_file); + } + else { + return false; + } + } + + if (strlen($response) === $header_size) { + return false; + } + + $body = substr($response, $header_size); + + if ($http_code === 200) { + $dirname = dirname($filename); + + if ($dirname !== '.') { + mkdir($this->cache_dir . DIRECTORY_SEPARATOR . $dirname, 0777, true); + } + + file_put_contents($cache_file, $body); + } + + return $body; + } +} diff --git a/schedule/index.php b/schedule/index.php new file mode 100644 index 0000000..32fc571 --- /dev/null +++ b/schedule/index.php @@ -0,0 +1,49 @@ + + +Test schedule + + + +
+
+
+ + + + + + + + + + + + +
 
+
+ 'events.json', + 'speakers' => 'speakers.json', + 'tracks' => 'tracks.json', + 'event_types' => 'event_types.json', + 'halls' => 'halls.json', + 'slots' => 'slots.json', +]; + + +$data = []; + +foreach ($filenames as $name => $filename) { + $curl = new SmartCurl($base_url, 'cache' . DIRECTORY_SEPARATOR .$CF['confid']); + $json = $curl->getUrl($filename); + + if ($json === false) { + echo 'get failed: ', $filename, ' ', $base_url, PHP_EOL; + exit; + } + + $decoded = json_decode($json, true); + + if ($decoded === false) { + echo 'decode failed: ', $filename, PHP_EOL; + exit; + } + + $add = true; + switch ($name) { + case 'halls': + $ret = array(); + foreach($decoded as $id => $hall) { + if (in_array($id, $CF['allowedhallids'])) $ret[$id] = $hall['name']; + } + $decoded = $ret; + break; + case 'slots': + $decoded = array_map(function($el) { + foreach (['starts_at', 'ends_at'] as $key) { + $el[$key] = strtotime($el[$key]); + } + + return $el; + }, $decoded); + break; + } + + $data[$name] = $decoded; +} + +function compareKeys($a, $b, $key) { + $valA = &$a[$key]; + $valB = &$b[$key]; + + return ($valA < $valB) ? -1 : (($valA > $valB) ? 1 : 0); +} + +uasort($data['slots'], function($a, $b) { + return compareKeys($a, $b, 'starts_at') ?: compareKeys($a, $b, 'hall_id'); +}); + +//array_pop($data['halls']); + +return $data; diff --git a/schedule/parse.php b/schedule/parse.php new file mode 100644 index 0000000..6ab9345 --- /dev/null +++ b/schedule/parse.php @@ -0,0 +1,169 @@ + array('name' => 'English', 'locale' => 'en_US.UTF8'), 'bg' => array ('name' => 'Български', 'locale' => 'bg_BG.UTF8')); + +$cut_len = 70; +$cfp_url = 'http://cfp.openfest.org'; +$time = 0; +$date = 0; +$lines = []; +$fulltalks = []; +$prev_event_id = 0; +$colspan = 1; +$hall_ids = array_keys($data['halls']); +$first_hall_id = min($hall_ids); +$last_hall_id = max($hall_ids); + +/* We need to set these so we actually parse properly the dates. WP fucks up both. */ +date_default_timezone_set('Europe/Sofia'); +setlocale(LC_TIME, $languages[$CF['lang']]['locale']); + +foreach ($data['slots'] as $slot_id => $slot) { + if (! in_array($slot['hall_id'], $CF['allowedhallids'])) continue; + $slotTime = $slot['starts_at']; + $slotDate = date('d', $slotTime); + + if ($slotDate !== $date) { + /* this seems to be the easiest way to localize the date */ + $localdate = strftime('%d %B - %A' ,$slotTime); + $lines[] = ''; + $lines[] = '' . $localdate . ''; + $lines[] = ' '; + $lines[] = ''; + + $date = $slotDate; + } + + if ($slotTime !== $time) { + if ($time !== 0) { + $lines[] = ''; + } + + $lines[] = ''; + $lines[] = '' . date('H:i', $slot['starts_at']) . ' - ' . date('H:i', $slot['ends_at']) . ''; + + $time = $slotTime; + } + + $eid = &$slot['event_id']; + $event = &$data['events'][$eid]; + + if (is_null($eid)) { + $lines[] = 'TBA'; + } + else { + $title = mb_substr($event['title'], 0, $cut_len) . (mb_strlen($event['title']) > $cut_len ? '...' : ''); + $speakers = ''; + + if (count($event['participant_user_ids']) > 0) { + $speakers = json_encode($event['participant_user_ids']) . '
'; + + $spk = array(); + $speaker_name = array(); + foreach ($event['participant_user_ids'] as $uid) { + /* The check for uid==4 is for us not to show the "Opefest Team" as a presenter for lunches, etc. */ + if ($uid == 4 || empty ($data['speakers'][$uid])) { + continue; + } else { + /* TODO: fix the URL */ + $name = $data['speakers'][$uid]['first_name'] . ' ' . $data['speakers'][$uid]['last_name']; + $spk[$uid] = '' . $name . ''; + } + } + $speakers = implode (', ', $spk); + } + + + /* Hack, we don't want language for the misc track. This is the same for all years. */ + if ('misc' !== $data['tracks'][$event['track_id']]['name']['en']) { + $csslang = "schedule-".$event['language']; + } else { + $csslang = ""; + } + $cssclass = &$data['tracks'][$event['track_id']]['css_class']; + $style = ' class="' . $cssclass . ' ' . $csslang . '"'; + $content = '' . htmlspecialchars($title) . '
' . $speakers; + + + /* these are done by $eid, as otherwise we get some talks more than once (for example the lunch) */ + $fulltalks[$eid] = ''; + $fulltalks[$eid] .= '
'; + /* We don't want '()' when we don't have a speaker name */ + $fulltalk_spkr = strlen($speakers)>1 ? ' (' . $speakers . ')' : ''; + $fulltalks[$eid] .= '

' . $event['title'] . ' ' . $fulltalk_spkr . ''; + $fulltalks[$eid] .= '

' . $event['abstract'] . '

'; + $fulltalks[$eid] .= '
'; + + if ($slot['event_id'] === $prev_event_id) { + array_pop($lines); + $lines[] = '' . $content . ''; + } + else { + $lines[] = '' . $content . ''; + $colspan = 1; + } + } + + $prev_event_id = $slot['event_id']; +} + +$lines[] = ''; +/* create the legend */ + +$legend = []; + +foreach($data['tracks'] as $track) { + $legend[] = '' . $track['name'][$CF['lang']] . ''; +} +foreach ($languages as $l => $n) { + $legend[] = '' . $n['name'] . ''; +} + +$gspk = []; +$fspk = []; +$types = []; +$types['twitter']['url']='https://twitter.com/'; +$types['twitter']['class']='fa fa-twitter'; +$types['github']['url']='https://github.com/'; +$types['github']['class']='fa fa-github'; +$types['email']['url']='mailto:'; +$types['email']['class']='fa fa-envelope'; + +$gspk[] = '
'; + +foreach ($data['speakers'] as $speaker) { + $name = $speaker['first_name'] . ' ' . $speaker['last_name']; + + $gspk[] = ''; + + $fspk[] = '
'; + $fspk[] = '' . $name .''; + $fspk[] = '

' . $name . '

'; + $fspk[] = '
'; + foreach ($types as $type => $parm) { + if (!empty($speaker[$type])) { + $fspk[] = ''; + } + } + $fspk[] = '
'; + $fspk[] = '

' . $speaker['biography'] . '

'; + $fspk[] = '
'; +} + +$gspk[] = '
'; + +return array_merge($data, compact('lines', 'fulltalks', 'gspk', 'fspk', 'legend'));