Example #1
0
File: tz.php Project: smoobs/sjh
    return $result;
}
/** Formats a Unix time as a time in the current timezone. */
function ec3_strftime($format, $unix_time = 0)
{
    global $ec3;
    if (!$unix_time) {
        $unix_time = time();
    }
    // Express the Unix time as a string for timezone $ec3->tz.
    $old_tz = ec3_tz_push($ec3->tz);
    $result = strftime($format, $unix_time);
    ec3_tz_pop($old_tz);
    return $result;
}
$ec3->today = ec3_strftime("%Y-%m-%d 00:00:00");
/** Call from within a <select>. Echos grouped options for all timezones. */
function ec3_get_tz_options($selected = '')
{
    /** All possible timezones, by group. */
    $groups = array('Africa' => array('Abidjan', 'Accra', 'Addis_Ababa', 'Algiers', 'Asmera', 'Bamako', 'Bangui', 'Banjul', 'Bissau', 'Blantyre', 'Brazzaville', 'Bujumbura', 'Cairo', 'Casablanca', 'Ceuta', 'Conakry', 'Dakar', 'Dar_es_Salaam', 'Djibouti', 'Douala', 'El_Aaiun', 'Freetown', 'Gaborone', 'Harare', 'Johannesburg', 'Kampala', 'Khartoum', 'Kigali', 'Kinshasa', 'Lagos', 'Libreville', 'Lome', 'Luanda', 'Lubumbashi', 'Lusaka', 'Malabo', 'Maputo', 'Maseru', 'Mbabane', 'Mogadishu', 'Monrovia', 'Nairobi', 'Ndjamena', 'Niamey', 'Nouakchott', 'Ouagadougou', 'Porto-Novo', 'Sao_Tome', 'Timbuktu', 'Tripoli', 'Tunis', 'Windhoek'), 'America' => array('Adak', 'Anchorage', 'Anguilla', 'Antigua', 'Araguaina', 'Argentina/Buenos_Aires', 'Argentina/Catamarca', 'Argentina/ComodRivadavia', 'Argentina/Cordoba', 'Argentina/Jujuy', 'Argentina/La_Rioja', 'Argentina/Mendoza', 'Argentina/Rio_Gallegos', 'Argentina/San_Juan', 'Argentina/Tucuman', 'Argentina/Ushuaia', 'Aruba', 'Asuncion', 'Atikokan', 'Atka', 'Bahia', 'Barbados', 'Belem', 'Belize', 'Blanc-Sablon', 'Boa_Vista', 'Bogota', 'Boise', 'Buenos_Aires', 'Cambridge_Bay', 'Campo_Grande', 'Cancun', 'Caracas', 'Catamarca', 'Cayenne', 'Cayman', 'Chicago', 'Chihuahua', 'Coral_Harbour', 'Cordoba', 'Costa_Rica', 'Cuiaba', 'Curacao', 'Danmarkshavn', 'Dawson', 'Dawson_Creek', 'Denver', 'Detroit', 'Dominica', 'Edmonton', 'Eirunepe', 'El_Salvador', 'Ensenada', 'Fort_Wayne', 'Fortaleza', 'Glace_Bay', 'Godthab', 'Goose_Bay', 'Grand_Turk', 'Grenada', 'Guadeloupe', 'Guatemala', 'Guayaquil', 'Guyana', 'Halifax', 'Havana', 'Hermosillo', 'Indiana/Indianapolis', 'Indiana/Knox', 'Indiana/Marengo', 'Indiana/Petersburg', 'Indiana/Vevay', 'Indiana/Vincennes', 'Indianapolis', 'Inuvik', 'Iqaluit', 'Jamaica', 'Jujuy', 'Juneau', 'Kentucky/Louisville', 'Kentucky/Monticello', 'Knox_IN', 'La_Paz', 'Lima', 'Los_Angeles', 'Louisville', 'Maceio', 'Managua', 'Manaus', 'Martinique', 'Mazatlan', 'Mendoza', 'Menominee', 'Merida', 'Mexico_City', 'Miquelon', 'Moncton', 'Monterrey', 'Montevideo', 'Montreal', 'Montserrat', 'Nassau', 'New_York', 'Nipigon', 'Nome', 'Noronha', 'North_Dakota/Center', 'North_Dakota/New_Salem', 'Panama', 'Pangnirtung', 'Paramaribo', 'Phoenix', 'Port-au-Prince', 'Port_of_Spain', 'Porto_Acre', 'Porto_Velho', 'Puerto_Rico', 'Rainy_River', 'Rankin_Inlet', 'Recife', 'Regina', 'Rio_Branco', 'Rosario', 'Santiago', 'Santo_Domingo', 'Sao_Paulo', 'Scoresbysund', 'Shiprock', 'St_Johns', 'St_Kitts', 'St_Lucia', 'St_Thomas', 'St_Vincent', 'Swift_Current', 'Tegucigalpa', 'Thule', 'Thunder_Bay', 'Tijuana', 'Toronto', 'Tortola', 'Vancouver', 'Virgin', 'Whitehorse', 'Winnipeg', 'Yakutat', 'Yellowknife'), 'Antarctica' => array('Casey', 'Davis', 'DumontDUrville', 'Mawson', 'McMurdo', 'Palmer', 'Rothera', 'South_Pole', 'Syowa', 'Vostok'), 'Arctic' => array('Longyearbyen'), 'Asia' => array('Aden', 'Almaty', 'Amman', 'Anadyr', 'Aqtau', 'Aqtobe', 'Ashgabat', 'Ashkhabad', 'Baghdad', 'Bahrain', 'Baku', 'Bangkok', 'Beirut', 'Bishkek', 'Brunei', 'Calcutta', 'Choibalsan', 'Chongqing', 'Chungking', 'Colombo', 'Dacca', 'Damascus', 'Dhaka', 'Dili', 'Dubai', 'Dushanbe', 'Gaza', 'Harbin', 'Hong_Kong', 'Hovd', 'Irkutsk', 'Istanbul', 'Jakarta', 'Jayapura', 'Jerusalem', 'Kabul', 'Kamchatka', 'Karachi', 'Kashgar', 'Katmandu', 'Krasnoyarsk', 'Kuala_Lumpur', 'Kuching', 'Kuwait', 'Macao', 'Macau', 'Magadan', 'Makassar', 'Manila', 'Muscat', 'Nicosia', 'Novosibirsk', 'Omsk', 'Oral', 'Phnom_Penh', 'Pontianak', 'Pyongyang', 'Qatar', 'Qyzylorda', 'Rangoon', 'Riyadh', 'Saigon', 'Sakhalin', 'Samarkand', 'Seoul', 'Shanghai', 'Singapore', 'Taipei', 'Tashkent', 'Tbilisi', 'Tehran', 'Tel_Aviv', 'Thimbu', 'Thimphu', 'Tokyo', 'Ujung_Pandang', 'Ulaanbaatar', 'Ulan_Bator', 'Urumqi', 'Vientiane', 'Vladivostok', 'Yakutsk', 'Yekaterinburg', 'Yerevan'), 'Atlantic' => array('Azores', 'Bermuda', 'Canary', 'Cape_Verde', 'Faeroe', 'Jan_Mayen', 'Madeira', 'Reykjavik', 'South_Georgia', 'St_Helena', 'Stanley'), 'Australia' => array('ACT', 'Adelaide', 'Brisbane', 'Broken_Hill', 'Canberra', 'Currie', 'Darwin', 'Hobart', 'LHI', 'Lindeman', 'Lord_Howe', 'Melbourne', 'North', 'NSW', 'Perth', 'Queensland', 'South', 'Sydney', 'Tasmania', 'Victoria', 'West', 'Yancowinna'), 'Europe' => array('Amsterdam', 'Andorra', 'Athens', 'Belfast', 'Belgrade', 'Berlin', 'Bratislava', 'Brussels', 'Bucharest', 'Budapest', 'Chisinau', 'Copenhagen', 'Dublin', 'Gibraltar', 'Guernsey', 'Helsinki', 'Isle_of_Man', 'Istanbul', 'Jersey', 'Kaliningrad', 'Kiev', 'Lisbon', 'Ljubljana', 'London', 'Luxembourg', 'Madrid', 'Malta', 'Mariehamn', 'Minsk', 'Monaco', 'Moscow', 'Nicosia', 'Oslo', 'Paris', 'Prague', 'Riga', 'Rome', 'Samara', 'San_Marino', 'Sarajevo', 'Simferopol', 'Skopje', 'Sofia', 'Stockholm', 'Tallinn', 'Tirane', 'Tiraspol', 'Uzhgorod', 'Vaduz', 'Vatican', 'Vienna', 'Vilnius', 'Volgograd', 'Warsaw', 'Zagreb', 'Zaporozhye', 'Zurich'), 'Indian' => array('Antananarivo', 'Chagos', 'Christmas', 'Cocos', 'Comoro', 'Kerguelen', 'Mahe', 'Maldives', 'Mauritius', 'Mayotte', 'Reunion'), 'Pacific' => array('Apia', 'Auckland', 'Chatham', 'Easter', 'Efate', 'Enderbury', 'Fakaofo', 'Fiji', 'Funafuti', 'Galapagos', 'Gambier', 'Guadalcanal', 'Guam', 'Honolulu', 'Johnston', 'Kiritimati', 'Kosrae', 'Kwajalein', 'Majuro', 'Marquesas', 'Midway', 'Nauru', 'Niue', 'Norfolk', 'Noumea', 'Pago_Pago', 'Palau', 'Pitcairn', 'Ponape', 'Port_Moresby', 'Rarotonga', 'Saipan', 'Samoa', 'Tahiti', 'Tarawa', 'Tongatapu', 'Truk', 'Wake', 'Wallis', 'Yap'));
    foreach ($groups as $group => $zones) {
        echo "<optgroup label='{$group}'>\n";
        foreach ($zones as $z) {
            echo "<option value='{$group}/{$z}'";
            if ($selected == "{$group}/{$z}") {
                echo ' selected="selected"';
            }
            echo ">{$z}</option>\n";
        }
        echo '</optgroup>\\n';
Example #2
0
    function event_editor_box()
    {
        global $ec3, $wp_version, $wpdb, $post_ID;
        if (isset($post_ID)) {
            $schedule = $wpdb->get_results("SELECT\n           sched_id,\n           DATE_FORMAT(start,'%Y-%m-%d %H:%i') AS start,\n           DATE_FORMAT(end,'%Y-%m-%d %H:%i') AS end,\n           allday,\n           rpt\n         FROM {$ec3->schedule} WHERE post_id={$post_ID} ORDER BY start");
        } else {
            $schedule = false;
        }
        if (function_exists('wp_create_nonce')) {
            echo '<input type="hidden" name="ec3_nonce" id="ec3_nonce" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />';
        }
        ?>

    <!-- Event-Calendar: Event Editor -->
    <table width="100%" cellspacing="2" cellpadding="5" class="editform">
     <thead><tr>
      <th><?php 
        _e('Start', 'ec3');
        ?>
</th>
      <th><?php 
        _e('End', 'ec3');
        ?>
</th>
      <th style="text-align:center"><?php 
        _e('All Day', 'ec3');
        ?>
</th>
       <th style="text-align:center"></th>
      <!-- th><?php 
        _e('Repeat', 'ec3');
        ?>
</th -->
      <th></th>
     </tr></thead>
     <tbody>
    <?php 
        if ($schedule) {
            echo '<script>';
            echo 'var ec3_oldrows = new Array();';
            echo 'function ec3_show_oldrows(){ for (var i=0; i<ec3_oldrows.length; i++) ec3_oldrows[i].style.display = ""; }';
            echo 'function ec3_hide_oldrows(){ for (var i=0; i<ec3_oldrows.length; i++) ec3_oldrows[i].style.display = "none"; }';
            echo '</script>';
            foreach ($schedule as $s) {
                $this->schedule_row($s->start, $s->end, $s->sched_id, 'update', $s->allday);
            }
            $ec3_rows = count($schedule);
            echo '<script>ec3_hide_oldrows();</script>';
        }
        $default = ec3_strftime('%Y-%m-%d %H:00', 3600 + time());
        $this->schedule_row($default, $default, '_', 'create', False);
        ?>
      <tr> 
       <td colspan="4" style="text-align:left">
        <p style="margin:0;padding:0;text-align:left">
          <span style="vertical-align:middle;"><input type="button" name="ec3_new_row" style="display: block; margin-bottom: 20px;" value=" + " title="<?php 
        _e('Add a new event', 'ec3');
        ?>
" onclick="if (document.getElementById('ec3_repeat_check').checked && document.getElementById('ec3_repeat_count').value == '') { alert('Please enter a repeat number!'); return false; } else if (document.getElementById('ec3_repeatuntil_check').checked && (document.getElementById('ec3_repeatuntil_date').value == '' || document.getElementById('ec3_repeatuntil_date').value == 'yyyy-mm-dd')) { alert('Please enter a repeat end date!'); return false; } else { if (ec3_repeatuntil_check.checked) { Ec3EditForm.add_row(ec3_repeatuntil_check.checked,ec3_repeatuntil_date.value,ec3_repeatuntil_type.value); } else { Ec3EditForm.add_row(ec3_repeat_check.checked,ec3_repeat_count.value,ec3_repeat_type.value); } }" /></span>
	  <span style="vertical-align:middle;">&nbsp;&nbsp;<input type="checkbox" onclick="if (this.checked) { ec3_show_oldrows(); } else { ec3_hide_oldrows(); }"></span>
	  <span style="vertical-align:middle;">Show past events</span>
          <br>
	    <span style="vertical-align:middle;">&nbsp;&nbsp;<input type="checkbox" name="ec3_repeat_check" id="ec3_repeat_check" value="yes" onclick="if (this.checked && document.getElementById('ec3_repeatuntil_check').checked) document.getElementById('ec3_repeatuntil_check').click(); document.getElementById('ec3_repeat_type').disabled = !this.checked; document.getElementById('ec3_repeat_count').disabled = !this.checked;" /></span>

          <span style="vertical-align:middle;">Repeat last entry for</span>
          <span style="vertical-align:middle;"><input type="text" name="ec3_repeat_count" id="ec3_repeat_count" size="4" style="font-size:8pt;" disabled /></span>
          <span style="vertical-align:middle;padding-top:5px;"><select name="ec3_repeat_type" id="ec3_repeat_type" disabled>
            <option value="opt1">weeks</option>
            <option value="opt2">months (e.g. 15th of every month)</option>
            <option value="opt3">months (e.g. 2nd Monday of every month)</option>
          </select></span><br>

          <span style="vertical-align:middle;">&nbsp;&nbsp;<input type="checkbox" name="ec3_repeatuntil_check" id="ec3_repeatuntil_check" value="yes" onclick="if (this.checked && document.getElementById('ec3_repeat_check').checked) document.getElementById('ec3_repeat_check').click(); document.getElementById('ec3_repeatuntil_type').disabled = !this.checked; document.getElementById('ec3_repeatuntil_date').disabled = !this.checked;" /></span>
          <span style="vertical-align:middle;">Repeat last entry every</span>
          <span style="vertical-align:bottom;"><select name="ec3_repeatuntil_type" id="ec3_repeatuntil_type" disabled>
            <option value="opt1">week</option>
            <option value="opt2">month (e.g. 15th of every month)</option>
            <option value="opt3">month (e.g. 2nd Monday of every month)</option>
          </select></span>
          <span style="vertical-align:middle;">until</span>
	    <span style="vertical-align:bottom;"><input type="text" size="10" maxlength="10" value="yyyy-mm-dd" onclick="if (this.value=='yyyy-mm-dd') this.value='';" onblur="if (this.value=='') this.value='yyyy-mm-dd';" name="ec3_repeatuntil_count" id="ec3_repeatuntil_date" size="4" style="font-size:8pt;" disabled /></span>
          <input type="hidden" id="ec3_rows" name="ec3_rows" value="<?php 
        echo $ec3_rows;
        ?>
" />

        </p>
       </td>
      </tr> 
     </tbody>
    </table>

    <?php 
    }
Example #3
0
/** Add support for new query vars:
 *
 *  - ec3_today : sets date to today.
 *  - ec3_days=N : Finds events for the next N days.
 *  - ec3_after=YYYY-MM-DD : limits search to events on or after YYYY-MM-DD.
 *  - ec3_before=YYYY-MM-DD : limits search to events on or before YYYY-MM-DD.
 */
function ec3_filter_parse_query($wp_query)
{
    global $ec3;
    // query_posts() can be called multiple times. So reset all our variables.
    $ec3->reset_query();
    // Deal with EC3-specific parameters.
    if (!empty($wp_query->query_vars['ec3_listing'])) {
        $ec3->is_listing = true;
    }
    if (!empty($wp_query->query_vars['ec3_today'])) {
        // Force the value of 'm' to today's date.
        $wp_query->query_vars['m'] = ec3_strftime('%Y%m%d');
        $wp_query->is_date = true;
        $wp_query->is_day = true;
        $wp_query->is_month = true;
        $wp_query->is_year = true;
        $ec3->is_today = true;
        return;
    }
    if (!empty($wp_query->query_vars['ec3_days'])) {
        // Show the next N days.
        $ec3->days = intval($wp_query->query_vars['ec3_days']);
        $secs = $ec3->days * 24 * 3600;
        $wp_query->query_vars['ec3_after'] = ec3_strftime('%Y_%m_%d');
        $wp_query->query_vars['ec3_before'] = ec3_strftime('%Y_%m_%d', time() + $secs);
    }
    // Get values (if any) for after ($a) & before ($b).
    if (!empty($wp_query->query_vars['ec3_after'])) {
        $a = $wp_query->query_vars['ec3_after'];
    } else {
        if (!empty($wp_query->query_vars['ec3_from'])) {
            $a = $wp_query->query_vars['ec3_from'];
        }
    }
    $b = $wp_query->query_vars['ec3_before'];
    if ($a == 'today') {
        $a = ec3_strftime('%Y-%m-%d');
    }
    if ($b == 'today') {
        $b = ec3_strftime('%Y-%m-%d');
    }
    $re = '/\\d\\d\\d\\d[-_]\\d?\\d[-_]\\d?\\d/';
    if (!empty($a) && preg_match($re, $a) || !empty($b) && preg_match($re, $b)) {
        // Kill any other date parameters.
        foreach (array('m', 'second', 'minute', 'hour', 'day', 'monthnum', 'year', 'w') as $param) {
            unset($wp_query->query_vars[$param]);
        }
        $wp_query->is_date = false;
        $wp_query->is_time = false;
        $wp_query->is_day = false;
        $wp_query->is_month = false;
        $wp_query->is_year = false;
        $ec3->is_date_range = true;
        $ec3->range_from = $a;
        $ec3->range_before = $b;
    }
}
Example #4
0
$name = ec3_ical_quote(get_bloginfo_rss('name'));
$filename = preg_replace('/[^0-9a-zA-Z]/', '', $name) . '.ics';
header('Content-Type: text/calendar; charset=' . get_option('blog_charset'));
header('Content-Disposition: inline; filename=' . $filename);
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
ec3_ical_echo('BEGIN:VCALENDAR');
ec3_ical_echo('VERSION:2.0');
ec3_ical_echo("X-WR-CALNAME:{$name}");
global $ec3, $wpdb;
remove_filter('the_content', 'ec3_filter_the_content', 20);
remove_filter('get_the_excerpt', 'ec3_get_the_excerpt');
add_filter('get_the_excerpt', 'wp_trim_excerpt');
$month_ago = ec3_strftime('%Y-%m-%d', time() - 3600 * 24 * 31);
query_posts('ec3_after=' . $month_ago . '&nopaging=1');
if (have_posts()) {
    for ($evt = ec3_iter_all_events(); $evt->valid(); $evt->next()) {
        $permalink = ec3_ical_quote(get_permalink());
        $entry =& $ec3->event;
        ec3_ical_echo('BEGIN:VEVENT');
        ec3_ical_echo('SUMMARY:' . ec3_ical_quote(get_the_title()));
        ec3_ical_echo("URL;VALUE=URI:{$permalink}");
        ec3_ical_echo("SEQUENCE:{$entry->sequence}");
        ec3_ical_echo('UID:' . ec3_ical_quote("{$entry->sched_id}-{$permalink}"));
        if (function_exists('first_para_excerpt_no_headings')) {
            $description = first_para_excerpt_no_headings();
        } else {
            $description = get_the_excerpt();
        }
Example #5
0
 /** Helper function, only called by the constructor. Calculates the value of
  *  month/year for the current page. Code block from
  *  wp-includes/template-functions-general.php (get_calendar function). */
 function _from_date()
 {
     global $wpdb;
     $m = get_query_var('m');
     $year = get_query_var('year');
     $monthnum = get_query_var('monthnum');
     if (isset($_GET['w'])) {
         $w = '' . intval($_GET['w']);
     }
     // Let's figure out when we are
     if (!empty($monthnum) && !empty($year)) {
         $thismonth = '' . zeroise(intval($monthnum), 2);
         $thisyear = '' . intval($year);
     } elseif (!empty($w)) {
         // We need to get the month from MySQL
         $thisyear = '' . intval(substr($m, 0, 4));
         $d = ($w - 1) * 7 + 6;
         //it seems MySQL's weeks disagree with PHP's
         $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL {$d} DAY) ), '%m')");
     } elseif (!empty($m)) {
         //        $calendar = substr($m, 0, 6);
         $thisyear = '' . intval(substr($m, 0, 4));
         if (strlen($m) < 6) {
             $thismonth = '01';
         } else {
             $thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
         }
     } else {
         $thisyear = ec3_strftime("%Y");
         $thismonth = ec3_strftime("%m");
     }
     $this->year_num = intval($thisyear);
     $this->month_num = intval($thismonth);
     $this->day_num = 1;
 }
Example #6
0
/** Template function. Call this from your template to insert a list of
 *  forthcoming events. Available template variables are:
 *   - template_day: %DATE% %SINCE% (only with Time Since plugin)
 *   - template_event: %DATE% %TIME% %LINK% %TITLE% %AUTHOR%
 */
function ec3_get_events($limit, $template_event = EC3_DEFAULT_TEMPLATE_EVENT, $template_day = EC3_DEFAULT_TEMPLATE_DAY, $date_format = EC3_DEFAULT_DATE_FORMAT, $template_month = EC3_DEFAULT_TEMPLATE_MONTH, $month_format = EC3_DEFAULT_MONTH_FORMAT)
{
    if (!ec3_check_installed(__('Upcoming Events', 'ec3'))) {
        return;
    }
    global $ec3, $wpdb, $wp_version;
    // Parse $limit:
    //  NUMBER      - limits number of posts
    //  NUMBER days - next NUMBER of days
    if (empty($limit)) {
        $limit_numposts = 'LIMIT 5';
    } elseif (preg_match('/^ *([0-9]+) *d(ays?)?/', $limit, $matches)) {
        $secs = intval($matches[1]) * 24 * 3600;
        $and_before = "AND start<='" . ec3_strftime('%Y-%m-%d', time() + $secs) . "'";
    } elseif (intval($limit) < 1) {
        $limit_numposts = 'LIMIT 5';
    } else {
        $limit_numposts = 'LIMIT ' . intval($limit);
    }
    if (!$date_format) {
        $date_format = get_option('date_format');
    }
    // Find the upcoming events.
    $calendar_entries = $wpdb->get_results("SELECT DISTINCT\r\n       p.id AS id,\r\n       post_title,\r\n       start,\r\n       u.{$ec3->wp_user_nicename} AS author,\r\n       allday\r\n     FROM {$ec3->schedule} s\r\n     LEFT JOIN {$wpdb->posts} p ON s.post_id=p.id\r\n     LEFT JOIN {$wpdb->users} u ON p.post_author = u.id\r\n     WHERE p.post_status='publish'\r\n       AND end>='{$ec3->today}' {$and_before}\r\n     ORDER BY start {$limit_numposts}");
    echo "<ul class='ec3_events'>";
    echo "<!-- Generated by Event Calendar v{$ec3->version} -->\n";
    if ($calendar_entries) {
        $time_format = get_option('time_format');
        $current_month = false;
        $current_date = false;
        $data = array();
        foreach ($calendar_entries as $entry) {
            // To use %SINCE%, you need Dunstan's 'Time Since' plugin.
            if (function_exists('time_since')) {
                $data['SINCE'] = time_since(time(), ec3_to_time($entry->start));
            }
            // Month changed?
            $data['MONTH'] = mysql2date($month_format, $entry->start);
            if ((!$current_month || $current_month != $data['MONTH']) && $template_month) {
                if ($current_date) {
                    echo "</ul></li>\n";
                }
                if ($current_month) {
                    echo "</ul></li>\n";
                }
                echo "<li class='ec3_list ec3_list_month'>" . ec3_format_str($template_month, $data) . "\n<ul>\n";
                $current_month = $data['MONTH'];
                $current_date = false;
            }
            // Date changed?
            $data['DATE'] = mysql2date($date_format, $entry->start);
            if ((!$current_date || $current_date != $data['DATE']) && $template_day) {
                if ($current_date) {
                    echo "</ul></li>\n";
                }
                echo "<li class='ec3_list ec3_list_day'>" . ec3_format_str($template_day, $data) . "\n<ul>\n";
                $current_date = $data['DATE'];
            }
            if ($entry->allday) {
                $data['TIME'] = __('all day', 'ec3');
            } else {
                $data['TIME'] = mysql2date($time_format, $entry->start);
            }
            $data['TITLE'] = htmlentities(stripslashes(strip_tags($entry->post_title)), ENT_QUOTES, get_option('blog_charset'));
            $data['LINK'] = get_permalink($entry->id);
            $data['AUTHOR'] = htmlentities($entry->author, ENT_QUOTES, get_option('blog_charset'));
            echo " <li>" . ec3_format_str($template_event, $data) . "</li>\n";
        }
        if ($current_date) {
            echo "</ul></li>\n";
        }
        if ($current_month) {
            echo "</ul></li>\n";
        }
    } else {
        echo "<li>" . __('No events.', 'ec3') . "</li>\n";
    }
    echo "</ul>\n";
}
Example #7
0
    function event_editor_box()
    {
        global $ec3, $wp_version, $wpdb, $post_ID;
        if (isset($post_ID)) {
            $schedule = $wpdb->get_results("SELECT\n           sched_id,\n           DATE_FORMAT(start,'%Y-%m-%d %H:%i') AS start,\n           DATE_FORMAT(end,'%Y-%m-%d %H:%i') AS end,\n           allday,\n           rpt\n         FROM {$ec3->schedule} WHERE post_id={$post_ID} ORDER BY start");
        } else {
            $schedule = false;
        }
        if (function_exists('wp_create_nonce')) {
            echo '<input type="hidden" name="ec3_nonce" id="ec3_nonce" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />';
        }
        ?>

    <!-- Event Calendar: Event Editor -->
    <table width="100%" cellspacing="2" cellpadding="5" class="editform">
     <thead><tr>
      <th><?php 
        _e('Start', 'ec3');
        ?>
</th>
      <th><?php 
        _e('End', 'ec3');
        ?>
</th>
      <th style="text-align:center"><?php 
        _e('All Day', 'ec3');
        ?>
</th>
      <!-- th><?php 
        _e('Repeat', 'ec3');
        ?>
</th -->
      <th></th>
     </tr></thead>
     <tbody>
    <?php 
        $ec3_rows = 0;
        if ($schedule) {
            foreach ($schedule as $s) {
                $this->schedule_row($s->start, $s->end, $s->sched_id, 'update', $s->allday);
            }
            $ec3_rows = count($schedule);
        }
        $default = ec3_strftime('%Y-%m-%d %H:00', 3600 + time());
        $this->schedule_row($default, $default, '_', 'create', False);
        ?>
      <tr> 
       <td colspan="4" style="text-align:left">
        <p style="margin:0;padding:0;text-align:left">
         <input type="button" name="ec3_new_row" value=" + "
          title="<?php 
        _e('Add a new event', 'ec3');
        ?>
"
          onclick="Ec3EditForm.add_row()" />
         <input type="hidden" id="ec3_rows" name="ec3_rows"
          value="<?php 
        echo $ec3_rows;
        ?>
" />
        </p>
       </td>
      </tr> 
     </tbody>
    </table>

    <?php 
    }
Example #8
0
    function filter_edit_form()
    {
        global $ec3, $wp_version, $wpdb, $post_ID;
        if (isset($post_ID)) {
            $schedule = $wpdb->get_results("SELECT\n           sched_id,\n           DATE_FORMAT(start,'%Y-%m-%d %H:%i') AS start,\n           DATE_FORMAT(end,'%Y-%m-%d %H:%i') AS end,\n           allday,\n           rpt\n         FROM {$ec3->schedule} WHERE post_id={$post_ID} ORDER BY start");
        } else {
            $schedule = false;
        }
        ?>
    
    <!-- Build the user interface for Event Calendar. -->
    <div class="dbx-b-ox-wrapper">
    <fieldset id='ec3_schedule_editor' class="dbx-box">
    <div class="dbx-h-andle-wrapper">
    <h3 class="dbx-handle"><?php 
        _e('Event Editor', 'ec3');
        ?>
</h3>
    </div>
    <div class="dbx-c-ontent-wrapper">
    <div class="dbx-content">

    <table width="100%" cellspacing="2" cellpadding="5" class="editform">
     <thead><tr>
      <th><?php 
        _e('Start', 'ec3');
        ?>
</th>
      <th><?php 
        _e('End', 'ec3');
        ?>
</th>
      <th><?php 
        _e('All Day', 'ec3');
        ?>
</th>
      <!-- th><?php 
        _e('Repeat', 'ec3');
        ?>
</th -->
      <th></th>
     </tr></thead>
     <tbody>
    <?php 
        $ec3_rows = 0;
        if ($schedule) {
            foreach ($schedule as $s) {
                $this->schedule_row($s->start, $s->end, $s->sched_id, 'update', $s->allday);
            }
            $ec3_rows = count($schedule);
        }
        $default = ec3_strftime('%Y-%m-%d %H:00', 3600 + time());
        $this->schedule_row($default, $default, '_', 'create', False);
        ?>
      <tr> 
       <td colspan="4" style="text-align:left">
        <p class="submit" style="margin:0;padding:0;text-align:left">
         <input type="button" name="ec3_new_row" value=" + "
          title="<?php 
        _e('Add a new event', 'ec3');
        ?>
"
          onclick="Ec3EditForm.add_row()" />
         <input type="hidden" id="ec3_rows" name="ec3_rows"
          value="<?php 
        echo $ec3_rows;
        ?>
" />
        </p>
       </td>
      </tr> 
     <tbody>
    </table>
    </div>
    </div>
    </fieldset>
    </div>

    <?php 
    }
Example #9
0
    function event_editor_box()
    {
        global $ec3, $wp_version, $wpdb, $post_ID, $current_user;
        //
        get_currentuserinfo();
        if (get_post_type() == 'exposition') {
            if (!is_admin() && $current_user->user_email != '*****@*****.**') {
                return;
            }
        }
        if (isset($post_ID)) {
            $schedule = $wpdb->get_results("SELECT\n           sched_id,\n           start,\n           end,\n           allday,\n           lieux_id,\n           option_id,\n           rpt,\n           infos\n         FROM {$ec3->schedule} WHERE post_id={$post_ID} ORDER BY start");
        } else {
            $schedule = false;
        }
        if (function_exists('wp_create_nonce')) {
            echo '<input type="hidden" name="ec3_nonce" id="ec3_nonce" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />';
        }
        ?>

    <!-- Event-Calendar: Event Editor -->
    <table cellspacing="2" cellpadding="5" class="editform" style="position : relative;">
     <thead><tr>
      <th><?php 
        _e('Start', 'ec3');
        ?>
 / <?php 
        _e('End', 'ec3');
        ?>
</th>
      <?php 
        if (get_post_type() != 'exposition') {
            ?>
          <th><?php 
            _e('Time Start', 'ec3');
            ?>
 / <?php 
            _e('End', 'ec3');
            ?>
</th>
          <th style="text-align:center"><?php 
            _e('All Day', 'ec3');
            ?>
</th>
       <?php 
        }
        ?>
      <th style="text-align:center"><?php 
        _e('Lieux', 'ec3');
        ?>
</th>
      <th><?php 
        _e('Options', 'ec3');
        ?>
</th>
      <th><?php 
        _e('Info', 'ec3');
        ?>
</th>
     </tr></thead>
     <tbody>
    <?php 
        if ($schedule) {
            echo '<script>';
            echo 'var ec3_oldrows = new Array();';
            echo 'function ec3_show_oldrows(){ for (var i=0; i<ec3_oldrows.length; i++) ec3_oldrows[i].style.display = ""; }';
            echo 'function ec3_hide_oldrows(){ for (var i=0; i<ec3_oldrows.length; i++) ec3_oldrows[i].style.display = "none"; }';
            echo '</script>';
            foreach ($schedule as $s) {
                $time_start = substr($s->start, 11, 16);
                $time_end = substr($s->end, 11, 16);
                $s->start = substr($s->start, 0, 10);
                $s->end = substr($s->end, 0, 10);
                $this->schedule_row($s->start, $s->end, $time_start, $time_end, $s->sched_id, 'update', $s->allday, $s->lieux_id, $s->option_id, $s->infos);
            }
            $ec3_rows = count($schedule);
            echo '<script>ec3_hide_oldrows();</script>';
        }
        $default = ec3_strftime('%Y-%m-%d', 3600 + time());
        $time_default = '00:00';
        $this->schedule_row($default, $default, $time_default, $time_default, '', 'create', False, '', '', '');
        ?>
      <tr> 
       <td colspan="7" style="text-align:left">
        <p style="margin:0;padding:0;text-align:left">
          <span style="vertical-align:middle;"><input type="button" name="ec3_new_row" style="display: block; margin-bottom: 20px;" value=" + " title="<?php 
        _e('Add a new event', 'ec3');
        ?>
" onclick="if (document.getElementById('ec3_repeat_check').checked && document.getElementById('ec3_repeat_count').value == '') { alert('Please enter a repeat number!'); return false; } else if (document.getElementById('ec3_repeatuntil_check').checked && (document.getElementById('ec3_repeatuntil_date').value == '' || document.getElementById('ec3_repeatuntil_date').value == 'yyyy-mm-dd')) { alert('Please enter a repeat end date!'); return false; } else { if (ec3_repeatuntil_check.checked) { Ec3EditForm.add_row(ec3_repeatuntil_check.checked,ec3_repeatuntil_date.value,ec3_repeatuntil_type.value); } else { Ec3EditForm.add_row(ec3_repeat_check.checked,ec3_repeat_count.value,ec3_repeat_type.value); } }" /></span>
    <span style="vertical-align:middle;">&nbsp;&nbsp;<input type="checkbox" onclick="if (this.checked) { ec3_show_oldrows(); } else { ec3_hide_oldrows(); }"></span>
    <span style="vertical-align:middle;">Show past events</span>
          <br>

          <div class="paramDefault">
            <label for="lieuxDefault">Lieux par défault</label>
            <span style="max-width:160px; display:inline-block;">
              <?php 
        get_lieux('def', $post_ID);
        ?>
            </span>
            <?php 
        if (get_post_type() != 'exposition') {
            ?>
              <label for="horraireDefault">Horraire par défault</label>:
              <label for="debut">debut :</label><input class="hD" name="ec3_hDebut" type="text" size="3" maxlength="5" disabled="disabled" placeholder="00:00">
              <label for="fin">fin :</label><input type="text" size="3" maxlength="5" disabled="disabled" placeholder="00:00">
            <?php 
        }
        ?>
          </div>

      <span style="vertical-align:middle;">&nbsp;&nbsp;<input type="checkbox" name="ec3_repeat_check" id="ec3_repeat_check" value="yes" onclick="if (this.checked && document.getElementById('ec3_repeatuntil_check').checked) document.getElementById('ec3_repeatuntil_check').click(); document.getElementById('ec3_repeat_type').disabled = !this.checked; document.getElementById('ec3_repeat_count').disabled = !this.checked;" /></span>

          <span style="vertical-align:middle;">Repeat last entry for</span>
          <span style="vertical-align:middle;"><input type="text" name="ec3_repeat_count" id="ec3_repeat_count" size="4" style="font-size:8pt;" disabled /></span>
          <span style="vertical-align:middle;padding-top:5px;"><select name="ec3_repeat_type" id="ec3_repeat_type" disabled>
            <option value="opt1">weeks</option>
            <option value="opt2">months (e.g. 15th of every month)</option>
            <option value="opt3">months (e.g. 2nd Monday of every month)</option>
          </select></span><br>

          <span style="vertical-align:middle;">&nbsp;&nbsp;<input type="checkbox" name="ec3_repeatuntil_check" id="ec3_repeatuntil_check" value="yes" onclick="if (this.checked && document.getElementById('ec3_repeat_check').checked) document.getElementById('ec3_repeat_check').click(); document.getElementById('ec3_repeatuntil_type').disabled = !this.checked; document.getElementById('ec3_repeatuntil_date').disabled = !this.checked;" /></span>
          <span style="vertical-align:middle;">Repeat last entry every</span>
          <span style="vertical-align:bottom;"><select name="ec3_repeatuntil_type" id="ec3_repeatuntil_type" disabled>
            <option value="opt1">week</option>
            <option value="opt2">month (e.g. 15th of every month)</option>
            <option value="opt3">month (e.g. 2nd Monday of every month)</option>
          </select></span>
          <span style="vertical-align:middle;">until</span>
      <span style="vertical-align:bottom;"><input type="text" size="10" maxlength="10" value="yyyy-mm-dd" onclick="if (this.value=='yyyy-mm-dd') this.value='';" onblur="if (this.value=='') this.value='yyyy-mm-dd';" name="ec3_repeatuntil_count" id="ec3_repeatuntil_date" size="4" style="font-size:8pt;" disabled /></span>
          <input type="hidden" id="ec3_rows" name="ec3_rows" value="<?php 
        echo $ec3_rows;
        ?>
" />

        </p>
       </td>
      </tr> 
     </tbody>
    </table>


    <?php 
    }