web/wp-content/plugins/event-calendar/eventcalendar3.php
branchwordpress
changeset 132 4d4862461b8d
parent 129 df612fc5a5de
child 133 c0473fcf3be5
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    32 require_once(dirname(__FILE__).'/template-functions.php');
    32 require_once(dirname(__FILE__).'/template-functions.php');
    33 require_once(dirname(__FILE__).'/admin.php');
    33 require_once(dirname(__FILE__).'/admin.php');
    34 require_once(dirname(__FILE__).'/tz.php');
    34 require_once(dirname(__FILE__).'/tz.php');
    35 
    35 
    36 
    36 
    37 $ec3_today_id = str_replace('_0','_',ec3_strftime("ec3_%Y_%m_%d"));
    37 $ec3_today_id=str_replace('_0','_',ec3_strftime("ec3_%Y_%m_%d"));
    38 
    38 
    39 
    39 
    40 /** Read the schedule table for the posts, and add an ec3_schedule array
    40 /** Read the schedule table for the posts, and add an ec3_schedule array
    41  * to each post. */
    41  * to each post. */
    42 function ec3_filter_the_posts($posts)
    42 function ec3_filter_the_posts($posts)
   130   $ec3->advanced=false;
   130   $ec3->advanced=false;
   131 }
   131 }
   132 
   132 
   133 
   133 
   134 /** Rewrite date restrictions if the query is day- or category- specific. */
   134 /** Rewrite date restrictions if the query is day- or category- specific. */
   135 function ec3_filter_posts_where($where)
   135 function ec3_filter_posts_where(&$where)
   136 {
   136 {
   137   global $ec3,$wp_query,$wpdb;
   137   global $ec3,$wp_query,$wpdb;
   138 
   138 
   139   // To prevent breaking prior to WordPress v2.3
   139   // To prevent breaking prior to WordPress v2.3
   140   if(function_exists('get_the_tags') && $wp_query->is_tag)
   140   if(function_exists('get_the_tags') && $wp_query->is_tag)
   223 
   223 
   224   return $where;
   224   return $where;
   225 }
   225 }
   226 
   226 
   227 /** */
   227 /** */
   228 function ec3_filter_posts_join($join)
   228 function ec3_filter_posts_join(&$join)
   229 {
   229 {
   230   global $ec3,$wpdb;
   230   global $ec3,$wpdb;
   231   // The necessary joins are decided upon in ec3_filter_posts_where().
   231   // The necessary joins are decided upon in ec3_filter_posts_where().
   232   if($ec3->join_ec3_sch || $ec3->order_by_start)
   232   if($ec3->join_ec3_sch || $ec3->order_by_start)
   233   {
   233   {
   237   }
   237   }
   238   return $join;
   238   return $join;
   239 }
   239 }
   240 
   240 
   241 /** Change the order of event listings (only advanced mode). */
   241 /** Change the order of event listings (only advanced mode). */
   242 function ec3_filter_posts_orderby($orderby)
   242 function ec3_filter_posts_orderby(&$orderby)
   243 {
   243 {
   244   global $ec3, $wpdb;
   244   global $ec3, $wpdb;
   245   if($ec3->order_by_start)
   245   if($ec3->order_by_start)
   246   {
   246   {
   247     $regexp="/(?<!DATE_FORMAT[(])\b$wpdb->posts\.post_date\b( DESC\b| ASC\b)?/i";
   247     $regexp="/(?<!DATE_FORMAT[(])\b$wpdb->posts\.post_date\b( DESC\b| ASC\b)?/i";
   261   return $orderby;
   261   return $orderby;
   262 }
   262 }
   263 
   263 
   264 
   264 
   265 /** Eliminate double-listings for posts with >1 scheduled event. */
   265 /** Eliminate double-listings for posts with >1 scheduled event. */
   266 function ec3_filter_posts_groupby($groupby)
   266 function ec3_filter_posts_groupby(&$groupby)
   267 {
   267 {
   268   global $ec3,$wpdb;
   268   global $ec3,$wpdb;
   269   if($ec3->join_ec3_sch || $ec3->order_by_start)
   269   if($ec3->join_ec3_sch || $ec3->order_by_start)
   270   {
   270   {
   271     if(empty($groupby))
   271     if(empty($groupby))
   276   return $groupby;
   276   return $groupby;
   277 }
   277 }
   278 
   278 
   279 
   279 
   280 /** Add a sched_id field, if we want a listing. */
   280 /** Add a sched_id field, if we want a listing. */
   281 function ec3_filter_posts_fields($fields)
   281 function ec3_filter_posts_fields(&$fields)
   282 {
   282 {
   283   global $ec3;
   283   global $ec3;
   284   if($ec3->is_listing && ($ec3->join_ec3_sch || $ec3->order_by_start))
   284   if($ec3->is_listing && ($ec3->join_ec3_sch || $ec3->order_by_start))
   285     $fields.=',ec3_sch.sched_id';
   285     $fields.=',ec3_sch.sched_id';
   286   return $fields;
   286   return $fields;