/** {@inheritDoc} */ public function upgrade() { // add key 'LINK' to FTV_SETTINGS // change options to multidimensional array with array key = tree id. $module_settings = 'FTV_SETTINGS'; $ftv_settings = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_settings))->fetchOne(); $settings = unserialize($ftv_settings); if (!empty($settings)) { foreach ($settings as $setting) { if (!array_key_exists('LINK', $setting)) { $setting['LINK'] = I18N::translate('Descendants of the %s family', $setting['SURNAME']); $new_settings[] = $setting; } } if (isset($new_settings)) { Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_settings), $module_settings)); } unset($new_settings); } $module_options = 'FTV_OPTIONS'; $ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne(); $options = unserialize($ftv_options); if (!empty($options)) { $show_places = array_key_exists('SHOW_PLACES', $options) ? $options['SHOW_PLACES'] : '1'; $country = array_key_exists('COUNTRY', $options) ? $options['COUNTRY'] : ''; $show_occu = array_key_exists('SHOW_OCCU', $options) ? $options['SHOW_OCCU'] : '1'; foreach (Tree::getAll() as $tree) { $new_options[$tree->getTreeId()] = array('SHOW_PLACES' => $show_places, 'COUNTRY' => $country, 'SHOW_OCCU' => $show_occu); } if (isset($new_options)) { Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options)); } unset($new_options); } }
/** * A menu for the home (family tree) pages. * * @return Menu */ protected function menuHomePage() { if (count(Tree::getAll()) === 1 || Site::getPreference('ALLOW_CHANGE_GEDCOM') === '0') { return new Menu(I18N::translate('Family tree'), 'index.php?ctype=gedcom&' . $this->tree_url, 'menu-tree'); } else { $submenus = array(); foreach (Tree::getAll() as $tree) { if ($tree == $this->tree) { $active = 'active '; } else { $active = ''; } $submenus[] = new Menu($tree->getTitleHtml(), 'index.php?ctype=gedcom&ged=' . $tree->getNameUrl(), $active . 'menu-tree-' . $tree->getTreeId()); } return new Menu(I18N::translate('Family trees'), '#', 'menu-tree', array(), $submenus); } }
private function pageBody(PageController $controller) { $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); ?> <!-- ADMIN PAGE CONTENT --> <ol class="breadcrumb small"> <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?> </a></li> <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?> </a></li> <li class="active"><?php echo $controller->getPageTitle(); ?> </li> </ol> <h2><?php echo $controller->getPageTitle(); ?> </h2> <!-- *** FORM 1 *** --> <form class="form-horizontal" method="post" name="form1"> <?php echo Filter::getCsrf(); ?> <!-- SELECT TREE --> <div class="form-group"> <label class="control-label col-sm-2" for="tree"> <?php echo I18N::translate('Family tree'); ?> </label> <div class="col-sm-4"> <select id="tree" name="NEW_FIB_TREE" class="form-control"> <?php foreach (Tree::getAll() as $tree) { ?> <?php if ($tree->getTreeId() == $this->tree_id) { ?> <option value="<?php echo $tree->getTreeId(); ?> " data-ged="<?php echo $tree->getNameHtml(); ?> " selected="selected"> <?php echo $tree->getTitleHtml(); ?> </option> <?php } else { ?> <option value="<?php echo $tree->getTreeId(); ?> " data-ged="<?php echo $tree->getNameHtml(); ?> "> <?php echo $tree->getTitleHtml(); ?> </option> <?php } ?> <?php } ?> </select> </div> </div> </form> <!-- PANEL GROUP ACCORDION --> <div class="panel-group" id="accordion"> <!-- PANEL 1 --> <div class="panel panel-default" id="panel1"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-target="#collapseOne" href="#"> <?php echo I18N::translate('Pages'); ?> </a> </h4> </div> <div id="collapseOne" class="panel-collapse collapse in"> <div class="panel-body"> <?php if (empty($FTV_SETTINGS) || !empty($FTV_SETTINGS) && !$this->searchArray($FTV_SETTINGS, 'TREE', $this->tree_id)) { ?> <div class="alert alert-info alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="' . I18N::translate('close') . '"> <span aria-hidden="true">×</span> </button> <p class="small text-muted"> <?php echo I18N::translate('Use the search form below to search for a root person. After a successful search the Fancy Treeview page will be automatically created. You can add as many root persons as you want.'); ?> </p> </div> <?php } ?> <!-- *** FORM 2 *** --> <div id="ftv-search-form" class="form-group alert alert-info"> <form class="form-inline" method="post" name="form2"> <!-- SURNAME SEARCH FIELD --> <div class="form-group"> <label class="control-label"> <?php echo I18N::translate('Search root person'); ?> </label> <input class="form-control" data-autocomplete-type="SURN" id="surname-search" name="SURNAME" placeholder="<?php echo I18N::translate('Surname'); ?> " type="text" > <label class="checkbox-inline"> <?php echo FunctionsEdit::checkbox('soundex_std') . I18N::translate('Russell'); ?> </label> <label class="checkbox-inline"> <?php echo FunctionsEdit::checkbox('soudex_dm') . I18N::translate('Daitch-Mokotoff'); ?> </label> <button name="search" class="btn btn-primary" type="submit"> <i class="fa fa-search"></i> <?php echo I18N::translate('search'); ?> </button> </div> <!-- PID SEARCH FIELD --> <?php $class = I18N::direction() === 'rtl' ? 'pull-left' : 'pull-right'; ?> <div class="form-group <?php echo $class; ?> "> <label class="control-label" for="pid-search"> <?php echo I18N::translate('Or enter an ID'); ?> </label> <input class="form-control" data-autocomplete-type="INDI" id="pid-search" name="PID" placeholder="<?php echo I18N::translate('Search ID by name'); ?> " type="text" value="" > <button name="Ok" class="btn btn-primary" type="submit"> <i class="fa fa-check"></i> <?php echo I18N::translate('ok'); ?> </button> </div> </form> <!-- *** FORM 3 *** --> <form class="form-horizontal" method="post" name="form3"> <!-- TABLE --> <table id="search-result-table" class="table" style="display: none"> <thead> <tr> <th><?php echo I18N::translate('Root person'); ?> </th> <?php if (!$this->options('use_fullname')) { ?> <th><?php echo I18N::translate('Surname in page title'); ?> </th> <?php } ?> <th><?php echo I18N::translate('Page title'); ?> </th> <th><?php echo I18N::translate('Access level'); ?> </th> <th><?php echo I18N::translate('Add'); ?> </th> </tr> </thead> <tbody> <tr> <!-- ROOT PERSONS FULL NAME --> <td id="root"> <?php if ($this->options('use_fullname')) { ?> <input name="surname" type="hidden" value="" > <?php } ?> <input name="pid" type="hidden" value="" > <input name="sort" type="hidden" value="" > <span></span> </td> <?php if (!$this->options('use_fullname')) { ?> <!-- SURNAME IN PAGE TITLE --> <td id="surn"> <label class="showname"></label> <input class="form-control editname" name="surname" type="text" value="" > </td> <?php } ?> <!-- PAGE TITLE --> <td id="title"></td> <!-- ACCESS LEVEL --> <td> <?php echo FunctionsEdit::editFieldAccessLevel('access_level', 2, 'class="form-control"'); ?> </td> <!-- ADD BUTTON --> <td> <button type="submit" name="add" class="btn btn-success btn-sm" title="<?php I18N::translate('Add'); ?> "> <i class="fa fa-plus"></i> </button> </td> </tr> </tbody> </table> </form> </div> <?php echo $this->addMessage("error", "danger", true); ?> <?php echo $this->addMessage('update-settings', 'success', true, I18N::translate('The settings for this tree are succesfully updated')); ?> <div id="fancy-treeview-form" class="form-group"> <?php if (!empty($FTV_SETTINGS) && $this->searchArray($FTV_SETTINGS, 'TREE', $this->tree_id)) { ?> <form class="form-horizontal" method="post" name="form4"> <!-- TABLE --> <table id="fancy-treeview-table" class="table table-hover"> <thead> <tr> <th><?php echo I18N::translate('Root person'); ?> </th> <?php if (!$this->options('use_fullname')) { ?> <th><?php echo I18N::translate('Surname in page title'); ?> </th> <?php } ?> <th><?php echo I18N::translate('Page title'); ?> </th> <th><?php echo I18N::translate('Access level'); ?> </th> <th><?php echo I18N::translate('Delete'); ?> </th> </tr> </thead> <tbody> <?php foreach ($FTV_SETTINGS as $key => $this_ITEM) { ?> <?php if ($this_ITEM['TREE'] == $this->tree_id) { ?> <?php if (Individual::getInstance($this_ITEM['PID'], $this->tree)) { ?> <tr class="sortme"> <!-- ROOT PERSONS FULL NAME --> <td> <input name="pid[<?php echo $key; ?> ]" type="hidden" value="<?php echo $this_ITEM['PID']; ?> " > <input name="sort[<?php echo $key; ?> ]" type="hidden" value="<?php echo $this_ITEM['SORT']; ?> " > <?php echo Individual::getInstance($this_ITEM['PID'], $this->tree)->getFullName() . ''; ?> (<?php echo Individual::getInstance($this_ITEM['PID'], $this->tree)->getLifeSpan(); ?> ) </td> <?php if (!$this->options('use_fullname')) { ?> <!-- SURNAME IN PAGE TITLE --> <td> <label class="showname"> <?php echo $this_ITEM['SURNAME']; ?> </label> <input class="form-control editname" name="surname[<?php echo $key; ?> ]" type="text" value="<?php echo $this_ITEM['SURNAME']; ?> " > </td> <?php } ?> <!-- PAGE TITLE --> <td> <a href="module.php?mod=<?php echo $this->getName(); ?> &mod_action=page&ged=<?php echo $this->tree->getNameHtml(); ?> &rootid=<?php echo $this_ITEM['PID']; ?> " target="_blank"> <?php if ($this->options('use_fullname') == true) { echo I18N::translate('Descendants of %s', Individual::getInstance($this_ITEM['PID'], $this->tree)->getFullName()); } else { echo I18N::translate('Descendants of the %s family', $this_ITEM['SURNAME']); } ?> </a> </td> <!-- ACCESS LEVEL --> <td> <?php echo FunctionsEdit::editFieldAccessLevel('access_level[' . $key . ']', $this_ITEM['ACCESS_LEVEL'], 'class="form-control"'); ?> </td> <!-- DELETE BUTTON --> <td> <button type="button" name="delete" class="btn btn-danger btn-sm" data-key="<?php echo $key; ?> " title="<?php I18N::translate('Delete'); ?> "> <i class="fa fa-trash-o"></i> </button> </td> </tr> <?php } else { ?> <tr> <!-- SURNAME --> <td class="error"> <input name="pid[<?php echo $key; ?> ]" type="hidden" value="<?php echo $this_ITEM['PID']; ?> " > <?php echo $this_ITEM['SURNAME']; ?> </td> <!-- ERROR MESSAGE --> <td colspan="4" class="error"> <?php echo I18N::translate('The person with root id %s doesn’t exist anymore in this tree', $this_ITEM['PID']); ?> </td> <!-- DELETE BUTTON --> <td> <button name="delete" type="button" class="btn btn-danger btn-sm" title="<?php I18N::translate('Delete'); ?> "> <i class="fa fa-trash-o"></i> </button> </td> </tr> <?php } ?> <?php } ?> <?php } ?> </tbody> </table> <!-- BUTTONS --> <button name="update" class="btn btn-primary" type="submit"> <i class="fa fa-check"></i> <?php echo I18N::translate('update'); ?> </button> </form> <?php } ?> </div> </div> </div> </div> <!-- PANEL 2 --> <div class="panel panel-default" id="panel2"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-target="#collapseTwo" href="#" class="collapsed"> <?php echo I18N::translate('Options for %s', $this->tree->getTitleHtml()); ?> </a> </h4> </div> <div id="collapseTwo" class="panel-collapse collapse"> <div class="panel-body"> <?php echo $this->addMessage('save-options', 'success', true, I18N::translate('The options for this tree are succesfully saved')); ?> <?php echo $this->addMessage('reset-options', 'success', true, I18N::translate('The options for this tree are succesfully reset to the default settings')); ?> <div id="ftv-options-form" class="form-group"> <form class="form-horizontal" method="post" name="form5"> <!-- USE FULLNAME IN MENU --> <div class="form-group fullname"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Use fullname in menu'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[USE_FULLNAME]', $this->options('use_fullname'), 'class="radio-inline"'); ?> </div> </div> <!-- GENERATION BLOCKS --> <div class="form-group"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Number of generation blocks to show'); ?> </label> <div class="col-sm-4"> <?php echo FunctionsEdit::selectEditControl('NEW_FTV_OPTIONS[NUMBLOCKS]', array(I18N::translate('All'), '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'), null, $this->options('numblocks'), 'class="form-control"'); ?> </div> <p class="col-sm-8 col-sm-offset-4 small text-muted"> <?php echo I18N::translate('This option is especially usefull for large trees. When you notice a slow page load, here you can set the number of generation blocks to load at once to a lower level. Below the last generation block a button will appear to add the next set of generation blocks. The new blocks will be added to the blocks already loaded. Clicking on a “follow” link in the last visible generation block, will also load the next set of generation blocks.'); ?> </p> </div> <!-- SHOW SINGLES --> <div class="form-group"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Show single persons'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[SHOW_SINGLES]', $this->options('show_singles'), 'class="radio-inline"'); ?> </div> <p class="col-sm-8 col-sm-offset-4 small text-muted"> <?php echo I18N::translate('Turn this option on if you want to show single persons in the generation blocks. Single persons are persons without partner and children. With this option turned on, every child of a family will be shown in a detailed way in the next generation block.'); ?> </p> </div> <!-- CHECK RELATIONSHIP --> <div class="form-group"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Check relationship between partners'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[CHECK_RELATIONSHIP]', $this->options('check_relationship'), 'class="radio-inline"'); ?> </div> <p class="col-sm-8 col-sm-offset-4 small text-muted"> <?php echo I18N::translate('With this option turned on, the script checks if a (married) couple has the same ancestors. If a relationship between the partners is found, a text will appear between brackets after the spouses’ name to indicate the blood relationship.'); ?> </p> <p class="col-sm-8 col-sm-offset-4 small text-muted"> <?php echo I18N::translate('<strong>Note</strong>: this option can be time and/or memory consuming, especially on large trees. It can cause very slow page loading or an ’execution time out error’ on your server. If you notice such a behavior, reduce the number of generation blocks to load at once or don’t use it in combination with the option to show singles (see the previous options). If you still experience any problems, don’t use this option at all.'); ?> </p> </div> <!-- SHOW PLACES --> <div id="places" class="form-group"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Show places?'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[SHOW_PLACES]', $this->options('show_places'), 'class="radio-inline"'); ?> </div> </div> <!-- USE GEDCOM PLACE SETTING --> <div id="gedcom_places" class="form-group<?php if (!$this->options('show_places')) { echo ' collapse'; } ?> "> <label class="control-label col-sm-4"> <?php echo I18N::translate('Use default GEDCOM settings to abbreviate place names?'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[USE_GEDCOM_PLACES]', $this->options('use_gedcom_places'), 'class="radio-inline"'); ?> </div> <p class="col-sm-8 col-sm-offset-4 small text-muted"> <?php echo I18N::translate('If you have ticked the “Show places” option, you can choose to use the default GEDCOM settings to abbreviate placenames. If you don’t set this option, full place names will be shown.'); ?> </p> </div> <!-- GET COUNTRYLIST --> <?php if ($this->getCountrylist()) { ?> <div id="country_list" class="form-group<?php if (!$this->options('show_places') || $this->options('use_gedcom_places')) { echo ' collapse'; } ?> "> <label class="control-label col-sm-4"> <?php echo I18N::translate('Select your country'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::selectEditControl('NEW_FTV_OPTIONS[COUNTRY]', $this->getCountryList(), '', $this->options('country'), 'class="form-control"'); ?> </div> <p class="col-sm-8 col-sm-offset-4 small text-muted"> <?php echo I18N::translate('If you have ticked the “Show places” option but NOT the option to abbreviate placenames, you can set your own country here. Full places will be listed on the Fancy Treeview pages, but when a place includes the name of your own country, this name will be left out. If you don’t select a country then all countries will be shown, including your own.'); ?> </p> </div> <?php } ?> <!-- SHOW OCCUPATIONS --> <div class="form-group"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Show occupations'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[SHOW_OCCU]', $this->options('show_occu'), 'class="radio-inline"'); ?> </div> </div> <!-- RESIZE THUMBS --> <div id="resize_thumbs" class="form-group"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Resize thumbnails'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[RESIZE_THUMBS]', $this->options('resize_thumbs'), 'class="radio-inline"'); ?> </div> <p class="col-sm-8 col-sm-offset-4 small text-muted"> <?php echo I18N::translate('Here you can choose to resize the default webtrees thumbnails especially for the Fancy Treeview pages. You can set a custom size in percentage or in pixels. If you choose “no” the default webtrees thumbnails will be used with the formats you have set on the tree configuration page.'); ?> </p> </div> <!-- THUMB SIZE --> <div id="thumb_size" class="form-group<?php if (!$this->options('resize_thumbs')) { echo ' collapse'; } ?> "> <label class="control-label col-sm-4"> <?php echo I18N::translate('Thumbnail size'); ?> </label> <div class="row"> <div class="col-sm-1"> <input class="form-control" id="NEW_FTV_OPTIONS[THUMB_SIZE]" name="NEW_FTV_OPTIONS[THUMB_SIZE]" type="text" value="<?php echo $this->options('thumb_size'); ?> " > </div> <div class="col-sm-2"> <?php echo FunctionsEdit::selectEditControl('NEW_FTV_OPTIONS[THUMB_RESIZE_FORMAT]', array('1' => I18N::translate('percent'), '2' => I18N::translate('pixels')), null, $this->options('thumb_resize_format'), 'class="form-control"'); ?> </div> </div> </div> <!-- SQUARE THUMBS --> <div id="square_thumbs" class="form-group<?php if (!$this->options('resize_thumbs')) { echo ' collapse'; } ?> "> <label class="control-label col-sm-4"> <?php echo I18N::translate('Use square thumbnails'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[USE_SQUARE_THUMBS]', $this->options('use_square_thumbs'), 'class="radio-inline"'); ?> </div> </div> <!-- SHOW USERFORM --> <div class="form-group"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Show form to change start person'); ?> </label> <div class="col-sm-4"> <?php echo FunctionsEdit::editFieldAccessLevel('NEW_FTV_OPTIONS[SHOW_USERFORM]', $this->options('show_userform'), 'class="form-control"'); ?> </div> </div> <!-- SHOW PDF --> <div class="form-group"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Show PDF icon?'); ?> </label> <div class="col-sm-4"> <?php echo FunctionsEdit::editFieldAccessLevel('NEW_FTV_OPTIONS[SHOW_PDF_ICON]', $this->options('show_pdf_icon'), 'class="form-control"'); ?> </div> </div> <!-- SHOW FANCY TREEVIEW ON INDI PAGE --> <div class="form-group fullname"> <label class="control-label col-sm-4"> <?php echo I18N::translate('Show a Fancy Treeview tab on the individual page'); ?> </label> <div class="col-sm-8"> <?php echo FunctionsEdit::editFieldYesNo('NEW_FTV_OPTIONS[FTV_TAB]', $this->options('ftv_tab'), 'class="radio-inline"'); ?> </div> </div> <!-- BUTTONS --> <button name="save-options" class="btn btn-primary" type="submit"> <i class="fa fa-check"></i> <?php echo I18N::translate('save'); ?> </button> <button name="reset-options" class="btn btn-primary" type="reset"> <i class="fa fa-recycle"></i> <?php echo I18N::translate('reset'); ?> </button> </form> </div> </div> </div> </div> </div> <?php }
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; $sendmail = $this->getBlockSetting($block_id, 'sendmail', '1'); $days = $this->getBlockSetting($block_id, 'days', '1'); $block = $this->getBlockSetting($block_id, 'block', '1'); foreach (array('days', 'sendmail', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } $changes = Database::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne(); if ($changes === '1' && $sendmail === '1') { // There are pending changes - tell moderators/managers/administrators about them. if (WT_TIMESTAMP - Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) { // Which users have pending changes? foreach (User::all() as $user) { if ($user->getPreference('contactmethod') !== 'none') { foreach (Tree::getAll() as $tree) { if ($tree->hasPendingEdit() && Auth::isManager($tree, $user)) { I18N::init($user->getPreference('language')); Mail::systemMessage($tree, $user, I18N::translate('Pending changes'), I18N::translate('There are pending changes for you to moderate.') . Mail::EOL . Mail::EOL . '<a href="' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '</a>'); I18N::init(WT_LOCALE); } } } } Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP); } } if (Auth::isEditor($WT_TREE) && $WT_TREE->hasPendingEdit()) { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype === 'user' || Auth::isManager($WT_TREE)) { $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; } else { $title = ''; } $title .= $this->getTitle(); $content = ''; if (Auth::isModerator($WT_TREE)) { $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . I18N::translate('There are pending changes for you to moderate.') . "</a><br>"; } if ($sendmail === '1') { $content .= I18N::translate('Last email reminder was sent ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>"; $content .= I18N::translate('Next email reminder will be sent after ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>"; } $content .= '<ul>'; $changes = Database::prepare("SELECT xref" . " FROM `##change`" . " WHERE status='pending'" . " AND gedcom_id=?" . " GROUP BY xref")->execute(array($WT_TREE->getTreeId()))->fetchAll(); foreach ($changes as $change) { $record = GedcomRecord::getInstance($change->xref, $WT_TREE); if ($record->canShow()) { $content .= '<li><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></li>'; } } $content .= '</ul>'; if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } } }
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { global $WT_TREE; if (Filter::postBool('save') && Filter::checkCsrf()) { $languages = Filter::postArray('lang'); $this->setBlockSetting($block_id, 'gedcom', Filter::post('gedcom')); $this->setBlockSetting($block_id, 'title', Filter::post('title')); $this->setBlockSetting($block_id, 'html', Filter::post('html')); $this->setBlockSetting($block_id, 'show_timestamp', Filter::postBool('show_timestamp')); $this->setBlockSetting($block_id, 'timestamp', Filter::post('timestamp')); $this->setBlockSetting($block_id, 'languages', implode(',', $languages)); } $templates = array(I18N::translate('Keyword examples') => '#getAllTagsTable#', I18N::translate('Narrative description') => I18N::translate('This family tree was last updated on #gedcomUpdated#. There are #totalSurnames# surnames in this family tree. The earliest recorded event is the #firstEventType# of #firstEventName# in #firstEventYear#. The most recent event is the #lastEventType# of #lastEventName# in #lastEventYear#.<br><br>If you have any comments or feedback please contact #contactWebmaster#.'), I18N::translate('Statistics') => '<div class="gedcom_stats"> <span style="font-weight: bold;"><a href="index.php?command=gedcom">#gedcomTitle#</a></span><br> ' . I18N::translate('This family tree was last updated on %s.', '#gedcomUpdated#') . ' <table id="keywords"> <tr> <td valign="top" class="width20"> <table cellspacing="1" cellpadding="0"> <tr> <td class="facts_label">' . I18N::translate('Individuals') . '</td> <td class="facts_value" align="right"><a href="indilist.php?surname_sublist=no">#totalIndividuals#</a></td> </tr> <tr> <td class="facts_label">' . I18N::translate('Males') . '</td> <td class="facts_value" align="right">#totalSexMales#<br>#totalSexMalesPercentage#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Females') . '</td> <td class="facts_value" align="right">#totalSexFemales#<br>#totalSexFemalesPercentage#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Total surnames') . '</td> <td class="facts_value" align="right"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . $WT_TREE->getNameUrl() . '">#totalSurnames#</a></td> </tr> <tr> <td class="facts_label">' . I18N::translate('Families') . '</td> <td class="facts_value" align="right"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalFamilies#</a></td> </tr> <tr> <td class="facts_label">' . I18N::translate('Sources') . '</td> <td class="facts_value" align="right"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalSources#</a></td> </tr> <tr> <td class="facts_label">' . I18N::translate('Media objects') . '</td> <td class="facts_value" align="right"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalMedia#</a></td> </tr> <tr> <td class="facts_label">' . I18N::translate('Repositories') . '</td> <td class="facts_value" align="right"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalRepositories#</a></td> </tr> <tr> <td class="facts_label">' . I18N::translate('Total events') . '</td> <td class="facts_value" align="right">#totalEvents#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Total users') . '</td> <td class="facts_value" align="right">#totalUsers#</td> </tr> </table> </td> <td><br></td> <td valign="top"> <table cellspacing="1" cellpadding="0" border="0"> <tr> <td class="facts_label">' . I18N::translate('Earliest birth year') . '</td> <td class="facts_value" align="right">#firstBirthYear#</td> <td class="facts_value">#firstBirth#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Latest birth year') . '</td> <td class="facts_value" align="right">#lastBirthYear#</td> <td class="facts_value">#lastBirth#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Earliest death year') . '</td> <td class="facts_value" align="right">#firstDeathYear#</td> <td class="facts_value">#firstDeath#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Latest death year') . '</td> <td class="facts_value" align="right">#lastDeathYear#</td> <td class="facts_value">#lastDeath#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Individual who lived the longest') . '</td> <td class="facts_value" align="right">#longestLifeAge#</td> <td class="facts_value">#longestLife#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Average age at death') . '</td> <td class="facts_value" align="right">#averageLifespan#</td> <td class="facts_value"></td> </tr> <tr> <td class="facts_label">' . I18N::translate('Family with the most children') . '</td> <td class="facts_value" align="right">#largestFamilySize#</td> <td class="facts_value">#largestFamily#</td> </tr> <tr> <td class="facts_label">' . I18N::translate('Average number of children per family') . '</td> <td class="facts_value" align="right">#averageChildren#</td> <td class="facts_value"></td> </tr> </table> </td> </tr> </table><br> <span style="font-weight: bold;">' . I18N::translate('Most common surnames') . '</span><br> #commonSurnames# </div>'); $title = $this->getBlockSetting($block_id, 'title'); $html = $this->getBlockSetting($block_id, 'html'); $gedcom = $this->getBlockSetting($block_id, 'gedcom'); $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0'); $languages = explode(',', $this->getBlockSetting($block_id, 'languages')); echo '<tr><td class="descriptionbox wrap">', GedcomTag::getLabel('TITL'), '</td><td class="optionbox"><input type="text" name="title" size="30" value="', Filter::escapeHtml($title), '"></td></tr>'; // templates echo '<tr><td class="descriptionbox wrap">', I18N::translate('Templates'), '</td><td class="optionbox wrap">'; // The CK editor needs lots of help to load/save data :-( if (Module::getModuleByName('ckeditor')) { $ckeditor_onchange = 'CKEDITOR.instances.html.setData(document.block.html.value);'; } else { $ckeditor_onchange = ''; } echo '<select name="template" onchange="document.block.html.value=document.block.template.options[document.block.template.selectedIndex].value;', $ckeditor_onchange, '">'; echo '<option value="', Filter::escapeHtml($html), '">', I18N::translate('Custom'), '</option>'; foreach ($templates as $title => $template) { echo '<option value="', Filter::escapeHtml($template), '">', $title, '</option>'; } echo '</select>'; if (!$html) { echo '<p>', I18N::translate('To assist you in getting started with this block, we have created several standard templates. When you select one of these templates, the text area will contain a copy that you can then alter to suit your site’s requirements.'), '</p>'; } echo '</td></tr>'; if (count(Tree::getAll()) > 1) { if ($gedcom == '__current__') { $sel_current = 'selected'; } else { $sel_current = ''; } if ($gedcom == '__default__') { $sel_default = 'selected'; } else { $sel_default = ''; } echo '<tr><td class="descriptionbox wrap">', I18N::translate('Family tree'), '</td><td class="optionbox">', '<select name="gedcom">', '<option value="__current__" ', $sel_current, '>', I18N::translate('Current'), '</option>', '<option value="__default__" ', $sel_default, '>', I18N::translate('Default'), '</option>'; foreach (Tree::getAll() as $tree) { if ($tree->getName() === $gedcom) { $sel = 'selected'; } else { $sel = ''; } echo '<option value="', $tree->getNameHtml(), '" ', $sel, '>', $tree->getTitleHtml(), '</option>'; } echo '</select>'; echo '</td></tr>'; } // html echo '<tr><td colspan="2" class="descriptionbox">', I18N::translate('Content'); if (!$html) { echo '<p>', I18N::translate('As well as using the toolbar to apply HTML formatting, you can insert database fields which are updated automatically. These special fields are marked with <b>#</b> characters. For example <b>#totalFamilies#</b> will be replaced with the actual number of families in the database. Advanced users may wish to apply CSS classes to their text, so that the formatting matches the currently selected theme.'), '</p>'; } echo '</td></tr><tr>', '<td colspan="2" class="optionbox">'; echo '<textarea name="html" class="html-edit" rows="10" style="width:98%;">', Filter::escapeHtml($html), '</textarea>'; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap">'; echo I18N::translate('Show the date and time of update'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('show_timestamp', $show_timestamp); echo '<input type="hidden" name="timestamp" value="', WT_TIMESTAMP, '">'; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap">'; echo I18N::translate('Show this block for which languages?'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editLanguageCheckboxes('lang', $languages); echo '</td></tr>'; }
/** * {@inheritDoc} * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface::saveConfig() */ public function saveConfig() { try { foreach (Tree::getAll() as $tree) { if (Auth::isManager($tree)) { $tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), 0, 1); $tree->setPreference('MAJ_AT_' . $this->getName() . '_ENABLED', $tree_enabled); } } return true; } catch (\Exception $ex) { Log::addErrorLog(sprintf('Error while updating the Admin Task "%s". Exception: %s', $this->getName(), $ex->getMessage())); return false; } }
/** * Save updated configuration settings. */ private function saveConfig() { if (Auth::isAdmin()) { foreach (Tree::getAll() as $tree) { $tree->setPreference('RELATIONSHIP_RECURSION', Filter::post('relationship-recursion-' . $tree->getTreeId())); $tree->setPreference('RELATIONSHIP_ANCESTORS', Filter::post('relationship-ancestors-' . $tree->getTreeId())); } FlashMessages::addMessage(I18N::translate('The preferences for the chart “%s” have been updated.', $this->getTitle()), 'success'); } header('Location: ' . WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&mod_action=admin'); }
<?php echo I18N::translate('Where a user is associated to an individual record in a family tree and has a role of member, editor, or moderator, you can prevent them from accessing the details of distant, living relations. You specify the number of relationship steps that the user is allowed to see.'); ?> <?php echo I18N::translate('For example, if you specify a path length of 2, the individual will be able to see their grandson (child, child), their aunt (parent, sibling), their step-daughter (spouse, child), but not their first cousin (parent, sibling, child).'); ?> <?php echo I18N::translate('Note: longer path lengths require a lot of calculation, which can make your website run slowly for these users.'); ?> </p> </td> </tr> </thead> <tbody> <?php foreach (Tree::getAll() as $tree) { ?> <tr> <td> <?php echo $tree->getTitleHtml(); ?> </td> <td> <select name="canedit<?php echo $tree->getTreeId(); ?> "> <?php foreach ($ALL_EDIT_OPTIONS as $EDIT_OPTION => $desc) { ?>
/** * Edit the configuration */ private function admin() { $controller = new PageController(); $controller->restrictAccess(Auth::isAdmin())->setPageTitle($this->getTitle())->pageHeader(); // Save the updated preferences if (Filter::post('action') == 'save') { foreach (Tree::getAll() as $tree) { $tree->setPreference('include_in_sitemap', Filter::postBool('include' . $tree->getTreeId())); } // Clear cache and force files to be regenerated Database::prepare("DELETE FROM `##module_setting` WHERE setting_name LIKE 'sitemap%'")->execute(); } $include_any = false; ?> <ol class="breadcrumb small"> <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?> </a></li> <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?> </a></li> <li class="active"><?php echo $controller->getPageTitle(); ?> </li> </ol> <h1><?php echo $controller->getPageTitle(); ?> </h1> <?php echo '<p>', I18N::translate('Sitemaps are a way for webmasters to tell search engines about the pages on a website that are available for crawling. All major search engines support sitemaps. For more information, see <a href="http://www.sitemaps.org/">www.sitemaps.org</a>.') . '</p>', '<p>', I18N::translate('Which family trees should be included in the sitemaps'), '</p>', '<form method="post" action="module.php?mod=' . $this->getName() . '&mod_action=admin">', '<input type="hidden" name="action" value="save">'; foreach (Tree::getAll() as $tree) { echo '<div class="checkbox"><label><input type="checkbox" name="include', $tree->getTreeId(), '" '; if ($tree->getPreference('include_in_sitemap')) { echo 'checked'; $include_any = true; } echo '>', $tree->getTitleHtml(), '</label></div>'; } echo '<input type="submit" value="', I18N::translate('save'), '">', '</form>', '<hr>'; if ($include_any) { $site_map_url1 = WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&mod_action=generate&file=sitemap.xml'; $site_map_url2 = rawurlencode(WT_BASE_URL . 'module.php?mod=' . $this->getName() . '&mod_action=generate&file=sitemap.xml'); echo '<p>', I18N::translate('To tell search engines that sitemaps are available, you should add the following line to your robots.txt file.'), '</p>', '<pre>Sitemap: ', $site_map_url1, '</pre>', '<hr>', '<p>', I18N::translate('To tell search engines that sitemaps are available, you can use the following links.'), '</p>', '<ul>', '<li><a href="http://www.bing.com/webmaster/ping.aspx?siteMap=' . $site_map_url2 . '">Bing</a></li>', '<li><a href="http://www.google.com/webmasters/tools/ping?sitemap=' . $site_map_url2 . '">Google</a></li>', '</ul>'; } }
Auth::user()->setPreference('sessiontime', WT_TIMESTAMP); Session::put('locale', Auth::user()->getPreference('language')); Session::put('theme_id', Auth::user()->getPreference('theme')); // We're logging in as an administrator if (Auth::isAdmin()) { // Check for updates $latest_version_txt = Functions::fetchLatestVersion(); if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) { list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt); if (version_compare(WT_VERSION, $latest_version) < 0) { FlashMessages::addMessage(I18N::translate('A new version of webtrees is available.') . ' <a href="admin_site_upgrade.php"><b>' . I18N::translate('Upgrade to webtrees %s.', '<span dir="ltr">' . $latest_version . '</span>') . '</b></a>'); } } } else { // We're not an administrator, so we can only log in if there is a tree. if (empty(Tree::getAll())) { Auth::logout(); FlashMessages::addMessage(I18N::translate('This user account does not have access to any tree.')); } } // If we were on a "home page", redirect to "my page" if ($url === '' || strpos($url, 'index.php?ctype=gedcom') === 0) { $url = 'index.php?ctype=user'; // Switch to a tree where we have a genealogy record (or keep to the current/default). $tree = Database::prepare("SELECT gedcom_name FROM `##gedcom` JOIN `##user_gedcom_setting` USING (gedcom_id)" . " WHERE setting_name = 'gedcomid' AND user_id = :user_id")->execute(array('user_id' => Auth::user()->getUserId()))->fetchOne(); $url .= '&ged=' . Filter::escapeUrl($tree); } // Redirect to the target URL header('Location: ' . WT_BASE_URL . $url); return; } catch (\Exception $ex) {
Session::regenerate(false); Session::put('initiated', true); } else { // An existing session } // Set the tree for the page; (1) the request, (2) the session, (3) the site default, (4) any tree foreach (array(Filter::post('ged'), Filter::get('ged'), Session::get('GEDCOM'), Site::getPreference('DEFAULT_GEDCOM')) as $tree_name) { $WT_TREE = Tree::findByName($tree_name); if ($WT_TREE) { Session::put('GEDCOM', $tree_name); break; } } // No chosen tree? Use any one. if (!$WT_TREE) { foreach (Tree::getAll() as $WT_TREE) { break; } } // With no parameters, init() looks to the environment to choose a language define('WT_LOCALE', I18N::init()); Session::put('locale', WT_LOCALE); // Note that the database/webservers may not be synchronised, so use DB time throughout. define('WT_TIMESTAMP', (int) Database::prepare("SELECT UNIX_TIMESTAMP()")->fetchOne()); // Users get their own time-zone. Visitors get the site time-zone. if (Auth::check()) { date_default_timezone_set(Auth::user()->getPreference('TIMEZONE', 'UTC')); } else { date_default_timezone_set(Site::getPreference('TIMEZONE') ?: 'UTC'); } define('WT_TIMESTAMP_OFFSET', date_offset_get(new \DateTime('now')));
<?php echo I18N::translate('After creating the family tree, you will be able to import data from a GEDCOM file.'); ?> </p> </div> </div> </form> </div> </div> </div> <?php } ?> <!-- display link to PhpGedView-WT transfer wizard on first visit to this page, before any GEDCOM is loaded --> <?php if (count(Tree::getAll()) === 0 && count(User::all()) === 1) { ?> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> <i class="fa fa-fw fa-magic"></i> <a data-toggle="collapse" data-parent="#accordion" href="#pgv-import-wizard"> <?php echo I18N::translate('PhpGedView to webtrees transfer wizard'); ?> </a> </h2> </div> <div id="pgv-import-wizard" class="panel-collapse collapse"> <div class="panel-body"> <p>
/** {@inheritdoc} */ public function modAction($mod_action) { Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); switch ($mod_action) { case 'admin_config': $template = new AdminTemplate(); return $template->pageContent(); case 'admin_search': // new settings $surname = Filter::post('SURNAME'); $pid = Filter::post('PID'); if ($surname) { $soundex_std = Filter::postBool('soundex_std'); $soundex_dm = Filter::postBool('soundex_dm'); $indis = $this->module()->indisArray($surname, $soundex_std, $soundex_dm); usort($indis, 'Fisharebest\\Webtrees\\Individual::compareBirthDate'); if (isset($indis) && count($indis) > 0) { $pid = $indis[0]->getXref(); } else { $result['error'] = I18N::translate('Error: The surname you entered doesn’t exist in this tree.'); } } if (isset($pid)) { $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); if ($this->module()->searchArray($this->module()->searchArray($FTV_SETTINGS, 'TREE', Filter::getInteger('tree')), 'PID', $pid)) { if ($surname) { $result['error'] = I18N::translate('Error: The root person belonging to this surname already exists'); } else { $result['error'] = I18N::translate('Error: A root person with ID %s already exists', $pid); } } else { $record = Individual::getInstance($pid, $this->tree()); if ($record) { $root = $record->getFullName() . ' (' . $record->getLifeSpan() . ')'; $title = $this->module()->getPageLink($pid); $result = array('access_level' => '2', 'pid' => $pid, 'root' => $root, 'sort' => count($this->module()->searchArray($FTV_SETTINGS, 'TREE', Filter::getInteger('tree'))) + 1, 'surname' => $this->module()->getSurname($pid), 'title' => $title, 'tree' => Filter::getInteger('tree')); } else { if (empty($result['error'])) { $result['error'] = I18N::translate('Error: A person with ID %s does not exist in this tree', $pid); } } } } echo json_encode($result); break; case 'admin_add': $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); $NEW_FTV_SETTINGS = $FTV_SETTINGS; $NEW_FTV_SETTINGS[] = array('TREE' => Filter::getInteger('tree'), 'SURNAME' => Filter::post('surname'), 'PID' => Filter::post('pid'), 'ACCESS_LEVEL' => Filter::postInteger('access_level'), 'SORT' => Filter::postInteger('sort')); $this->setSetting('FTV_SETTINGS', serialize(array_values($NEW_FTV_SETTINGS))); Log::addConfigurationLog($this->getTitle() . ' config updated'); break; case 'admin_update': $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); $new_surname = Filter::postArray('surname'); $new_access_level = Filter::postArray('access_level'); $new_sort = Filter::postArray('sort'); foreach ($new_surname as $key => $new_surname) { $FTV_SETTINGS[$key]['SURNAME'] = $new_surname; } foreach ($new_access_level as $key => $new_access_level) { $FTV_SETTINGS[$key]['ACCESS_LEVEL'] = $new_access_level; } foreach ($new_sort as $key => $new_sort) { $FTV_SETTINGS[$key]['SORT'] = $new_sort; } $NEW_FTV_SETTINGS = $this->module()->sortArray($FTV_SETTINGS, 'SORT'); $this->setSetting('FTV_SETTINGS', serialize($NEW_FTV_SETTINGS)); break; case 'admin_save': $FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS')); $FTV_OPTIONS[Filter::getInteger('tree')] = Filter::postArray('NEW_FTV_OPTIONS'); $this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS)); Log::addConfigurationLog($this->getTitle() . ' config updated'); // the cache has to be recreated because the image options could have been changed $this->module()->emptyCache(); break; case 'admin_copy': $FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS')); foreach (Tree::getAll() as $tree) { $FTV_OPTIONS[$tree->getTreeId()] = Filter::postArray('NEW_FTV_OPTIONS'); } $this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS)); Log::addConfigurationLog($this->getTitle() . ' config saved and copied to all trees'); // the cache has to be recreated because the image options could have been changed $this->module()->emptyCache(); break; case 'admin_reset': $FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS')); unset($FTV_OPTIONS[Filter::getInteger('tree')]); $this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS)); Log::addConfigurationLog($this->getTitle() . ' options set to default'); break; case 'admin_delete': $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); unset($FTV_SETTINGS[Filter::getInteger('key')]); $this->setSetting('FTV_SETTINGS', serialize($FTV_SETTINGS)); Log::addConfigurationLog($this->getTitle() . ' item deleted'); break; case 'page': $template = new PageTemplate(); return $template->pageContent(); // See mediafirewall.php // See mediafirewall.php case 'thumbnail': $mid = Filter::get('mid', WT_REGEX_XREF); $media = Media::getInstance($mid, $this->tree()); $mimetype = $media->mimeType(); $cache_filename = $this->module()->cacheFileName($media); $filetime = filemtime($cache_filename); $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; $expireOffset = 3600 * 24 * 7; // tell browser to cache this image for 7 days $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $expireOffset) . ' GMT'; $etag = $media->getEtag(); $filesize = filesize($cache_filename); // parse IF_MODIFIED_SINCE header from client $if_modified_since = 'x'; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); } // parse IF_NONE_MATCH header from client $if_none_match = 'x'; if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { $if_none_match = str_replace('"', '', $_SERVER['HTTP_IF_NONE_MATCH']); } // add caching headers. allow browser to cache file, but not proxy header('Last-Modified: ' . $filetimeHeader); header('ETag: "' . $etag . '"'); header('Expires: ' . $expireHeader); header('Cache-Control: max-age=' . $expireOffset . ', s-maxage=0, proxy-revalidate'); // if this file is already in the user’s cache, don’t resend it // first check if the if_modified_since param matches if ($if_modified_since === $filetimeHeader) { // then check if the etag matches if ($if_none_match === $etag) { http_response_code(304); return; } } // send headers for the image header('Content-Type: ' . $mimetype); header('Content-Disposition: filename="' . basename($cache_filename) . '"'); header('Content-Length: ' . $filesize); // Some servers disable fpassthru() and readfile() if (function_exists('readfile')) { readfile($cache_filename); } else { $fp = fopen($cache_filename, 'rb'); if (function_exists('fpassthru')) { fpassthru($fp); } else { while (!feof($fp)) { echo fread($fp, 65536); } } fclose($fp); } break; default: http_response_code(404); break; } }
/** * AdminConfig@index */ public function index() { global $WT_TREE; Theme::theme(new AdministrationTheme())->init($WT_TREE); $controller = new PageController(); $controller->restrictAccess(Auth::isManager($WT_TREE))->setPageTitle($this->module->getTitle()); $data = new ViewBag(); $data->set('title', $controller->getPageTitle()); $data->set('tree', $WT_TREE); $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); $table_id = 'table-geoanalysis-' . Uuid::uuid4(); $data->set('table_id', $table_id); $other_trees = array(); foreach (Tree::getAll() as $tree) { if ($tree->getTreeId() != $WT_TREE->getTreeId()) { $other_trees[] = $tree; } } $data->set('other_trees', $other_trees); $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addInlineJavascript(' //Datatable initialisation jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);}; jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; var geoAnalysisTable = jQuery("#' . $table_id . '") .on("draw.dt", function ( e, settings, json, xhr ) { jQuery("[data-toggle=\'tooltip\']").tooltip(); }).DataTable({ ' . I18N::datatablesI18N() . ', sorting: [[3, "asc"], [4, "asc"]], pageLength: 10, processing: true, serverSide : true, ajax : { url : "module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@jsonGeoAnalysisList&ged=' . $WT_TREE->getNameUrl() . '", type : "POST" }, columns: [ /* 0 Edit */ { sortable: false, className: "text-center"}, /* 1 ID */ { visible: false }, /* 2 Enabled */ { sortable: false, className: "text-center" }, /* 3 Description */ null, /* 4 Analysis Level */ { dataSort: 5, className: "text-center" }, /* 5 ANAL_LEVEL_SORT*/ { visible: false }, /* 6 Map */ { sortable: false, className: "text-center" }, /* 7 Map Top Level */ { sortable: false, className: "text-center" }, /* 8 Use Flags */ { sortable: false, className: "text-center" }, /* 9 Place Details */ { sortable: false, className: "text-center" } ], }); ')->addInlineJavascript(' function set_geoanalysis_status(ga_id, status, gedcom) { jQuery.ajax({ url: "module.php", type: "GET", data: { mod: "' . $this->module->getName() . '", mod_action: "GeoAnalysis@setStatus", ga_id: ga_id, ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom, status: status }, error: function(result, stat, error) { var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; alert("' . I18N::translate('An error occured while editing this analysis:') . '" + err); }, complete: function(result, stat) { geoAnalysisTable.ajax.reload(null, false); } }); } function delete_geoanalysis(ga_id, status, gedcom) { jQuery.ajax({ url: "module.php", type: "GET", data: { mod: "' . $this->module->getName() . '", mod_action: "GeoAnalysis@delete", ga_id: ga_id, ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom }, error: function(result, stat, error) { var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; alert("' . I18N::translate('An error occured while deleting this analysis:') . '" + err); }, complete: function(result, stat) { geoAnalysisTable.ajax.reload(null, false); } }); } '); ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); }
<?php } ?> <div class="form-group"> <div class="col-sm-offset-3 col-sm-9"> <button type="submit" class="btn btn-primary"> <i class="fa fa-check"></i> <?php echo I18N::translate('save'); ?> </button> <!-- Coming soon <div class="checkbox"> <?php if (count(Tree::getAll()) > 1) { ?> <label> <input type="checkbox" name="all_trees"> <?php echo I18N::translate('Apply these preferences to all family trees'); ?> </label> <?php } ?> </div> <div class="checkbox"> <label> <input type="checkbox" name="new_trees"> <?php
?> </td> </tr> <?php } ?> </tbody> <tfoot> <tr> <td> <?php echo I18N::translate('Total'); ?> - <?php echo I18N::plural('%s family tree', '%s family trees', count(Tree::getAll()), I18N::number(count(Tree::getAll()))); ?> </td> <td class="text-right flip"> <?php echo I18N::number(array_sum($changes)); ?> </td> <td class="text-right flip"> <?php echo I18N::number(array_sum($individuals)); ?> </td> <td class="text-right flip"> <?php echo I18N::number(array_sum($families));
<?php if (Auth::isAdmin()) { ?> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> <i class="fa fa-fw fa-plus"></i> <a data-toggle="collapse" data-parent="#accordion" href="#create-a-new-family-tree"> <?php echo I18N::translate('Create a new family tree'); ?> </a> </h2> </div> <div id="create-a-new-family-tree" class="panel-collapse collapse<?php echo Tree::getAll() ? '' : ' in'; ?> "> <div class="panel-body"> <form role="form" class="form-horizontal" method="post"> <?php echo Filter::getCsrf(); ?> <input type="hidden" name="action" value="new_tree"> <div class="form-group"> <label for="tree_title" class="col-sm-2 control-label"> <?php echo I18N::translate('Family tree title'); ?> </label> <div class="col-sm-10">
/** * Set default blocks menu. * * @return Menu|null */ protected function menuAdminTreesSetDefault() { if (Auth::isAdmin() && count(Tree::getAll()) > 1) { return new Menu(I18N::translate('Set the default blocks for new family trees'), 'index_edit.php?gedcom_id=-1'); } else { return null; } }
/** * Startup activity */ public function __construct() { global $WT_TREE; parent::__construct(); // $action comes from GET (search) or POST (replace) if (Filter::post('action')) { $this->action = Filter::post('action', 'replace', 'general'); $this->query = Filter::post('query'); $this->replace = Filter::post('replace'); $this->replaceNames = Filter::post('replaceNames', 'checked', ''); $this->replacePlaces = Filter::post('replacePlaces', 'checked', ''); $this->replacePlacesWord = Filter::post('replacePlacesWord', 'checked', ''); $this->replaceAll = Filter::post('replaceAll', 'checked', ''); } else { $this->action = Filter::get('action', 'advanced|general|soundex|replace|header', 'general'); $this->query = Filter::get('query'); $this->replace = Filter::get('replace'); $this->replaceNames = Filter::get('replaceNames', 'checked', ''); $this->replacePlaces = Filter::get('replacePlaces', 'checked', ''); $this->replacePlacesWord = Filter::get('replacePlacesWord', 'checked', ''); $this->replaceAll = Filter::get('replaceAll', 'checked', ''); } // Only editors can use search/replace if ($this->action === 'replace' && !Auth::isEditor($WT_TREE)) { $this->action = 'general'; } $this->srindi = Filter::get('srindi', 'checked', ''); $this->srfams = Filter::get('srfams', 'checked', ''); $this->srsour = Filter::get('srsour', 'checked', ''); $this->srnote = Filter::get('srnote', 'checked', ''); $this->soundex = Filter::get('soundex', 'DaitchM|Russell', 'DaitchM'); $this->showasso = Filter::get('showasso'); $this->firstname = Filter::get('firstname'); $this->lastname = Filter::get('lastname'); $this->place = Filter::get('place'); $this->year = Filter::get('year'); // If no record types specified, search individuals if (!$this->srfams && !$this->srsour && !$this->srnote) { $this->srindi = 'checked'; } // If no replace types specifiied, replace full records if (!$this->replaceNames && !$this->replacePlaces && !$this->replacePlacesWord) { $this->replaceAll = 'checked'; } // Trees to search if (Site::getPreference('ALLOW_CHANGE_GEDCOM')) { foreach (Tree::getAll() as $search_tree) { if (Filter::get('tree_' . $search_tree->getTreeId())) { $this->search_trees[] = $search_tree; } } if (!$this->search_trees) { $this->search_trees[] = $WT_TREE; } } else { $this->search_trees[] = $WT_TREE; } // If we want to show associated persons, build the list switch ($this->action) { case 'header': // We can type in an XREF into the header search, and jump straight to it. // Otherwise, the header search is the same as the general search if (preg_match('/' . WT_REGEX_XREF . '/', $this->query)) { $record = GedcomRecord::getInstance($this->query, $WT_TREE); if ($record && $record->canShowName()) { header('Location: ' . WT_BASE_URL . $record->getRawUrl()); exit; } } $this->action = 'general'; $this->srindi = 'checked'; $this->srfams = 'checked'; $this->srsour = 'checked'; $this->srnote = 'checked'; $this->setPageTitle(I18N::translate('General search')); $this->generalSearch(); break; case 'general': $this->setPageTitle(I18N::translate('General search')); $this->generalSearch(); break; case 'soundex': // Create a dummy search query to use as a title to the results list $this->query = trim($this->firstname . ' ' . $this->lastname . ' ' . $this->place); $this->setPageTitle(I18N::translate('Phonetic search')); $this->soundexSearch(); break; case 'replace': $this->setPageTitle(I18N::translate('Search and replace')); $this->search_trees = array($WT_TREE); $this->srindi = 'checked'; $this->srfams = 'checked'; $this->srsour = 'checked'; $this->srnote = 'checked'; if (Filter::post('query')) { $this->searchAndReplace($WT_TREE); header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=replace&query=' . Filter::escapeUrl($this->query) . '&replace=' . Filter::escapeUrl($this->replace) . '&replaceAll=' . $this->replaceAll . '&replaceNames=' . $this->replaceNames . '&replacePlaces=' . $this->replacePlaces . '&replacePlacesWord=' . $this->replacePlacesWord); exit; } } }
/** * A menu for the home (family tree) pages. * * @return Menu */ protected function menuHomePage() { $submenus = array(); $ALLOW_CHANGE_GEDCOM = Site::getPreference('ALLOW_CHANGE_GEDCOM') && count(Tree::getAll()) > 1; foreach (Tree::getAll() as $tree) { if ($tree == $this->tree || $ALLOW_CHANGE_GEDCOM) { $submenu = new Menu($tree->getTitleHtml(), 'index.php?ctype=gedcom&ged=' . $tree->getNameUrl(), 'menu-tree-' . $tree->getTreeId()); $submenus[] = $submenu; } } if (count($submenus) > 1) { $label = I18N::translate('Family trees'); } else { $label = I18N::translate('Family trees'); } return new Menu($label, 'index.php?ctype=gedcom&' . $this->tree_url, 'menu-tree', array(), $submenus); }