Ejemplo n.º 1
0
/* *******************************************
 // This is a demo file to show usage.
 //
 // @package TheCity
 // @author Wes Hays <*****@*****.**>
 ******************************************* */
require_once 'lib/the_city.php';
// Initalize
// First param is your church's subdomain key.
// Second param is whether or not to cache the data.
$the_city = new TheCity('vintage21', true);
$the_city->add_url_params('wp=1');
// Set group nickname to pull plaza items for.
// http://helpdesk.onthecity.org/entries/422776-group-nickname
$the_city->set_group_nickname('@v21west');
// Load Topics
$array_of_topic_titles = $the_city->topics()->titles();
// by default will grab 10 topics.
$topics = $the_city->topics();
// limit the amount of topics fetched from The City.
$topics = $the_city->topics(3);
// Get topic.
$topic = $topics->select(2);
// Get count.
$topic_count = $topics->size();
// Load Events
$array_of_event_titles = $the_city->events()->titles();
// by default will grab 10 events.
$events = $the_city->events();
// limit the amount of events fetched from The City
Ejemplo n.º 2
0
function shcaa_list_events($eventtag = '', $groupname = '')
{
    // attempt to get cached request
    if (isset($groupname) && !empty($groupname)) {
        $transient_key = "_shcaa_events_feed_" . $groupname;
    } else {
        $transient_key = "_shcaa_events_feed_all";
    }
    // If cached (transient) data are used, output an HTML
    // comment indicating such
    $cached = get_transient($transient_key);
    if (false !== $cached) {
        $myevents = $cached;
    } else {
        // create array of the events filtered by the args and include the tags
        $args = array();
        //$args['group_types'] = 'Hope';
        //$args['include_addresses'] = 'true';
        $the_city = new TheCity('theCityUsername');
        if (isset($groupname) && !empty($groupname)) {
            $the_city->set_group_nickname($groupname);
        }
        $events = $the_city->events(50);
        $event_titles = $events->titles();
        $myevents = array();
        $i = 0;
        foreach ($event_titles as $indx => $eve) {
            // get the object
            $rawevent = $events->select($indx);
            // get the body
            $event = accessProtected($rawevent, 'data');
            //print_r('<pre style="padding: 10px; border: 1px solid #000; font-size: 11px; margin: 10px">'); print_r( $event ); print_r('</pre>');
            // unique id
            $myevents[$i]['eve_id'] = $event->euid;
            // starting
            $myevents[$i]['starting_at'] = $event->starting_at;
            // ending
            $myevents[$i]['ending_at'] = $event->ending_at;
            // title
            $myevents[$i]['title'] = $event->title;
            // event_items
            $myevents[$i]['event_items'] = $event->event_items;
            // array
            //body
            $myevents[$i]['body'] = $event->body;
            // shorturl
            $myevents[$i]['short_url'] = $event->short_url;
            $i++;
        }
        // end foreach
        //print_r('<pre style="padding: 10px; border: 1px solid #000; font-size: 12px;  margin: 10px">'); print_r( $event ); print_r('</pre>');
        set_transient($transient_key, $myevents, 60 * 60 * 1);
    }
    // end if not cached
    // events output
    if (!isset($myevents) || empty($myevents)) {
        return;
    }
    // find equipping classess and add extra date modifications
    $myevents = add_event_date_info($myevents);
    $output = '<ul class="eventlist">';
    $cnt = 0;
    //print_r('<pre style="padding: 10px; border: 1px solid #000; font-size: 11px; margin: 10px">'); print_r( $myevents ); print_r('</pre>');
    $dupcheck = array();
    foreach ($myevents as $myeve) {
        $eve_id = $myeve['eve_id'];
        //$image = $myeve['image'];
        $title = trim($myeve['title']);
        // set a virtual event category by detecting substring in the title
        $tag = 'General';
        if (strpos($title, 'Equipping Class') !== false) {
            $tag = 'Equipping Class';
        }
        if (strpos($title, 'Sunday Morning Worship') !== false) {
            $tag = 'Sunday Morning Worship';
        }
        if (!isset($eventtag) || empty($eventtag) || isset($eventtag) && $eventtag == $tag) {
            // if(!in_array($title,$dupcheck)) {   // turned off the dupcheck feature for all events
            $starting_at = $myeve['starting_at'];
            $ending_at = $myeve['ending_at'];
            $dateinfo = isset($myeve['dateinfo']) && !empty($myeve['dateinfo']) ? $myeve['dateinfo'] : '';
            $event_items = $myeve['event_items'];
            // array - may contain images??
            $body = $myeve['body'];
            $short_url = $myeve['short_url'];
            // dates
            if (isset($starting_at) && !empty($starting_at)) {
                if ($tag == 'Equipping Class' || $tag == 'Sunday Morning Worship') {
                    $dates = datetransmog($starting_at, $ending_at, $dateinfo, true);
                } else {
                    $dates = datetransmog($starting_at, $ending_at);
                }
            }
            // if this is a class
            if ($tag == 'Equipping Class') {
                if (!in_array($title, $dupcheck)) {
                    $stitle = str_replace('| Equipping Class', '', $title);
                    $output .= '<li class="event eclass">';
                    $output .= '<table class="blanktable">';
                    $output .= '<tr>';
                    $output .= '<td class="month">' . $dates['month'] . '</td>';
                    $output .= '<td class="title"><h3 class="eve-title">' . $stitle . '</h3></td>';
                    $output .= '</tr>';
                    $output .= '<tr>';
                    $output .= '<td class="datelabel">Dates:</td>';
                    $output .= '<td class="dates"><div class="eve-days">' . $dates['days'] . '</div></td>';
                    $output .= '</tr>';
                    $output .= '<tr>';
                    $output .= '<td class="timelabel">Time:</td>';
                    $output .= '<td class="time"><div class="eve-time">' . $dates['time'] . '</div></td>';
                    $output .= '</tr>';
                    $output .= '</table>';
                    // description
                    if (isset($body) && !empty($body)) {
                        $output .= '<div class="eve-description">' . $body . '</div>';
                    }
                    // link
                    if (isset($short_url) && !empty($short_url)) {
                        $output .= '<a href="' . $short_url . '" target="_blank" class="eve-link button">Learn More and Register</a>';
                    }
                    $output .= '</li>';
                }
            } else {
                $output .= '<li class="event">';
                // name
                if (isset($title) && !empty($title)) {
                    $output .= '<h3 class="eve-title">' . $title . '</h3>';
                }
                // dates
                if (isset($dates['month']) && !empty($dates['month'])) {
                    $output .= '<div class="eve-month">' . $dates['month'] . '</div>';
                }
                if (isset($dates['days']) && !empty($dates['days'])) {
                    $output .= '<div class="eve-days">' . $dates['days'] . '</div>';
                }
                if (isset($dates['time']) && !empty($dates['time'])) {
                    $output .= '<div class="eve-dates">' . $dates['time'] . '</div>';
                }
                // description
                if (isset($body) && !empty($body)) {
                    $output .= '<div class="eve-description">' . $body . '</div>';
                }
                // link
                if (isset($short_url) && !empty($short_url)) {
                    $output .= '<a href="' . $short_url . '" target="_blank" class="eve-link button">Learn More</a>';
                }
                $output .= '</li>';
            }
            // end if
            // } // end if dupcheck
        }
        // end if in tag
        $dupcheck[] = $title;
    }
    // end foreach
    $output .= '</ul>';
    return $output;
}
<?php

require_once '../../../wp-blog-header.php';
require_once 'lib/plaza-php/lib/the_city.php';
require_once 'lib/plaza_collection.php';
require_once 'lib/plaza_wordpress_cache.php';
if (empty($_GET['subdomain_key'])) {
    echo 'Subdomain not set';
} else {
    global $wpdb;
    $cacher = new PlazaWordPressCache($_GET['subdomain_key']);
    $cacher->set_db_connection($wpdb);
    $the_city = new TheCity($_GET['subdomain_key'], true, $cacher);
    $the_city->add_url_params('wp=1');
    if (isset($_GET['group_nickname'])) {
        $the_city->set_group_nickname($_GET['group_nickname']);
    }
    $subdomain_key = $_GET['subdomain_key'];
    $plaza_choice = $_GET['plaza_display'];
    $items_to_display = $_GET['items_to_display'];
    $show_dates = isset($_GET['show_dates']) ? $_GET['show_dates'] : '';
    $show_type = isset($_GET['show_type']) ? $_GET['show_type'] : '';
    $plaza_choice_key = '';
    $plaza_display = '';
    switch ($_GET['plaza_display']) {
        case 'all':
            $plaza_display = new PlazaCollection($the_city, $items_to_display);
            break;
        case 'topics':
            $plaza_display = $the_city->topics($items_to_display);
            break;