|
141 | 141 | // Print body of home page. |
142 | 142 | echo $content; |
143 | 143 |
|
144 | | -// Prepare announcements. |
145 | | -if (is_array($CONF_TEASER)) { |
| 144 | +// Prepare announcements from conferences. |
| 145 | +$conferences = (new NewsHandler())->getConferences(); |
| 146 | +if ($conferences) { |
| 147 | + $confsByCategory = []; |
| 148 | + foreach ($conferences as $entry) { |
| 149 | + foreach ($entry['category'] as $cat) { |
| 150 | + if ($cat['term'] === 'conferences' || $cat['term'] === 'cfp') { |
| 151 | + $confsByCategory[$cat['term']][] = $entry; |
| 152 | + break; |
| 153 | + } |
| 154 | + } |
| 155 | + } |
146 | 156 | $conftype = [ |
147 | | - 'conference' => 'Upcoming conferences', |
| 157 | + 'conferences' => 'Upcoming conferences', |
148 | 158 | 'cfp' => 'Conferences calling for papers', |
149 | 159 | ]; |
150 | 160 | $announcements = ""; |
151 | | - foreach ($CONF_TEASER as $category => $entries) { |
152 | | - if ($entries) { |
153 | | - $announcements .= '<div class="panel">'; |
154 | | - $announcements .= ' <a href="/conferences" class="headline" title="' . $conftype[$category] . '">' . $conftype[$category] . '</a>'; |
155 | | - $announcements .= '<div class="body"><ul>'; |
156 | | - foreach (array_slice($entries, 0, 4) as $url => $title) { |
157 | | - $title = preg_replace("'([A-Za-z0-9])([\s:\-,]*?)call for(.*?)$'i", "$1", $title); |
158 | | - $announcements .= "<li><a href='$url' title='$title'>$title</a></li>"; |
| 161 | + foreach ($confsByCategory as $category => $entries) { |
| 162 | + $announcements .= '<div class="panel">'; |
| 163 | + $announcements .= ' <a href="/conferences" class="headline" title="' . $conftype[$category] . '">' . $conftype[$category] . '</a>'; |
| 164 | + $announcements .= '<div class="body"><ul>'; |
| 165 | + foreach (array_slice($entries, 0, 4) as $entry) { |
| 166 | + $title = preg_replace("'([A-Za-z0-9])([\s:\-,]*?)call for(.*?)$'i", "$1", $entry['title']); |
| 167 | + $link = $entry['newsImage']['link'] ?? preg_replace('~^(http://php.net/|https://www.php.net/)~', '', $entry['id']); |
| 168 | + $dateInfo = ''; |
| 169 | + if (!empty($entry['finalTeaserDate'])) { |
| 170 | + $confDate = date_create($entry['finalTeaserDate']); |
| 171 | + if ($confDate) { |
| 172 | + $dateInfo = ' <small>' . date_format($confDate, 'M j') . '</small>'; |
| 173 | + } |
159 | 174 | } |
160 | | - $announcements .= '</ul></div>'; |
161 | | - $announcements .= '</div>'; |
| 175 | + $announcements .= "<li><a href='" . htmlspecialchars($link) . "' title='" . htmlspecialchars($title) . "'>" . htmlspecialchars($title) . "</a>$dateInfo</li>"; |
| 176 | + } |
| 177 | + $announcements .= '</ul></div>'; |
| 178 | + if (count($entries) > 4) { |
| 179 | + $announcements .= '<div class="body"><a href="/conferences">View all »</a></div>'; |
162 | 180 | } |
| 181 | + $announcements .= '</div>'; |
163 | 182 | } |
164 | 183 | } else { |
165 | 184 | $announcements = ''; |
|
0 commit comments