/** * Find the oldest living individuals. * * @param string $type * @param string $sex * @param string[] $params * * @return string */ private function topTenOldestAliveQuery($type = 'list', $sex = 'BOTH', $params = array()) { if (!Auth::isMember($this->tree)) { return I18N::translate('This information is private and cannot be shown.'); } if ($sex == 'F') { $sex_search = " AND i_sex='F'"; } elseif ($sex == 'M') { $sex_search = " AND i_sex='M'"; } else { $sex_search = ''; } if (isset($params[0])) { $total = (int) $params[0]; } else { $total = 10; } $rows = $this->runSql("SELECT SQL_CACHE" . " birth.d_gid AS id," . " MIN(birth.d_julianday1) AS age" . " FROM" . " `##dates` AS birth," . " `##individuals` AS indi" . " WHERE" . " indi.i_id=birth.d_gid AND" . " indi.i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")' AND" . " birth.d_file={$this->tree->getTreeId()} AND" . " birth.d_fact='BIRT' AND" . " birth.d_file=indi.i_file AND" . " birth.d_julianday1<>0" . $sex_search . " GROUP BY id" . " ORDER BY age" . " ASC LIMIT " . $total); $top10 = array(); foreach ($rows as $row) { $person = Individual::getInstance($row['id'], $this->tree); $age = WT_CLIENT_JD - $row['age']; if ((int) ($age / 365.25) > 0) { $age = (int) ($age / 365.25) . 'y'; } elseif ((int) ($age / 30.4375) > 0) { $age = (int) ($age / 30.4375) . 'm'; } else { $age = $age . 'd'; } $age = FunctionsDate::getAgeAtEvent($age, true); if ($type === 'list') { $top10[] = "<li><a href=\"" . $person->getHtmlUrl() . "\">" . $person->getFullName() . "</a> (" . $age . ")" . "</li>"; } else { $top10[] = "<a href=\"" . $person->getHtmlUrl() . "\">" . $person->getFullName() . "</a> (" . $age . ")"; } } if ($type === 'list') { $top10 = implode('', $top10); } else { $top10 = implode('; ', $top10); } if (I18N::direction() === 'rtl') { $top10 = str_replace(array('[', ']', '(', ')', '+'), array('‏[', '‏]', '‏(', '‏)', '‏+'), $top10); } if ($type === 'list') { return '<ul>' . $top10 . '</ul>'; } return $top10; }
$NO_UPDATE_CHAN = $WT_TREE->getPreference('NO_UPDATE_CHAN'); $MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY'); $pid = Filter::get('pid', WT_REGEX_XREF, Filter::post('pid', WT_REGEX_XREF)); // edit this media object $linktoid = Filter::get('linktoid', WT_REGEX_XREF, Filter::post('linktoid', WT_REGEX_XREF)); // create a new media object, linked to this record $action = Filter::get('action', null, Filter::post('action')); $filename = Filter::get('filename', null, Filter::post('filename')); $text = Filter::postArray('text'); $tag = Filter::postArray('tag', WT_REGEX_TAG); $islink = Filter::postArray('islink'); $glevels = Filter::postArray('glevels', '[0-9]'); $folder = Filter::post('folder'); $update_CHAN = !Filter::postBool('preserve_last_changed'); $controller = new SimpleController(); $controller->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();')->restrictAccess(Auth::isMember($WT_TREE)); $disp = true; $media = Media::getInstance($pid, $WT_TREE); if ($media) { $disp = $media->canShow(); } if ($action == 'update' || $action == 'create') { if ($linktoid) { $disp = GedcomRecord::getInstance($linktoid, $WT_TREE)->canShow(); } } if (!Auth::isEditor($WT_TREE) || !$disp) { $controller->pageHeader()->addInlineJavascript('closePopupAndReloadParent();'); return; } // There is a lot of common code in the create and update cases…
/** * A form to choose the download options. * * @param ClippingsCartController $clip_ctrl * * @return string */ public function downloadForm(ClippingsCartController $clip_ctrl) { global $WT_TREE; $pid = Filter::get('pid', WT_REGEX_XREF); $out = '<script>'; $out .= 'function cancelDownload() { var link = "module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=clippings&pid=' . $pid . '"; jQuery("#sb_clippings_content").load(link); }'; $out .= '</script>'; $out .= '<form method="get" action="module.php"> <input type="hidden" name="mod" value="clippings"> <input type="hidden" name="mod_action" value="index"> <input type="hidden" name="pid" value="' . $pid . '"> <input type="hidden" name="action" value="download"> <table> <tr><td colspan="2" class="topbottombar"><h2>' . I18N::translate('Download') . '</h2></td></tr> <tr><td class="descriptionbox width50 wrap">' . I18N::translate('Zip file(s)') . '</td> <td class="optionbox"><input type="checkbox" name="Zip" value="yes" checked></td></tr> <tr><td class="descriptionbox width50 wrap">' . I18N::translate('Include media (automatically zips files)') . '</td> <td class="optionbox"><input type="checkbox" name="IncludeMedia" value="yes" checked></td></tr> '; if (Auth::isManager($WT_TREE)) { $out .= '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . '</td>' . '<td class="optionbox">' . '<input type="radio" name="privatize_export" value="none" checked> ' . I18N::translate('None') . '<br>' . '<input type="radio" name="privatize_export" value="gedadmin"> ' . I18N::translate('Manager') . '<br>' . '<input type="radio" name="privatize_export" value="user"> ' . I18N::translate('Member') . '<br>' . '<input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') . '</td></tr>'; } elseif (Auth::isMember($WT_TREE)) { $out .= '<tr><td class="descriptionbox width50 wrap">' . I18N::translate('Apply privacy settings') . '</td>' . '<td class="list_value">' . '<input type="radio" name="privatize_export" value="user" checked> ' . I18N::translate('Member') . '<br>' . '<input type="radio" name="privatize_export" value="visitor"> ' . I18N::translate('Visitor') . '</td></tr>'; } $out .= ' <tr><td class="descriptionbox width50 wrap">' . I18N::translate('Convert from UTF-8 to ISO-8859-1') . '</td> <td class="optionbox"><input type="checkbox" name="convert" value="yes"></td></tr> <tr> <td class="descriptionbox width50 wrap">' . I18N::translate('Add the GEDCOM media path to filenames') . '</td> <td class="optionbox"> <input type="checkbox" name="conv_path" value="' . Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')) . '"> <span dir="auto">' . Filter::escapeHtml($WT_TREE->getPreference('GEDCOM_MEDIA_PATH')) . '</span></td> </tr> <input type="hidden" name="conv_path" value="' . $clip_ctrl->conv_path . '"> </td></tr> <tr><td class="topbottombar" colspan="2"> <input type="button" value="' . I18N::translate('Cancel') . '" onclick="cancelDownload();"> <input type="submit" value="' . I18N::translate('Download') . '"> </form>'; return $out; }
<!-- WEBMASTER_USER_ID --> <div class="form-group"> <label class="control-label col-sm-3" for="WEBMASTER_USER_ID"> <?php echo I18N::translate('Technical help contact'); ?> </label> <div class="col-sm-9"> <select id="WEBMASTER_USER_ID" name="WEBMASTER_USER_ID" class="form-control"> <option value=""></option> <?php foreach (User::all() as $user) { ?> <?php if (Auth::isMember($WT_TREE, $user)) { ?> <option value="<?php echo $user->getUserId(); ?> " <?php echo $WT_TREE->getPreference('WEBMASTER_USER_ID') === $user->getUserId() ? 'selected' : ''; ?> > <?php echo $user->getRealNameHtml() . ' - ' . Filter::escapeHtml($user->getUserName()); ?> </option> <?php } ?>
/** * Create the clippings controller */ public function __construct() { global $WT_TREE; // Our cart is an array of items in the session $this->cart = Session::get('cart', array()); if (!array_key_exists($WT_TREE->getTreeId(), $this->cart)) { $this->cart[$WT_TREE->getTreeId()] = array(); } $this->action = Filter::get('action'); $this->id = Filter::get('id'); $convert = Filter::get('convert', 'yes|no', 'no'); $this->Zip = Filter::get('Zip'); $this->IncludeMedia = Filter::get('IncludeMedia'); $this->conv_path = Filter::get('conv_path'); $this->privatize_export = Filter::get('privatize_export', 'none|visitor|user|gedadmin', 'visitor'); $this->level1 = Filter::getInteger('level1'); $this->level2 = Filter::getInteger('level2'); $this->level3 = Filter::getInteger('level3'); $others = Filter::get('others'); $this->type = Filter::get('type'); if (($this->privatize_export === 'none' || $this->privatize_export === 'none') && !Auth::isManager($WT_TREE)) { $this->privatize_export = 'visitor'; } if ($this->privatize_export === 'user' && !Auth::isMember($WT_TREE)) { $this->privatize_export = 'visitor'; } if ($this->action === 'add') { if (empty($this->type) && !empty($this->id)) { $obj = GedcomRecord::getInstance($this->id, $WT_TREE); if ($obj) { $this->type = $obj::RECORD_TYPE; } else { $this->type = ''; $this->id = ''; $this->action = ''; } } elseif (empty($this->id)) { $this->action = ''; } if (!empty($this->id) && $this->type !== 'FAM' && $this->type !== 'INDI' && $this->type !== 'SOUR') { $this->action = 'add1'; } } if ($this->action === 'add1') { $obj = GedcomRecord::getInstance($this->id, $WT_TREE); $this->addClipping($obj); if ($this->type === 'SOUR') { if ($others === 'linked') { foreach ($obj->linkedIndividuals('SOUR') as $indi) { $this->addClipping($indi); } foreach ($obj->linkedFamilies('SOUR') as $fam) { $this->addClipping($fam); } } } if ($this->type === 'FAM') { if ($others === 'parents') { $this->addClipping($obj->getHusband()); $this->addClipping($obj->getWife()); } elseif ($others === "members") { $this->addFamilyMembers(Family::getInstance($this->id, $WT_TREE)); } elseif ($others === "descendants") { $this->addFamilyDescendancy(Family::getInstance($this->id, $WT_TREE)); } } elseif ($this->type === 'INDI') { if ($others === 'parents') { foreach (Individual::getInstance($this->id, $WT_TREE)->getChildFamilies() as $family) { $this->addFamilyMembers($family); } } elseif ($others === 'ancestors') { $this->addAncestorsToCart(Individual::getInstance($this->id, $WT_TREE), $this->level1); } elseif ($others === 'ancestorsfamilies') { $this->addAncestorsToCartFamilies(Individual::getInstance($this->id, $WT_TREE), $this->level2); } elseif ($others === 'members') { foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) { $this->addFamilyMembers($family); } } elseif ($others === 'descendants') { foreach (Individual::getInstance($this->id, $WT_TREE)->getSpouseFamilies() as $family) { $this->addClipping($family); $this->addFamilyDescendancy($family, $this->level3); } } uksort($this->cart[$WT_TREE->getTreeId()], array($this, 'compareClippings')); } } elseif ($this->action === 'remove') { unset($this->cart[$WT_TREE->getTreeId()][$this->id]); } elseif ($this->action === 'empty') { $this->cart[$WT_TREE->getTreeId()] = array(); } elseif ($this->action === 'download') { $media = array(); $mediacount = 0; $filetext = FunctionsExport::gedcomHeader($WT_TREE); // Include SUBM/SUBN records, if they exist $subn = Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBN', $WT_TREE->getTreeId()))->fetchOne(); if ($subn) { $filetext .= $subn . "\n"; } $subm = Database::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBM', $WT_TREE->getTreeId()))->fetchOne(); if ($subm) { $filetext .= $subm . "\n"; } if ($convert === "yes") { $filetext = str_replace("UTF-8", "ANSI", $filetext); $filetext = utf8_decode($filetext); } switch ($this->privatize_export) { case 'gedadmin': $access_level = Auth::PRIV_NONE; break; case 'user': $access_level = Auth::PRIV_USER; break; case 'visitor': $access_level = Auth::PRIV_PRIVATE; break; case 'none': $access_level = Auth::PRIV_HIDE; break; } foreach (array_keys($this->cart[$WT_TREE->getTreeId()]) as $xref) { $object = GedcomRecord::getInstance($xref, $WT_TREE); // The object may have been deleted since we added it to the cart.... if ($object) { $record = $object->privatizeGedcom($access_level); // Remove links to objects that aren't in the cart preg_match_all('/\\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { $record = str_replace($match[0], '', $record); } } preg_match_all('/\\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { $record = str_replace($match[0], '', $record); } } preg_match_all('/\\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if (!array_key_exists($match[1], $this->cart[$WT_TREE->getTreeId()])) { $record = str_replace($match[0], '', $record); } } $record = FunctionsExport::convertMediaPath($record, $this->conv_path); $savedRecord = $record; // Save this for the "does this file exist" check if ($convert === 'yes') { $record = utf8_decode($record); } switch ($object::RECORD_TYPE) { case 'INDI': $filetext .= $record . "\n"; $filetext .= "1 SOUR @WEBTREES@\n"; $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; break; case 'FAM': $filetext .= $record . "\n"; $filetext .= "1 SOUR @WEBTREES@\n"; $filetext .= "2 PAGE " . WT_BASE_URL . $object->getRawUrl() . "\n"; break; case 'SOUR': $filetext .= $record . "\n"; $filetext .= "1 NOTE " . WT_BASE_URL . $object->getRawUrl() . "\n"; break; default: // This autoloads the PclZip library, so we can use its constants. new PclZip(''); $ft = preg_match_all("/\n\\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER); $MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY'); for ($k = 0; $k < $ft; $k++) { // Skip external files and non-existant files if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) { $media[$mediacount] = array(\PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], \PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1]); $mediacount++; } } $filetext .= trim($record) . "\n"; break; } } } if ($this->IncludeMedia === "yes") { $this->media_list = $media; } else { $this->media_list = array(); } $filetext .= "0 @WEBTREES@ SOUR\n1 TITL " . WT_BASE_URL . "\n"; if ($user_id = $WT_TREE->getPreference('CONTACT_EMAIL')) { $user = User::find($user_id); $filetext .= "1 AUTH " . $user->getRealName() . "\n"; } $filetext .= "0 TRLR\n"; //-- make sure the preferred line endings are used $filetext = preg_replace("/[\r\n]+/", WT_EOL, $filetext); $this->download_data = $filetext; $this->downloadClipping(); } Session::put('cart', $this->cart); }
*/ namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Module\CkeditorModule; use PDO; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; define('WT_SCRIPT_NAME', 'editnews.php'); require './includes/session.php'; $controller = new SimpleController(); $controller->setPageTitle(I18N::translate('Add/edit a journal/news entry'))->restrictAccess(Auth::isMember($WT_TREE))->pageHeader(); $action = Filter::get('action', 'compose|save', 'compose'); $news_id = Filter::getInteger('news_id'); $user_id = Filter::get('user_id', WT_REGEX_INTEGER, Filter::post('user_id', WT_REGEX_INTEGER)); $gedcom_id = Filter::get('gedcom_id', WT_REGEX_INTEGER, Filter::post('gedcom_id', WT_REGEX_INTEGER)); $date = Filter::postInteger('date', 0, PHP_INT_MAX, WT_TIMESTAMP); $title = Filter::post('title'); $text = Filter::post('text'); switch ($action) { case 'compose': if (Module::getModuleByName('ckeditor')) { CkeditorModule::enableEditor($controller); } echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>'; echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">'; if ($news_id) {