function __construct() { parent::__construct(); $this->setPageTitle(WT_I18N::translate('Timeline')); $this->baseyear = date("Y"); // new pid $newpid = WT_Filter::get('newpid', WT_REGEX_XREF); // pids array $this->pids = WT_Filter::getArray('pids', WT_REGEX_XREF); // make sure that arrays are indexed by numbers $this->pids = array_values($this->pids); if (!empty($newpid) && !in_array($newpid, $this->pids)) { $this->pids[] = $newpid; } if (count($this->pids) == 0) { $this->pids[] = $this->getSignificantIndividual()->getXref(); } $remove = WT_Filter::get('remove', WT_REGEX_XREF); // cleanup user input $newpids = array(); foreach ($this->pids as $value) { if ($value != $remove) { $newpids[] = $value; $person = WT_Individual::getInstance($value); if ($person) { $this->people[] = $person; } } } $this->pids = $newpids; $this->pidlinks = ""; /* @var $indi Person */ foreach ($this->people as $p => $indi) { if (!is_null($indi) && $indi->canShow()) { // setup string of valid pids for links $this->pidlinks .= "pids%5B%5D=" . $indi->getXref() . "&"; $bdate = $indi->getBirthDate(); if ($bdate->isOK()) { $date = $bdate->MinDate(); $date = $date->convert_to_cal('gregorian'); if ($date->y) { $this->birthyears[$indi->getXref()] = $date->y; $this->birthmonths[$indi->getXref()] = max(1, $date->m); $this->birthdays[$indi->getXref()] = max(1, $date->d); } } // find all the fact information $facts = $indi->getFacts(); foreach ($indi->getSpouseFamilies() as $family) { foreach ($family->getFacts() as $fact) { $fact->spouse = $family->getSpouse($indi); $facts[] = $fact; } } foreach ($facts as $event) { // get the fact type $fact = $event->getTag(); if (!in_array($fact, $this->nonfacts)) { // check for a date $date = $event->getDate(); $date = $date->MinDate(); $date = $date->convert_to_cal('gregorian'); if ($date->y) { $this->baseyear = min($this->baseyear, $date->y); $this->topyear = max($this->topyear, $date->y); if (!$indi->isDead()) { $this->topyear = max($this->topyear, date('Y')); } $event->temp = $p; // do not add the same fact twice (prevents marriages from being added multiple times) // TODO - this code does not work. If both spouses are shown, their marriage is duplicated... if (!in_array($event, $this->indifacts, true)) { $this->indifacts[] = $event; } } } } } } $scale = WT_Filter::getInteger('scale', 0, 200); if ($scale == 0) { $this->scale = round(($this->topyear - $this->baseyear) / 20 * count($this->indifacts) / 4); if ($this->scale < 6) { $this->scale = 6; } } else { $this->scale = $scale; } if ($this->scale < 2) { $this->scale = 2; } $this->baseyear -= 5; $this->topyear += 5; }
// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA define('WT_SCRIPT_NAME', 'placelist.php'); require './includes/session.php'; require_once WT_ROOT . 'includes/functions/functions_print_lists.php'; $controller = new WT_Controller_Page(); $action = WT_Filter::get('action', 'find|show', 'find'); $display = WT_Filter::get('display', 'hierarchy|list', 'hierarchy'); $parent = WT_Filter::getArray('parent'); $level = count($parent); if ($display == 'hierarchy') { if ($level) { $controller->setPageTitle(WT_I18N::translate('Place hierarchy') . ' - <span dir="auto">' . WT_Filter::escapeHtml(end($parent)) . '</span>'); } else { $controller->setPageTitle(WT_I18N::translate('Place hierarchy')); } } else { $controller->setPageTitle(WT_I18N::translate('Place list')); } $controller->pageHeader(); echo '<div id="place-hierarchy">'; switch ($display) { case 'list': echo '<h2>', $controller->getPageTitle(), '</h2>';
function __construct() { global $WT_SESSION; parent::__construct(); $this->setPageTitle(WT_I18N::translate('Lifespans')); $this->colorindex = 0; $this->Fcolorindex = 0; $this->Mcolorindex = 0; $this->zoomfactor = 10; $this->color = "#0000FF"; $this->currentYear = date("Y"); $this->deathMod = 0; $this->endDate = $this->currentYear; // Request parameters $newpid = WT_Filter::get('newpid', WT_REGEX_XREF); $remove = WT_Filter::get('remove', WT_REGEX_XREF); $pids = WT_Filter::getArray('pids', WT_REGEX_XREF); $clear = WT_Filter::getBool('clear'); $addfam = WT_Filter::getBool('addFamily'); $place = WT_Filter::get('place'); $beginYear = WT_Filter::getInteger('beginYear', 0, date('Y') + 100, 0); $endYear = WT_Filter::getInteger('endYear', 0, date('Y') + 100, 0); if ($clear) { // Empty list $this->pids = array(); } elseif ($pids) { // List of specified records $this->pids = $pids; } elseif ($place) { // All records found in a place $wt_place = new WT_Place($place, WT_GED_ID); $this->pids = WT_DB::prepare("SELECT DISTINCT pl_gid FROM `##placelinks` WHERE pl_p_id=? AND pl_file=?")->execute(array($wt_place->getPlaceId(), WT_GED_ID))->fetchOneColumn(); $this->place = $place; } else { // Modify an existing list of records if (is_array($WT_SESSION->timeline_pids)) { $this->pids = $WT_SESSION->timeline_pids; } else { $this->pids = array(); } if ($remove) { foreach ($this->pids as $key => $value) { if ($value == $remove) { unset($this->pids[$key]); } } } elseif ($newpid) { $person = WT_Individual::getInstance($newpid); $this->addFamily($person, $addfam); } elseif (!$this->pids) { $this->addFamily($this->getSignificantIndividual(), false); } } $WT_SESSION->timeline_pids = $this->pids; $this->beginYear = $beginYear; $this->endYear = $endYear; if ($beginYear == 0 || $endYear == 0) { //-- cleanup user input $this->pids = array_unique($this->pids); //removes duplicates foreach ($this->pids as $key => $value) { if ($value != $remove) { $this->pids[$key] = $value; $person = WT_Individual::getInstance($value); // list of linked records includes families as well as individuals. if ($person) { $bdate = $person->getEstimatedBirthDate(); if ($bdate->isOK() && $person->canShow()) { $this->people[] = $person; } } } } } else { //--Finds if the begin year and end year textboxes are not empty //-- reset the people array when doing a year range search $this->people = array(); //Takes the begining year and end year passed by the postback and modifies them and uses them to populate //the time line //Variables to restrict the person boxes to the year searched. //--Searches for individuals who had an even between the year begin and end years $indis = self::search_indis_year_range($beginYear, $endYear); //--Populates an array of people that had an event within those years foreach ($indis as $person) { if (empty($searchplace) || in_array($person->getXref(), $this->pids)) { $bdate = $person->getEstimatedBirthDate(); if ($bdate->isOK() && $person->canShow()) { $this->people[] = $person; } } } $WT_SESSION->timeline_pids = null; } // Sort the array in order of birth year uasort($this->people, function (WT_Individual $a, WT_Individual $b) { return WT_Date::Compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); }); //If there is people in the array posted back this if occurs if (isset($this->people[0])) { //Find the maximum Death year and mimimum Birth year for each individual returned in the array. $bdate = $this->people[0]->getEstimatedBirthDate(); $ddate = $this->people[0]->getEstimatedDeathDate(); $this->timelineMinYear = $bdate->gregorianYear(); $this->timelineMaxYear = $ddate->gregorianYear() ? $ddate->gregorianYear() : date('Y'); foreach ($this->people as $value) { $bdate = $value->getEstimatedBirthDate(); $ddate = $value->getEstimatedDeathDate(); $this->timelineMinYear = min($this->timelineMinYear, $bdate->gregorianYear()); $this->timelineMaxYear = max($this->timelineMaxYear, $ddate->gregorianYear() ? $ddate->gregorianYear() : date('Y')); } if ($this->timelineMaxYear > $this->currentYear) { $this->timelineMaxYear = $this->currentYear; } } else { // Sets the default timeline length $this->timelineMinYear = date("Y") - 101; $this->timelineMaxYear = date("Y"); } }
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype; require_once WT_ROOT . 'includes/functions/functions_print_facts.php'; // Block actions $action = WT_Filter::get('action'); $message_id = WT_Filter::getArray('message_id'); if ($action == 'deletemessage') { foreach ($message_id as $msg_id) { deleteMessage($msg_id); } } $block = get_block_setting($block_id, 'block', true); if ($cfg) { foreach (array('block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } $messages = getUserMessages(WT_USER_ID); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $title = WT_I18N::plural('%s message', '%s messages', count($messages), WT_I18N::number(count($messages))); $content = '<form name="messageform" action="index.php?ctype=' . $ctype . '" method="get" onsubmit="return confirm(\'' . WT_I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\');">'; if (count(User::all()) > 1) { $content .= '<br>' . WT_I18N::translate('Send message') . " <select name=\"touser\">"; $content .= '<option value="">' . WT_I18N::translate('<select>') . '</option>'; foreach (User::all() as $user) { if ($user->getUserId() != WT_USER_ID && $user->getSetting('verified_by_admin') && $user->getSetting('contactmethod') != 'none') { $content .= '<option value="' . WT_Filter::escapeHtml($user->getUserName()) . '">'; $content .= '<span dir="auto">' . WT_Filter::escapeHtml($user->getRealName()) . '</span> - <span dir="auto">' . WT_Filter::escapeHtml($user->getUserName()) . '</span>'; $content .= '</option>'; } } $content .= '</select> <input type="button" value="' . WT_I18N::translate('Send') . '" onclick="message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, \'messaging2\', \'\'); return false;"><br><br>'; } if (count($messages) == 0) { $content .= WT_I18N::translate('You have no pending messages.') . "<br>"; } else { $content .= '<input type="hidden" name="action" value="deletemessage">'; $content .= '<table class="list_table"><tr>'; $content .= '<td class="list_label">' . WT_I18N::translate('Delete') . '<br><a href="#" onclick="jQuery(\'#' . $this->getName() . $block_id . ' :checkbox\').prop(\'checked\', true); return false;">' . WT_I18N::translate('All') . '</a></td>'; $content .= '<td class="list_label">' . WT_I18N::translate('Subject:') . '</td>'; $content .= '<td class="list_label">' . WT_I18N::translate('Date sent:') . '</td>'; $content .= '<td class="list_label">' . WT_I18N::translate('Email address:') . '</td>'; $content .= '</tr>'; foreach ($messages as $message) { $content .= '<tr>'; $content .= '<td class="list_value_wrap"><input type="checkbox" id="cb_message' . $message->message_id . '" name="message_id[]" value="' . $message->message_id . '"></td>'; $content .= '<td class="list_value_wrap"><a href="#" onclick="return expand_layer(\'message' . $message->message_id . '\');"><i id="message' . $message->message_id . '_img" class="icon-plus"></i> <b dir="auto">' . WT_Filter::escapeHtml($message->subject) . '</b></a></td>'; $content .= '<td class="list_value_wrap">' . format_timestamp($message->created) . '</td>'; $content .= '<td class="list_value_wrap">'; $user = User::findByIdentifier($message->sender); if ($user) { $content .= '<span dir="auto">' . $user->getRealName() . '</span>'; $content .= ' - <span dir="auto">' . $user->getEmail() . '</span>'; } else { $content .= '<a href="mailto:' . WT_Filter::escapeHtml($message->sender) . '">' . WT_Filter::escapeHtml($message->sender) . '</a>'; } $content .= '</td>'; $content .= '</tr>'; $content .= '<tr><td class="list_value_wrap" colspan="5"><div id="message' . $message->message_id . '" style="display:none;">'; $content .= '<div dir="auto" style="white-space: pre-wrap;">' . WT_Filter::expandUrls($message->body) . '</div><br>'; if (strpos($message->subject, WT_I18N::translate('RE: ')) !== 0) { $message->subject = WT_I18N::translate('RE: ') . $message->subject; } if ($user) { $content .= '<a href="#" onclick="reply(\'' . WT_Filter::escapeJs($message->sender) . '\', \'' . WT_Filter::escapeJs($message->subject) . '\'); return false;">' . WT_I18N::translate('Reply') . '</a> | '; } $content .= '<a href="index.php?action=deletemessage&message_id[]=' . $message->message_id . '" onclick="return confirm(\'' . WT_I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\');">' . WT_I18N::translate('Delete') . '</a></div></td></tr>'; } $content .= '</table>'; $content .= '<input type="submit" value="' . WT_I18N::translate('Delete selected messages') . '"><br>'; } $content .= '</form>'; 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; } }