/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-sour'); if (Auth::isEditor($this->record->getTree())) { $fact = $this->record->getFirstFact('TITL'); if ($fact) { // Edit existing name $menu->addSubmenu(new Menu(I18N::translate('Edit the source'), '#', 'menu-sour-edit', array('onclick' => 'return edit_record("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");'))); } else { // Add new name $menu->addSubmenu(new Menu(I18N::translate('Edit the source'), '#', 'menu-sour-edit', array('onclick' => 'return add_fact("' . $this->record->getXref() . '", "TITL");'))); } // delete $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-sour-del', array('onclick' => "return delete_record('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');"))); } // edit raw if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-sour-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");'))); } return $menu; }
/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-note'); if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Edit note'), '#', 'menu-note-edit', array('onclick' => 'return edit_note("' . $this->record->getXref() . '");'))); } // delete if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-note-del', array('onclick' => 'return delete_note("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");'))); } // add to favorites if (Module::getModuleByName('user_favorites')) { $menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-note-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite",{xref:"' . $this->record->getXref() . '"},function(){location.reload();})'))); } // Get the link for the first submenu and set it as the link for the main menu if ($menu->getSubmenus()) { $submenus = $menu->getSubmenus(); $menu->setLink($submenus[0]->getLink()); $menu->setAttrs($submenus[0]->getAttrs()); } return $menu; }
/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-obje'); if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Edit the media object'), '#', 'menu-obje-edit', array('onclick' => 'window.open("addmedia.php?action=editmedia&pid=' . $this->record->getXref() . '", "_blank", edit_window_specs)'))); // main link displayed on page if (Module::getModuleByName('GEDFact_assistant')) { $menu->addSubmenu(new Menu(I18N::translate('Manage the links'), '#', 'menu-obje-link', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","manage");'))); } else { $menu->addSubmenu(new Menu(I18N::translate('Link this media object to an individual'), '#', 'menu-obje-link-indi', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","person");'))); $menu->addSubmenu(new Menu(I18N::translate('Link this media object to a family'), '#', 'menu-obje-link-fam', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","family");'))); $menu->addSubmenu(new Menu(I18N::translate('Link this media object to a source'), '#', 'menu-obje-link-sour', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","source");'))); } // delete $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-obje-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");'))); } // edit raw if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-obje-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");'))); } return $menu; }
/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-repo'); if (Auth::isEditor($this->record->getTree())) { $fact = $this->record->getFirstFact('NAME'); if ($fact) { // Edit existing name $menu->addSubmenu(new Menu(I18N::translate('Edit the repository'), '#', 'menu-repo-edit', array('onclick' => 'return edit_record("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");'))); } else { // Add new name $menu->addSubmenu(new Menu(I18N::translate('Edit the repository'), '#', 'menu-repo-edit', array('onclick' => 'return add_fact("' . $this->record->getXref() . '", "NAME");'))); } } // delete if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-repo-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");'))); } // edit raw if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-repo-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");'))); } // add to favorites if (Module::getModuleByName('user_favorites')) { $menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-repo-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite" ,{xref:"' . $this->record->getXref() . '"},function(){location.reload();})'))); } return $menu; }
/** * A menu, to be added to the main application menu. * * @return Menu|null */ public function getMenu() { global $controller, $WT_TREE; $menu = null; if (empty($controller)) { return null; } if (Auth::isEditor($WT_TREE) && method_exists($controller, 'getEditMenu')) { $menu = $controller->getEditMenu(); } return $menu; }
/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-note'); if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Edit the note'), '#', 'menu-note-edit', array('onclick' => 'return edit_note("' . $this->record->getXref() . '");'))); // delete $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-note-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");'))); } return $menu; }
/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-obje'); if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Edit media object'), '#', 'menu-obje-edit', array('onclick' => 'window.open("addmedia.php?action=editmedia&pid=' . $this->record->getXref() . '", "_blank", edit_window_specs)'))); // main link displayed on page if (Module::getModuleByName('GEDFact_assistant')) { $menu->addSubmenu(new Menu(I18N::translate('Manage links'), '#', 'menu-obje-link', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","manage");'))); } else { $menu->addSubmenu(new Menu(I18N::translate('Link this media object to an individual'), '#', 'menu-obje-link-indi', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","person");'))); $menu->addSubmenu(new Menu(I18N::translate('Link this media object to a family'), '#', 'menu-obje-link-fam', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","family");'))); $menu->addSubmenu(new Menu(I18N::translate('Link this media object to a source'), '#', 'menu-obje-link-sour', array('onclick' => 'return ilinkitem("' . $this->record->getXref() . '","source");'))); } } // delete if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-obje-del', array('onclick' => 'return delete_media("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");'))); } // edit raw if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $menu->addSubmenu(new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-obje-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");'))); } // add to favorites if (Module::getModuleByName('user_favorites')) { $menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-obje-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite",{xref:"' . $this->record->getXref() . '"},function(){location.reload();})'))); } // Get the link for the first submenu and set it as the link for the main menu if ($menu->getSubmenus()) { $submenus = $menu->getSubmenus(); $menu->setLink($submenus[0]->getLink()); $menu->setAttrs($submenus[0]->getAttrs()); } return $menu; }
/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-sour'); if (Auth::isEditor($this->record->getTree())) { $fact = $this->record->getFirstFact('TITL'); if ($fact) { // Edit existing name $menu->addSubmenu(new Menu(I18N::translate('Edit source'), '#', 'menu-sour-edit', array('onclick' => 'return edit_record("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");'))); } else { // Add new name $menu->addSubmenu(new Menu(I18N::translate('Edit source'), '#', 'menu-sour-edit', array('onclick' => 'return add_fact("' . $this->record->getXref() . '", "TITL");'))); } } // delete if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-sour-del', array('onclick' => "return delete_record('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');"))); } // edit raw if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $menu->addSubmenu(new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-sour-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");'))); } // add to favorites if (Module::getModuleByName('user_favorites')) { $menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-sour-addfav', array('onlick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite",{xref:"' . $this->record->getXref() . '"},function(){location.reload();})'))); } // Get the link for the first submenu and set it as the link for the main menu if ($menu->getSubmenus()) { $submenus = $menu->getSubmenus(); $menu->setLink($submenus[0]->getLink()); $menu->setAttrs($submenus[0]->getAttrs()); } return $menu; }
/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-record'); // edit raw if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-record-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");'))); } // delete if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-record-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");'))); } return $menu; }
/** * Print the associations from the associated individuals in $event to the individuals in $record * * @param Fact $event * * @return string */ private static function formatAssociateRelationship(Fact $event) { $parent = $event->getParent(); // To whom is this record an assocate? if ($parent instanceof Individual) { // On an individual page, we just show links to the person $associates = array($parent); } elseif ($parent instanceof Family) { // On a family page, we show links to both spouses $associates = $parent->getSpouses(); } else { // On other pages, it does not make sense to show associates return ''; } preg_match_all('/^1 ASSO @(' . WT_REGEX_XREF . ')@((\\n[2-9].*)*)/', $event->getGedcom(), $amatches1, PREG_SET_ORDER); preg_match_all('/\\n2 _?ASSO @(' . WT_REGEX_XREF . ')@((\\n[3-9].*)*)/', $event->getGedcom(), $amatches2, PREG_SET_ORDER); $html = ''; // For each ASSO record foreach (array_merge($amatches1, $amatches2) as $amatch) { $person = Individual::getInstance($amatch[1], $event->getParent()->getTree()); if ($person && $person->canShowName()) { // Is there a "RELA" tag if (preg_match('/\\n[23] RELA (.+)/', $amatch[2], $rmatch)) { // Use the supplied relationship as a label $label = GedcomCodeRela::getValue($rmatch[1], $person); } else { // Use a default label $label = GedcomTag::getLabel('ASSO', $person); } $values = array('<a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a>'); foreach ($associates as $associate) { $relationship_name = Functions::getAssociateRelationshipName($associate, $person); if (!$relationship_name) { $relationship_name = GedcomTag::getLabel('RELA'); } if ($parent instanceof Family) { // For family ASSO records (e.g. MARR), identify the spouse with a sex icon $relationship_name .= $associate->getSexImage(); } $values[] = '<a href="relationship.php?pid1=' . $associate->getXref() . '&pid2=' . $person->getXref() . '&ged=' . $associate->getTree()->getNameUrl() . '" rel="nofollow">' . $relationship_name . '</a>'; } $value = implode(' — ', $values); // Use same markup as GedcomTag::getLabelValue() $asso = I18N::translate('<span class="label">%1$s:</span> <span class="field" dir="auto">%2$s</span>', $label, $value); } elseif (!$person && Auth::isEditor($event->getParent()->getTree())) { $asso = GedcomTag::getLabelValue('ASSO', '<span class="error">' . $amatch[1] . '</span>'); } else { $asso = ''; } $html .= '<div class="fact_ASSO">' . $asso . '</div>'; } return $html; }
/** * Print the facts */ public function printFamilyFacts() { global $linkToID; $linkToID = $this->record->getXref(); // -- Tell addmedia.php what to link to $indifacts = $this->record->getFacts(); if ($indifacts) { Functions::sortFacts($indifacts); foreach ($indifacts as $fact) { FunctionsPrintFacts::printFact($fact, $this->record); } } else { echo '<tr><td class="messagebox" colspan="2">', I18N::translate('No facts exist for this family.'), '</td></tr>'; } if (Auth::isEditor($this->record->getTree())) { FunctionsPrint::printAddNewFact($this->record->getXref(), $indifacts, 'FAM'); echo '<tr><td class="descriptionbox">'; echo I18N::translate('Note'); echo '</td><td class="optionbox">'; echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','NOTE');\">", I18N::translate('Add a note'), '</a>'; echo '</td></tr>'; echo '<tr><td class="descriptionbox">'; echo I18N::translate('Shared note'); echo '</td><td class="optionbox">'; echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SHARED_NOTE');\">", I18N::translate('Add a shared note'), '</a>'; echo '</td></tr>'; if ($this->record->getTree()->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($this->record->getTree())) { echo '<tr><td class="descriptionbox">'; echo I18N::translate('Media object'); echo '</td><td class="optionbox">'; echo "<a href=\"#\" onclick=\"window.open('addmedia.php?action=showmediaform&linktoid=" . $this->record->getXref() . "', '_blank', edit_window_specs); return false;\">", I18N::translate('Add a media object'), '</a>'; echo FunctionsPrint::helpLink('OBJE'); echo '<br>'; echo "<a href=\"#\" onclick=\"window.open('inverselink.php?linktoid=" . $this->record->getXref() . "&linkto=family', '_blank', find_window_specs); return false;\">", I18N::translate('Link to an existing media object'), '</a>'; echo '</td></tr>'; } echo '<tr><td class="descriptionbox">'; echo I18N::translate('Source'); echo '</td><td class="optionbox">'; echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SOUR');\">", I18N::translate('Add a source citation'), '</a>'; echo '</td></tr>'; } }
$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… // …and also in the admin_media_upload.php script switch ($action) { case 'create': // Save the information from the “showcreateform” action $controller->setPageTitle(I18N::translate('Create a new media object')); // Validate the media folder $folderName = str_replace('\\', '/', $folder); $folderName = trim($folderName, '/'); if ($folderName == '.') { $folderName = ''; }
/** * Print a table of media objects * * @param Media[] $media_objects * * @return string */ public static function mediaTable($media_objects) { global $WT_TREE, $controller; $html = ''; $table_id = 'table-obje-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript(' 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("#' . $table_id . '").dataTable({ dom: \'<"H"pf<"dt-clear">irl>t<"F"pl>\', ' . I18N::datatablesI18N() . ', jQueryUI: true, autoWidth:false, processing: true, columns: [ /* 0 media */ { sortable: false }, /* 1 title */ { type: "unicode" }, /* 2 #indi */ { dataSort: 3, class: "center" }, /* 3 #INDI */ { type: "num", visible: false }, /* 4 #fam */ { dataSort: 5, class: "center" }, /* 5 #FAM */ { type: "num", visible: false }, /* 6 #sour */ { dataSort: 7, class: "center" }, /* 7 #SOUR */ { type: "num", visible: false }, /* 8 CHAN */ { dataSort: 9, visible: ' . ($WT_TREE->getPreference('SHOW_LAST_CHANGE') ? 'true' : 'false') . ' }, /* 9 CHAN_sort */ { visible: false }, ], displayLength: 20, pagingType: "full_numbers" }); jQuery(".media-list").css("visibility", "visible"); jQuery(".loading-image").css("display", "none"); '); //--table wrapper $html .= '<div class="loading-image"> </div>'; $html .= '<div class="media-list">'; //-- table header $html .= '<table id="' . $table_id . '"><thead><tr>'; $html .= '<th>' . I18N::translate('Media') . '</th>'; $html .= '<th>' . GedcomTag::getLabel('TITL') . '</th>'; $html .= '<th>' . I18N::translate('Individuals') . '</th>'; $html .= '<th>#INDI</th>'; $html .= '<th>' . I18N::translate('Families') . '</th>'; $html .= '<th>#FAM</th>'; $html .= '<th>' . I18N::translate('Sources') . '</th>'; $html .= '<th>#SOUR</th>'; $html .= '<th' . ($WT_TREE->getPreference('SHOW_LAST_CHANGE') ? '' : '') . '>' . GedcomTag::getLabel('CHAN') . '</th>'; $html .= '<th' . ($WT_TREE->getPreference('SHOW_LAST_CHANGE') ? '' : '') . '>CHAN</th>'; $html .= '</tr></thead>'; //-- table body $html .= '<tbody>'; foreach ($media_objects as $media_object) { if ($media_object->canShow()) { $name = $media_object->getFullName(); if ($media_object->isPendingAddtion()) { $class = ' class="new"'; } elseif ($media_object->isPendingDeletion()) { $class = ' class="old"'; } else { $class = ''; } $html .= '<tr' . $class . '>'; //-- Object thumbnail $html .= '<td>' . $media_object->displayImage() . '</td>'; //-- Object name(s) $html .= '<td>'; $html .= '<a href="' . $media_object->getHtmlUrl() . '" class="list_item name2">'; $html .= FunctionsPrint::highlightSearchHits($name) . '</a>'; if (Auth::isEditor($media_object->getTree())) { $html .= '<br><a href="' . $media_object->getHtmlUrl() . '">' . basename($media_object->getFilename()) . '</a>'; } $html .= '</td>'; //-- Linked INDIs $num = count($media_object->linkedIndividuals('OBJE')); $html .= '<td>' . I18N::number($num) . '</td><td>' . $num . '</td>'; //-- Linked FAMs $num = count($media_object->linkedfamilies('OBJE')); $html .= '<td>' . I18N::number($num) . '</td><td>' . $num . '</td>'; //-- Linked SOURces $num = count($media_object->linkedSources('OBJE')); $html .= '<td>' . I18N::number($num) . '</td><td>' . $num . '</td>'; //-- Last change if ($WT_TREE->getPreference('SHOW_LAST_CHANGE')) { $html .= '<td>' . $media_object->LastChangeTimestamp() . '</td>'; } else { $html .= '<td></td>'; } //-- Last change hidden sort column if ($WT_TREE->getPreference('SHOW_LAST_CHANGE')) { $html .= '<td>' . $media_object->LastChangeTimestamp(true) . '</td>'; } else { $html .= '<td></td>'; } $html .= '</tr>'; } } $html .= '</tbody></table></div>'; return $html; }
/** {@inheritdoc} */ public function hasTabContent() { global $WT_TREE; return Auth::isEditor($WT_TREE) || $this->getFactsWithNotes(); }
private function edit() { global $WT_TREE; if (webtrees\Filter::postBool('save') && webtrees\Filter::checkCsrf()) { $block_id = webtrees\Filter::post('block_id'); if ($block_id) { webtrees\Database::prepare("UPDATE `##block` SET gedcom_id=NULLIF(?, ''), block_order=? WHERE block_id=?")->execute(array(webtrees\Filter::post('gedcom_id'), (int) webtrees\Filter::post('block_order'), $block_id)); } else { webtrees\Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(?, ''), ?, ?)")->execute(array(webtrees\Filter::post('gedcom_id'), $this->getName(), (int) webtrees\Filter::post('block_order'))); $block_id = webtrees\Database::getInstance()->lastInsertId(); } $this->setBlockSetting($block_id, 'menu_title', webtrees\Filter::post('menu_title')); $this->setBlockSetting($block_id, 'menu_address', webtrees\Filter::post('menu_address')); $this->setBlockSetting($block_id, 'menu_access', webtrees\Filter::post('menu_access')); $languages = array(); foreach (webtrees\I18N::installedLocales() as $locale) { if (webtrees\Filter::postBool('lang_' . $locale->languageTag())) { $languages[] = $locale->languageTag(); } } $this->setBlockSetting($block_id, 'languages', implode(',', $languages)); $this->config(); } else { $block_id = webtrees\Filter::get('block_id'); $controller = new webtrees\Controller\PageController(); $controller->restrictAccess(webtrees\Auth::isEditor($WT_TREE)); if ($block_id) { $controller->setPageTitle(webtrees\I18N::translate('Edit menu')); $menu_title = $this->getBlockSetting($block_id, 'menu_title'); $menu_address = $this->getBlockSetting($block_id, 'menu_address'); $menu_access = $this->getBlockSetting($block_id, 'menu_access'); $block_order = webtrees\Database::prepare("SELECT block_order FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne(); $gedcom_id = webtrees\Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne(); } else { $controller->setPageTitle(webtrees\I18N::translate('Add menu')); $menu_access = 1; $menu_title = ''; $menu_address = ''; $block_order = webtrees\Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne(); $gedcom_id = $WT_TREE->getTreeId(); } $controller->pageHeader(); ?> <ol class="breadcrumb small"> <li><a href="admin.php"><?php echo webtrees\I18N::translate('Control panel'); ?> </a></li> <li><a href="admin_modules.php"><?php echo webtrees\I18N::translate('Module administration'); ?> </a></li> <li><a href="module.php?mod=<?php echo $this->getName(); ?> &mod_action=admin_config"><?php echo webtrees\I18N::translate($this->getTitle()); ?> </a></li> <li class="active"><?php echo $controller->getPageTitle(); ?> </li> </ol> <form class="form-horizontal" method="POST" action="#" name="menu" id="menuForm"> <?php echo webtrees\Filter::getCsrf(); ?> <input type="hidden" name="save" value="1"> <input type="hidden" name="block_id" value="<?php echo $block_id; ?> "> <h3><?php echo webtrees\I18N::translate('General'); ?> </h3> <div class="form-group"> <label class="control-label col-sm-3" for="menu_title"> <?php echo webtrees\I18N::translate('Title'); ?> </label> <div class="col-sm-9"> <input class="form-control" id="menu_title" size="90" name="menu_title" required type="text" value="<?php echo webtrees\Filter::escapeHtml($menu_title); ?> " > </div> <span class="help-block col-sm-9 col-sm-offset-3 small text-muted"> <?php echo webtrees\I18N::translate('Add your menu title here'); ?> </span> </div> <div class="form-group"> <label class="control-label col-sm-3" for="menu_address"> <?php echo webtrees\I18N::translate('Menu address'); ?> </label> <div class="col-sm-9"> <input class="form-control" id="menu_address" size="90" name="menu_address" required type="text" value="<?php echo webtrees\Filter::escapeHtml($menu_address); ?> " > </div> <span class="help-block col-sm-9 col-sm-offset-3 small text-muted"> <?php echo webtrees\I18N::translate('Add your menu address here'); ?> </span> </div> <h3><?php echo webtrees\I18N::translate('Languages'); ?> </h3> <div class="form-group"> <label class="control-label col-sm-3" for="lang_*"> <?php echo webtrees\I18N::translate('Show this menu for which languages?'); ?> </label> <div class="col-sm-9"> <?php $accepted_languages = explode(',', $this->getBlockSetting($block_id, 'languages')); foreach (webtrees\I18N::installedLocales() as $locale) { ?> <div class="checkbox"> <label title="<?php echo $locale->languageTag(); ?> "> <input type="checkbox" name="lang_<?php echo $locale->languageTag(); ?> " <?php echo in_array($locale->languageTag(), $accepted_languages) ? 'checked' : ''; ?> ><?php echo $locale->endonym(); ?> </label> </div> <?php } ?> </div> </div> <h3><?php echo webtrees\I18N::translate('Visibility and Access'); ?> </h3> <div class="form-group"> <label class="control-label col-sm-3" for="block_order"> <?php echo webtrees\I18N::translate('Menu position'); ?> </label> <div class="col-sm-9"> <input class="form-control" id="position" name="block_order" size="3" required type="number" value="<?php echo webtrees\Filter::escapeHtml($block_order); ?> " > </div> <span class="help-block col-sm-9 col-sm-offset-3 small text-muted"> <?php echo webtrees\I18N::translate('This field controls the order in which the menu items are displayed.'), '<br><br>', webtrees\I18N::translate('You do not have to enter the numbers sequentially. If you leave holes in the numbering scheme, you can insert other menu items later. For example, if you use the numbers 1, 6, 11, 16, you can later insert menu items with the missing sequence numbers. Negative numbers and zero are allowed, and can be used to insert menu items in front of the first one.'), '<br><br>', webtrees\I18N::translate('When more than one menu item has the same position number, only one of these menu items will be visible.'); ?> </span> </div> <div class="form-group"> <label class="control-label col-sm-3" for="block_order"> <?php echo webtrees\I18N::translate('Menu visibility'); ?> </label> <div class="col-sm-9"> <?php echo webtrees\Functions\FunctionsEdit::selectEditControl('gedcom_id', webtrees\Tree::getIdList(), webtrees\I18N::translate('All'), $WT_TREE->getTreeId(), 'class="form-control"'); ?> </div> <span class="help-block col-sm-9 col-sm-offset-3 small text-muted"> <?php echo webtrees\I18N::translate('You can determine whether this menu item will be visible regardless of family tree, or whether it will be visible only to the current family tree.'); ?> </span> </div> <div class="form-group"> <label class="control-label col-sm-3" for="menu_access"> <?php echo webtrees\I18N::translate('Access level'); ?> </label> <div class="col-sm-9"> <?php echo webtrees\Functions\FunctionsEdit::editFieldAccessLevel('menu_access', $menu_access, 'class="form-control"'); ?> </div> </div> <div class="row col-sm-9 col-sm-offset-3"> <button class="btn btn-primary" type="submit"> <i class="fa fa-check"></i> <?php echo webtrees\I18N::translate('save'); ?> </button> <button class="btn" type="button" onclick="window.location='<?php echo $this->getConfigLink(); ?> ';"> <i class="fa fa-close"></i> <?php echo webtrees\I18N::translate('cancel'); ?> </button> </div> </form> <?php } }
$fact_id = Filter::post('fact_id'); $record = GedcomRecord::getInstance($xref, $WT_TREE); if ($record && $record->canShow() && $record->canEdit()) { foreach ($record->getFacts() as $fact) { if ($fact->getFactId() == $fact_id && $fact->canShow() && $fact->canEdit()) { $record->deleteFact($fact_id, true); break 2; } } } // Can’t find the record/fact, or don’t have permission to delete it. http_response_code(406); break; case 'delete-record': $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) { // Delete links to this record foreach (FunctionsDb::fetchAllLinks($record->getXref(), $record->getTree()->getTreeId()) as $xref) { $linker = GedcomRecord::getInstance($xref, $WT_TREE); $old_gedcom = $linker->getGedcom(); $new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref()); // FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the // record itself) may have already been deleted. if ($old_gedcom !== $new_gedcom) { // If we have removed a link from a family to an individual, and it has only one member if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) { // Delete the family $family = GedcomRecord::getInstance($xref, $WT_TREE); FlashMessages::addMessage(I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName())); $family->deleteRecord(); // Delete any remaining link to this family
/** * Create the search menu * * @return Menu */ protected function menuSearch() { //-- main search menu item $menu = new Menu(I18N::translate('Search'), '#', 'menu-search', array('rel' => 'nofollow')); //-- search_general sub menu $menu->addSubmenu(new Menu(I18N::translate('General search'), 'search.php?' . $this->tree_url, 'menu-search-general', array('rel' => 'nofollow'))); //-- search_soundex sub menu $menu->addSubmenu(new Menu(I18N::translate('Phonetic search'), 'search.php?' . $this->tree_url . '&action=soundex', 'menu-search-soundex', array('rel' => 'nofollow'))); //-- advanced search $menu->addSubmenu(new Menu(I18N::translate('Advanced search'), 'search_advanced.php?' . $this->tree_url, 'menu-search-advanced', array('rel' => 'nofollow'))); //-- search_replace sub menu if (Auth::isEditor($this->tree)) { $menu->addSubmenu(new Menu(I18N::translate('Search and replace'), 'search.php?' . $this->tree_url . '&action=replace', 'menu-search-replace')); } return $menu; }
/** * 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; } } }
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Functions\FunctionsPrint; define('WT_SCRIPT_NAME', 'inverselink.php'); require './includes/session.php'; $controller = new SimpleController(); $controller->restrictAccess(Auth::isEditor($WT_TREE))->setPageTitle(I18N::translate('Link to an existing media object'))->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();')->pageHeader(); //-- page parameters and checking $linktoid = Filter::get('linktoid', WT_REGEX_XREF); $mediaid = Filter::get('mediaid', WT_REGEX_XREF); $linkto = Filter::get('linkto', 'person|source|family|manage|repository|note'); $action = Filter::get('action', 'choose|update', 'choose'); // If GedFAct_assistant/_MEDIA/ installed ====================== if ($linkto == 'manage' && Module::getModuleByName('GEDFact_assistant')) { require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/_MEDIA/media_0_inverselink.php'; } else { //-- check for admin $paramok = true; if (!empty($linktoid)) { $paramok = GedcomRecord::getInstance($linktoid, $WT_TREE)->canShow(); } if ($action == "choose" && $paramok) {
/** * Respond to a request to delete a story. */ private function delete() { global $WT_TREE; if (Auth::isEditor($WT_TREE)) { $block_id = Filter::getInteger('block_id'); Database::prepare("DELETE FROM `##block_setting` WHERE block_id=?")->execute(array($block_id)); Database::prepare("DELETE FROM `##block` WHERE block_id=?")->execute(array($block_id)); } else { header('Location: ' . WT_BASE_URL); exit; } }
/** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Functions\FunctionsEdit; use Fisharebest\Webtrees\Functions\FunctionsPrint; use Fisharebest\Webtrees\GedcomCode\GedcomCodePedi; define('WT_SCRIPT_NAME', 'edit_interface.php'); require './includes/session.php'; $action = Filter::post('action', null, Filter::get('action')); $controller = new SimpleController(); $controller->restrictAccess(Auth::isEditor($WT_TREE))->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();')->addInlineJavascript('var locale_date_format="' . preg_replace('/[^DMY]/', '', str_replace(array('J', 'F'), array('D', 'M'), I18N::dateFormat())) . '";'); switch ($action) { //////////////////////////////////////////////////////////////////////////////// case 'editraw': $xref = Filter::get('xref', WT_REGEX_XREF); $record = GedcomRecord::getInstance($xref, $WT_TREE); check_record_access($record); $controller->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit raw GEDCOM'))->pageHeader()->addInlineJavascript('jQuery("#raw-gedcom-list").sortable({opacity: 0.7, cursor: "move", axis: "y"});'); ?> <div id="edit_interface-page"> <h4> <?php echo $controller->getPageTitle(); ?> <?php echo FunctionsPrint::helpLink('edit_edit_raw');
/** * Can we edit this record? * * @return bool */ public function canEdit() { return Auth::isManager($this->tree) || Auth::isEditor($this->tree) && strpos($this->gedcom, "\n1 RESN locked") === false; }
use Fisharebest\Webtrees\Functions\FunctionsPrintLists; define('WT_SCRIPT_NAME', 'mediaviewer.php'); require './includes/session.php'; $controller = new MediaController(); if ($controller->record && $controller->record->canShow()) { $controller->pageHeader(); if ($controller->record->isPendingDeletion()) { if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This media object has been deleted. You should review the deletion and then %1$s or %2$s it.', '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>'; } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This media object has been deleted. The deletion will need to be reviewed by a moderator.'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>'; } } elseif ($controller->record->isPendingAddtion()) { if (Auth::isModerator($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This media object has been edited. You should review the changes and then %1$s or %2$s them.', '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>'; } elseif (Auth::isEditor($controller->record->getTree())) { echo '<p class="ui-state-highlight">', I18N::translate('This media object has been edited. The changes need to be reviewed by a moderator.'), ' ', FunctionsPrint::helpLink('pending_changes'), '</p>'; } } } else { http_response_code(404); $controller->pageHeader(); echo '<p class="ui-state-error">', I18N::translate('This media object does not exist or you do not have permission to view it.'), '</p>'; return; } $controller->addInlineJavascript(' jQuery("#media-tabs") .tabs({ create: function(e, ui){ jQuery(e.target).css("visibility", "visible"); // prevent FOUC }
/** * Create the advanced search sub-menu. * * @return Menu */ protected function menuSearchAndReplace() { if (Auth::isEditor($this->tree)) { return new Menu(I18N::translate('Search and replace'), 'search.php?' . $this->tree_url . '&action=replace', 'menu-search-replace'); } else { return null; } }
/** * Generate the HTML content of this tab. * * @return string */ public function getTabContent() { global $WT_TREE, $controller; $html = '<div id="' . $this->getName() . '_content">'; //Show Lightbox-Album header Links if (Auth::isEditor($WT_TREE)) { $html .= '<table class="facts_table"><tr><td class="descriptionbox rela">'; // Add a new media object if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) { $html .= '<span><a href="#" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=' . $controller->record->getXref() . '\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=780,width=600\');return false;">'; $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_add.png" id="head_icon" class="icon" title="' . I18N::translate('Add a new media object') . '" alt="' . I18N::translate('Add a new media object') . '">'; $html .= I18N::translate('Add a new media object'); $html .= '</a></span>'; // Link to an existing item $html .= '<span><a href="#" onclick="window.open(\'inverselink.php?linktoid=' . $controller->record->getXref() . '&linkto=person\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=300,width=450\');">'; $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_link.png" id="head_icon" class="icon" title="' . I18N::translate('Link to an existing media object') . '" alt="' . I18N::translate('Link to an existing media object') . '">'; $html .= I18N::translate('Link to an existing media object'); $html .= '</a></span>'; } if (Auth::isManager($WT_TREE) && $this->getMedia()) { // Popup Reorder Media $html .= '<span><a href="#" onclick="reorder_media(\'' . $controller->record->getXref() . '\')">'; $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/images.png" id="head_icon" class="icon" title="' . I18N::translate('Re-order media') . '" alt="' . I18N::translate('Re-order media') . '">'; $html .= I18N::translate('Re-order media'); $html .= '</a></span>'; } $html .= '</td></tr></table>'; } // Used when sorting media on album tab page $html .= '<table class="facts_table"><tr><td class="facts_value">'; // one-cell table - for presentation only $html .= '<ul class="album-list">'; foreach ($this->getMedia() as $media) { //View Edit Menu ---------------------------------- //Get media item Notes $haystack = $media->getGedcom(); $needle = '1 NOTE'; $before = substr($haystack, 0, strpos($haystack, $needle)); $after = substr(strstr($haystack, $needle), strlen($needle)); $notes = FunctionsPrint::printFactNotes($before . $needle . $after, 1, true); // Prepare Below Thumbnail menu ---------------------------------------------------- $menu = new Menu('<div style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap">' . $media->getFullName() . '</div>'); $menu->addClass('', 'submenu'); // View Notes if (strpos($media->getGedcom(), "\n1 NOTE")) { $submenu = new Menu(I18N::translate('View notes'), '#', '', array('onclick' => 'modalNotes("' . Filter::escapeJs($notes) . '","' . I18N::translate('View notes') . '"); return false;')); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); } //View Details $submenu = new Menu(I18N::translate('View details'), $media->getHtmlUrl()); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); //View Sources foreach ($media->getFacts('SOUR') as $source_fact) { $source = $source_fact->getTarget(); if ($source && $source->canShow()) { $submenu = new Menu(I18N::translate('Source') . ' – ' . $source->getFullName(), $source->getHtmlUrl()); $submenu->addClass('submenuitem'); $menu->addSubmenu($submenu); } } if (Auth::isEditor($media->getTree())) { // Edit Media $submenu = new Menu(I18N::translate('Edit media'), '#', '', array('onclick' => 'return window.open("addmedia.php?action=editmedia&pid=' . $media->getXref() . '", "_blank", edit_window_specs);')); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); if (Auth::isAdmin()) { if (Module::getModuleByName('GEDFact_assistant')) { $submenu = new Menu(I18N::translate('Manage links'), '#', '', array('onclick' => 'return window.open("inverselink.php?mediaid=' . $media->getXref() . '&linkto=manage", "_blank", find_window_specs);')); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); } else { $submenu = new Menu(I18N::translate('Link this media object to an individual'), '#', 'menu-obje-link-indi', array('onclick' => 'return ilinkitem("' . $media->getXref() . '","person");')); $submenu->addClass('submenuitem'); $menu->addSubmenu($submenu); $submenu = new Menu(I18N::translate('Link this media object to a family'), '#', 'menu-obje-link-fam', array('onclick' => 'return ilinkitem("' . $media->getXref() . '","family");')); $submenu->addClass('submenuitem'); $menu->addSubmenu($submenu); $submenu = new Menu(I18N::translate('Link this media object to a source'), '#', 'menu-obje-link-sour', array('onclick' => 'return ilinkitem("' . $media->getXref() . '","source");')); $submenu->addClass('submenuitem'); $menu->addSubmenu($submenu); } $submenu = new Menu(I18N::translate('Unlink media'), '#', '', array('onclick' => 'return unlink_media("' . I18N::translate('Are you sure you want to remove links to this media object?') . '", "' . $controller->record->getXref() . '", "' . $media->getXref() . '");')); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); } } $html .= '<li class="album-list-item">'; $html .= '<div class="album-image">' . $media->displayImage() . '</div>'; $html .= '<div class="album-title">' . $menu->getMenu() . '</div>'; $html .= '</li>'; } $html .= '</ul>'; $html .= '</td></tr></table>'; return $html; }
/** * print the children table for a family * * @param Family $family family * @param string $childid child ID * @param int $sosa child sosa number * @param string $label indi label (descendancy booklet) * @param int $show_cousins display cousins on chart * @param int $show_full large or small box */ public static function printFamilyChildren(Family $family, $childid = '', $sosa = 0, $label = '', $show_cousins = 0, $show_full = 1) { if ($show_full) { $bheight = Theme::theme()->parameter('chart-box-y'); } else { $bheight = Theme::theme()->parameter('compact-chart-box-y'); } $pbheight = $bheight + 14; $children = $family->getChildren(); $numchil = count($children); echo '<table border="0" cellpadding="0" cellspacing="2"><tr>'; if ($sosa > 0) { echo '<td></td>'; } echo '<td><span class="subheaders">'; if ($numchil == 0) { echo I18N::translate('No children'); } else { echo I18N::plural('%s child', '%s children', $numchil, $numchil); } echo '</span>'; if ($sosa == 0 && Auth::isEditor($family->getTree())) { echo '<br>'; echo "<a href=\"#\" onclick=\"return add_child_to_family('", $family->getXref(), "', 'U');\">" . I18N::translate('Add a child to this family') . "</a>"; echo ' <a class="icon-sex_m_15x15" href="#" onclick="return add_child_to_family(\'', $family->getXref(), '\', \'M\');" title="', I18N::translate('son'), '"></a>'; echo ' <a class="icon-sex_f_15x15" href="#" onclick="return add_child_to_family(\'', $family->getXref(), '\', \'F\');" title="', I18N::translate('daughter'), '"></a>'; echo '<br><br>'; } echo '</td>'; if ($sosa > 0) { echo '<td></td><td></td>'; } echo '</tr>'; $nchi = 1; if ($children) { foreach ($children as $child) { echo '<tr>'; if ($sosa != 0) { if ($child->getXref() == $childid) { self::printSosaNumber($sosa, $childid); } elseif (empty($label)) { self::printSosaNumber(""); } else { self::printSosaNumber($label . $nchi++ . "."); } } if ($child->isPendingAddtion()) { echo '<td valign="middle" class="new">'; } elseif ($child->isPendingDeletion()) { echo '<td valign="middle" class="old">'; } else { echo '<td valign="middle">'; } FunctionsPrint::printPedigreePerson($child, $show_full); echo "</td>"; if ($sosa != 0) { // loop for all families where current child is a spouse $famids = $child->getSpouseFamilies(); $maxfam = count($famids) - 1; for ($f = 0; $f <= $maxfam; $f++) { $famid_child = $famids[$f]->getXref(); // multiple marriages if ($f > 0) { echo '</tr><tr><td></td>'; echo '<td valign="top"'; if (I18N::direction() === 'rtl') { echo ' align="left">'; } else { echo ' align="right">'; } //find out how many cousins there are to establish vertical line on second families $fchildren = $famids[$f]->getChildren(); $kids = count($fchildren); $Pheader = ($bheight - 1) * $kids; $PBadj = 6; // default if ($show_cousins > 0) { if ($kids) { $PBadj = max(0, $Pheader / 2 + $kids * 4.5); } } if ($f == $maxfam) { echo "<img height=\"" . ($bheight / 2 + $PBadj) . "px\""; } else { echo "<img height=\"" . $pbheight . "px\""; } echo " width=\"3\" src=\"" . Theme::theme()->parameter('image-vline') . "\" alt=\"\">"; echo "</td>"; } echo "<td class=\"details1\" valign=\"middle\" align=\"center\">"; $spouse = $famids[$f]->getSpouse($child); $marr = $famids[$f]->getFirstFact('MARR'); $div = $famids[$f]->getFirstFact('DIV'); if ($marr) { // marriage date echo $marr->getDate()->minimumDate()->format('%Y'); // divorce date if ($div) { echo '–', $div->getDate()->minimumDate()->format('%Y'); } } echo "<br><img width=\"100%\" class=\"line5\" height=\"3\" src=\"" . Theme::theme()->parameter('image-hline') . "\" alt=\"\">"; echo "</td>"; // spouse information echo "<td style=\"vertical-align: center;"; if (!empty($divrec)) { echo " filter:alpha(opacity=40);opacity:0.4;\">"; } else { echo "\">"; } FunctionsPrint::printPedigreePerson($spouse, $show_full); echo "</td>"; // cousins if ($show_cousins) { self::printCousins($famid_child, $show_full); } } } echo "</tr>"; } } elseif ($sosa < 1) { // message 'no children' except for sosa if (preg_match('/\\n1 NCHI (\\d+)/', $family->getGedcom(), $match) && $match[1] == 0) { echo '<tr><td><i class="icon-childless"></i> ' . I18N::translate('This family remained childless') . '</td></tr>'; } } echo "</table><br>"; }
/** * get edit menu */ public function getEditMenu() { if (!$this->record || $this->record->isPendingDeletion()) { return null; } // edit menu $menu = new Menu(I18N::translate('Edit'), '#', 'menu-indi', array('onclick' => 'return false;')); // What behaviour shall we give the main menu? If we leave it blank, the framework // will copy the first submenu - which may be edit-raw or delete. // As a temporary solution, make it edit the name if (Auth::isEditor($this->record->getTree())) { foreach ($this->record->getFacts() as $fact) { if ($fact->getTag() === 'NAME' && $fact->canEdit()) { $menu->setAttrs(array('onclick' => 'return edit_name("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");')); break; } } $menu->addSubmenu(new Menu(I18N::translate('Add a new name'), '#', 'menu-indi-addname', array('onclick' => 'return add_name("' . $this->record->getXref() . '");'))); $has_sex_record = false; foreach ($this->record->getFacts() as $fact) { if ($fact->getTag() === 'SEX' && $fact->canEdit()) { $menu->addSubmenu(new Menu(I18N::translate('Edit gender'), '#', 'menu-indi-editsex', array('onclick' => 'return edit_record("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");'))); $has_sex_record = true; break; } } if (!$has_sex_record) { $menu->addSubmenu(new Menu(I18N::translate('Edit gender'), '#', 'menu-indi-editsex', array('return add_new_record("' . $this->record->getXref() . '", "SEX");'))); } if (count($this->record->getSpouseFamilies()) > 1) { $menu->addSubmenu(new Menu(I18N::translate('Re-order families'), '#', 'menu-indi-orderfam', array('onclick' => 'return reorder_families("' . $this->record->getXref() . '");'))); } } // delete if (Auth::isEditor($this->record->getTree())) { $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-indi-del', array('onclick' => 'return delete_individual("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");'))); } // edit raw if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) { $menu->addSubmenu(new Menu(I18N::translate('Edit raw GEDCOM'), '#', 'menu-indi-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");'))); } // add to favorites if (Module::getModuleByName('user_favorites')) { $menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-indi-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite",{xref:"' . $this->record->getXref() . '"},function(){location.reload();})'))); } return $menu; }
if ($sortby === 'title') { echo '<p><b><a href="', $mediaobject->getHtmlUrl(), '">'; echo $mediaobject->getFullName(); echo '</a></b></p>'; } else { echo '<p><b><a href="', $mediaobject->getHtmlUrl(), '">'; echo basename($mediaobject->getFilename()); echo '</a></b></p>'; echo GedcomTag::getLabelValue('TITL', $mediaobject->getFullName()); } // Show file details if ($mediaobject->isExternal()) { echo GedcomTag::getLabelValue('URL', $mediaobject->getFilename()); } else { if ($mediaobject->fileExists()) { if (Auth::isEditor($WT_TREE)) { echo GedcomTag::getLabelValue('FILE', $mediaobject->getFilename()); $mediatype = $mediaobject->getMediaType(); if ($mediatype) { echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype)); } } echo GedcomTag::getLabelValue('FORM', $mediaobject->mimeType()); echo GedcomTag::getLabelValue('__FILE_SIZE__', $mediaobject->getFilesize()); $imgsize = $mediaobject->getImageAttributes(); if ($imgsize['WxH']) { echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']); } } else { echo '<p class="ui-state-error">', I18N::translate('The file “%s” does not exist.', $mediaobject->getFilename()), '</p>'; }
/** * 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; } } }
/** * Check whether this fact is protected against edit * * @return bool */ public function canEdit() { // Managers can edit anything // Members cannot edit RESN, CHAN and locked records return $this->parent->canEdit() && !$this->isPendingDeletion() && (Auth::isManager($this->parent->getTree()) || Auth::isEditor($this->parent->getTree()) && strpos($this->gedcom, "\n2 RESN locked") === false && $this->getTag() != 'RESN' && $this->getTag() != 'CHAN'); }