Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 /**
  * {@inhericDoc}
  * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
  */
 public function validatePrerequisites()
 {
     try {
         Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
         return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME));
     } catch (\Exception $ex) {
     }
     return false;
 }
Ejemplo n.º 5
0
 /**
  * Get an array of the different titles (tag TITL) of an individual
  * 
  * @return array Array of titles
  */
 public function getTitles()
 {
     if (is_null($this->titles) && ($module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME))) {
         $pattern = '/(.*) ((' . $module->getSetting('MAJ_TITLE_PREFIX', '') . ')(.*))/';
         $this->titles = array();
         $titlefacts = $this->gedcomrecord->getFacts('TITL');
         foreach ($titlefacts as $titlefact) {
             $ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2);
             if ($ct2 > 0) {
                 $this->titles[$match2[1][0]][] = trim($match2[2][0]);
             } else {
                 $this->titles[$titlefact->getValue()][] = '';
             }
         }
     }
     return $this->titles;
 }
Ejemplo n.º 6
0
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getPossibleHooks()
  */
 public function getPossibleHooks()
 {
     static $hooks = null;
     if ($hooks === null) {
         $hooks = array();
         // Cannot use the same logic as the core Module loading,
         // as this forces a new include of the module.php file.
         // This causes issue when classes are defined in this file.
         // Cannot use Module::getActiveModules as well, as this is private.
         $module_names = Database::prepare('SELECT SQL_CACHE module_name FROM `##module`')->fetchOneColumn();
         foreach ($module_names as $module_name) {
             $module = Module::getModuleByName($module_name);
             if ($module instanceof HookSubscriberInterface) {
                 $subscribedhooks = $module->getSubscribedHooks();
                 if (is_array($subscribedhooks)) {
                     foreach ($subscribedhooks as $key => $value) {
                         if (is_int($key)) {
                             $hook_item = $value;
                             $priority = self::DEFAULT_PRIORITY;
                         } else {
                             $hook_item = explode('#', $key, 2);
                             $priority = $value;
                         }
                         if ($hook_item && count($hook_item) == 2) {
                             $hook_func = $hook_item[0];
                             $hook_cont = $hook_item[1];
                         } else {
                             $hook_func = $hook_item[0];
                             $hook_cont = 'all';
                         }
                         if (method_exists($module, $hook_func)) {
                             $hooks[$module->getName() . '#' . $hook_func . '#' . $hook_cont] = $priority;
                         }
                     }
                 }
             }
         }
     }
     return $hooks;
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
Ejemplo n.º 8
0
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Module\ModuleManagerInterface::isOperational()
  */
 public function isOperational($moduleName)
 {
     if (!array_key_exists($moduleName, $this->modules_list)) {
         if ($module = fw\Module::getModuleByName($moduleName)) {
             if ($module instanceof DependentInterface) {
                 if ($module->validatePrerequisites()) {
                     $this->modules_list[$moduleName] = TRUE;
                     return true;
                 } else {
                     // Do not cache the result,
                     // as they could change by the next call to the method
                     return false;
                 }
             } else {
                 $this->modules_list[$moduleName] = TRUE;
                 return true;
             }
         } else {
             $this->modules_list[$moduleName] = FALSE;
         }
     }
     return $this->modules_list[$moduleName];
 }
Ejemplo n.º 9
0
 /**
  * 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;
 }
Ejemplo n.º 10
0
 /**
  * Print a row for the notes tab on the individual page.
  *
  * @param Fact $fact
  * @param int $level
  */
 public static function printMainNotes(Fact $fact, $level)
 {
     $factrec = $fact->getGedcom();
     $fact_id = $fact->getFactId();
     $parent = $fact->getParent();
     $pid = $parent->getXref();
     if ($fact->isPendingAddition()) {
         $styleadd = ' new';
         $can_edit = $level == 1 && $fact->canEdit();
     } elseif ($fact->isPendingDeletion()) {
         $styleadd = ' old';
         $can_edit = false;
     } else {
         $styleadd = '';
         $can_edit = $level == 1 && $fact->canEdit();
     }
     $ct = preg_match_all("/{$level} NOTE (.*)/", $factrec, $match, PREG_SET_ORDER);
     for ($j = 0; $j < $ct; $j++) {
         // Note object, or inline note?
         if (preg_match("/{$level} NOTE @(.*)@/", $match[$j][0], $nmatch)) {
             $note = Note::getInstance($nmatch[1], $fact->getParent()->getTree());
             if ($note && !$note->canShow()) {
                 continue;
             }
         } else {
             $note = null;
         }
         if ($level >= 2) {
             echo '<tr class="row_note2"><td class="descriptionbox rela ', $styleadd, ' width20">';
         } else {
             echo '<tr><td class="descriptionbox ', $styleadd, ' width20">';
         }
         if ($can_edit) {
             echo '<a onclick="return edit_record(\'', $pid, '\', \'', $fact_id, '\');" href="#" title="', I18N::translate('Edit'), '">';
             if ($level < 2) {
                 if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) {
                     echo '<i class="icon-note"></i> ';
                 }
                 if ($note) {
                     echo GedcomTag::getLabel('SHARED_NOTE');
                 } else {
                     echo GedcomTag::getLabel('NOTE');
                 }
                 echo '</a>';
                 echo '<div class="editfacts">';
                 echo "<div class=\"editlink\"><a class=\"editicon\" onclick=\"return edit_record('{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . I18N::translate('Edit') . "\"><span class=\"link_text\">" . I18N::translate('Edit') . "</span></a></div>";
                 echo '<div class="copylink"><a class="copyicon" href="#" onclick="return copy_fact(\'', $pid, '\', \'', $fact_id, '\');" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>';
                 echo "<div class=\"deletelink\"><a class=\"deleteicon\" onclick=\"return delete_fact('" . I18N::translate('Are you sure you want to delete this fact?') . "', '{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . I18N::translate('Delete') . "\"><span class=\"link_text\">" . I18N::translate('Delete') . "</span></a></div>";
                 if ($note) {
                     echo '<a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . I18N::translate('View') . '"><span class="link_text">' . I18N::translate('View') . '</span></a>';
                 }
                 echo '</div>';
             }
         } else {
             if ($level < 2) {
                 if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) {
                     echo '<i class="icon-note"></i> ';
                 }
                 if ($note) {
                     echo GedcomTag::getLabel('SHARED_NOTE');
                 } else {
                     echo GedcomTag::getLabel('NOTE');
                 }
             }
             $factlines = explode("\n", $factrec);
             // 1 BIRT Y\n2 NOTE ...
             $factwords = explode(" ", $factlines[0]);
             // 1 BIRT Y
             $factname = $factwords[1];
             // BIRT
             $parent = GedcomRecord::getInstance($pid, $fact->getParent()->getTree());
             if ($factname == 'EVEN' || $factname == 'FACT') {
                 // Add ' EVEN' to provide sensible output for an event with an empty TYPE record
                 $ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch);
                 if ($ct > 0) {
                     $factname = trim($ematch[1]);
                     echo $factname;
                 } else {
                     echo GedcomTag::getLabel($factname, $parent);
                 }
             } elseif ($factname != 'NOTE') {
                 // Note is already printed
                 echo GedcomTag::getLabel($factname, $parent);
                 if ($note) {
                     echo '<div class="editfacts"><a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . I18N::translate('View') . '"><span class="link_text">' . I18N::translate('View') . '</span></a></div>';
                 }
             }
         }
         echo '</td>';
         if ($note) {
             // Note objects
             if (Module::getModuleByName('GEDFact_assistant')) {
                 // If Census assistant installed, allow it to format the note
                 $text = CensusAssistantModule::formatCensusNote($note);
             } else {
                 $text = Filter::formatText($note->getNote(), $fact->getParent()->getTree());
             }
         } else {
             // Inline notes
             $nrec = Functions::getSubRecord($level, "{$level} NOTE", $factrec, $j + 1);
             $text = $match[$j][1] . Functions::getCont($level + 1, $nrec);
             $text = Filter::formatText($text, $fact->getParent()->getTree());
         }
         echo '<td class="optionbox', $styleadd, ' wrap">';
         echo $text;
         if (!empty($noterec)) {
             echo self::printFactSources($noterec, 1);
         }
         // 2 RESN tags.  Note, there can be more than one, such as "privacy" and "locked"
         if (preg_match_all("/\n2 RESN (.+)/", $factrec, $matches)) {
             foreach ($matches[1] as $match) {
                 echo '<br><span class="label">', GedcomTag::getLabel('RESN'), ':</span> <span class="field">';
                 switch ($match) {
                     case 'none':
                         // Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it.
                         // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
                         echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
                         break;
                     case 'privacy':
                         echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members');
                         break;
                     case 'confidential':
                         echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers');
                         break;
                     case 'locked':
                         echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit');
                         break;
                     default:
                         echo $match;
                         break;
                 }
                 echo '</span>';
             }
         }
         echo '</td></tr>';
     }
 }
Ejemplo n.º 11
0
 /**
  * Generate both the HTML and PNG components of the fan chart
  *
  * The HTML and PNG components both require the same co-ordinate calculations,
  * so we generate them using the same code, but we send them in separate
  * HTTP requests.
  *
  * @param string $what "png" or "html"
  *
  * @return string
  */
 public function generateFanChart($what)
 {
     $treeid = $this->sosaAncestors($this->generations);
     $fanw = 640 * $this->fan_width / 100;
     $fandeg = 90 * $this->fan_style;
     $html = '';
     $treesize = count($treeid) + 1;
     // generations count
     $gen = log($treesize) / log(2) - 1;
     $sosa = $treesize - 1;
     // fan size
     if ($fandeg == 0) {
         $fandeg = 360;
     }
     $fandeg = min($fandeg, 360);
     $fandeg = max($fandeg, 90);
     $cx = $fanw / 2 - 1;
     // center x
     $cy = $cx;
     // center y
     $rx = $fanw - 1;
     $rw = $fanw / ($gen + 1);
     $fanh = $fanw;
     // fan height
     if ($fandeg == 180) {
         $fanh = round($fanh * ($gen + 1) / ($gen * 2));
     }
     if ($fandeg == 270) {
         $fanh = round($fanh * 0.86);
     }
     $scale = $fanw / 640;
     // image init
     $image = ImageCreate($fanw, $fanh);
     $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
     ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
     ImageColorTransparent($image, $white);
     $color = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-font-color'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-font-color'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-font-color'), 4, 2)));
     $bgcolor = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-u'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-u'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-u'), 4, 2)));
     $bgcolorM = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-m'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-m'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-m'), 4, 2)));
     $bgcolorF = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-f'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-f'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-f'), 4, 2)));
     // imagemap
     $imagemap = '<map id="fanmap" name="fanmap">';
     // loop to create fan cells
     while ($gen >= 0) {
         // clean current generation area
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $fandeg;
         ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
         $rx -= 3;
         // calculate new angle
         $p2 = pow(2, $gen);
         $angle = $fandeg / $p2;
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $angle;
         // special case for rootid cell
         if ($gen == 0) {
             $deg1 = 90;
             $deg2 = 360 + $deg1;
         }
         // draw each cell
         while ($sosa >= $p2) {
             $person = $treeid[$sosa];
             if ($person) {
                 $name = $person->getFullName();
                 $addname = $person->getAddName();
                 $text = I18N::reverseText($name);
                 if ($addname) {
                     $text .= "\n" . I18N::reverseText($addname);
                 }
                 $text .= "\n" . I18N::reverseText($person->getLifeSpan());
                 switch ($person->getSex()) {
                     case 'M':
                         $bg = $bgcolorM;
                         break;
                     case 'F':
                         $bg = $bgcolorF;
                         break;
                     default:
                         $bg = $bgcolor;
                         break;
                 }
                 ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                 // split and center text by lines
                 $wmax = (int) ($angle * 7 / Theme::theme()->parameter('chart-font-size') * $scale);
                 $wmax = min($wmax, 35 * $scale);
                 if ($gen == 0) {
                     $wmax = min($wmax, 17 * $scale);
                 }
                 $text = $this->splitAlignText($text, $wmax);
                 // text angle
                 $tangle = 270 - ($deg1 + $angle / 2);
                 if ($gen == 0) {
                     $tangle = 0;
                 }
                 // calculate text position
                 $deg = $deg1 + 0.44;
                 if ($deg2 - $deg1 > 40) {
                     $deg = $deg1 + ($deg2 - $deg1) / 11;
                 }
                 if ($deg2 - $deg1 > 80) {
                     $deg = $deg1 + ($deg2 - $deg1) / 7;
                 }
                 if ($deg2 - $deg1 > 140) {
                     $deg = $deg1 + ($deg2 - $deg1) / 4;
                 }
                 if ($gen == 0) {
                     $deg = 180;
                 }
                 $rad = deg2rad($deg);
                 $mr = ($rx - $rw / 4) / 2;
                 if ($gen > 0 && $deg2 - $deg1 > 80) {
                     $mr = $rx / 2;
                 }
                 $tx = $cx + $mr * cos($rad);
                 $ty = $cy - $mr * -sin($rad);
                 if ($sosa == 1) {
                     $ty -= $mr / 2;
                 }
                 // print text
                 ImageTtfText($image, Theme::theme()->parameter('chart-font-size'), $tangle, $tx, $ty, $color, Theme::theme()->parameter('chart-font-name'), $text);
                 $imagemap .= '<area shape="poly" coords="';
                 // plot upper points
                 $mr = $rx / 2;
                 $deg = $deg1;
                 while ($deg <= $deg2) {
                     $rad = deg2rad($deg);
                     $tx = round($cx + $mr * cos($rad));
                     $ty = round($cy - $mr * -sin($rad));
                     $imagemap .= "{$tx},{$ty},";
                     $deg += ($deg2 - $deg1) / 6;
                 }
                 // plot lower points
                 $mr = ($rx - $rw) / 2;
                 $deg = $deg2;
                 while ($deg >= $deg1) {
                     $rad = deg2rad($deg);
                     $tx = round($cx + $mr * cos($rad));
                     $ty = round($cy - $mr * -sin($rad));
                     $imagemap .= "{$tx},{$ty},";
                     $deg -= ($deg2 - $deg1) / 6;
                 }
                 // join first point
                 $mr = $rx / 2;
                 $deg = $deg1;
                 $rad = deg2rad($deg);
                 $tx = round($cx + $mr * cos($rad));
                 $ty = round($cy - $mr * -sin($rad));
                 $imagemap .= "{$tx},{$ty}";
                 // add action url
                 $pid = $person->getXref();
                 $imagemap .= '" href="#' . $pid . '"';
                 $tempURL = 'fanchart.php?rootid=' . $pid . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;fan_style=' . $this->fan_style . '&amp;ged=' . $person->getTree()->getNameUrl();
                 $html .= '<div id="' . $pid . '" class="fan_chart_menu">';
                 $html .= '<div class="person_box"><div class="details1">';
                 $html .= '<a href="' . $person->getHtmlUrl() . '" class="name1">' . $name;
                 if ($addname) {
                     $html .= $addname;
                 }
                 $html .= '</a>';
                 $html .= '<ul class="charts">';
                 $html .= '<li><a href="pedigree.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '" >' . I18N::translate('Pedigree') . '</a></li>';
                 if (Module::getModuleByName('googlemap')) {
                     $html .= '<li><a href="module.php?mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Pedigree map') . '</a></li>';
                 }
                 $gedcomid = $person->getTree()->getUserPreference(Auth::user(), 'gedcomid');
                 if ($gedcomid && $gedcomid != $pid) {
                     $html .= '<li><a href="relationship.php?pid1=' . $gedcomid . '&amp;pid2=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Relationship to me') . '</a></li>';
                 }
                 $html .= '<li><a href="descendancy.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '" >' . I18N::translate('Descendants') . '</a></li>';
                 $html .= '<li><a href="ancestry.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Ancestors') . '</a></li>';
                 $html .= '<li><a href="compact.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Compact tree') . '</a></li>';
                 $html .= '<li><a href="' . $tempURL . '">' . I18N::translate('Fan chart') . '</a></li>';
                 $html .= '<li><a href="hourglass.php?rootid=' . $pid . '&amp;ged=' . $person->getTree()->getNameUrl() . '">' . I18N::translate('Hourglass chart') . '</a></li>';
                 if (Module::getModuleByName('tree')) {
                     $html .= '<li><a href="module.php?mod=tree&amp;mod_action=treeview&amp;ged=' . $person->getTree()->getNameUrl() . '&amp;rootid=' . $pid . '">' . I18N::translate('Interactive tree') . '</a></li>';
                 }
                 $html .= '</ul>';
                 // spouse(s) and children
                 foreach ($person->getSpouseFamilies() as $family) {
                     $spouse = $family->getSpouse($person);
                     if ($spouse) {
                         $html .= '<a href="' . $spouse->getHtmlUrl() . '" class="name1">' . $spouse->getFullName() . '</a>';
                         $kids = $family->getChildren();
                         if ($kids) {
                             $html .= '<ul class="children">';
                             foreach ($kids as $child) {
                                 $html .= '<li><a href="' . $child->getHtmlUrl() . '" class="name1">' . $child->getFullName() . '</a></li>';
                             }
                             $html .= '</ul>';
                         }
                     }
                 }
                 // siblings
                 foreach ($person->getChildFamilies() as $family) {
                     $children = $family->getChildren();
                     if ($children) {
                         $html .= '<div class="name1">';
                         // With two children in a family, you have only one sibling.
                         $html .= count($children) > 2 ? I18N::translate('Siblings') : I18N::translate('Sibling');
                         $html .= '</div>';
                         $html .= '<ul class="siblings">';
                         foreach ($children as $sibling) {
                             if ($sibling !== $person) {
                                 $html .= '<li><a href="' . $sibling->getHtmlUrl() . '" class="name1"> ' . $sibling->getFullName() . '</a></li>';
                             }
                         }
                         $html .= '</ul>';
                     }
                 }
                 $html .= '</div></div>';
                 $html .= '</div>';
                 $imagemap .= ' alt="' . strip_tags($person->getFullName()) . '" title="' . strip_tags($person->getFullName()) . '">';
             }
             $deg1 -= $angle;
             $deg2 -= $angle;
             $sosa--;
         }
         $rx -= $rw;
         $gen--;
     }
     $imagemap .= '</map>';
     switch ($what) {
         case 'html':
             return $html . $imagemap . '<div id="fan_chart_img"><img src="' . WT_SCRIPT_NAME . '?rootid=' . $this->root->getXref() . '&amp;fan_style=' . $this->fan_style . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;img=1" width="' . $fanw . '" height="' . $fanh . '" alt="' . strip_tags($this->getPageTitle()) . '" usemap="#fanmap"></div>';
         case 'png':
             ImageStringUp($image, 1, $fanw - 10, $fanh / 3, WT_BASE_URL, $color);
             ob_start();
             ImagePng($image);
             ImageDestroy($image);
             return ob_get_clean();
         default:
             throw new \InvalidArgumentException(__METHOD__ . ' ' . $what);
     }
 }
    /**
     * Action from the configuration page
     */
    private function edit()
    {
        global $WT_TREE;
        if (Filter::postBool('save') && Filter::checkCsrf()) {
            $block_id = Filter::postInteger('block_id');
            if ($block_id) {
                Database::prepare("UPDATE `##block` SET gedcom_id = NULLIF(:tree_id, '0'), block_order = :block_order WHERE block_id = :block_id")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'block_order' => Filter::postInteger('block_order'), 'block_id' => $block_id));
            } else {
                Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, '0'), :module_name, :block_order)")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'module_name' => $this->getName(), 'block_order' => Filter::postInteger('block_order')));
                $block_id = Database::getInstance()->lastInsertId();
            }
            $this->setBlockSetting($block_id, 'header', Filter::post('header'));
            $this->setBlockSetting($block_id, 'faqbody', Filter::post('faqbody'));
            $languages = Filter::postArray('lang');
            $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
            $this->config();
        } else {
            $block_id = Filter::getInteger('block_id');
            $controller = new PageController();
            if ($block_id) {
                $controller->setPageTitle(I18N::translate('Edit FAQ item'));
                $header = $this->getBlockSetting($block_id, 'header');
                $faqbody = $this->getBlockSetting($block_id, 'faqbody');
                $block_order = Database::prepare("SELECT block_order FROM `##block` WHERE block_id = :block_id")->execute(array('block_id' => $block_id))->fetchOne();
                $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id = :block_id")->execute(array('block_id' => $block_id))->fetchOne();
            } else {
                $controller->setPageTitle(I18N::translate('Add an FAQ item'));
                $header = '';
                $faqbody = '';
                $block_order = Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name = :module_name")->execute(array('module_name' => $this->getName()))->fetchOne();
                $gedcom_id = $WT_TREE->getTreeId();
            }
            $controller->pageHeader();
            if (Module::getModuleByName('ckeditor')) {
                CkeditorModule::enableEditor($controller);
            }
            ?>
			<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><a
						href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&mod_action=admin_config"><?php 
            echo I18N::translate('Frequently asked questions');
            ?>
</a>
				</li>
				<li class="active"><?php 
            echo $controller->getPageTitle();
            ?>
</li>
			</ol>
			<h1><?php 
            echo $controller->getPageTitle();
            ?>
</h1>

			<form name="faq" class="form-horizontal" method="post" action="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_edit">
			<?php 
            echo Filter::getCsrf();
            ?>
			<input type="hidden" name="save" value="1">
			<input type="hidden" name="block_id" value="<?php 
            echo $block_id;
            ?>
">

			<div class="form-group">
				<label for="header" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Question');
            ?>
				</label>

				<div class="col-sm-9">
					<input type="text" class="form-control" name="header" id="header"
					       value="<?php 
            echo Filter::escapeHtml($header);
            ?>
">
				</div>
			</div>

			<div class="form-group">
				<label for="faqbody" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Answer');
            ?>
				</label>

				<div class="col-sm-9">
					<textarea name="faqbody" id="faqbody" class="form-control html-edit"
					          rows="10"><?php 
            echo Filter::escapeHtml($faqbody);
            ?>
</textarea>
				</div>
			</div>

			<div class="form-group">
				<label for="xref" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Show this block for which languages?');
            ?>
				</label>

				<div class="col-sm-9">
					<?php 
            echo FunctionsEdit::editLanguageCheckboxes('lang', explode(',', $this->getBlockSetting($block_id, 'languages')));
            ?>
				</div>
			</div>

			<div class="form-group">
				<label for="block_order" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('FAQ position');
            ?>
				</label>

				<div class="col-sm-9">
					<input type="text" name="block_order" id="block_order" class="form-control" value="<?php 
            echo $block_order;
            ?>
">
				</div>
			</div>

			<div class="form-group">
				<label for="gedcom_id" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('FAQ visibility');
            ?>
				</label>

				<div class="col-sm-9">
					<?php 
            echo FunctionsEdit::selectEditControl('gedcom_id', Tree::getIdList(), I18N::translate('All'), $gedcom_id, 'class="form-control"');
            ?>
					<p class="small text-muted">
						<?php 
            echo I18N::translate('A FAQ item can be displayed on just one of the family trees, or on all the family trees.');
            ?>
					</p>
				</div>
			</div>

			<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>
				</div>
			</div>

		</form>
		<?php 
        }
    }
Ejemplo n.º 13
0
    /**
     * {@inhericDoc}
     * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
     */
    protected function renderContent()
    {
        if (Module::getModuleByName('ckeditor')) {
            CkeditorModule::enableEditor($this->ctrl);
        }
        /** @var AbstractModule $module  */
        $module = $this->data->get('module');
        ?>
        
        <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 $this->data->get('title');
        ?>
</li>
		</ol>
		
		<h1><?php 
        echo $this->data->get('title');
        ?>
</h1>

		<form method="post" class="form-horizontal">
			<?php 
        echo Filter::getCsrf();
        ?>
			<input type="hidden" name="action" value="update">
			
			<h3><?php 
        echo I18N::translate('Titles');
        ?>
</h3>
			
			<!--  MAJ_TITLE_PREFIX -->        	
        	<div class="form-group">			
        		<label for="MAJ_TITLE_PREFIX" class="col-sm-3 control-label">
        			<?php 
        echo I18N::translate('Title prefixes');
        ?>
        		</label>
    			<div class="col-sm-9">
    				<input type="text" class="form-control" dir="auto" id="MAJ_TITLE_PREFIX" name="MAJ_TITLE_PREFIX" value="<?php 
        echo Filter::escapeHtml($module->getSetting('MAJ_TITLE_PREFIX'));
        ?>
" maxlength="255" placeholder="de |d'|du |of |von |vom |am |zur |van |del |della |t'|da |ten |ter |das |dos |af ">
        			<p class="small text-muted">
        				<?php 
        echo I18N::translate('Set possible aristocratic particles to separate titles from the land they refer to (e.g. Earl <strong>of</strong> Essex). Variants must be separated by the character |.');
        ?>
<br />
        				<?php 
        echo I18N::translate('An example for this setting is : <strong>de |d\'|du |of |von |vom |am |zur |van |del |della |t\'|da |ten |ter |das |dos |af </strong> (covering some of French, English, German, Dutch, Italian, Spanish, Portuguese, Swedish common particles).');
        ?>
        			</p>
        		</div>        		
        	</div>
        	
        	<h3><?php 
        echo I18N::translate('Header');
        ?>
</h3>
        	
        	<!-- MAJ_ADD_HTML_HEADER -->
    		<div class="form-group">
    			<label class="control-label col-sm-3" for="MAJ_ADD_HTML_HEADER">
    				<?php 
        echo I18N::translate('Include additional HTML in header');
        ?>
    			</label>
    			<div class="col-sm-9">
    				<?php 
        echo FunctionsEdit::editFieldYesNo('MAJ_ADD_HTML_HEADER', $module->getSetting('MAJ_ADD_HTML_HEADER', 0), 'class="radio-inline"');
        ?>
				    <p class="small text-muted">
    					<?php 
        echo I18N::translate('Enable this option to include raw additional HTML in the header of the page.');
        ?>
    				</p>
    			</div>
    		</div>
        	
        	<!-- MAJ_SHOW_HTML_HEADER -->
        	<div class="form-group">
        		<label class="control-label col-sm-3" for="MAJ_SHOW_HTML_HEADER">
        			<?php 
        echo I18N::translate('Hide additional header');
        ?>
        		</label>
        		<div class="col-sm-9">
        			<?php 
        echo FunctionsEdit::editFieldAccessLevel('MAJ_SHOW_HTML_HEADER', $module->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE), 'class="form-control"');
        ?>
        			<p class="small text-muted">
        				<?php 
        echo I18N::translate('Select the access level until which the additional header should be displayed. The <em>Hide from everyone</em> should be used to show the header to everybody.');
        ?>
        			</p>
        		</div>
        	</div>
        	
        	<!--  MAJ_HTML_HEADER -->        	
        	<div class="form-group">			
        		<label for="MAJ_HTML_HEADER" class="col-sm-3 control-label">
        			<?php 
        echo I18N::translate('Additional HTML in header');
        ?>
        		</label>
    			<div class="col-sm-9">
    				<textarea class="form-control html-edit" rows="10" dir="auto" id="MAJ_HTML_HEADER" name="MAJ_HTML_HEADER" ><?php 
        echo Filter::escapeHtml($module->getSetting('MAJ_HTML_HEADER'));
        ?>
</textarea>
        			<p class="small text-muted">
        				<?php 
        echo I18N::translate('If the option has been enabled, the saved HTML will be inserted in the header.');
        ?>
<br>
        				<?php 
        echo I18N::translate('In edit mode, the HTML characters might have been transformed to their HTML equivalents (for instance &amp;gt; for &gt;), it is however possible to insert HTML characters, they will be automatically converted to their equivalent values.');
        ?>
        			</p>
        		</div>        		
        	</div>
        	
        	<h3><?php 
        echo I18N::translate('Footer');
        ?>
</h3>
        	
        	<!-- MAJ_DISPLAY_CNIL -->
    		<div class="form-group">
    			<label class="control-label col-sm-3" for="MAJ_DISPLAY_CNIL">
    				<?php 
        echo I18N::translate('Display French <em>CNIL</em> disclaimer');
        ?>
    			</label>
    			<div class="col-sm-9">
    				<?php 
        echo FunctionsEdit::editFieldYesNo('MAJ_DISPLAY_CNIL', $module->getSetting('MAJ_DISPLAY_CNIL', 0), 'class="radio-inline"');
        ?>
				    <p class="small text-muted">
    					<?php 
        echo I18N::translate('Enable this option to display an information disclaimer in the footer required by the French <em>CNIL</em> for detaining personal information on users.');
        ?>
    				</p>
    			</div>
    		</div>
    		
    		<!--  MAJ_CNIL_REFERENCE -->        	
        	<div class="form-group">			
        		<label for="MAJ_CNIL_REFERENCE" class="col-sm-3 control-label">
        			<?php 
        echo I18N::translate('<em>CNIL</em> reference');
        ?>
        		</label>
    			<div class="col-sm-9">
    				<input type="text" class="form-control" dir="auto" id="MAJ_CNIL_REFERENCE" name="MAJ_CNIL_REFERENCE" value="<?php 
        echo Filter::escapeHtml($module->getSetting('MAJ_CNIL_REFERENCE'));
        ?>
" maxlength="255">
        			<p class="small text-muted">
        				<?php 
        echo I18N::translate('If the website has been notified to the French <em>CNIL</em>, an authorisation number may have been delivered. Providing this reference will display a message in the footer visible to all users.');
        ?>
        			</p>
        		</div>        		
        	</div>
        	
        	<!-- MAJ_ADD_HTML_FOOTER -->
    		<div class="form-group">
    			<label class="control-label col-sm-3" for="MAJ_ADD_HTML_FOOTER">
    				<?php 
        echo I18N::translate('Include additional HTML in footer');
        ?>
    			</label>
    			<div class="col-sm-9">
    				<?php 
        echo FunctionsEdit::editFieldYesNo('MAJ_ADD_HTML_FOOTER', $module->getSetting('MAJ_ADD_HTML_FOOTER', 0), 'class="radio-inline"');
        ?>
				    <p class="small text-muted">
    					<?php 
        echo I18N::translate('Enable this option to include raw additional HTML in the footer of the page.');
        ?>
    				</p>
    			</div>
    		</div>
        	
        	<!-- MAJ_SHOW_HTML_FOOTER -->
        	<div class="form-group">
        		<label class="control-label col-sm-3" for="MAJ_SHOW_HTML_FOOTER">
        			<?php 
        echo I18N::translate('Hide additional footer');
        ?>
        		</label>
        		<div class="col-sm-9">
        			<?php 
        echo FunctionsEdit::editFieldAccessLevel('MAJ_SHOW_HTML_FOOTER', $module->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE), 'class="form-control"');
        ?>
        			<p class="small text-muted">
        				<?php 
        echo I18N::translate('Select the access level until which the additional footer should be displayed. The <em>Hide from everyone</em> should be used to show the footer to everybody.');
        ?>
        			</p>
        		</div>
        	</div>
        	
        	<!--  MAJ_HTML_FOOTER -->        	
        	<div class="form-group">			
        		<label for="MAJ_HTML_FOOTER" class="col-sm-3 control-label">
        			<?php 
        echo I18N::translate('Additional HTML in footer');
        ?>
        		</label>
    			<div class="col-sm-9">
    				<textarea class="form-control html-edit" rows="10" dir="auto" id="MAJ_HTML_FOOTER" name="MAJ_HTML_FOOTER" ><?php 
        echo Filter::escapeHtml($module->getSetting('MAJ_HTML_FOOTER'));
        ?>
</textarea>
        			<p class="small text-muted">
        				<?php 
        echo I18N::translate('If the option has been enabled, the saved HTML will be inserted in the footer, before the logo.');
        ?>
<br>
        				<?php 
        echo I18N::translate('In edit mode, the HTML characters might have been transformed to their HTML equivalents (for instance &amp;gt; for &gt;), it is however possible to insert HTML characters, they will be automatically converted to their equivalent values.');
        ?>
        			</p>
        		</div>        		
        	</div>
        	
        	<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>
        		</div>
        	</div>
        	
        </form>
		
		<?php 
    }
Ejemplo n.º 14
0
 /**
  * add a new tag input field
  *
  * called for each fact to be edited on a form.
  * Fact level=0 means a new empty form : data are POSTed by name
  * else data are POSTed using arrays :
  * glevels[] : tag level
  *  islink[] : tag is a link
  *     tag[] : tag name
  *    text[] : tag value
  *
  * @param string $tag fact record to edit (eg 2 DATE xxxxx)
  * @param string $upperlevel optional upper level tag (eg BIRT)
  * @param string $label An optional label to echo instead of the default
  * @param string $extra optional text to display after the input field
  * @param Individual $person For male/female translations
  *
  * @return string
  */
 public static function addSimpleTag($tag, $upperlevel = '', $label = '', $extra = null, Individual $person = null)
 {
     global $tags, $main_fact, $xref, $bdm, $action, $WT_TREE;
     // Keep track of SOUR fields, so we can reference them in subsequent PAGE fields.
     static $source_element_id;
     $subnamefacts = array('NPFX', 'GIVN', 'SPFX', 'SURN', 'NSFX', '_MARNM_SURN');
     preg_match('/^(?:(\\d+) (' . WT_REGEX_TAG . ') ?(.*))/', $tag, $match);
     list(, $level, $fact, $value) = $match;
     $level = (int) $level;
     // element name : used to POST data
     if ($level === 0) {
         if ($upperlevel) {
             $element_name = $upperlevel . '_' . $fact;
         } else {
             $element_name = $fact;
         }
     } else {
         $element_name = 'text[]';
     }
     if ($level === 1) {
         $main_fact = $fact;
     }
     // element id : used by javascript functions
     if ($level === 0) {
         $element_id = $fact;
     } else {
         $element_id = $fact . Uuid::uuid4();
     }
     if ($upperlevel) {
         $element_id = $upperlevel . '_' . $fact . Uuid::uuid4();
     }
     // field value
     $islink = substr($value, 0, 1) === '@' && substr($value, 0, 2) !== '@#';
     if ($islink) {
         $value = trim(substr($tag, strlen($fact) + 3), ' @\\r');
     } else {
         $value = (string) substr($tag, strlen($fact) + 3);
     }
     if ($fact === 'REPO' || $fact === 'SOUR' || $fact === 'OBJE' || $fact === 'FAMC') {
         $islink = true;
     }
     if ($fact === 'SHARED_NOTE_EDIT' || $fact === 'SHARED_NOTE') {
         $islink = true;
         $fact = 'NOTE';
     }
     // label
     echo '<tr id="', $element_id, '_tr"';
     if ($fact === 'MAP' || ($fact === 'LATI' || $fact === 'LONG') && $value === '') {
         echo ' style="display:none;"';
     }
     echo '>';
     if (in_array($fact, $subnamefacts) || $fact === 'LATI' || $fact === 'LONG') {
         echo '<td class="optionbox wrap width25">';
     } else {
         echo '<td class="descriptionbox wrap width25">';
     }
     // tag name
     if ($label) {
         echo $label;
     } elseif ($upperlevel) {
         echo GedcomTag::getLabel($upperlevel . ':' . $fact);
     } else {
         echo GedcomTag::getLabel($fact);
     }
     // If using GEDFact-assistant window
     if ($action === 'addnewnote_assisted') {
         // Do not print on GEDFact Assistant window
     } else {
         // Not all facts have help text.
         switch ($fact) {
             case 'NAME':
                 if ($upperlevel !== 'REPO' && $upperlevel !== 'UNKNOWN') {
                     echo FunctionsPrint::helpLink($fact);
                 }
                 break;
             case 'DATE':
             case 'PLAC':
             case 'RESN':
             case 'ROMN':
             case 'SURN':
             case '_HEB':
                 echo FunctionsPrint::helpLink($fact);
                 break;
         }
     }
     // tag level
     if ($level > 0) {
         if ($fact === 'TEXT' && $level > 1) {
             echo '<input type="hidden" name="glevels[]" value="', $level - 1, '">';
             echo '<input type="hidden" name="islink[]" value="0">';
             echo '<input type="hidden" name="tag[]" value="DATA">';
             // leave data text[] value empty because the following TEXT line will cause the DATA to be added
             echo '<input type="hidden" name="text[]" value="">';
         }
         echo '<input type="hidden" name="glevels[]" value="', $level, '">';
         echo '<input type="hidden" name="islink[]" value="', $islink, '">';
         echo '<input type="hidden" name="tag[]" value="', $fact, '">';
     }
     echo '</td>';
     // value
     echo '<td class="optionbox wrap">';
     // retrieve linked NOTE
     if ($fact === 'NOTE' && $islink) {
         $note1 = Note::getInstance($value, $WT_TREE);
         if ($note1) {
             $noterec = $note1->getGedcom();
             preg_match('/' . $value . '/i', $noterec, $notematch);
             $value = $notematch[0];
         }
     }
     // Show names for spouses in MARR/HUSB/AGE and MARR/WIFE/AGE
     if ($fact === 'HUSB' || $fact === 'WIFE') {
         $family = Family::getInstance($xref, $WT_TREE);
         if ($family) {
             $spouse_link = $family->getFirstFact($fact);
             if ($spouse_link) {
                 $spouse = $spouse_link->getTarget();
                 if ($spouse) {
                     echo $spouse->getFullName();
                 }
             }
         }
     }
     if (in_array($fact, Config::emptyFacts()) && ($value === '' || $value === 'Y' || $value === 'y')) {
         echo '<input type="hidden" id="', $element_id, '" name="', $element_name, '" value="', $value, '">';
         if ($level <= 1) {
             echo '<input type="checkbox" ';
             if ($value) {
                 echo 'checked';
             }
             echo ' onclick="document.getElementById(\'' . $element_id . '\').value = (this.checked) ? \'Y\' : \'\';">';
             echo I18N::translate('yes');
         }
         if ($fact === 'CENS' && $value === 'Y') {
             echo self::censusDateSelector(WT_LOCALE, $xref);
             if (Module::getModuleByName('GEDFact_assistant') && GedcomRecord::getInstance($xref, $WT_TREE) instanceof Individual) {
                 echo '<div></div><a href="#" style="display: none;" id="assistant-link" onclick="return activateCensusAssistant();">' . I18N::translate('Create a new shared note using assistant') . '</a></div>';
             }
         }
     } elseif ($fact === 'TEMP') {
         echo self::selectEditControl($element_name, GedcomCodeTemp::templeNames(), I18N::translate('No temple - living ordinance'), $value);
     } elseif ($fact === 'ADOP') {
         echo self::editFieldAdoption($element_name, $value, '', $person);
     } elseif ($fact === 'PEDI') {
         echo self::editFieldPedigree($element_name, $value, '', $person);
     } elseif ($fact === 'STAT') {
         echo self::selectEditControl($element_name, GedcomCodeStat::statusNames($upperlevel), '', $value);
     } elseif ($fact === 'RELA') {
         echo self::editFieldRelationship($element_name, strtolower($value));
     } elseif ($fact === 'QUAY') {
         echo self::selectEditControl($element_name, GedcomCodeQuay::getValues(), '', $value);
     } elseif ($fact === '_WT_USER') {
         echo self::editFieldUsername($element_name, $value);
     } elseif ($fact === 'RESN') {
         echo self::editFieldRestriction($element_name, $value);
     } elseif ($fact === '_PRIM') {
         echo '<select id="', $element_id, '" name="', $element_name, '" >';
         echo '<option value=""></option>';
         echo '<option value="Y" ';
         if ($value === 'Y') {
             echo ' selected';
         }
         echo '>', I18N::translate('always'), '</option>';
         echo '<option value="N" ';
         if ($value === 'N') {
             echo 'selected';
         }
         echo '>', I18N::translate('never'), '</option>';
         echo '</select>';
         echo '<p class="small text-muted">', I18N::translate('Use this image for charts and on the individual’s page.'), '</p>';
     } elseif ($fact === 'SEX') {
         echo '<select id="', $element_id, '" name="', $element_name, '"><option value="M" ';
         if ($value === 'M') {
             echo 'selected';
         }
         echo '>', I18N::translate('Male'), '</option><option value="F" ';
         if ($value === 'F') {
             echo 'selected';
         }
         echo '>', I18N::translate('Female'), '</option><option value="U" ';
         if ($value === 'U' || empty($value)) {
             echo 'selected';
         }
         echo '>', I18N::translateContext('unknown gender', 'Unknown'), '</option></select>';
     } elseif ($fact === 'TYPE' && $level === 3) {
         //-- Build the selector for the Media 'TYPE' Fact
         echo '<select name="text[]"><option selected value="" ></option>';
         $selectedValue = strtolower($value);
         if (!array_key_exists($selectedValue, GedcomTag::getFileFormTypes())) {
             echo '<option selected value="', Filter::escapeHtml($value), '" >', Filter::escapeHtml($value), '</option>';
         }
         foreach (GedcomTag::getFileFormTypes() as $typeName => $typeValue) {
             echo '<option value="', $typeName, '" ';
             if ($selectedValue === $typeName) {
                 echo 'selected';
             }
             echo '>', $typeValue, '</option>';
         }
         echo '</select>';
     } elseif ($fact === 'NAME' && $upperlevel !== 'REPO' && $upperlevel !== 'UNKNOWN' || $fact === '_MARNM') {
         // Populated in javascript from sub-tags
         echo '<input type="hidden" id="', $element_id, '" name="', $element_name, '" onchange="updateTextName(\'', $element_id, '\');" value="', Filter::escapeHtml($value), '" class="', $fact, '">';
         echo '<span id="', $element_id, '_display" dir="auto">', Filter::escapeHtml($value), '</span>';
         echo ' <a href="#edit_name" onclick="convertHidden(\'', $element_id, '\'); return false;" class="icon-edit_indi" title="' . I18N::translate('Edit name') . '"></a>';
     } else {
         // textarea
         if ($fact === 'TEXT' || $fact === 'ADDR' || $fact === 'NOTE' && !$islink) {
             echo '<textarea id="', $element_id, '" name="', $element_name, '" dir="auto">', Filter::escapeHtml($value), '</textarea><br>';
         } else {
             // text
             // If using GEDFact-assistant window
             if ($action === 'addnewnote_assisted') {
                 echo '<input type="text" id="', $element_id, '" name="', $element_name, '" value="', Filter::escapeHtml($value), '" style="width:4.1em;" dir="ltr"';
             } else {
                 echo '<input type="text" id="', $element_id, '" name="', $element_name, '" value="', Filter::escapeHtml($value), '" dir="ltr"';
             }
             echo ' class="', $fact, '"';
             if (in_array($fact, $subnamefacts)) {
                 echo ' onblur="updatewholename();" onkeyup="updatewholename();"';
             }
             // Extra markup for specific fact types
             switch ($fact) {
                 case 'ALIA':
                 case 'ASSO':
                 case '_ASSO':
                     echo ' data-autocomplete-type="ASSO" data-autocomplete-extra="input.DATE"';
                     break;
                 case 'DATE':
                     echo ' onblur="valid_date(this);" onmouseout="valid_date(this);"';
                     break;
                 case 'GIVN':
                     echo ' autofocus data-autocomplete-type="GIVN"';
                     break;
                 case 'LATI':
                     echo ' onblur="valid_lati_long(this, \'N\', \'S\');" onmouseout="valid_lati_long(this, \'N\', \'S\');"';
                     break;
                 case 'LONG':
                     echo ' onblur="valid_lati_long(this, \'E\', \'W\');" onmouseout="valid_lati_long(this, \'E\', \'W\');"';
                     break;
                 case 'NOTE':
                     // Shared notes. Inline notes are handled elsewhere.
                     echo ' data-autocomplete-type="NOTE"';
                     break;
                 case 'OBJE':
                     echo ' data-autocomplete-type="OBJE"';
                     break;
                 case 'PAGE':
                     echo ' data-autocomplete-type="PAGE" data-autocomplete-extra="#' . $source_element_id . '"';
                     break;
                 case 'PLAC':
                     echo ' data-autocomplete-type="PLAC"';
                     break;
                 case 'REPO':
                     echo ' data-autocomplete-type="REPO"';
                     break;
                 case 'SOUR':
                     $source_element_id = $element_id;
                     echo ' data-autocomplete-type="SOUR"';
                     break;
                 case 'SURN':
                 case '_MARNM_SURN':
                     echo ' data-autocomplete-type="SURN"';
                     break;
                 case 'TIME':
                     echo ' pattern="([0-1][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?" dir="ltr" placeholder="' . I18N::translate('hh:mm or hh:mm:ss') . '"';
                     break;
             }
             echo '>';
         }
         $tmp_array = array('TYPE', 'TIME', 'NOTE', 'SOUR', 'REPO', 'OBJE', 'ASSO', '_ASSO', 'AGE');
         // split PLAC
         if ($fact === 'PLAC') {
             echo '<div id="', $element_id, '_pop" style="display: inline;">';
             echo FunctionsPrint::printSpecialCharacterLink($element_id), ' ', FunctionsPrint::printFindPlaceLink($element_id);
             echo '<span  onclick="jQuery(\'tr[id^=', $upperlevel, '_LATI],tr[id^=', $upperlevel, '_LONG],tr[id^=LATI],tr[id^=LONG]\').toggle(\'fast\'); return false;" class="icon-target" title="', GedcomTag::getLabel('LATI'), ' / ', GedcomTag::getLabel('LONG'), '"></span>';
             echo '</div>';
             if (Module::getModuleByName('places_assistant')) {
                 \PlacesAssistantModule::setup_place_subfields($element_id);
                 \PlacesAssistantModule::print_place_subfields($element_id);
             }
         } elseif (!in_array($fact, $tmp_array)) {
             echo FunctionsPrint::printSpecialCharacterLink($element_id);
         }
     }
     // MARRiage TYPE : hide text field and show a selection list
     if ($fact === 'TYPE' && $level === 2 && $tags[0] === 'MARR') {
         echo '<script>';
         echo 'document.getElementById(\'', $element_id, '\').style.display=\'none\'';
         echo '</script>';
         echo '<select id="', $element_id, '_sel" onchange="document.getElementById(\'', $element_id, '\').value=this.value;" >';
         foreach (array('Unknown', 'Civil', 'Religious', 'Partners') as $key) {
             if ($key === 'Unknown') {
                 echo '<option value="" ';
             } else {
                 echo '<option value="', $key, '" ';
             }
             $a = strtolower($key);
             $b = strtolower($value);
             if ($b !== '' && strpos($a, $b) !== false || strpos($b, $a) !== false) {
                 echo 'selected';
             }
             echo '>', GedcomTag::getLabel('MARR_' . strtoupper($key)), '</option>';
         }
         echo '</select>';
     } elseif ($fact === 'TYPE' && $level === 0) {
         // NAME TYPE : hide text field and show a selection list
         $onchange = 'onchange="document.getElementById(\'' . $element_id . '\').value=this.value;"';
         echo self::editFieldNameType($element_name, $value, $onchange, $person);
         echo '<script>document.getElementById("', $element_id, '").style.display="none";</script>';
     }
     // popup links
     switch ($fact) {
         case 'DATE':
             echo self::printCalendarPopup($element_id);
             break;
         case 'FAMC':
         case 'FAMS':
             echo FunctionsPrint::printFindFamilyLink($element_id);
             break;
         case 'ALIA':
         case 'ASSO':
         case '_ASSO':
             echo FunctionsPrint::printFindIndividualLink($element_id, $element_id . '_description');
             break;
         case 'FILE':
             FunctionsPrint::printFindMediaLink($element_id, '0file');
             break;
         case 'SOUR':
             echo FunctionsPrint::printFindSourceLink($element_id, $element_id . '_description'), ' ', self::printAddNewSourceLink($element_id);
             //-- checkboxes to apply '1 SOUR' to BIRT/MARR/DEAT as '2 SOUR'
             if ($level === 1) {
                 echo '<br>';
                 switch ($WT_TREE->getPreference('PREFER_LEVEL2_SOURCES')) {
                     case '2':
                         // records
                         $level1_checked = 'checked';
                         $level2_checked = '';
                         break;
                     case '1':
                         // facts
                         $level1_checked = '';
                         $level2_checked = 'checked';
                         break;
                     case '0':
                         // none
                     // none
                     default:
                         $level1_checked = '';
                         $level2_checked = '';
                         break;
                 }
                 if (strpos($bdm, 'B') !== false) {
                     echo ' <label><input type="checkbox" name="SOUR_INDI" ', $level1_checked, ' value="1">', I18N::translate('Individual'), '</label>';
                     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
                         foreach ($matches[1] as $match) {
                             if (!in_array($match, explode('|', WT_EVENTS_DEAT))) {
                                 echo ' <label><input type="checkbox" name="SOUR_', $match, '" ', $level2_checked, ' value="1">', GedcomTag::getLabel($match), '</label>';
                             }
                         }
                     }
                 }
                 if (strpos($bdm, 'D') !== false) {
                     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
                         foreach ($matches[1] as $match) {
                             if (in_array($match, explode('|', WT_EVENTS_DEAT))) {
                                 echo ' <label><input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="1">', GedcomTag::getLabel($match), '</label>';
                             }
                         }
                     }
                 }
                 if (strpos($bdm, 'M') !== false) {
                     echo ' <label><input type="checkbox" name="SOUR_FAM" ', $level1_checked, ' value="1">', I18N::translate('Family'), '</label>';
                     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) {
                         foreach ($matches[1] as $match) {
                             echo ' <label><input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="1">', GedcomTag::getLabel($match), '</label>';
                         }
                     }
                 }
             }
             break;
         case 'REPO':
             echo FunctionsPrint::printFindRepositoryLink($element_id), ' ', self::printAddNewRepositoryLink($element_id);
             break;
         case 'NOTE':
             // Shared Notes Icons ========================================
             if ($islink) {
                 // Print regular Shared Note icons ---------------------------
                 echo ' ', FunctionsPrint::printFindNoteLink($element_id, $element_id . '_description'), ' ', self::printAddNewNoteLink($element_id);
                 if ($value) {
                     echo ' ', self::printEditNoteLink($value);
                 }
             }
             break;
         case 'OBJE':
             echo FunctionsPrint::printFindMediaLink($element_id, '1media');
             if (!$value) {
                 echo ' ', self::printAddNewMediaLink($element_id);
                 $value = 'new';
             }
             break;
     }
     echo '<div id="' . $element_id . '_description">';
     // current value
     if ($fact === 'DATE') {
         $date = new Date($value);
         echo $date->display();
     }
     if (($fact === 'ASSO' || $fact === '_ASSO') && $value === '') {
         if ($level === 1) {
             echo '<p class="small text-muted">' . I18N::translate('An associate is another individual who was involved with this individual, such as a friend or an employer.') . '</p>';
         } else {
             echo '<p class="small text-muted">' . I18N::translate('An associate is another individual who was involved with this fact or event, such as a witness or a priest.') . '</p>';
         }
     }
     if ($value && $value !== 'new' && $islink) {
         switch ($fact) {
             case 'ALIA':
             case 'ASSO':
             case '_ASSO':
                 $tmp = Individual::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
             case 'SOUR':
                 $tmp = Source::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
             case 'NOTE':
                 $tmp = Note::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
             case 'OBJE':
                 $tmp = Media::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
             case 'REPO':
                 $tmp = Repository::getInstance($value, $WT_TREE);
                 if ($tmp) {
                     echo ' ', $tmp->getFullName();
                 }
                 break;
         }
     }
     // pastable values
     if ($fact === 'FORM' && $upperlevel === 'OBJE') {
         FunctionsPrint::printAutoPasteLink($element_id, Config::fileFormats());
     }
     echo '</div>', $extra, '</td></tr>';
     return $element_id;
 }
Ejemplo n.º 15
0
 }
 echo '</h2>';
 if ($gm_module && $gm_module->getSetting('GM_PLACE_HIERARCHY')) {
     $linklevels = '';
     $placelevels = '';
     $place_names = array();
     for ($j = 0; $j < $level; $j++) {
         $linklevels .= '&amp;parent[' . $j . ']=' . rawurlencode($parent[$j]);
         if ($parent[$j] == '') {
             $placelevels = ', ' . I18N::translate('unknown') . $placelevels;
         } else {
             $placelevels = ', ' . $parent[$j] . $placelevels;
         }
     }
     $gm_module->createMap($placelevels);
 } elseif (Module::getModuleByName('places_assistant')) {
     // Places Assistant is a custom/add-on module that was once part of the core code.
     \PlacesAssistantModule::display_map($level, $parent);
 }
 // -- echo the array
 foreach ($child_places as $n => $child_place) {
     if ($n == 0) {
         echo '<table id="place_hierarchy" class="list_table"><tr><td class="list_label" ';
         if ($numfound > 20) {
             echo 'colspan="3"';
         } elseif ($numfound > 4) {
             echo 'colspan="2"';
         }
         echo '><i class="icon-place"></i> ';
         if ($place_id) {
             echo I18N::translate('Places in %s', $place->getPlaceName());
Ejemplo n.º 16
0
 /**
  * Find the number of favorites for the user.
  *
  * @return int
  */
 public function totalUserFavorites()
 {
     if (Module::getModuleByName('user_favorites')) {
         return count(UserFavoritesModule::getFavorites(Auth::id()));
     } else {
         return 0;
     }
 }
Ejemplo n.º 17
0
 * @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) {
        echo '<form name="link" method="get" action="inverselink.php">';
        echo '<input type="hidden" name="action" value="update">';
        if (!empty($mediaid)) {
            echo '<input type="hidden" name="mediaid" value="', $mediaid, '">';
        }
        if (!empty($linktoid)) {
            echo '<input type="hidden" name="linktoid" value="', $linktoid, '">';
Ejemplo n.º 18
0
/**
 * Generate some useful information and links about a media object.
 *
 * @param Media $media
 *
 * @return string HTML
 */
function mediaObjectInfo(Media $media)
{
    $xref = $media->getXref();
    $gedcom = $media->getTree()->getName();
    $html = '<div class="btn-group"><button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-pencil"></i> <span class="caret"></span></button><ul class="dropdown-menu" role="menu">' . '<li><a href="#" onclick="window.open(\'addmedia.php?action=editmedia&amp;pid=' . $xref . '&ged=' . Filter::escapeJs($gedcom) . '\', \'_blank\', edit_window_specs);"><i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . '</a></li>' . '<li><a href="#" onclick="return delete_record(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($media->getFullName()))) . '\', \'' . $media->getXref() . '\', \'' . Filter::escapeJs($gedcom) . '\');"><i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete') . '</a></li>' . '<li><a href="#" onclick="return ilinkitem(\'' . $media->getXref() . '\', \'person\', WT_GEDCOM)"><i class="fa fa-fw fa-link"></i> ' . I18N::translate('Link this media object to an individual') . '</a></li>' . '<li><a href="#" onclick="return ilinkitem(\'' . $media->getXref() . '\', \'family\', WT_GEDCOM)"><i class="fa fa-fw fa-link"></i> ' . I18N::translate('Link this media object to a family') . '</a></li>' . '<li><a href="#" onclick="return ilinkitem(\'' . $media->getXref() . '\', \'source\', WT_GEDCOM)"><i class="fa fa-fw fa-link"></i> ' . I18N::translate('Link this media object to a source') . '</a></li>';
    if (Module::getModuleByName('GEDFact_assistant')) {
        $html .= '<li><a href="#" onclick="return ilinkitem(\'' . $media->getXref() . '\', \'manage\', WT_GEDCOM)"><i class="fa fa-fw fa-link"></i> ' . I18N::translate('Manage the links') . '</a></li>';
    }
    $html .= '</ul></div> ' . '<b><a href="' . $media->getHtmlUrl() . '">' . $media->getFullName() . '</a></b>' . '<div><i>' . Filter::escapeHtml($media->getNote()) . '</i></div>';
    $html .= '<br>';
    $linked = array();
    foreach ($media->linkedIndividuals('OBJE') as $link) {
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    foreach ($media->linkedFamilies('OBJE') as $link) {
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    foreach ($media->linkedSources('OBJE') as $link) {
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    foreach ($media->linkedNotes('OBJE') as $link) {
        // Invalid GEDCOM - you cannot link a NOTE to an OBJE
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    foreach ($media->linkedRepositories('OBJE') as $link) {
        // Invalid GEDCOM - you cannot link a REPO to an OBJE
        $linked[] = '<a href="' . $link->getHtmlUrl() . '">' . $link->getFullName() . '</a>';
    }
    if ($linked) {
        $html .= '<ul>';
        foreach ($linked as $link) {
            $html .= '<li>' . $link . '</li>';
        }
        $html .= '</ul>';
    } else {
        $html .= '<div class="alert alert-danger">' . I18N::translate('This media object is not linked to any other record.') . '</div>';
    }
    return $html;
}
Ejemplo n.º 19
0
    /**
     * Show and process a form to edit a story.
     */
    private function edit()
    {
        global $WT_TREE;
        if (Auth::isEditor($WT_TREE)) {
            if (Filter::postBool('save') && Filter::checkCsrf()) {
                $block_id = Filter::postInteger('block_id');
                if ($block_id) {
                    Database::prepare("UPDATE `##block` SET gedcom_id=?, xref=? WHERE block_id=?")->execute(array(Filter::postInteger('gedcom_id'), Filter::post('xref', WT_REGEX_XREF), $block_id));
                } else {
                    Database::prepare("INSERT INTO `##block` (gedcom_id, xref, module_name, block_order) VALUES (?, ?, ?, ?)")->execute(array(Filter::postInteger('gedcom_id'), Filter::post('xref', WT_REGEX_XREF), $this->getName(), 0));
                    $block_id = Database::getInstance()->lastInsertId();
                }
                $this->setBlockSetting($block_id, 'title', Filter::post('title'));
                $this->setBlockSetting($block_id, 'story_body', Filter::post('story_body'));
                $languages = Filter::postArray('lang');
                $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
                $this->config();
            } else {
                $block_id = Filter::getInteger('block_id');
                $controller = new PageController();
                if ($block_id) {
                    $controller->setPageTitle(I18N::translate('Edit story'));
                    $title = $this->getBlockSetting($block_id, 'title');
                    $story_body = $this->getBlockSetting($block_id, 'story_body');
                    $xref = Database::prepare("SELECT xref FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
                } else {
                    $controller->setPageTitle(I18N::translate('Add a story'));
                    $title = '';
                    $story_body = '';
                    $xref = Filter::get('xref', WT_REGEX_XREF);
                }
                $controller->pageHeader()->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();');
                if (Module::getModuleByName('ckeditor')) {
                    CkeditorModule::enableEditor($controller);
                }
                $individual = Individual::getInstance($xref, $WT_TREE);
                ?>
				<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><a href="module.php?mod=<?php 
                echo $this->getName();
                ?>
&mod_action=admin_config"><?php 
                echo $this->getTitle();
                ?>
</a></li>
					<li class="active"><?php 
                echo $controller->getPageTitle();
                ?>
</li>
				</ol>

				<h1><?php 
                echo $controller->getPageTitle();
                ?>
</h1>

				<form class="form-horizontal" method="post" action="module.php?mod=<?php 
                echo $this->getName();
                ?>
&amp;mod_action=admin_edit">
					<?php 
                echo Filter::getCsrf();
                ?>
					<input type="hidden" name="save" value="1">
					<input type="hidden" name="block_id" value="<?php 
                echo $block_id;
                ?>
">
					<input type="hidden" name="gedcom_id" value="<?php 
                echo $WT_TREE->getTreeId();
                ?>
">

					<div class="form-group">
						<label for="title" class="col-sm-3 control-label">
							<?php 
                echo I18N::translate('Story title');
                ?>
						</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" name="title" id="title" value="<?php 
                echo Filter::escapeHtml($title);
                ?>
">
						</div>
					</div>

					<div class="form-group">
						<label for="story_body" class="col-sm-3 control-label">
							<?php 
                echo I18N::translate('Story');
                ?>
						</label>
						<div class="col-sm-9">
							<textarea name="story_body" id="story_body" class="html-edit form-control" rows="10"><?php 
                echo Filter::escapeHtml($story_body);
                ?>
</textarea>
						</div>
					</div>

					<div class="form-group">
						<label for="xref" class="col-sm-3 control-label">
							<?php 
                echo I18N::translate('Individual');
                ?>
						</label>
						<div class="col-sm-9">
							<input data-autocomplete-type="INDI" type="text" name="xref" id="xref" size="4" value="<?php 
                echo $xref;
                ?>
">
							<?php 
                echo FunctionsPrint::printFindIndividualLink('xref');
                ?>
							<?php 
                if ($individual) {
                    ?>
								<?php 
                    echo $individual->formatList('span');
                    ?>
							<?php 
                }
                ?>
						</div>
					</div>

					<div class="form-group">
						<label for="xref" class="col-sm-3 control-label">
							<?php 
                echo I18N::translate('Show this block for which languages?');
                ?>
						</label>
						<div class="col-sm-9">
							<?php 
                echo FunctionsEdit::editLanguageCheckboxes('lang', explode(',', $this->getBlockSetting($block_id, 'languages')));
                ?>
						</div>
					</div>

					<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>
						</div>
					</div>

				</form>
				<?php 
            }
        } else {
            header('Location: ' . WT_BASE_URL);
        }
    }
Ejemplo n.º 20
0
    private function edit()
    {
        global $WT_TREE;
        $args = array();
        if (webtrees\Filter::postBool('save') && webtrees\Filter::checkCsrf()) {
            $block_id = webtrees\Filter::post('block_id');
            if ($block_id) {
                $args['tree_id'] = webtrees\Filter::post('gedcom_id');
                $args['block_order'] = (int) webtrees\Filter::post('block_order');
                $args['block_id'] = $block_id;
                webtrees\Database::prepare("UPDATE `##block` SET gedcom_id=NULLIF(:tree_id, ''), block_order=:block_order WHERE block_id=:block_id")->execute($args);
            } else {
                $args['tree_id'] = webtrees\Filter::post('gedcom_id');
                $args['module_name'] = $this->getName();
                $args['block_order'] = (int) webtrees\Filter::post('block_order');
                webtrees\Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, ''), :module_name, :block_order)")->execute($args);
                $block_id = webtrees\Database::getInstance()->lastInsertId();
            }
            $this->setBlockSetting($block_id, 'pages_title', webtrees\Filter::post('pages_title'));
            $this->setBlockSetting($block_id, 'pages_content', webtrees\Filter::post('pages_content'));
            // allow html
            $this->setBlockSetting($block_id, 'pages_access', webtrees\Filter::post('pages_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 page'));
                $items_title = $this->getBlockSetting($block_id, 'pages_title');
                $items_content = $this->getBlockSetting($block_id, 'pages_content');
                $items_access = $this->getBlockSetting($block_id, 'pages_access');
                $args['block_id'] = $block_id;
                $block_order = webtrees\Database::prepare("SELECT block_order FROM `##block` WHERE block_id=:block_id")->execute($args)->fetchOne();
                $gedcom_id = webtrees\Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=:block_id")->execute($args)->fetchOne();
            } else {
                $controller->setPageTitle(webtrees\I18N::translate('Add page'));
                $items_title = '';
                $items_content = '';
                $items_access = 1;
                $args['module_name'] = $this->getName();
                $block_order = webtrees\Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name=:module_name")->execute($args)->fetchOne();
                $gedcom_id = $WT_TREE->getTreeId();
            }
            $controller->pageHeader();
            if (webtrees\Module::getModuleByName('ckeditor')) {
                webtrees\Module\CkeditorModule::enableEditor($controller);
            }
            ?>
			
			<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="pages" id="pagesForm">
				<?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="pages_title">
						<?php 
            echo webtrees\I18N::translate('Title');
            ?>
					</label>
					<div class="col-sm-9">
						<input
							class="form-control"
							id="pages_title"
							size="90"
							name="pages_title"
							required
							type="text"
							value="<?php 
            echo webtrees\Filter::escapeHtml($items_title);
            ?>
"
							>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="pages_content">
						<?php 
            echo webtrees\I18N::translate('Content');
            ?>
					</label>
					<div class="col-sm-9">
						<textarea
							class="form-control html-edit"
							id="pages_content"
							rows="10"
							cols="90"
							name="pages_content"
							required
							type="text">
								<?php 
            echo webtrees\Filter::escapeHtml($items_content);
            ?>
						</textarea>
					</div>
				</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 page for which languages?');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            $accepted_languages = explode(',', $this->getBlockSetting($block_id, 'languages'));
            foreach (webtrees\I18N::activeLocales() 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('Page 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 pages are displayed.<br><br>You do not have to enter the numbers sequentially. If you leave holes in the numbering scheme, you can insert other pages later. For example, if you use the numbers 1, 6, 11, 16, you can later insert pages 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>When more than one page has the same position number, only one of these pages will be visible.');
            ?>
					</span>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="block_order">
						<?php 
            echo webtrees\I18N::translate('Page visibility');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            echo webtrees\Functions\FunctionsEdit::selectEditControl('gedcom_id', webtrees\Tree::getIdList(), webtrees\I18N::translate('All'), $gedcom_id, '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 page 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="pages_access">
						<?php 
            echo webtrees\I18N::translate('Access level');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            echo webtrees\Functions\FunctionsEdit::editFieldAccessLevel('pages_access', $items_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 
        }
    }
Ejemplo n.º 21
0
 /** {@inheritdoc} */
 public function hasTabContent()
 {
     return Module::getModuleByName('googlemap') || Auth::isAdmin();
 }
Ejemplo n.º 22
0
    /**
     * Called by placelist.php
     *
     * @param string $placelevels
     */
    public function createMap($placelevels)
    {
        global $level, $levelm, $plzoom, $controller, $WT_TREE;
        Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
        $STREETVIEW = $this->getSetting('GM_USE_STREETVIEW');
        $parent = Filter::getArray('parent');
        // create the map
        echo '<table style="margin:20px auto 0 auto;"><tr valign="top"><td>';
        //<!-- start of map display -->
        echo '<table><tr valign="top">';
        echo '<td class="center" width="200px">';
        $levelm = $this->setLevelMap($level, $parent);
        $latlng = Database::prepare("SELECT pl_place, pl_id, pl_lati, pl_long, pl_zoom, sv_long, sv_lati, sv_bearing, sv_elevation, sv_zoom FROM `##placelocation` WHERE pl_id=?")->execute(array($levelm))->fetch(PDO::FETCH_ASSOC);
        if ($STREETVIEW && $level != 0) {
            echo '<div id="place_map" style="margin-top:20px; border:1px solid gray; width: ', $this->getSetting('GM_PH_XSIZE'), 'px; height: ', $this->getSetting('GM_PH_YSIZE'), 'px; ';
        } else {
            echo '<div id="place_map" style="border:1px solid gray; width:', $this->getSetting('GM_PH_XSIZE'), 'px; height:', $this->getSetting('GM_PH_YSIZE'), 'px; ';
        }
        echo "\"><i class=\"icon-loading-large\"></i></div>";
        echo '</td>';
        echo '<script src="', $this->googleMapsScript(), '"></script>';
        $plzoom = $latlng['pl_zoom'];
        // Map zoom level
        if (Auth::isAdmin()) {
            $placecheck_url = 'module.php?mod=googlemap&amp;mod_action=admin_placecheck';
            if ($parent && isset($parent[0])) {
                $placecheck_url .= '&amp;country=' . $parent[0];
                if (isset($parent[1])) {
                    $placecheck_url .= '&amp;state=' . $parent[1];
                }
            }
            $adminplaces_url = 'module.php?mod=googlemap&amp;mod_action=admin_places';
            if ($latlng && isset($latlng['pl_id'])) {
                $adminplaces_url .= '&amp;parent=' . $latlng['pl_id'];
            }
            echo '</tr><tr><td>';
            echo '<a href="module.php?mod=googlemap&amp;mod_action=admin_config">', I18N::translate('Google Maps™ preferences'), '</a>';
            echo '&nbsp;|&nbsp;';
            echo '<a href="' . $adminplaces_url . '">', I18N::translate('Geographic data'), '</a>';
            echo '&nbsp;|&nbsp;';
            echo '<a href="' . $placecheck_url . '">', I18N::translate('Place check'), '</a>';
            if (Module::getModuleByName('batch_update')) {
                $placelevels = preg_replace('/, ' . I18N::translate('unknown') . '/', ', ', $placelevels);
                // replace ", unknown" with ", "
                $placelevels = substr($placelevels, 2);
                // remove the leading ", "
                if ($placelevels) {
                    $batchupdate_url = 'module.php?mod=batch_update&amp;mod_action=admin_batch_update&amp;plugin=BatchUpdateSearchReplacePlugin&amp;method=exact&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;search=' . urlencode($placelevels);
                    // exact match
                    echo '&nbsp;|&nbsp;';
                    echo '<a href="' . $batchupdate_url . '">', I18N::translate('Batch update'), '</a>';
                }
            }
        }
        echo '</td></tr></table>';
        echo '</td>';
        echo '<td style="margin-left:15px; float:right;">';
        if ($STREETVIEW) {
            $controller->addInlineJavascript('
				function update_sv_params(placeid) {
					var svlati = document.getElementById("sv_latiText").value.slice(0, -1);
					var svlong = document.getElementById("sv_longText").value.slice(0, -1);
					var svbear = document.getElementById("sv_bearText").value.slice(0, -1);
					var svelev = document.getElementById("sv_elevText").value.slice(0, -1);
					var svzoom = document.getElementById("sv_zoomText").value;
					win03 = window.open("module.php?mod=googlemap&mod_action=places_edit&action=update_sv_params&placeid="+placeid+"&svlati="+svlati+"&svlong="+svlong+"&svbear="+svbear+"&svelev="+svelev+"&svzoom="+svzoom, "win03", indx_window_specs);
					if (window.focus) {win03.focus();}
				}
			');
            global $pl_lati, $pl_long;
            if ($level >= 1) {
                $pl_lati = str_replace(array('N', 'S', ','), array('', '-', '.'), $latlng['pl_lati']);
                // WT_placelocation lati
                $pl_long = str_replace(array('E', 'W', ','), array('', '-', '.'), $latlng['pl_long']);
                // WT_placelocation long
                // Check if Streetview location parameters are stored in database
                $placeid = $latlng['pl_id'];
                // Placelocation place id
                $sv_lat = $latlng['sv_lati'];
                // StreetView Point of View Latitude
                $sv_lng = $latlng['sv_long'];
                // StreetView Point of View Longitude
                $sv_dir = $latlng['sv_bearing'];
                // StreetView Point of View Direction (degrees from North)
                $sv_pitch = $latlng['sv_elevation'];
                // StreetView Point of View Elevation (+90 to -90 degrees (+=down, -=up)
                $sv_zoom = $latlng['sv_zoom'];
                // StreetView Point of View Zoom (0, 1, 2 or 3)
                // Check if Street View Lati/Long are the default of 0, if so use regular Place Lati/Long to set an initial location for the panda
                if ($latlng['sv_lati'] == 0 && $latlng['sv_long'] == 0) {
                    $sv_lat = $pl_lati;
                    $sv_lng = $pl_long;
                }
                ?>
				<div>
				<iframe style="background: transparent; margin-top: -3px; margin-left: 2px; width: 530px; height: 405px; padding: 0; border: 0;" src="module.php?mod=googlemap&amp;mod_action=wt_street_view&amp;x=<?php 
                echo $sv_lng;
                ?>
&amp;y=<?php 
                echo $sv_lat;
                ?>
&amp;z=18&amp;t=2&amp;c=1&amp;s=1&amp;b=<?php 
                echo $sv_dir;
                ?>
&amp;p=<?php 
                echo $sv_pitch;
                ?>
&amp;m=<?php 
                echo $sv_zoom;
                ?>
&amp;j=1&amp;k=1&amp;v=1" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>
				</div>

				<?php 
                $list_latlon = GedcomTag::getLabel('LATI') . "<input name='sv_latiText' id='sv_latiText' type='text' style='width:42px; background:none; border:none;' value='" . $sv_lat . "'>" . GedcomTag::getLabel('LONG') . "<input name='sv_longText' id='sv_longText' type='text' style='width:42px; background:none; border:none;' value='" . $sv_lng . "'>" . I18N::translate('Bearing') . "<input name='sv_bearText' id='sv_bearText' type='text' style='width:46px; background:none; border:none;' value='" . $sv_dir . "'>" . I18N::translate('Elevation') . "<input name='sv_elevText' id='sv_elevText' type='text' style='width:30px; background:none; border:none;' value='" . $sv_pitch . "'>" . I18N::translate('Zoom') . "<input name='sv_zoomText' id='sv_zoomText' type='text' style='width:30px; background:none; border:none;' value='" . $sv_zoom . "'>\n\t\t\t\t";
                if (Auth::isAdmin()) {
                    echo "<table align=\"center\" style=\"margin-left:6px; border:solid 1px black; width:522px; margin-top:-28px; background:#cccccc; \">";
                } else {
                    echo "<table align=\"center\" style=\"display:none; \">";
                }
                echo "<tr><td>";
                echo "<form style=\"text-align:left; margin-left:5px; font:11px verdana; color:blue;\" method=\"post\" action=\"\">";
                echo $list_latlon;
                echo "<input type=\"submit\" name=\"Submit\" onclick=\"update_sv_params({$placeid});\" value=\"", I18N::translate('save'), "\">";
                echo "</form>";
                echo "</td></tr>";
                echo "</table>";
            }
            // Next line puts Place hierarchy on new row -----
            echo '</td></tr><tr>';
        }
        // End Streetview window ===================================================================
    }
Ejemplo n.º 23
0
$blocks = Module::getActiveBlocks($WT_TREE);
if (!$block || !array_key_exists($block->module_name, $blocks) || $block->gedcom_id && !Auth::isManager(Tree::findById($block->gedcom_id)) || $block->user_id && $block->user_id != Auth::id() && !Auth::isAdmin()) {
    header('Location: ' . WT_BASE_URL);
    return;
}
$block = $blocks[$block->module_name];
if (Filter::post('save')) {
    $ctype = Filter::post('ctype', 'user', 'gedcom');
    header('Location: ' . WT_BASE_URL . 'index.php?ctype=' . $ctype . '&ged=' . $WT_TREE->getNameUrl());
    $block->configureBlock($block_id);
    return;
}
$ctype = FIlter::get('ctype', 'user', 'gedcom');
$controller = new PageController();
$controller->setPageTitle(I18N::translate('Configure') . ' — ' . $block->getTitle())->pageHeader();
if (Module::getModuleByName('ckeditor')) {
    CkeditorModule::enableEditor($controller);
}
?>
<h2><?php 
echo $controller->getPageTitle();
?>
</h2>

<form name="block" method="post" action="?block_id=<?php 
echo $block_id;
?>
">
	<input type="hidden" name="save" value="1">
	<input type="hidden" name="ged" value="<?php 
echo $WT_TREE->getNameHtml();
Ejemplo n.º 24
0
 /**
  * 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;
 }
Ejemplo n.º 25
0
 /**
  * print a note record
  *
  * @param string $text
  * @param int $nlevel the level of the note record
  * @param string $nrec the note record to print
  * @param bool $textOnly Don't print the "Note: " introduction
  *
  * @return string
  */
 public static function printNoteRecord($text, $nlevel, $nrec, $textOnly = false)
 {
     global $WT_TREE;
     $text .= Functions::getCont($nlevel, $nrec);
     // Check if shared note (we have already checked that it exists)
     if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ NOTE/', $nrec, $match)) {
         $note = Note::getInstance($match[1], $WT_TREE);
         $label = 'SHARED_NOTE';
         // If Census assistant installed, allow it to format the note
         if (Module::getModuleByName('GEDFact_assistant')) {
             $html = CensusAssistantModule::formatCensusNote($note);
         } else {
             $html = Filter::formatText($note->getNote(), $WT_TREE);
         }
     } else {
         $note = null;
         $label = 'NOTE';
         $html = Filter::formatText($text, $WT_TREE);
     }
     if ($textOnly) {
         return strip_tags($text);
     }
     if (strpos($text, "\n") === false) {
         // A one-line note? strip the block-level tags, so it displays inline
         return GedcomTag::getLabelValue($label, strip_tags($html, '<a><strong><em>'));
     } elseif ($WT_TREE->getPreference('EXPAND_NOTES')) {
         // A multi-line note, and we're expanding notes by default
         return GedcomTag::getLabelValue($label, $html);
     } else {
         // A multi-line note, with an expand/collapse option
         $element_id = Uuid::uuid4();
         // NOTE: class "note-details" is (currently) used only by some third-party themes
         if ($note) {
             $first_line = '<a href="' . $note->getHtmlUrl() . '">' . $note->getFullName() . '</a>';
         } else {
             list($text) = explode("\n", strip_tags($html));
             $first_line = strlen($text) > 100 ? mb_substr($text, 0, 100) . I18N::translate('…') : $text;
         }
         return '<div class="fact_NOTE"><span class="label">' . '<a href="#" onclick="expand_layer(\'' . $element_id . '\'); return false;"><i id="' . $element_id . '_img" class="icon-plus"></i></a> ' . GedcomTag::getLabel($label) . ':</span> ' . '<span id="' . $element_id . '-alt">' . $first_line . '</span>' . '</div>' . '<div class="note-details" id="' . $element_id . '" style="display:none">' . $html . '</div>';
     }
 }
Ejemplo n.º 26
0
				jQuery(e.target).css("visibility", "visible");  // prevent FOUC
			}
		});
');
$linked_indi = $controller->record->linkedIndividuals('NOTE');
$linked_fam = $controller->record->linkedFamilies('NOTE');
$linked_obje = $controller->record->linkedMedia('NOTE');
$linked_sour = $controller->record->linkedSources('NOTE');
$facts = array();
foreach ($controller->record->getFacts() as $fact) {
    if ($fact->getTag() != 'CONT') {
        $facts[] = $fact;
    }
}
// Legacy formatting, created by the census assistant
if (Module::getModuleByName('GEDFact_assistant')) {
    $text = CensusAssistantModule::formatCensusNote($controller->record);
} else {
    $text = Filter::formatText($controller->record->getNote(), $controller->record->getTree());
}
?>
<div id="note-details">
	<h2><?php 
echo $controller->record->getFullName();
?>
</h2>
	<div id="note-tabs">
		<ul>
			<li>
				<a href="#note-edit">
					<span><?php 
Ejemplo n.º 27
0
 /**
  * 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;
 }
Ejemplo n.º 28
0
    /**
     * 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&amp;surname_sublist=yes&amp;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>';
    }
Ejemplo n.º 29
0
 /**
  * Favorites menu.
  *
  * @return Menu|null
  */
 protected function menuFavorites()
 {
     global $controller;
     $show_user_favorites = $this->tree && Module::getModuleByName('user_favorites') && Auth::check();
     $show_tree_favorites = $this->tree && Module::getModuleByName('gedcom_favorites');
     if ($show_user_favorites && $show_tree_favorites) {
         $favorites = array_merge(FamilyTreeFavoritesModule::getFavorites($this->tree->getTreeId()), UserFavoritesModule::getFavorites(Auth::id()));
     } elseif ($show_user_favorites) {
         $favorites = UserFavoritesModule::getFavorites(Auth::id());
     } elseif ($show_tree_favorites) {
         $favorites = FamilyTreeFavoritesModule::getFavorites($this->tree->getTreeId());
     } else {
         $favorites = array();
     }
     $submenus = array();
     $records = array();
     foreach ($favorites as $favorite) {
         switch ($favorite['type']) {
             case 'URL':
                 $submenus[] = new Menu($favorite['title'], $favorite['url']);
                 break;
             case 'INDI':
             case 'FAM':
             case 'SOUR':
             case 'OBJE':
             case 'NOTE':
                 $record = GedcomRecord::getInstance($favorite['gid'], $this->tree);
                 if ($record && $record->canShowName()) {
                     $submenus[] = new Menu($record->getFullName(), $record->getHtmlUrl());
                     $records[] = $record;
                 }
                 break;
         }
     }
     if ($show_user_favorites && isset($controller->record) && $controller->record instanceof GedcomRecord && !in_array($controller->record, $records)) {
         $submenus[] = new Menu(I18N::translate('Add to favorites'), '#', '', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite", {xref:"' . $controller->record->getXref() . '"},function(){location.reload();})'));
     }
     if (empty($submenus)) {
         return null;
     } else {
         return new Menu(I18N::translate('Favorites'), '#', 'menu-favorites', array(), $submenus);
     }
 }
Ejemplo n.º 30
0
 /**
  * get edit menu
  */
 public function getEditMenu()
 {
     if (!$this->record || $this->record->isPendingDeletion()) {
         return null;
     }
     // edit menu
     $menu = new Menu(I18N::translate('Edit'), '#', 'menu-fam');
     if (Auth::isEditor($this->record->getTree())) {
         // edit_fam / members
         $menu->addSubmenu(new Menu(I18N::translate('Change family members'), '#', 'menu-fam-change', array('onclick' => 'return change_family_members("' . $this->record->getXref() . '");')));
         // edit_fam / add child
         $menu->addSubmenu(new Menu(I18N::translate('Add a child to this family'), '#', 'menu-fam-addchil', array('onclick' => 'return add_child_to_family("' . $this->record->getXref() . '", "U");')));
         // edit_fam / reorder_children
         if ($this->record->getNumberOfChildren() > 1) {
             $menu->addSubmenu(new Menu(I18N::translate('Re-order children'), '#', 'menu-fam-orderchil', array('onclick' => 'return reorder_children("' . $this->record->getXref() . '");')));
         }
     }
     // delete
     if (Auth::isEditor($this->record->getTree())) {
         $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-fam-del', array('onclick' => 'return delete_family("' . I18N::translate('Deleting the family will unlink all of the individuals from each other but will leave the individuals in place.  Are you sure you want to delete this family?') . '", "' . $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-fam-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-fam-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;
 }