예제 #1
0
 /**
  * print fact PLACe TEMPle STATus
  *
  * @param Fact $event gedcom fact record
  * @param bool $anchor to print a link to placelist
  * @param bool $sub_records to print place subrecords
  * @param bool $lds to print LDS TEMPle and STATus
  *
  * @return string HTML
  */
 public static function formatFactPlace(Fact $event, $anchor = false, $sub_records = false, $lds = false)
 {
     if ($anchor) {
         // Show the full place name, for facts/events tab
         $html = '<a href="' . $event->getPlace()->getURL() . '">' . $event->getPlace()->getFullName() . '</a>';
     } else {
         // Abbreviate the place name, for chart boxes
         return ' - ' . $event->getPlace()->getShortName();
     }
     if ($sub_records) {
         $placerec = Functions::getSubRecord(2, '2 PLAC', $event->getGedcom());
         if (!empty($placerec)) {
             if (preg_match_all('/\\n3 (?:_HEB|ROMN) (.+)/', $placerec, $matches)) {
                 foreach ($matches[1] as $match) {
                     $wt_place = new Place($match, $event->getParent()->getTree());
                     $html .= ' - ' . $wt_place->getFullName();
                 }
             }
             $map_lati = "";
             $cts = preg_match('/\\d LATI (.*)/', $placerec, $match);
             if ($cts > 0) {
                 $map_lati = $match[1];
                 $html .= '<br><span class="label">' . GedcomTag::getLabel('LATI') . ': </span>' . $map_lati;
             }
             $map_long = '';
             $cts = preg_match('/\\d LONG (.*)/', $placerec, $match);
             if ($cts > 0) {
                 $map_long = $match[1];
                 $html .= ' <span class="label">' . GedcomTag::getLabel('LONG') . ': </span>' . $map_long;
             }
             if ($map_lati && $map_long) {
                 $map_lati = trim(strtr($map_lati, "NSEW,�", " - -. "));
                 // S5,6789 ==> -5.6789
                 $map_long = trim(strtr($map_long, "NSEW,�", " - -. "));
                 // E3.456� ==> 3.456
                 $html .= ' <a rel="nofollow" href="https://maps.google.com/maps?q=' . $map_lati . ',' . $map_long . '" class="icon-googlemaps" title="' . I18N::translate('Google Maps™') . '"></a>';
                 $html .= ' <a rel="nofollow" href="https://www.bing.com/maps/?lvl=15&cp=' . $map_lati . '~' . $map_long . '" class="icon-bing" title="' . I18N::translate('Bing Maps™') . '"></a>';
                 $html .= ' <a rel="nofollow" href="https://www.openstreetmap.org/#map=15/' . $map_lati . '/' . $map_long . '" class="icon-osm" title="' . I18N::translate('OpenStreetMap™') . '"></a>';
             }
             if (preg_match('/\\d NOTE (.*)/', $placerec, $match)) {
                 $html .= '<br>' . self::printFactNotes($placerec, 3);
             }
         }
     }
     if ($lds) {
         if (preg_match('/2 TEMP (.*)/', $event->getGedcom(), $match)) {
             $html .= '<br>' . I18N::translate('LDS temple') . ': ' . GedcomCodeTemp::templeName($match[1]);
         }
         if (preg_match('/2 STAT (.*)/', $event->getGedcom(), $match)) {
             $html .= '<br>' . I18N::translate('Status') . ': ' . GedcomCodeStat::statusName($match[1]);
             if (preg_match('/3 DATE (.*)/', $event->getGedcom(), $match)) {
                 $date = new Date($match[1]);
                 $html .= ', ' . GedcomTag::getLabel('STAT:DATE') . ': ' . $date->display();
             }
         }
     }
     return $html;
 }
예제 #2
0
// Extract values from date
$days_in_month = $cal_date->daysInMonth();
$days_in_week = $cal_date->daysInWeek();
$cal_month = $cal_date->format('%O');
$today_month = $today->format('%O');
// Invalid dates? Go to monthly view, where they'll be found.
if ($cal_date->d > $days_in_month && $view === 'day') {
    $view = 'month';
}
// All further uses of $cal are to generate URLs
$cal = rawurlencode($cal);
$controller = new PageController();
$controller->setPageTitle(I18N::translate('Anniversary calendar'));
switch ($view) {
    case 'day':
        $controller->setPageTitle(I18N::translate('On this day…') . ' ' . $ged_date->display(false));
        break;
    case 'month':
        $controller->setPageTitle(I18N::translate('In this month…') . ' ' . $ged_date->display(false, '%F %Y'));
        break;
    case 'year':
        $controller->setPageTitle(I18N::translate('In this year…') . ' ' . $ged_date->display(false, '%Y'));
        break;
}
$controller->pageHeader();
?>
<div id="calendar-page">
	<table class="facts_table width100">
		<tbody>
			<tr>
				<td class="facts_label">
예제 #3
0
 /**
  * Prints the time line scale
  */
 public function printTimeline()
 {
     $startYear = $this->timelineMinYear;
     while ($startYear < $this->timelineMaxYear) {
         $date = new Date($this->calendarEscape . $startYear);
         echo $date->display(false, '%Y', false);
         $startYear += self::YEAR_SPAN;
     }
 }
예제 #4
0
파일: Stats.php 프로젝트: AlexSnet/webtrees
 /**
  * Events
  *
  * @param string $type
  * @param string $direction
  * @param string $facts
  *
  * @return string
  */
 private function eventQuery($type, $direction, $facts)
 {
     $eventTypes = array('BIRT' => I18N::translate('birth'), 'DEAT' => I18N::translate('death'), 'MARR' => I18N::translate('marriage'), 'ADOP' => I18N::translate('adoption'), 'BURI' => I18N::translate('burial'), 'CENS' => I18N::translate('census added'));
     $fact_query = "IN ('" . str_replace('|', "','", $facts) . "')";
     if ($direction != 'ASC') {
         $direction = 'DESC';
     }
     $rows = $this->runSql('' . ' SELECT SQL_CACHE' . ' d_gid AS id,' . ' d_year AS year,' . ' d_fact AS fact,' . ' d_type AS type' . ' FROM' . " `##dates`" . ' WHERE' . " d_file={$this->tree->getTreeId()} AND" . " d_gid<>'HEAD' AND" . " d_fact {$fact_query} AND" . ' d_julianday1<>0' . ' ORDER BY' . " d_julianday1 {$direction}, d_type LIMIT 1");
     if (!isset($rows[0])) {
         return '';
     }
     $row = $rows[0];
     $record = GedcomRecord::getInstance($row['id'], $this->tree);
     switch ($type) {
         default:
         case 'full':
             if ($record->canShow()) {
                 $result = $record->formatList('span', false, $record->getFullName());
             } else {
                 $result = I18N::translate('This information is private and cannot be shown.');
             }
             break;
         case 'year':
             $date = new Date($row['type'] . ' ' . $row['year']);
             $result = $date->display();
             break;
         case 'type':
             if (isset($eventTypes[$row['fact']])) {
                 $result = $eventTypes[$row['fact']];
             } else {
                 $result = GedcomTag::getLabel($row['fact']);
             }
             break;
         case 'name':
             $result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>";
             break;
         case 'place':
             $fact = $record->getFirstFact($row['fact']);
             if ($fact) {
                 $result = FunctionsPrint::formatFactPlace($fact, true, true, true);
             } else {
                 $result = I18N::translate('Private');
             }
             break;
     }
     return $result;
 }
예제 #5
0
use Fisharebest\Webtrees\Controller\SimpleController;
use Fisharebest\Webtrees\Module\CensusAssistantModule;
/** @var SimpleController $controller */
global $controller;
/** @var Tree $WT_TREE */
global $WT_TREE;
$xref = Filter::get('xref', WT_REGEX_XREF);
$census = Filter::get('census');
$head = Individual::getInstance($xref, $WT_TREE);
check_record_access($head);
$controller->restrictAccess(class_exists($census));
/** @var CensusInterface */
$census = new $census();
$controller->restrictAccess($census instanceof CensusInterface);
$date = new Date($census->censusDate());
$year = strip_tags($date->display(false, '%Y', false));
$headImg = '<i class="icon-button_head"></i>';
$controller->setPageTitle(I18N::translate('Create a new shared note using assistant'))->addInlineJavascript('jQuery("head").append(\'<link rel="stylesheet" href="' . WT_STATIC_URL . WT_MODULES_DIR . 'GEDFact_assistant/census/style.css" type="text/css">\');' . 'jQuery("#tblSample").on("click", ".icon-remove", function() { jQuery(this).closest("tr").remove(); });')->pageHeader();
?>

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

<form method="post" action="edit_interface.php" onsubmit="updateCensusText();">
	<input type="hidden" name="action" value="addnoteaction_assisted">
	<input type="hidden" name="noteid" value="newnote">
	<input id="pid_array" type="hidden" name="pid_array" value="none">
	<input id="xref" type="hidden" name="xref" value="<?php 
예제 #6
0
 /**
  * Print SOUR structure
  *  This function prints the input array of SOUR sub-records built by the
  *  getSourceStructure() function.
  *
  * @param string[] $textSOUR
  *
  * @return string
  */
 public static function printSourceStructure($textSOUR)
 {
     global $WT_TREE;
     $html = '';
     if ($textSOUR['PAGE']) {
         $html .= GedcomTag::getLabelValue('PAGE', Filter::expandUrls($textSOUR['PAGE']));
     }
     if ($textSOUR['EVEN']) {
         $html .= GedcomTag::getLabelValue('EVEN', Filter::escapeHtml($textSOUR['EVEN']));
         if ($textSOUR['ROLE']) {
             $html .= GedcomTag::getLabelValue('ROLE', Filter::escapeHtml($textSOUR['ROLE']));
         }
     }
     if ($textSOUR['DATE'] || count($textSOUR['TEXT'])) {
         if ($textSOUR['DATE']) {
             $date = new Date($textSOUR['DATE']);
             $html .= GedcomTag::getLabelValue('DATA:DATE', $date->display());
         }
         foreach ($textSOUR['TEXT'] as $text) {
             $html .= GedcomTag::getLabelValue('TEXT', Filter::formatText($text, $WT_TREE));
         }
     }
     if ($textSOUR['QUAY'] != '') {
         $html .= GedcomTag::getLabelValue('QUAY', GedcomCodeQuay::getValue($textSOUR['QUAY']));
     }
     return '<div class="indent">' . $html . '</div>';
 }
예제 #7
0
    /**
     * Generate the HTML content of this block.
     *
     * @param int      $block_id
     * @param bool     $template
     * @param string[] $cfg
     *
     * @return string
     */
    public function getBlock($block_id, $template = true, $cfg = array())
    {
        global $ctype, $controller, $WT_TREE;
        $days = $this->getBlockSetting($block_id, 'days', '7');
        $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
        $calendar = $this->getBlockSetting($block_id, 'calendar', 'jewish');
        $block = $this->getBlockSetting($block_id, 'block', '1');
        foreach (array('days', 'infoStyle', 'block') as $name) {
            if (array_key_exists($name, $cfg)) {
                ${$name} = $cfg[$name];
            }
        }
        $startjd = WT_CLIENT_JD;
        $endjd = WT_CLIENT_JD + $days - 1;
        $id = $this->getName() . $block_id;
        $class = $this->getName() . '_block';
        if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
            $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
        } else {
            $title = '';
        }
        $title .= $this->getTitle();
        $content = '';
        // The standard anniversary rules cover most of the Yahrzeit rules, we just
        // need to handle a few special cases.
        // Fetch normal anniversaries...
        $yahrzeits = array();
        for ($jd = $startjd - 1; $jd <= $endjd + $days; ++$jd) {
            foreach (FunctionsDb::getAnniversaryEvents($jd, 'DEAT _YART', $WT_TREE) as $fact) {
                // Exact hebrew dates only
                $date = $fact->getDate();
                if ($date->minimumDate() instanceof JewishDate && $date->minimumJulianDay() === $date->maximumJulianDay()) {
                    $fact->jd = $jd;
                    $yahrzeits[] = $fact;
                }
            }
        }
        // ...then adjust dates
        $jewish_calendar = new JewishCalendar();
        foreach ($yahrzeits as $yahrzeit) {
            if ($yahrzeit->getTag() === 'DEAT') {
                $today = new JewishDate($yahrzeit->jd);
                $hd = $yahrzeit->getDate()->minimumDate();
                $hd1 = new JewishDate($hd);
                $hd1->y += 1;
                $hd1->setJdFromYmd();
                // Special rules. See http://www.hebcal.com/help/anniv.html
                // Everything else is taken care of by our standard anniversary rules.
                if ($hd->d == 30 && $hd->m == 2 && $hd->y != 0 && $hd1->daysInMonth() < 30) {
                    // 30 CSH - Last day in CSH
                    $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 3, 1) - 1;
                } elseif ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->daysInMonth() < 30) {
                    // 30 KSL - Last day in KSL
                    $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 4, 1) - 1;
                } elseif ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->daysInMonth() < 30 && !$today->isLeapYear()) {
                    // 30 ADR - Last day in SHV
                    $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 6, 1) - 1;
                }
            }
        }
        switch ($infoStyle) {
            case 'list':
                foreach ($yahrzeits as $yahrzeit) {
                    if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
                        $ind = $yahrzeit->getParent();
                        $content .= "<a href=\"" . $ind->getHtmlUrl() . "\" class=\"list_item name2\">" . $ind->getFullName() . "</a>" . $ind->getSexImage();
                        $content .= "<div class=\"indent\">";
                        $content .= $yahrzeit->getDate()->display(true);
                        $content .= ', ' . I18N::translate('%s year anniversary', $yahrzeit->anniv);
                        $content .= "</div>";
                    }
                }
                break;
            case 'table':
            default:
                $table_id = Uuid::uuid4();
                // table requires a unique ID
                $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript('
					jQuery("#' . $table_id . '").dataTable({
						dom: \'t\',
						' . I18N::datatablesI18N() . ',
						autoWidth: false,
						paginate: false,
						lengthChange: false,
						filter: false,
						info: true,
						jQueryUI: true,
						sorting: [[5,"asc"]],
						columns: [
							/* 0-name */ { dataSort: 1 },
							/* 1-NAME */ { visible: false },
							/* 2-date */ { dataSort: 3 },
							/* 3-DATE */ { visible: false },
							/* 4-Aniv */ { class: "center"},
							/* 5-yart */ { dataSort: 6 },
							/* 6-YART */ { visible: false }
						]
					});
					jQuery("#' . $table_id . '").css("visibility", "visible");
					jQuery(".loading-image").css("display", "none");
				');
                $content = '';
                $content .= '<div class="loading-image">&nbsp;</div>';
                $content .= '<table id="' . $table_id . '" class="width100" style="visibility:hidden;">';
                $content .= '<thead><tr>';
                $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
                $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>';
                $content .= '<th>' . GedcomTag::getLabel('DEAT') . '</th>';
                $content .= '<th>DEAT</th>';
                $content .= '<th><i class="icon-reminder" title="' . I18N::translate('Anniversary') . '"></i></th>';
                $content .= '<th>' . GedcomTag::getLabel('_YART') . '</th>';
                $content .= '<th>_YART</th>';
                $content .= '</tr></thead><tbody>';
                foreach ($yahrzeits as $yahrzeit) {
                    if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) {
                        $content .= '<tr>';
                        $ind = $yahrzeit->getParent();
                        // Individual name(s)
                        $name = $ind->getFullName();
                        $url = $ind->getHtmlUrl();
                        $content .= '<td>';
                        $content .= '<a href="' . $url . '">' . $name . '</a>';
                        $content .= $ind->getSexImage();
                        $addname = $ind->getAddName();
                        if ($addname) {
                            $content .= '<br><a href="' . $url . '">' . $addname . '</a>';
                        }
                        $content .= '</td>';
                        $content .= '<td>' . $ind->getSortName() . '</td>';
                        // death/yahrzeit event date
                        $content .= '<td>' . $yahrzeit->getDate()->display() . '</td>';
                        $content .= '<td>' . $yahrzeit->getDate()->julianDay() . '</td>';
                        // sortable date
                        // Anniversary
                        $content .= '<td>' . $yahrzeit->anniv . '</td>';
                        // upcomming yahrzeit dates
                        switch ($calendar) {
                            case 'gregorian':
                                $today = new GregorianDate($yahrzeit->jd);
                                break;
                            case 'jewish':
                            default:
                                $today = new JewishDate($yahrzeit->jd);
                                break;
                        }
                        $td = new Date($today->format('%@ %A %O %E'));
                        $content .= '<td>' . $td->display() . '</td>';
                        $content .= '<td>' . $td->julianDay() . '</td>';
                        // sortable date
                        $content .= '</tr>';
                    }
                }
                $content .= '</tbody></table>';
                break;
        }
        if ($template) {
            if ($block) {
                $class .= ' small_inner_block';
            }
            return Theme::theme()->formatBlock($id, $title, $class, $content);
        } else {
            return $content;
        }
    }
예제 #8
0
    ?>
				</div>
				<div class="col-sm-6" style="padding-right: 0;">
					<?php 
    echo FunctionsEdit::selectEditControl('CALENDAR_FORMAT1', $calendars, null, $CALENDAR_FORMATS[1], 'class="form-control"');
    ?>
				</div>
			</div>
			<p class="small text-muted">
				<?php 
    echo I18N::translate('Different calendar systems are used in different parts of the world, and many other calendar systems have been used in the past. Where possible, you should enter dates using the calendar in which the event was originally recorded. You can then specify a conversion, to show these dates in a more familiar calendar. If you regularly use two calendars, you can specify two conversions and dates will be converted to both the selected calendars.');
    ?>
			</p>
			<p class="small text-muted">
				<?php 
    echo I18N::translate('Dates are only converted if they are valid for the calendar. For example, only dates between %1$s and %2$s will be converted to the French calendar and only dates after %3$s will be converted to the Gregorian calendar.', $french_calendar_start->display(false, null, false), $french_calendar_end->display(false, null, false), $gregorian_calendar_start->display(false, null, false));
    ?>
			</p>
			<p class="small text-muted">
				<?php 
    echo I18N::translate('In some calendars, days start at midnight. In other calendars, days start at sunset. The conversion process does not take account of the time, so for any event that occurs between sunset and midnight, the conversion between these types of calendar will be one day out.');
    ?>
			</p>
		</div>
	</fieldset>

	<!-- GENERATE_UIDS -->
	<fieldset class="form-group">
		<legend class="control-label col-sm-3">
			<?php 
    echo I18N::translate('Add unique identifiers');
예제 #9
0
/**
 * Calculate the Z axis.
 *
 * @param string $boundaries_z_axis
 */
function calculate_legend($boundaries_z_axis)
{
    global $legend, $zmax, $z_boundaries;
    // calculate the legend values
    $hulpar = explode(',', $boundaries_z_axis);
    $i = 1;
    $date = new Date('BEF ' . $hulpar[0]);
    $legend[0] = strip_tags($date->display());
    $z_boundaries[0] = $hulpar[0] - 1;
    while (isset($hulpar[$i])) {
        $i1 = $i - 1;
        $date = new Date('BET ' . $hulpar[$i1] . ' AND ' . ($hulpar[$i] - 1));
        $legend[$i] = strip_tags($date->display());
        $z_boundaries[$i] = $hulpar[$i] - 1;
        $i++;
    }
    $zmax = $i;
    $zmax1 = $zmax - 1;
    $date = new Date('AFT ' . $hulpar[$zmax1]);
    $legend[$zmax] = strip_tags($date->display());
    $z_boundaries[$zmax] = 10000;
    $zmax = $zmax + 1;
    if ($zmax > 8) {
        $zmax = 8;
    }
}
예제 #10
0
 /**
  * Variable lookup
  *
  * Retrieve predefined variables :
  *
  * @ desc GEDCOM fact description, example:
  *        1 EVEN This is a description
  * @ fact GEDCOM fact tag, such as BIRT, DEAT etc.
  * $ I18N::translate('....')
  * $ language_settings[]
  *
  * @param array $attrs an array of key value pairs for the attributes
  */
 private function varStartHandler($attrs)
 {
     if (empty($attrs['var'])) {
         throw new \DomainException('REPORT ERROR var: The attribute "var=" is missing or not set in the XML file on line: ' . xml_get_current_line_number($this->parser));
     }
     $var = $attrs['var'];
     // SetVar element preset variables
     if (!empty($this->vars[$var]['id'])) {
         $var = $this->vars[$var]['id'];
     } else {
         $tfact = $this->fact;
         if (($this->fact === "EVEN" || $this->fact === "FACT") && $this->type !== " ") {
             // Use :
             // n TYPE This text if string
             $tfact = $this->type;
         }
         $var = str_replace(array("@fact", "@desc"), array(GedcomTag::getLabel($tfact), $this->desc), $var);
         if (preg_match('/^I18N::number\\((.+)\\)$/', $var, $match)) {
             $var = I18N::number($match[1]);
         } elseif (preg_match('/^I18N::translate\\(\'(.+)\'\\)$/', $var, $match)) {
             $var = I18N::translate($match[1]);
         } elseif (preg_match('/^I18N::translateContext\\(\'(.+)\', *\'(.+)\'\\)$/', $var, $match)) {
             $var = I18N::translateContext($match[1], $match[2]);
         }
     }
     // Check if variable is set as a date and reformat the date
     if (isset($attrs['date'])) {
         if ($attrs['date'] === "1") {
             $g = new Date($var);
             $var = $g->display();
         }
     }
     $this->current_element->addText($var);
     $this->text = $var;
     // Used for title/descriptio
 }
예제 #11
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;
 }
예제 #12
0
    /**
     * Genearate a <select> element, with the dates/places of all known censuses
     *
     *
     * @param string $locale - Sort the censuses for this locale
     * @param string $xref   - The individual for whom we are adding a census
     */
    public static function censusDateSelector($locale, $xref)
    {
        global $controller;
        // Show more likely census details at the top of the list.
        switch (WT_LOCALE) {
            case 'en-AU':
            case 'en-GB':
                $census_places = array(new CensusOfEngland(), new CensusOfWales(), new CensusOfScotland());
                break;
            case 'en-US':
                $census_places = array(new CensusOfUnitedStates());
                break;
            case 'fr':
            case 'fr-CA':
                $census_places = array(new CensusOfFrance());
                break;
            case 'da':
                $census_places = array(new CensusOfDenmark());
                break;
            default:
                $census_places = array();
                break;
        }
        foreach (Census::allCensusPlaces() as $census_place) {
            if (!in_array($census_place, $census_places)) {
                $census_places[] = $census_place;
            }
        }
        $controller->addInlineJavascript('
				function selectCensus(el) {
					var option = jQuery(":selected", el);
					jQuery("input.DATE", jQuery(el).closest("table")).val(option.val());
					jQuery("input.PLAC", jQuery(el).closest("table")).val(option.data("place"));
					jQuery("input.census-class", jQuery(el).closest("table")).val(option.data("census"));
					if (option.data("place")) {
						jQuery("#assistant-link").show();
					} else {
						jQuery("#assistant-link").hide();
					}
				}
				function set_pid_array(pa) {
					jQuery("#pid_array").val(pa);
				}
				function activateCensusAssistant() {
					if (jQuery("#newshared_note_img").hasClass("icon-plus")) {
						expand_layer("newshared_note");
					}
					var field  = jQuery("#newshared_note input.NOTE")[0];
					var xref   = jQuery("input[name=xref]").val();
					var census = jQuery(".census-assistant-selector :selected").data("census");
					return addnewnote_assisted(field, xref, census);
				}
			');
        $options = '<option value="">' . I18N::translate('Census date') . '</option>';
        foreach ($census_places as $census_place) {
            $options .= '<option value=""></option>';
            foreach ($census_place->allCensusDates() as $census) {
                $date = new Date($census->censusDate());
                $year = $date->display(false, '%Y', false);
                $place_hierarchy = explode(', ', $census->censusPlace());
                $options .= '<option value="' . $census->censusDate() . '" data-place="' . $census->censusPlace() . '" data-census="' . get_class($census) . '">' . $place_hierarchy[0] . ' ' . $year . '</option>';
            }
        }
        return '<input type="hidden" id="pid_array" name="pid_array" value="">' . '<select class="census-assistant-selector" onchange="selectCensus(this);">' . $options . '</select>';
    }
예제 #13
0
echo '<form name="dateform">';
echo '<input type="hidden" name="cal" value="', $cal, '">';
echo '<input type="hidden" name="day" value="', $cal_date->d, '">';
echo '<input type="hidden" name="month" value="', $cal_month, '">';
echo '<input type="hidden" name="year" value="', $cal_date->y, '">';
echo '<input type="hidden" name="view" value="', $view, '">';
echo '<input type="hidden" name="filterev" value="', $filterev, '">';
echo '<input type="hidden" name="filtersx" value="', $filtersx, '">';
echo '<input type="hidden" name="filterof" value="', $filterof, '">';
echo '<table class="facts_table width100">';
echo '<tr><td class="facts_label" colspan="4"><h2>';
// All further uses of $cal are to generate URLs
$cal = rawurlencode($cal);
switch ($view) {
    case 'day':
        echo I18N::translate('On this day…') . '<br>' . $ged_date->display();
        break;
    case 'month':
        echo I18N::translate('In this month…') . '<br>' . $ged_date->display(false, '%F %Y');
        break;
    case 'year':
        echo I18N::translate('In this year…') . '<br>' . $ged_date->display(false, '%Y');
        break;
}
echo '</h2></td></tr>';
// Day selector
echo '<tr><td class="descriptionbox vmiddle">';
echo I18N::translate('Day'), '</td><td colspan="3" class="optionbox">';
for ($d = 1; $d <= $days_in_month; $d++) {
    // Format the day number using the calendar
    $tmp = new Date($cal_date->format("%@ {$d} %O %E"));