[EventCalendar] 3.2dev

Alex Tingle alex at firetree.net
Thu Dec 18 19:07:37 UTC 2008


On 18 Dec 2008, at 18:59, Rick Boatright wrote:
> do you have drafts of the docs you've been working on Alex that we  
> can look
> over / comment on?

Oh yes, that's a good idea. Here you go...


function ec3_get_version()
Get the current version of the EC3 plug-in.


## Query functions.

These functions all get information about the current query. They all  
have a version that operates on the current Wordpress query, and  
another version that takes a query parameter.


function ec3_is_event_category()
function ec3_is_event_category_q(&$query)
Returns TRUE if the query is an event category query.


function ec3_get_listing()
function ec3_get_listing_q(&$query)
Determines the type of listing for the query -  
P(OST),E(VENT),A(LL),D(ISABLE).
When $query->ec3_listing the result is A or E, depending upon the query.


## Current post/event functions.

These functions all get information about the current post or current  
event. You must be inside a loop in order to use them. They all return  
their result, so if you want to echo it to the page, you must call  
'echo' yourself.

function ec3_is_event()
Returns TRUE if the current post is an event. Most of the rest of the  
post/event functions are meaningless if this returns FALSE.

function ec3_get_sched_id()
Get the sched_id of the current event.

function ec3_is_past()
Return TRUE if the current event is in the past.

function ec3_get_since()
Get a human-readable 'time since' the current event.


### Start/End time functions.

These all get the start or end time of the current event or current  
event-post. If the current post has no events, then they return an  
empty string. The end time of an event-post is the end time of the  
post's last scheduled event.

All of these functions take an optional 'date format' parameter which  
allows you to customise the output format. The only difference between  
most of the functions is the default date format.

function ec3_get_start_time($d='')
function ec3_get_end_time($d='')
These functions use Wordpress' 'time_format' setting.

function ec3_get_start_date($d='')
function ec3_get_end_date($d='')
These functions use Wordpress' 'date_format' setting.

function ec3_get_start_month($d='F Y')
function ec3_get_end_month($d='F Y')
These functions default to 'month year' format. E.g. 'May 2009'.

function ec3_get_time($d='')
function ec3_get_month($d='')
function ec3_get_date($d='')
These are just shorthand for ec3_get_start_time() etc.


function ec3_cmp_events(&$e0,&$e1)
Comparison function for events' start times.


## Event Loop Functions

function ec3_iter_post_events($id=0)
Initialise an event-loop, just for the events in the current $post.
Example:
     // First a normal loop over the current query's posts.
     while(have_posts())
     {
       the_post();
       // Now a nested loop, over the events in each post.
       for($evt=ec3_iter_post_events(); $evt->valid(); $evt->next())
       {
         ...
       }
     }


function ec3_iter_all_events()
function ec3_iter_all_events_q(&$query)
Initialise an event-loop, for ALL events in all posts in the query.
Example:
     if(have_posts())
     {
       for($evt=ec3_iter_all_events(); $evt->valid(); $evt->next())
       {
         ...
       }
     }


function ec3_reset_wp_query()
Resets the global $post status from $wp_query. Allows us to continue  
with the main loop, after a nested loop. */


### Event Iterator class

The ec3_EventIterator class implements loops over events. Generated by  
ec3_iter_post_events() or ec3_iter_all_events(). These iterators are  
not independent - don't try to get smart with nested loops! This class  
is ready to implement PHP5's Iterator interface.

class ec3_EventIterator
{
   /** Resets this iterator to the beginning. */
   function rewind()

   /** Move along to the next (possibly empty) event. */
   function next()

   /** Returns TRUE if this iterator points to an event. */
   function valid()

   /** Set the current event (global $ec3->event) to match this  
iterator's
    *  index. */
   function current()

   /** Returns the current index. */
   function key()
};


... Just the Javadoc style comments from here:


/** Formats the schedule for the current post.
  *  Returns the HTML fragment as a string. */
function ec3_get_schedule(
   $format_single =EC3_DEFAULT_FORMAT_SINGLE,
   $format_range  =EC3_DEFAULT_FORMAT_RANGE,
   $format_wrapper=EC3_DEFAULT_FORMAT_WRAPPER
)


/** Formats the schedule for the current post as one or more 'iconlets'.
  *  Returns the HTML fragment as a string. */
function ec3_get_iconlets()


/** Template function, for backwards compatibility.
  *  Call this from your template to insert the Sidebar Event  
Calendar. */
function ec3_get_calendar($options = false)

<end>



More information about the EventCalendar mailing list