function qem_event_construct($atts) { global $post; $event = event_get_stored_options(); $display = event_get_stored_display(); $vertical = $display['vertical']; $style = qem_get_stored_style(); $cal = qem_get_stored_calendar(); $custom = get_post_custom(); $link = get_post_meta($post->ID, 'event_link', true); $endtime = get_post_meta($post->ID, 'event_end_time', true); $endmonth = $amalgamated = $target = ''; $unixtime = get_post_meta($post->ID, 'event_date', true); $day = date_i18n("d", $unixtime); $enddate = get_post_meta($post->ID, 'event_end_date', true); $image = get_post_meta($post->ID, 'event_image', true); if (!$atts['popup'] && $atts['fullevent'] != 'popup') { $register = qem_get_stored_register(); $payment = qem_get_stored_payment(); $cost = get_post_meta($post->ID, 'event_cost', true); $usereg = get_post_meta($post->ID, 'event_register', true); $usecounter = get_post_meta($post->ID, 'event_counter', true); $usepay = get_post_meta($post->ID, 'event_pay', true); } $today = strtotime(date('Y-m-d')); $category = get_the_category(); $cat = $category && (!$atts['widget'] && $style['cat_border'] || $atts['cb']) ? ' ' . $category[0]->slug : ' '; $titlecat = $datecat = ''; if ($display['showcategory']) { if ($display['categorylocation'] == 'title') { $titlecat = ' - ' . $category[0]->name; } if ($display['categorylocation'] == 'date') { $datecat = ' - ' . $category[0]->name; } } if ($today > $unixtime && $register['notarchive']) { $register['useform'] = ''; $usereg = ''; } if ($atts['images'] == 'off') { $image = ''; } if ($atts['vw']) { $style['vanillawidget'] = 'checked'; } if ($atts['fields']) { foreach (explode(',', $event['sort']) as $name) { $event['summary'][$name] = ''; } $derek = explode(',', $atts['fields']); $event['sort'] = ''; foreach ($derek as $item) { $event['summary']['field' . $item] = 'checked'; $event['sort'] = $event['sort'] . 'field' . $item . ','; } } if ($display['external_link'] && $link) { add_filter('post_type_link', 'qem_external_permalink', 10, 2); } if ($display['external_link_target'] && $link) { $target = ' target="_blank" '; } if ($atts['popup']) { $popupcontent = get_event_popup($atts); } if ($display['show_end_date'] && $enddate || $enddate && is_singular('event')) { $join = 'checked'; } else { $join = ''; } if ($atts['size']) { $width = '-' . $atts['size']; } else { $atts['size'] = $style['calender_size']; $width = '-' . $style['calender_size']; } $h = $atts['headersize'] == 'headthree' ? 'h3' : 'h2'; $content = '<div class="qem' . $cat . '">'; if ($display['amalgamated']) { $month = date_i18n("M", $unixtime); $year = date_i18n("Y", $unixtime); if ($enddate) { $endmonth = date_i18n("M", $enddate); $endday = date_i18n("d", $enddate); $endyear = date_i18n("Y", $enddate); } if ($month == $endmonth && $year == $endyear && $endday) { $amalgamated = 'checked'; } } if (!$style['vanilla'] && !$style['vanillawidget'] || !$style['vanilla'] && $style['vanillawidget'] && !$atts['widget']) { if ($day != $atts['lastday']) { $content .= '<div class="qem-icon">' . get_event_calendar_icon($atts['size'], 'event_date', $join, $atts['vw'], $atts['widget']); if ($join && !$amalgamated && !$vertical) { $content .= '</div><div class="qem-icon">'; } if (($display['show_end_date'] || is_singular('event')) && !$amalgamated) { $content .= get_event_calendar_icon($atts['size'], 'event_end_date', '', $atts['vw'], $atts['widget']); } $content .= '</div>'; } $content .= '<div class="qem' . $width . '">'; $clear = '<div style="clear:both"></div></div>'; } if (!$display['titlelink']) { $linkclose = '</a>'; if ($atts['popup']) { $linkopen = '<a onclick=\'pseudo_popup("<div class =\\"qemeventpop\\">' . $popupcontent . '</div>")\'>'; } else { $linkopen = '<a href="' . get_permalink() . '">'; } } $content .= '<div class="qemright">'; if ($image && $display['event_image'] && !is_singular('event') && !$atts['widget'] || $image && $atts['images']) { $content .= $linkopen . '<img class="qem-list-image" src=' . $image . '>' . $linkclose . '<br>'; } if ($image && is_singular('event') && !$atts['widget']) { $content .= $linkopen . '<img class="qem-image" src=' . $image . '>' . $linkclose . '<br>'; } if ($image && $display['event_image'] && $atts['widget']) { $content .= $linkopen . '<img class="qem-list-image" src=' . $image . '>' . $linkclose . '<br>'; } if (function_exists('file_get_contents') && ($atts['fullevent'] && !$image || $display['map_in_list'] || $display['map_and_image'] && ($display['map_in_list'] || $atts['fullevent']))) { $content .= get_event_map(); } if ($atts['fullevent'] && (($register['useform'] && $usereg || $usereg) && $register['ontheright'])) { $content .= '<div class="qem-rightregister">' . qem_loop() . '</div>'; } $content .= '</div>'; if (!is_singular('event') || $atts['widget']) { $content .= '<' . $h . '>'; if ($atts['links'] == 'checked') { if ($display['titlelink']) { $content .= $post->post_title; } elseif ($atts['popup']) { $content .= '<a onclick=\'pseudo_popup("<div class =\\"qemeventpop\\">' . $popupcontent . '</div>")\'>' . $post->post_title . '</a>'; } else { $content .= '<a href="' . get_permalink() . '"' . $target . '>' . $post->post_title . $titlecat . '</a>'; } } else { $content .= $post->post_title . $titlecat; } $content .= '</' . $h . '>'; } if ($style['vanilla'] || $style['vanillawidget'] && $atts['widget']) { $content .= '<h3>' . get_event_calendar_icon($atts['size'], 'event_date', $join, $atts['vw'], $atts['widget']); if (($display['show_end_date'] || is_singular('event')) && !$amalgamated) { $content .= get_event_calendar_icon($atts['size'], 'event_end_date', '', $atts['vw'], $atts['widget']); } $content .= $datecat . '</h3>'; } if ($atts['fullevent'] == 'popup') { foreach (explode(',', $event['sort']) as $name) { if ($event['active_buttons'][$name]) { $content .= qem_build_event($name, $event, $display, $custom, 'checked'); } } } elseif ($atts['fullevent']) { foreach (explode(',', $event['sort']) as $name) { if ($event['active_buttons'][$name]) { $content .= qem_build_event($name, $event, $display, $custom, 'checked'); } } if (!$atts['popup']) { $content .= get_the_content(); if (($register['useform'] && $usereg || $usereg) && !$register['ontheright']) { $content .= qem_loop(); } } } else { foreach (explode(',', $event['sort']) as $name) { if ($event['summary'][$name] == 'checked') { $content .= qem_build_event($name, $event, $display, $custom, $atts['settings']); } } $content .= qem_totalcoming($register, $payment); if ($register['eventlist'] && $usecounter) { $num = qem_numberscoming($register, $post->ID, $payment); if (!$num) { $content .= '<p class="qem_full">' . $register['eventfullmessage'] . '</p>'; } else { $content .= $num; } } } if ($atts['links'] == 'checked' && ($atts['fullevent'] == 'popup' || !$atts['fullevent']) && $atts['popup']) { $content .= '<p style="cursor:pointer"><a onclick=\'pseudo_popup("<div class =\\"qemeventpop\\">' . $popupcontent . '</div>")\'>' . $display['read_more'] . '</a></p>'; } if ($display['uselistics'] && !is_singular('event')) { $content .= qem_ics(); } if (!$atts['popup'] && !$display['readmorelink'] && ($atts['fullevent'] == 'popup' || !$atts['fullevent'])) { $content .= '<p><a href="' . get_permalink() . '#eventtop"' . $target . '>' . $display['read_more'] . '</a></p>'; } if (is_singular('event') && $display['useics'] && !$atts['widget'] && !$atts['popup']) { $content .= qem_ics(); } if ($display['back_to_list'] && is_singular('event')) { if ($display['back_to_url']) { $content .= '<p><a href="' . $display['back_to_url'] . '">' . $display['back_to_list_caption'] . '</a></p>'; } else { $content .= '<p><a href="javascript:history.go(-1)">' . $display['back_to_list_caption'] . '</a></p>'; } } $content .= $clear . "</div>"; return $content; }
function qem_display_form($values, $errors) { $register = qem_get_stored_register(); $payment = qem_get_stored_payment(); global $post; $event = get_the_ID(); $check = get_post_meta($post->ID, 'event_counter', true); $cost = get_post_meta($post->ID, 'event_cost', true); $paypal = get_post_meta($post->ID, 'event_paypal', true); if ($paypal && $cost) { $payment['paypal'] = 'checked'; } $number = get_post_meta($event, 'event_number', true); if ($check) { $num = qem_numberscoming($register, $event, $payment); } $content = qem_totalcoming($register, $payment); $content .= qem_whoscoming($register, $payment); if ($errors['spam']) { $errors['alreadyregistered'] = 'checked'; $register['alreadyregistered'] = $register['spam']; } elseif ($values['completed']) { if (!empty($register['replytitle'])) { $register['replytitle'] = '<h2>' . $register['replytitle'] . '</h2>'; } if (!empty($register['replyblurb'])) { $register['replyblurb'] = '<p>' . $register['replyblurb'] . '</p>'; } $content .= $register['replytitle'] . $register['replyblurb']; if (function_exists('qpp_loop') && $cost && $payment['useqpp']) { $id = $payment['qppform']; $title = get_the_title(); $args = array('form' => $id, 'id' => $title, 'amount' => $cost); $content .= qpp_loop($args); } elseif (($payment['paypal'] && !$paypal || $paypal == 'checked') && $cost) { $content .= '<a id="qem_reload"></a>'; $content .= '<script type="text/javascript" language="javascript"> document.querySelector("#qem_reload").scrollIntoView(); </script>'; $content .= qem_process_payment_form($values); } elseif ($register['useread_more']) { $content .= '<p><a href="' . get_permalink() . '">' . $register['read_more'] . '</a></p>'; } $content .= '<a id="qem_reload"></a>'; } elseif (!$num && $check && $number) { $content .= '<h2>' . $register['eventfullmessage'] . '</h2>'; $content .= '<a id="qem_reload"></a>'; } elseif ($errors['alreadyregistered'] == 'checked') { $content .= $num . '<h2>' . $register['alreadyregistered'] . '</h2>'; if ($register['useread_more']) { $content .= '<p><a href="' . get_permalink() . '">' . $register['read_more'] . '</a></p>'; } $content .= '<a id="qem_reload"></a>'; } elseif ($errors['alreadyregistered'] == 'removed') { $content .= $num . '<h2>' . $register['nameremoved'] . '</h2>'; if ($register['useread_more']) { $content .= '<p><a href="' . get_permalink() . '">' . $register['read_more'] . '</a></p>'; } $content .= '<a id="qem_reload"></a>'; } else { if (!empty($register['title'])) { $register['title'] = '<h2>' . $register['title'] . '</h2>'; } if (!empty($register['blurb'])) { $register['blurb'] = '<p>' . $register['blurb'] . '</p>'; } $content .= '<div class="qem-register">'; if (count($errors) > 0) { $content .= "<h2 style='color:red'>" . $register['error'] . "</h2>\r\t"; $arr = array('yourname', 'youremail', 'yourtelephone', 'yourplaces', 'yourmessage', 'youranswer', 'yourblank1', 'yourblank2', 'yourdropdown'); foreach ($arr as $item) { if ($errors[$item] == 'error') { $errors[$item] = ' style="border:1px solid red;" '; } } if ($errors['yourplaces']) { $errors['yourplaces'] = 'border:1px solid red;'; } if ($errors['yournumber1']) { $errors['yournumber1'] = 'border:1px solid red;'; } if ($errors['youranswer']) { $errors['youranswer'] = 'border:1px solid red;'; } } else { $content .= $register['title'] . $register['blurb']; } $content .= $num; $content .= '<form action="" method="POST" enctype="multipart/form-data">'; foreach (explode(',', $register['sort']) as $name) { switch ($name) { case 'field1': if ($register['usename']) { $content .= '<input id="yourname" name="yourname" ' . $errors['yourname'] . ' type="text" value="' . $values['yourname'] . '"onblur="if (this.value == \'\') {this.value = \'' . $values['yourname'] . '\';}" onfocus="if (this.value == \'' . $values['yourname'] . '\') {this.value = \'\';}" />' . "\n"; } break; case 'field2': if ($register['usemail']) { $content .= '<input id="email" name="youremail" ' . $errors['youremail'] . ' type="text" value="' . $values['youremail'] . '" onblur="if (this.value == \'\') {this.value = \'' . $values['youremail'] . '\';}" onfocus="if (this.value == \'' . $values['youremail'] . '\') {this.value = \'\';}" />'; } break; case 'field3': if ($register['useattend']) { $content .= '<p><input type="checkbox" name="notattend" value="checked" ' . $values['notattend'] . ' /> ' . $register['yourattend'] . '</p>'; } break; case 'field4': if ($register['usetelephone']) { $content .= '<input id="email" name="yourtelephone" ' . $errors['yourtelephone'] . ' type="text" value="' . $values['yourtelephone'] . '" onblur="if (this.value == \'\') {this.value = \'' . $values['yourtelephone'] . '\';}" onfocus="if (this.value == \'' . $values['yourtelephone'] . '\') {this.value = \'\';}" />'; } break; case 'field5': if ($register['useplaces']) { $content .= '<p><input id="yourplaces" name="yourplaces" type="text" style="' . $errors['yourplaces'] . 'width:3em;margin-right:5px" value="' . $values['yourplaces'] . '" onblur="if (this.value == \'\') {this.value = \'' . $values['yourplaces'] . '\';}" onfocus="if (this.value == \'' . $values['yourplaces'] . '\') {this.value = \'\';}" />' . $register['yourplaces'] . '</p>'; } else { $content .= '<input type="hidden" name="yourplaces" value="1">'; } if ($register['usemorenames']) { $content .= '<div id="morenames" hidden="hidden"><p>' . $register['morenames'] . '</p> <textarea rows="4" label="message" name="morenames"></textarea></div>'; } break; case 'field6': if ($register['usemessage']) { $content .= '<textarea rows="4" label="message" name="yourmessage" ' . $errors['yourmessage'] . ' onblur="if (this.value == \'\') {this.value = \'' . $values['yourmessage'] . '\';}" onfocus="if (this.value == \'' . $values['yourmessage'] . '\') {this.value = \'\';}" />' . stripslashes($values['yourmessage']) . '</textarea>'; } break; case 'field7': if ($register['usecaptcha']) { $content .= $values['thesum'] . ' = <input id="youranswer" name="youranswer" type="text" style="' . $errors['youranswer'] . 'width:3em;" value="' . $values['youranswer'] . '" onblur="if (this.value == \'\') {this.value = \'' . $values['youranswer'] . '\';}" onfocus="if (this.value == \'' . $values['youranswer'] . '\') {this.value = \'\';}" /><input type="hidden" name="answer" value="' . strip_tags($values['answer']) . '" /> <input type="hidden" name="thesum" value="' . strip_tags($values['thesum']) . '" />'; } break; case 'field8': if ($register['usecopy']) { $content .= '<p><input type="checkbox" name="qem-copy" value="checked" ' . $values['qem-copy'] . ' /> ' . $register['copyblurb'] . '</p>'; } break; case 'field9': if ($register['useblank1']) { $content .= '<input id="yourblank1" name="yourblank1" ' . $errors['yourblank1'] . ' type="text" value="' . $values['yourblank1'] . '" onblur="if (this.value == \'\') {this.value = \'' . $values['yourblank1'] . '\';}" onfocus="if (this.value == \'' . $values['yourblank1'] . '\') {this.value = \'\';}" />'; } break; case 'field10': if ($register['useblank2']) { $content .= '<input id="yourblank2" name="yourblank2" ' . $errors['yourblank2'] . ' type="text" value="' . $values['yourblank2'] . '" onblur="if (this.value == \'\') {this.value = \'' . $values['yourblank2'] . '\';}" onfocus="if (this.value == \'' . $values['yourblank2'] . '\') {this.value = \'\';}" />'; } break; case 'field11': if ($register['usedropdown']) { $content .= '<select ' . $errors['yourdropdown'] . ' name="yourdropdown">'; $arr = explode(",", $register['yourdropdown']); foreach ($arr as $item) { $selected = ''; if ($values['yourdropdown'] == $item) { $selected = 'selected'; } $content .= '<option value="' . $item . '" ' . $selected . '>' . $item . '</option>'; } $content .= '</select>'; } break; case 'field12': if ($register['usenumber1']) { $content .= $register['yournumber1'] . ' <input id="yournumber1" name="yournumber1" ' . $errors['yournumber1'] . ' type="text" style="' . $errors['yournumber1'] . 'width:3em;margin-right:5px" value="' . $values['yournumber1'] . '" value="' . $values['yournumber1'] . '" onblur="if (this.value == \'\') {this.value = \'' . $values['yournumber1'] . '\';}" onfocus="if (this.value == \'' . $values['yournumber1'] . '\') {this.value = \'\';}" />'; } break; case 'field13': if ($register['useaddinfo']) { $content .= '<p>' . $register['addinfo'] . '</p>'; } break; case 'field14': if ($register['useselector']) { $content .= '<select ' . $errors['yourselector'] . ' name="yourselector">'; $arr = explode(",", $register['yourselector']); foreach ($arr as $item) { $selected = ''; if ($values['yourselector'] == $item) { $selected = 'selected'; } $content .= '<option value="' . $item . '" ' . $selected . '>' . $item . '</option>'; } $content .= '</select>'; } break; } } if ($register['useterms']) { if ($errors['terms']) { $termstyle = ' style="border:1px solid red;"'; $termslink = ' style="color:red;"'; } if ($register['termstarget']) { $target = ' target="_blank"'; } $content .= '<p><input type="checkbox" name="terms" value="checked" ' . $termstyle . $values['terms'] . ' /> <a href="' . $register['termsurl'] . '"' . $target . $termslink . '>' . $register['termslabel'] . '</a></p>'; } if (($payment['paypal'] && !$paypal || $paypal == 'checked') && $cost) { $register['qemsubmit'] = $payment['qempaypalsubmit']; if ($payment['usecoupon']) { $content .= '<input name="couponcode" type="text" value="' . $values['couponcode'] . '" onblur="if (this.value == \'\') {this.value = \'' . $values['couponcode'] . '\';}" onfocus="if (this.value == \'' . $values['couponcode'] . '\') {this.value = \'\';}" />'; } } $content .= '<input type="hidden" name="ipn" value="' . $values['ipn'] . '"> <input type="submit" value="' . $register['qemsubmit'] . '" id="submit" name="qemregister" /> </form> <div style="clear:both;"></div></div>'; } $content .= '<script type="text/javascript" language="javascript"> document.querySelector("#qem_reload").scrollIntoView(); </script>'; echo $content; }