options = &EL_Options::get_instance(); $this->db = &EL_Db::get_instance(); $this->categories = &EL_Categories::get_instance(); // All available attributes $this->atts = array( 'initial_event_id' => array('std_val' => 'all'), 'initial_date' => array('std_val' => 'upcoming'), 'initial_cat' => array('std_val' => 'all'), 'initial_order' => array('std_val' => 'date_asc'), 'date_filter' => array('std_val' => 'all'), 'cat_filter' => array('std_val' => 'all'), 'num_events' => array('std_val' => '0'), 'show_filterbar' => array('std_val' => 'true'), 'filterbar_items' => array('std_val' => 'years_hlist'), 'show_starttime' => array('std_val' => 'true'), 'show_location' => array('std_val' => 'true'), 'show_cat' => array('std_val' => 'false'), 'show_details' => array('std_val' => 'true'), 'details_length' => array('std_val' => '0'), 'collapse_details' => array('std_val' => 'false'), 'link_to_event' => array('std_val' => 'event_list_only'), 'add_feed_link' => array('std_val' => 'false'), 'url_to_page' => array('std_val' => ''), 'title_length' => array('std_val' => '0'), 'location_length' => array('std_val' => '0'), 'sc_id_for_url' => array('std_val' => ''), // Internal attributes: This parameters will be added by the script and are not available in the shortcode // 'sc_id' // 'actual_date' // 'actual_cat' ); $this->num_sc_loaded = 0; $this->single_event = false; } public function load_sc_eventlist_helptexts() { require_once(EL_PATH.'includes/sc_event-list_helptexts.php'); foreach($sc_eventlist_helptexts as $name => $values) { $this->atts[$name] = array_merge($this->atts[$name], $values); } unset($sc_eventlist_helptexts); } public function get_atts($only_visible=true) { if($only_visible) { $atts = null; foreach($this->atts as $aname => $attr) { if(!isset($attr['hidden']) || true !== $attr['hidden'] ) { $atts[$aname] = $attr; } } return $atts; } else { return $this->atts; } } // main function to show the rendered HTML output public function show_html($atts) { // change number of shortcodes $this->num_sc_loaded++; // check shortcode attributes $std_values = array(); foreach($this->atts as $aname => $attribute) { $std_values[$aname] = $attribute['std_val']; } $a = shortcode_atts($std_values, $atts); // add internal attributes $a['sc_id'] = $this->num_sc_loaded; $a['actual_date'] = $this->get_actual_date($a); $a['actual_cat'] = $this->get_actual_cat($a); if(isset($_GET['event_id'.$a['sc_id']])) { $a['event_id'] = (int)$_GET['event_id'.$a['sc_id']]; } elseif('all' != $a['initial_event_id'] && !isset($_GET['date'.$a['sc_id']]) && !isset($_GET['cat'.$a['sc_id']])) { $a['event_id'] = (int)$a['initial_event_id']; } else { $a['event_id'] = null; } // fix sc_id_for_url if required if(!is_numeric($a['sc_id_for_url'])) { $a['sc_id_for_url'] = $a['sc_id']; } $out = '
'.$this->options->get('el_no_event_text').'
'; } else { // print available events $out .= '
';
}
// prepare text
$text = $image.esc_attr($this->options->get('el_feed_link_text'));
// create html
$out .= '';
}
return $out;
}
private function get_actual_date(&$a) {
if(isset($_GET['event_id'.$a['sc_id']])) {
return null;
}
elseif(isset($_GET['date'.$a['sc_id']])) {
return $_GET['date'.$a['sc_id']];
}
return $a['initial_date'];
}
private function get_actual_cat(&$a) {
if(isset($_GET['event_id'.$a['sc_id']])) {
return null;
}
elseif(isset($_GET['cat'.$a['sc_id']])) {
return $_GET['cat'.$a['sc_id']];
}
return $a['initial_cat'];
}
private function get_date_filter($date_filter, $actual_date) {
if('all' == $date_filter || '' == $date_filter) {
if('all' == $actual_date || '' == $actual_date) {
return null;
}
else {
return $actual_date;
}
}
else {
// Convert html entities to correct characters, e.g. & to &
$date_filter = html_entity_decode($date_filter);
if('all' == $actual_date || '' == $actual_date) {
return $date_filter;
}
else {
return '('.$date_filter.')&('.$actual_date.')';
}
}
}
private function get_cat_filter($cat_filter, $actual_cat) {
if('all' == $cat_filter || '' == $cat_filter) {
if('all' == $actual_cat || '' == $actual_cat) {
return null;
}
else {
return $actual_cat;
}
}
else {
// Convert html entities to correct characters, e.g. & to &
$cat_filter = html_entity_decode($cat_filter);
if('all' == $actual_cat || '' == $actual_cat) {
return $cat_filter;
}
else {
return '('.$cat_filter.')&('.$actual_cat.')';
}
}
}
private function get_details(&$event, &$a) {
// check if details are available
if('' == $event->details) {
return '';
}
// check and handle the read more tag if available
//search fore more-tag (no more tag handling if truncate of details is set)
if(preg_match('//', $event->details, $matches)) {
$part = explode($matches[0], $event->details, 2);
if(!$this->is_link_available($a, $event->details) || 0 < $a['details_length'] || $this->single_event) {
//details with removed more-tag
$details = $part[0].$part[1];
}
else {
//set more-link text
if(!empty($matches[1])) {
$more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));
}
else {
$more_link_text = __('(more…)');
}
//details with more-link
$details = apply_filters('the_content_more_link', $part[0].$this->get_event_url($a, $event->id, $more_link_text));
}
}
else {
//normal details
$details = $event->details;
}
// last preparations of details
$details = $this->db->truncate(do_shortcode(wpautop($details)), $a['details_length'], $this->single_event);
// preparations for collapsed details
if($this->is_visible($a['collapse_details'])) {
wp_register_script('el_collapse_details', EL_URL.'includes/js/collapse_details.js', null, true);
add_action('wp_footer', array(&$this, 'print_collapse_details_script'));
return '