Exemple #1
0
function calendar_init($tools)
{
    $cnt = 0;
    $opts = array($tools->str[28]);
    $tools->save_to_global_store('help_strings', $opts);
    if ($tools->get_setting('calendar_event_summary')) {
        require_once $tools->include_path . 'page.php';
        require_once $tools->include_path . 'cal_include.php';
        if ($tools->get_db()) {
            $day = date('d');
            $year = date('Y');
            $month = date('m');
            $count = array();
            $events = get_calendar_events($month, $year, $day, 'calendar_day', $tools);
            foreach ($events as $date => $vals) {
                if ($date == $year . '-' . $month . '-' . $day) {
                    foreach ($vals as $time => $atts_list) {
                        foreach ($atts_list as $index => $event_array) {
                            foreach ($event_array as $atts) {
                                $count[$date . $time . $atts['id']] = 1;
                            }
                        }
                    }
                }
            }
            $cnt = count($count);
        }
    }
    $tools->add_to_store('event_cnt', $cnt);
}
Exemple #2
0
    public function getBlock($block_id, $template = true, $cfg = null)
    {
        global $ctype, $controller;
        $show_unassigned = get_block_setting($block_id, 'show_unassigned', true);
        $show_other = get_block_setting($block_id, 'show_other', true);
        $show_future = get_block_setting($block_id, 'show_future', true);
        $block = get_block_setting($block_id, 'block', true);
        if ($cfg) {
            foreach (array('show_unassigned', 'show_other', 'show_future', 'block') as $name) {
                if (array_key_exists($name, $cfg)) {
                    ${$name} = $cfg[$name];
                }
            }
        }
        $id = $this->getName() . $block_id;
        $class = $this->getName() . '_block';
        if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) {
            $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
        } else {
            $title = '';
        }
        $title .= $this->getTitle() . help_link('todo', $this->getName());
        $table_id = Uuid::uuid4();
        // create a unique ID
        $controller->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addInlineJavascript('
				jQuery("#' . $table_id . '").dataTable({
					dom: \'t\',
					' . WT_I18N::datatablesI18N() . ',
					autoWidth: false,
					paginate: false,
					lengthChange: false,
					filter: false,
					info: true,
					jQueryUI: true,
					columns: [
						/* 0-DATE */   		{ visible: false },
						/* 1-Date */		{ dataSort: 0 },
						/* 1-Record */ 		null,
						/* 2-Username */	null,
						/* 3-Text */		null
					]
				});
			jQuery("#' . $table_id . '").css("visibility", "visible");
			jQuery(".loading-image").css("display", "none");
			');
        $content = '';
        $content .= '<div class="loading-image">&nbsp;</div>';
        $content .= '<table id="' . $table_id . '" style="visibility:hidden;">';
        $content .= '<thead><tr>';
        $content .= '<th>DATE</th>';
        //hidden by datables code
        $content .= '<th>' . WT_Gedcom_Tag::getLabel('DATE') . '</th>';
        $content .= '<th>' . WT_I18N::translate('Record') . '</th>';
        if ($show_unassigned || $show_other) {
            $content .= '<th>' . WT_I18N::translate('Username') . '</th>';
        }
        $content .= '<th>' . WT_Gedcom_Tag::getLabel('TEXT') . '</th>';
        $content .= '</tr></thead><tbody>';
        $found = false;
        $end_jd = $show_future ? 99999999 : WT_CLIENT_JD;
        foreach (get_calendar_events(0, $end_jd, '_TODO', WT_GED_ID) as $fact) {
            $record = $fact->getParent();
            $user_name = $fact->getAttribute('_WT_USER');
            if ($user_name == WT_USER_NAME || !$user_name && $show_unassigned || $user_name && $show_other) {
                $content .= '<tr>';
                //-- Event date (sortable)
                $content .= '<td>';
                //hidden by datables code
                $content .= $fact->getDate()->JD();
                $content .= '</td>';
                $content .= '<td class="wrap">' . $fact->getDate()->Display(empty($SEARCH_SPIDER)) . '</td>';
                $content .= '<td class="wrap"><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>';
                if ($show_unassigned || $show_other) {
                    $content .= '<td class="wrap">' . $user_name . '</td>';
                }
                $text = $fact->getValue();
                $content .= '<td class="wrap">' . $text . '</td>';
                $content .= '</tr>';
                $found = true;
            }
        }
        $content .= '</tbody></table>';
        if (!$found) {
            $content .= '<p>' . WT_I18N::translate('There are no research tasks in this family tree.') . '</p>';
        }
        if ($template) {
            if ($block) {
                require WT_THEME_DIR . 'templates/block_small_temp.php';
            } else {
                require WT_THEME_DIR . 'templates/block_main_temp.php';
            }
        } else {
            return $content;
        }
    }
Exemple #3
0
function print_todo($block = true, $config = '', $side, $index)
{
    global $pgv_lang, $factarray, $ctype, $PGV_IMAGE_DIR, $PGV_IMAGES, $PGV_BLOCKS;
    $block = true;
    // Always restrict this block's height
    if (empty($config)) {
        $config = $PGV_BLOCKS['print_todo']['config'];
    }
    $id = 'todo';
    $title = print_help_link('todo_help', 'qm', '', false, true);
    if ($PGV_BLOCKS['print_todo']['canconfig']) {
        if ($ctype == 'gedcom' && PGV_USER_GEDCOM_ADMIN || $ctype == 'user' && PGV_USER_ID) {
            if ($ctype == 'gedcom') {
                $name = PGV_GEDCOM;
            } else {
                $name = PGV_USER_NAME;
            }
            $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
            $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['admin']['small']}\" width=\"15\" height=\"15\" border=\"0\" alt=\"{$pgv_lang['config_block']}\" /></a>";
        }
    }
    $title .= $pgv_lang['todo_block'];
    $content = "";
    require_once PGV_ROOT . 'js/sorttable.js.htm';
    require_once PGV_ROOT . 'includes/classes/class_gedcomrecord.php';
    $table_id = 'ID' . floor(microtime() * 1000000);
    // sorttable requires a unique ID
    $content .= '<table id="' . $table_id . '" class="sortable list_table center">';
    $content .= '<tr>';
    $content .= '<th class="list_label">' . $factarray['DATE'] . '</th>';
    $content .= '<th class="list_label">' . $pgv_lang['record'] . '</th>';
    if ($config['show_unassigned'] == 'yes' || $config['show_other'] == 'yes') {
        $content .= '<th class="list_label">' . $pgv_lang['username'] . '</th>';
    }
    $content .= '<th class="list_label">' . $factarray['TEXT'] . '</th>';
    $content .= '</tr>';
    $found = false;
    $end_jd = $config['show_future'] == 'yes' ? 99999999 : client_jd();
    foreach (get_calendar_events(0, $end_jd, '_TODO', PGV_GED_ID) as $todo) {
        $record = GedcomRecord::getInstance($todo['id']);
        if ($record && $record->canDisplayDetails()) {
            $pgvu = get_gedcom_value('_PGVU', 2, $todo['factrec']);
            if ($pgvu == PGV_USER_NAME || !$pgvu && $config['show_unassigned'] == 'yes' || $pgvu && $config['show_other'] == 'yes') {
                $content .= '<tr valign="top">';
                $content .= '<td class="list_value_wrap">' . str_replace('<a', '<a name="' . $todo['date']->MinJD() . '"', $todo['date']->Display(false)) . '</td>';
                $name = $record->getListName();
                $content .= '<td class="list_value_wrap" align="' . get_align(PGV_GEDCOM) . '"><a href="' . encode_url($record->getLinkUrl()) . '">' . PrintReady($name) . '</a></td>';
                if ($config['show_unassigned'] == 'yes' || $config['show_other'] == 'yes') {
                    $content .= '<td class="list_value_wrap">' . $pgvu . '</td>';
                }
                $text = get_gedcom_value('_TODO', 1, $todo['factrec']);
                $content .= '<td class="list_value_wrap" align="' . get_align($text) . '">' . PrintReady($text) . '</td>';
                $content .= '</tr>';
                $found = true;
            }
        }
    }
    $content .= '</table>';
    if (!$found) {
        $content .= '<p>' . $pgv_lang['todo_nothing'] . '</p>';
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
Exemple #4
0
function url_action_calendar($tools, $get, $post)
{
    require_once $tools->include_path . 'cal_include.php';
    if (!$tools->logged_in()) {
        $tools->page_not_found();
    }
    /* get the current mailbox if any */
    $mailbox = $tools->get_mailbox();
    /* set the current mailbox */
    if ($mailbox) {
        $tools->set_mailbox($mailbox);
    }
    /* default values */
    $page_data = array();
    $week = false;
    $month = false;
    $today = date('m-d-Y');
    $year = false;
    $title = '';
    $detail = '';
    $repeat = 0;
    $duration = 0;
    $event_time = 0;
    $month_label = false;
    $day = false;
    $last_day = false;
    $events = array();
    $duration = '';
    $duration2 = '';
    $event_time = '';
    $event_time2 = '';
    $first_week_day = false;
    $all_events = array();
    $edit_id = 0;
    $dsp_page = 'calendar_month';
    $final_week = false;
    if (isset($post['calendar_add'])) {
        $req_flds = array('title', 'year', 'month', 'day');
        $opt_flds = array('repeat', 'detail', 'event_time', 'event_time2', 'duration', 'duration2');
        $cal_atts = normalize_input($req_flds, $opt_flds, $post);
        $cnt = count($req_flds) + count($opt_flds);
        if (count($cal_atts) == $cnt) {
            $edit_id = add_cal_event($cal_atts, $tools);
            if ($edit_id) {
                $tools->send_notice('Event Added');
                $dsp_page = 'edit';
            } else {
                $tools->send_notice('An error occured adding this event');
                $dsp_page = 'add';
            }
        } else {
            $dsp_page = 'add';
            foreach ($req_flds as $v) {
                if (isset($cal_atts[$v])) {
                    ${$v} = $cal_atts[$v];
                }
            }
            foreach ($opt_flds as $v) {
                if (isset($cal_atts[$v])) {
                    ${$v} = $cal_atts[$v];
                }
            }
        }
    } elseif (isset($post['calendar_update'])) {
        if (isset($post['event_id']) && ($event_id = $post['event_id'])) {
            $edit_id = $post['event_id'];
            $dsp_page = 'edit';
            $req_flds = array('title', 'year', 'month', 'day', 'event_id');
            $opt_flds = array('repeat', 'detail', 'event_time', 'event_time2', 'duration', 'duration2');
            $cal_atts = normalize_input($req_flds, $opt_flds, $post);
            $cnt = count($req_flds) + count($opt_flds);
            if (count($cal_atts) == $cnt) {
                $res = update_event($tools, $cal_atts);
                if ($res) {
                    $tools->send_notice('Event Updated');
                }
            }
        }
    } elseif (isset($post['calendar_delete'])) {
        if (isset($post['event_id']) && ($del_id = intval($post['event_id']))) {
            if (delete_event($tools, $del_id)) {
                calendar_init($tools);
                $tools->send_notice('Event Deleted');
                $dsp_page = 'calendar_month';
                $month = date('m');
                $year = date('Y');
                $month_label = strtolower(date('F'));
                $last_day = date('d', mktime(0, 0, 0, $month + 1, 0, $year));
                $first_week_day = date('w', mktime(0, 0, 0, $month, 1, $year));
                if ($first_week_day + $last_day > 36) {
                    $final_week = 6;
                } elseif ($first_week_day == 0 && $last_day == 28) {
                    $final_week = 4;
                } else {
                    $final_week = 5;
                }
            } else {
                $edit_id = $del_id;
                send_notice('Could not delete event');
            }
        }
    } elseif (isset($get['list_events'])) {
        $dsp_page = 'list_events';
        $all_events = get_calendar_events(false, false, false, 'all', $tools);
    } elseif (isset($get['add_event'])) {
        $dsp_page = 'add';
        foreach (array('year', 'month', 'day') as $v) {
            if (isset($get[$v])) {
                ${$v} = $get[$v];
            }
        }
    } elseif (isset($get['edit_event'])) {
        $dsp_page = 'edit';
        $edit_id = intval($get['edit_event']);
        foreach (array('year', 'month', 'day') as $v) {
            if (isset($get[$v])) {
                ${$v} = $get[$v];
            }
        }
    } elseif (isset($get['year']) && $get['year']) {
        if (preg_match("/^\\d{4}\$/", $get['year'])) {
            $year = $get['year'];
            $dsp_page = 'calendar_year';
            /* check for month in URL args */
            if (isset($get['month']) && $get['month']) {
                $month = strtotime($get['month']);
                if ($month && $month != -1) {
                    $month_label = $get['month'];
                    $month = date('m', $month);
                    $dsp_page = 'calendar_month';
                    $last_day = date('d', mktime(0, 0, 0, $month + 1, 0, $year));
                    $first_week_day = date('w', mktime(0, 0, 0, $month, 1, $year));
                    if ($first_week_day + $last_day > 36) {
                        $final_week = 6;
                    } elseif ($first_week_day == 0 && $last_day == 28) {
                        $final_week = 4;
                    } else {
                        $final_week = 5;
                    }
                    /* check for week in the URL args */
                    if (isset($get['week']) && $get['week']) {
                        if (preg_match("/^week([1-{$final_week}])\$/", $get['week'], $matches)) {
                            $dsp_page = 'calendar_week';
                            $week = $matches[1];
                            if ($week == 1) {
                                $last_month = strtolower(date('F', mktime(0, 0, 0, $month - 1, 1, $year)));
                                $last_int_month = strtolower(date('m', mktime(0, 0, 0, $month - 1, 1, $year)));
                                $last_year = date('Y', mktime(0, 0, 0, $month - 1, 1, $year));
                                $last_last_day = date('d', mktime(0, 0, 0, $last_int_month + 1, 0, $last_year));
                                $last_month_first_week_day = date('w', mktime(0, 0, 0, $last_int_month, 1, $last_year));
                                if ($last_month_first_week_day + $last_last_day > 36) {
                                    $last_final_week = 6;
                                } elseif ($first_week_day == 0 && $last_day == 28) {
                                    $last_final_week = 4;
                                } else {
                                    $last_final_week = 5;
                                }
                                $last_url = '?page=calendar&amp;year=' . $last_year . '&amp;month=' . $last_month . '&amp;week=week' . $last_final_week;
                                $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;week=week2';
                            } elseif ($week == $final_week) {
                                $next_month = strtolower(date('F', mktime(0, 0, 0, $month + 1, 1, $year)));
                                $next_year = date('Y', mktime(0, 0, 0, $month + 1, 1, $year));
                                $next_url = '?page=calendar&amp;year=' . $next_year . '&amp;month=' . $next_month . '&amp;week=week1';
                                $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;week=week' . ($week - 1);
                            } else {
                                $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;week=week' . ($week + 1);
                                $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;week=week' . ($week - 1);
                            }
                            $page_data['last_url'] = $last_url;
                            $page_data['next_url'] = $next_url;
                        }
                    } elseif (isset($get['day']) && $get['day'] > 0 && $get['day'] <= $last_day) {
                        $dsp_page = 'calendar_day';
                        $day = $get['day'];
                        if ($day == $last_day) {
                            $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;day=' . ($day - 1);
                            if ($month == 12) {
                                $next_url = '?page=calendar&amp;year=' . ($year + 1) . '&amp;month=january&amp;day=1';
                            } else {
                                $next_month = strtolower(date("F", mktime(0, 0, 0, $month + 1, 1, $year)));
                                $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $next_month . '&amp;day=1';
                            }
                        } elseif ($day == 1) {
                            if ($month == 1) {
                                $last_url = '?page=calendar&amp;year=' . ($year - 1) . '&amp;month=december&amp;day=31';
                            } else {
                                $last_month = strtolower(date("F", mktime(0, 0, 0, $month - 1, 1, $year)));
                                $last_day = date("t", mktime(0, 0, 0, $month - 1, 1, $year));
                                $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $last_month . '&amp;day=' . $last_day;
                            }
                            $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;day=2';
                        } else {
                            $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;day=' . ($day - 1);
                            $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;day=' . ($day + 1);
                        }
                        $page_data['last_url'] = $last_url;
                        $page_data['next_url'] = $next_url;
                    }
                }
            }
        }
    } else {
        $dsp_page = 'calendar_month';
        $month = date('m');
        $year = date('Y');
        $month_label = strtolower(date('F'));
        $last_day = date('d', mktime(0, 0, 0, $month + 1, 0, $year));
        $first_week_day = date('w', mktime(0, 0, 0, $month, 1, $year));
        if ($first_week_day + $last_day > 36) {
            $final_week = 6;
        } elseif ($first_week_day == 0 && $last_day == 28) {
            $final_week = 4;
        } else {
            $final_week = 5;
        }
    }
    if ($dsp_page != 'add' && $dsp_page != 'edit') {
        $events = get_calendar_events($month, $year, $day, $dsp_page, $tools);
    }
    if ($edit_id != 0 && $dsp_page == 'edit') {
        list($year, $month, $day, $event_time, $event_time2, $duration, $duration2, $title, $detail, $repeat) = get_cal_event($tools, $edit_id);
    }
    /* Build some more values for the display and stick everything into the $page_data array */
    $prev_month = strtolower(date('F', mktime(0, 0, 0, $month - 1, 1, $year)));
    $prev_month_url = '?page=calendar&amp;year=' . date('Y', mktime(0, 0, 0, $month - 1, 1, $year)) . '&amp;month=' . $prev_month;
    $next_month = strtolower(date('F', mktime(0, 0, 0, $month + 1, 1, $year)));
    $next_month_url = '?page=calendar&amp;year=' . date('Y', mktime(0, 0, 0, $month + 1, 1, $year)) . '&amp;month=' . $next_month;
    $page_data['cal_data'] = array('events' => $events, 'all_events' => $all_events, 'month' => $month, 'year' => $year, 'day' => $day, 'week' => $week, 'last_day' => $last_day, 'first_week_day' => $first_week_day, 'final_week' => $final_week, 'prev_month' => $prev_month, 'next_month' => $next_month, 'today' => $today, 'next_month_url' => $next_month_url, 'prev_month_url' => $prev_month_url, 'month_label' => $month_label);
    $page_data['dsp_page'] = $dsp_page;
    $page_data['title'] = $title;
    $page_data['detail'] = $detail;
    $page_data['event_time'] = $event_time;
    $page_data['duration'] = $duration;
    $page_data['repeat'] = $repeat;
    $page_data['duration'] = $duration;
    $page_data['duration2'] = $duration2;
    $page_data['event_time'] = $event_time;
    $page_data['event_time2'] = $event_time2;
    $page_data['edit_id'] = $edit_id;
    $tools->set_title($tools->str[1]);
    return $page_data;
}
Exemple #5
0
        for ($jd = $cal_date->minJD; $jd <= $cal_date->maxJD; ++$jd) {
            foreach (apply_filter(get_anniversary_events($jd, $events), $filterof, $filtersx) as $fact) {
                $tmp = $fact->getDate()->MinDate();
                if ($tmp->d >= 1 && $tmp->d <= $tmp->DaysInMonth()) {
                    $d = $jd - $cal_date->minJD + 1;
                } else {
                    $d = 0;
                }
                $found_facts[$d][] = $fact;
            }
        }
        break;
    case 'year':
        $cal_date->m = 0;
        $cal_date->setJdFromYmd();
        $found_facts = apply_filter(get_calendar_events($ged_date->MinJD(), $ged_date->MaxJD(), $events), $filterof, $filtersx);
        // Eliminate duplicates (e.g. BET JUL 1900 AND SEP 1900 will appear twice in 1900)
        $found_facts = array_unique($found_facts);
        break;
}
// Group the facts by family/individual
switch ($action) {
    case 'year':
    case 'today':
        $indis = array();
        $fams = array();
        foreach ($found_facts as $fact) {
            $record = $fact->getParent();
            $xref = $record->getXref();
            if ($record instanceof WT_Individual) {
                if (empty($indis[$xref])) {
                } else {
                    $value = true;
                }
            } else {
                $value = substr($events_array[$i][$j], $colon + 3, -1);
            }
            $assoc_array[$key] = $value;
        }
        $events_array[$i] = $assoc_array;
    }
    return $events_array;
}
function get_json_cal_events($events_array)
{
    $json_cal = json_encode($events_array);
    echo $json_cal;
}
function get_calendar_events($cal_url)
{
    $events1 = curl_download($cal_url);
    $events2 = parse_output($events1);
    $events3 = parse_events($events2);
    $events4 = remove_colors($events3);
    $events5 = remove_whitespace($events4);
    $events6 = get_key_values($events5);
    get_json_cal_events($events6);
}
get_calendar_events($ha_url);
?>